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 unsigned int n=0)
 Constructor. More...
 
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)
 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
 
unsigned int _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 unsigned int  n = 0)
explicit

Constructor.

Definition at line 570 of file coupling_matrix.h.

References resize().

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

Member Function Documentation

◆ clear()

void libMesh::CouplingMatrix::clear ( )

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)
Resizes the matrix and initializes all entries to be 0.

◆ empty()

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

Definition at line 631 of file coupling_matrix.h.

References _size.

632 {
633  return (_size == 0);
634 }
unsigned int _size
The size of the matrix.

◆ operator &=()

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

◆ operator()() [1/2]

bool libMesh::CouplingMatrix::operator() ( const unsigned int  i,
const unsigned int  j 
) const
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 }
unsigned int _size
The size of the matrix.
friend class ConstCouplingAccessor

◆ operator()() [2/2]

CouplingAccessor libMesh::CouplingMatrix::operator() ( const unsigned int  i,
const unsigned int  j 
)
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 }
unsigned int _size
The size of the matrix.

◆ resize()

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

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 }
unsigned int _size
The size of the matrix.

◆ size()

unsigned int libMesh::CouplingMatrix::size ( ) const
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(), and libMesh::ConstCouplingRowConstIterator::operator*().

606 {
607  return _size;
608 }
unsigned int _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

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: