libMesh::CouplingMatrix Class Reference

Defines the coupling between variables of a System. More...

#include <coupling_matrix.h>

Public Member Functions

 CouplingMatrix (const unsigned int n=0)
 
bool operator() (const unsigned int i, const unsigned int j) const
 
CouplingAccessor operator() (const unsigned int i, const unsigned int j)
 
unsigned int size () const
 
void resize (const unsigned int n)
 
void clear ()
 
bool empty () const
 
CouplingMatrixoperator &= (const CouplingMatrix &other)
 

Private Types

typedef std::pair< std::size_t, std::size_t > range_type
 
typedef std::vector< range_typerc_type
 

Private Attributes

rc_type _ranges
 
unsigned int _size
 

Friends

class ConstCouplingAccessor
 
class CouplingAccessor
 
class ConstCouplingRow
 
class ConstCouplingRowConstIterator
 

Detailed Description

Defines the coupling between variables of a System.

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

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 unsigned int  n = 0)
inlineexplicit

Constructor.

Definition at line 570 of file coupling_matrix.h.

References resize().

570  :
571  _ranges(), _size(n)
572 {
573  this->resize(n);
574 }
void resize(const unsigned int n)

Member Function Documentation

◆ clear()

void libMesh::CouplingMatrix::clear ( )
inline

Clears the matrix.

Definition at line 623 of file coupling_matrix.h.

References resize().

624 {
625  this->resize(0);
626 }
void resize(const unsigned int n)

◆ empty()

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

Definition at line 631 of file coupling_matrix.h.

References _size.

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

632 {
633  return (_size == 0);
634 }

◆ operator &=()

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

◆ operator()() [1/2]

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

Definition at line 579 of file coupling_matrix.h.

References _size, and ConstCouplingAccessor.

581 {
582  libmesh_assert_less (i, _size);
583  libmesh_assert_less (j, _size);
584 
585  const std::size_t location = std::size_t(i)*_size + j;
586 
587  return bool(ConstCouplingAccessor(location, *this));
588 }
friend class ConstCouplingAccessor

◆ operator()() [2/2]

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

Definition at line 594 of file coupling_matrix.h.

References _size, and CouplingAccessor.

596 {
597  const std::size_t location = std::size_t(i)*_size + j;
598 
599  return CouplingAccessor(location, *this);
600 }

◆ resize()

void libMesh::CouplingMatrix::resize ( const unsigned int  n)
inline

Resizes the matrix and initializes all entries to be 0.

Definition at line 613 of file coupling_matrix.h.

References _ranges, and _size.

Referenced by clear(), and CouplingMatrix().

614 {
615  _size = n;
616 
617  _ranges.clear();
618 }

◆ size()

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

Definition at line 605 of file coupling_matrix.h.

References _size.

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

606 {
607  return _size;
608 }

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

◆ _size

unsigned int 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: