libMesh
Public Member Functions | Private Types | Private Attributes | Friends | List of all members
libMesh::CouplingMatrix Class Reference

This class defines a coupling matrix. More...

#include <coupling_matrix.h>

Public Member Functions

 CouplingMatrix (const std::size_t n=0)
 Constructor. More...
 
bool operator() (const std::size_t i, const std::size_t j) const
 
CouplingAccessor operator() (const std::size_t i, const std::size_t j)
 
std::size_t size () const
 
void resize (const std::size_t n)
 Resizes the matrix and initializes all entries to be 0. More...
 
void clear ()
 Clears the matrix. More...
 
bool empty () const
 
CouplingMatrixoperator &= (const CouplingMatrix &other)
 

Private Types

typedef std::pair< std::size_t, std::size_t > range_type
 Coupling matrices are typically either full or very sparse, and all values are only zero or one. More...
 
typedef std::vector< range_typerc_type
 

Private Attributes

rc_type _ranges
 
std::size_t _size
 The size of the matrix. More...
 

Friends

class ConstCouplingAccessor
 
class CouplingAccessor
 
class ConstCouplingRow
 
class ConstCouplingRowConstIterator
 

Detailed Description

This class defines a coupling matrix.

A coupling matrix is simply a matrix of ones and zeros describing how different components in a system couple with each other. A coupling matrix is necessarily square but not necessarily symmetric.

Author
Benjamin S. Kirk
Date
2002 Defines the coupling between variables of a System.

Definition at line 54 of file coupling_matrix.h.

Member Typedef Documentation

◆ range_type

typedef std::pair<std::size_t, std::size_t> libMesh::CouplingMatrix::range_type
private

Coupling matrices are typically either full or very sparse, and all values are only zero or one.

We store non-zeros as ranges: the first entry of each range pair is the location of the first non-zero, and the second is the location of the last subsequent non-zero (not the next subsequent zero; we drop empty ranges).

We store locations (i,j) as long integers i*_size+j

Definition at line 119 of file coupling_matrix.h.

◆ rc_type

typedef std::vector<range_type> libMesh::CouplingMatrix::rc_type
private

Definition at line 120 of file coupling_matrix.h.

Constructor & Destructor Documentation

◆ CouplingMatrix()

libMesh::CouplingMatrix::CouplingMatrix ( const std::size_t  n = 0)
inlineexplicit

Constructor.

Definition at line 571 of file coupling_matrix.h.

References resize().

571  :
572  _ranges(), _size(n)
573 {
574  this->resize(n);
575 }
void resize(const std::size_t n)
Resizes the matrix and initializes all entries to be 0.
std::size_t _size
The size of the matrix.

Member Function Documentation

◆ clear()

void libMesh::CouplingMatrix::clear ( )
inline

Clears the matrix.

Definition at line 624 of file coupling_matrix.h.

References resize().

625 {
626  this->resize(0);
627 }
void resize(const std::size_t n)
Resizes the matrix and initializes all entries to be 0.

◆ empty()

bool libMesh::CouplingMatrix::empty ( ) const
inline
Returns
true if the matrix is empty.

Definition at line 632 of file coupling_matrix.h.

References _size.

Referenced by libMesh::DofMap::reinit(), and libMesh::DefaultCoupling::set_dof_coupling().

633 {
634  return (_size == 0);
635 }
std::size_t _size
The size of the matrix.

◆ operator &=()

CouplingMatrix& libMesh::CouplingMatrix::operator&= ( const CouplingMatrix other)

◆ operator()() [1/2]

bool libMesh::CouplingMatrix::operator() ( const std::size_t  i,
const std::size_t  j 
) const
inline
Returns
The (i,j) entry of the matrix.

Definition at line 580 of file coupling_matrix.h.

References _size, and ConstCouplingAccessor.

582 {
583  libmesh_assert_less (i, _size);
584  libmesh_assert_less (j, _size);
585 
586  const std::size_t location = std::size_t(i)*_size + j;
587 
588  return bool(ConstCouplingAccessor(location, *this));
589 }
friend class ConstCouplingAccessor
std::size_t _size
The size of the matrix.

◆ operator()() [2/2]

CouplingAccessor libMesh::CouplingMatrix::operator() ( const std::size_t  i,
const std::size_t  j 
)
inline
Returns
The (i,j) entry of the matrix as a smart-reference.

Definition at line 595 of file coupling_matrix.h.

References _size, and CouplingAccessor.

597 {
598  const std::size_t location = std::size_t(i)*_size + j;
599 
600  return CouplingAccessor(location, *this);
601 }
std::size_t _size
The size of the matrix.

◆ resize()

void libMesh::CouplingMatrix::resize ( const std::size_t  n)
inline

Resizes the matrix and initializes all entries to be 0.

Definition at line 614 of file coupling_matrix.h.

References _ranges, and _size.

Referenced by clear(), CouplingMatrix(), main(), and CouplingMatrixTest::testSimpleAPI().

615 {
616  _size = n;
617 
618  _ranges.clear();
619 }
std::size_t _size
The size of the matrix.

◆ size()

std::size_t libMesh::CouplingMatrix::size ( ) const
inline
Returns
The size of the matrix, i.e. N for an NxN matrix.

Definition at line 606 of file coupling_matrix.h.

References _size.

Referenced by libMesh::ConstCouplingAccessor::ConstCouplingAccessor(), libMesh::ConstCouplingRow::ConstCouplingRow(), and libMesh::ConstCouplingRowConstIterator::operator*().

607 {
608  return _size;
609 }
std::size_t _size
The size of the matrix.

Friends And Related Function Documentation

◆ ConstCouplingAccessor

friend class ConstCouplingAccessor
friend

Definition at line 103 of file coupling_matrix.h.

Referenced by operator()().

◆ ConstCouplingRow

friend class ConstCouplingRow
friend

Definition at line 105 of file coupling_matrix.h.

◆ ConstCouplingRowConstIterator

friend class ConstCouplingRowConstIterator
friend

Definition at line 106 of file coupling_matrix.h.

◆ CouplingAccessor

friend class CouplingAccessor
friend

Definition at line 104 of file coupling_matrix.h.

Referenced by operator()().

Member Data Documentation

◆ _ranges

rc_type libMesh::CouplingMatrix::_ranges
private

◆ _size

std::size_t libMesh::CouplingMatrix::_size
private

The size of the matrix.

Definition at line 126 of file coupling_matrix.h.

Referenced by empty(), operator()(), resize(), and size().


The documentation for this class was generated from the following file: