MFEM  v3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Member Functions | Public Attributes | List of all members
mfem::BlockMatrix Class Reference

#include <blockmatrix.hpp>

Inheritance diagram for mfem::BlockMatrix:
[legend]
Collaboration diagram for mfem::BlockMatrix:
[legend]

Public Member Functions

 BlockMatrix (const Array< int > &offsets)
 Constructor for square block matrices. More...
 
 BlockMatrix (const Array< int > &row_offsets, const Array< int > &col_offsets)
 Constructor for rectangular block matrices. More...
 
void SetBlock (int i, int j, SparseMatrix *mat)
 Set A(i,j) = mat. More...
 
int NumRowBlocks () const
 Return the number of row blocks. More...
 
int NumColBlocks () const
 Return the number of column blocks. More...
 
SparseMatrixGetBlock (int i, int j)
 Return a reference to block (i,j). Reference may be invalid if Aij(i,j) == NULL. More...
 
const SparseMatrixGetBlock (int i, int j) const
 
int IsZeroBlock (int i, int j) const
 Check if block (i,j) is a zero block. More...
 
Array< int > & RowOffsets ()
 Return the row offsets for block starts. More...
 
Array< int > & ColOffsets ()
 Return the columns offsets for block starts. More...
 
const Array< int > & RowOffsets () const
 Return the row offsets for block starts (const version) More...
 
const Array< int > & ColOffsets () const
 Return the row offsets for block starts (const version) More...
 
int RowSize (const int i) const
 Return the number of non zeros in row i. More...
 
void EliminateRowCol (Array< int > &ess_bc_dofs, Vector &sol, Vector &rhs)
 Symmetric elimination of the marked degree of freedom. More...
 
SparseMatrixCreateMonolithic () const
 Returns a monolithic CSR matrix that represents this operator. More...
 
void PrintMatlab (std::ostream &os=std::cout) const
 Export the monolithic matrix to file. More...
 
virtual ~BlockMatrix ()
 Destructor. More...
 
virtual double & Elem (int i, int j)
 Returns reference to a_{ij}. More...
 
virtual const double & Elem (int i, int j) const
 Returns constant reference to a_{ij}. More...
 
virtual MatrixInverseInverse () const
 Returns a pointer to (approximation) of the matrix inverse. More...
 
virtual int NumNonZeroElems () const
 Returns the total number of non zeros in the matrix. More...
 
virtual int GetRow (const int row, Array< int > &cols, Vector &srow) const
 
virtual void EliminateZeroRows ()
 
virtual void Mult (const Vector &x, Vector &y) const
 Matrix-Vector Multiplication y = A*x. More...
 
virtual void AddMult (const Vector &x, Vector &y, const double val=1.) const
 Matrix-Vector Multiplication y = y + val*A*x. More...
 
virtual void MultTranspose (const Vector &x, Vector &y) const
 MatrixTranspose-Vector Multiplication y = A'*x. More...
 
virtual void AddMultTranspose (const Vector &x, Vector &y, const double val=1.) const
 MatrixTranspose-Vector Multiplication y = y + val*A'*x. More...
 
- Public Member Functions inherited from mfem::AbstractSparseMatrix
 AbstractSparseMatrix (int s=0)
 Creates a square matrix of the given size. More...
 
 AbstractSparseMatrix (int h, int w)
 Creates a matrix of the given height and width. More...
 
virtual ~AbstractSparseMatrix ()
 Destroys AbstractSparseMatrix. More...
 
- Public Member Functions inherited from mfem::Matrix
 Matrix (int s)
 Creates a square matrix of size s. More...
 
 Matrix (int h, int w)
 Creates a matrix of the given height and width. More...
 
virtual void Finalize (int)
 Finalizes the matrix initialization. More...
 
virtual void Print (std::ostream &out=std::cout, int width_=4) const
 Prints matrix to stream out. More...
 
virtual ~Matrix ()
 Destroys matrix. More...
 
- Public Member Functions inherited from mfem::Operator
 Operator (int s=0)
 Construct a square Operator with given size s (default 0) More...
 
 Operator (int h, int w)
 
int Height () const
 Get the height (size of output) of the Operator. Synonym with NumRows. More...
 
int NumRows () const
 
int Width () const
 Get the width (size of input) of the Operator. Synonym with NumCols. More...
 
int NumCols () const
 
virtual OperatorGetGradient (const Vector &x) const
 Evaluate the gradient operator at the point x. More...
 
void PrintMatlab (std::ostream &out, int n=0, int m=0)
 Prints operator with input size n and output size m in matlab format. More...
 
virtual ~Operator ()
 

Public Attributes

int owns_blocks
 if owns_blocks the SparseMatrix objects Aij will be deallocated. More...
 

Additional Inherited Members

- Protected Attributes inherited from mfem::Operator
int height
 
int width
 

Detailed Description

Definition at line 23 of file blockmatrix.hpp.

Constructor & Destructor Documentation

mfem::BlockMatrix::BlockMatrix ( const Array< int > &  offsets)

Constructor for square block matrices.

offsets: offsets that mark the start of each row/column block (size nRowBlocks+1). Note: BlockMatrix will not own/copy the data contained in offsets.

Definition at line 21 of file blockmatrix.cpp.

mfem::BlockMatrix::BlockMatrix ( const Array< int > &  row_offsets,
const Array< int > &  col_offsets 
)

Constructor for rectangular block matrices.

row_offsets: offsets that mark the start of each row block (size nRowBlocks+1). col_offsets: offsets that mark the start of each column block (size nColBlocks+1). Note: BlockMatrix will not own/copy the data contained in offsets.

Definition at line 33 of file blockmatrix.cpp.

mfem::BlockMatrix::~BlockMatrix ( )
virtual

Destructor.

Definition at line 46 of file blockmatrix.cpp.

Member Function Documentation

void mfem::BlockMatrix::AddMult ( const Vector x,
Vector y,
const double  val = 1. 
) const
virtual

Matrix-Vector Multiplication y = y + val*A*x.

Implements mfem::AbstractSparseMatrix.

Definition at line 288 of file blockmatrix.cpp.

void mfem::BlockMatrix::AddMultTranspose ( const Vector x,
Vector y,
const double  val = 1. 
) const
virtual

MatrixTranspose-Vector Multiplication y = y + val*A'*x.

Implements mfem::AbstractSparseMatrix.

Definition at line 323 of file blockmatrix.cpp.

Array<int>& mfem::BlockMatrix::ColOffsets ( )
inline

Return the columns offsets for block starts.

Definition at line 55 of file blockmatrix.hpp.

const Array<int>& mfem::BlockMatrix::ColOffsets ( ) const
inline

Return the row offsets for block starts (const version)

Definition at line 59 of file blockmatrix.hpp.

SparseMatrix * mfem::BlockMatrix::CreateMonolithic ( ) const

Returns a monolithic CSR matrix that represents this operator.

Definition at line 350 of file blockmatrix.cpp.

double & mfem::BlockMatrix::Elem ( int  i,
int  j 
)
virtual

Returns reference to a_{ij}.

Implements mfem::Matrix.

Definition at line 108 of file blockmatrix.cpp.

const double & mfem::BlockMatrix::Elem ( int  i,
int  j 
) const
virtual

Returns constant reference to a_{ij}.

Implements mfem::Matrix.

Definition at line 122 of file blockmatrix.cpp.

void mfem::BlockMatrix::EliminateRowCol ( Array< int > &  ess_bc_dofs,
Vector sol,
Vector rhs 
)

Symmetric elimination of the marked degree of freedom.

ess_bc_dofs: marker of the degree of freedom to be eliminated dof i is eliminated if ess_bc_dofs[i] = 1. sol: vector that stores the values of the degree of freedom that need to be eliminated rhs: vector that stores the rhs of the system.

Definition at line 178 of file blockmatrix.cpp.

void mfem::BlockMatrix::EliminateZeroRows ( )
virtual

If the matrix is square, it will place 1 on the diagonal (i,i) if row i has "almost" zero l1-norm. If entry (i,i) does not belong to the sparsity pattern of A, then a error will occur.

Implements mfem::AbstractSparseMatrix.

Definition at line 233 of file blockmatrix.cpp.

SparseMatrix & mfem::BlockMatrix::GetBlock ( int  i,
int  j 
)

Return a reference to block (i,j). Reference may be invalid if Aij(i,j) == NULL.

Definition at line 69 of file blockmatrix.cpp.

const SparseMatrix & mfem::BlockMatrix::GetBlock ( int  i,
int  j 
) const

Return a reference to block (i,j). Reference may be invalid if Aij(i,j) == NULL. (const version)

Definition at line 81 of file blockmatrix.cpp.

int mfem::BlockMatrix::GetRow ( const int  row,
Array< int > &  cols,
Vector srow 
) const
virtual

Gets the columns indexes and values for row row. The return value is always 0 since cols and srow are copies of the values in the matrix.

Implements mfem::AbstractSparseMatrix.

Definition at line 150 of file blockmatrix.cpp.

virtual MatrixInverse* mfem::BlockMatrix::Inverse ( ) const
inlinevirtual

Returns a pointer to (approximation) of the matrix inverse.

Implements mfem::Matrix.

Definition at line 83 of file blockmatrix.hpp.

int mfem::BlockMatrix::IsZeroBlock ( int  i,
int  j 
) const
inline

Check if block (i,j) is a zero block.

Definition at line 51 of file blockmatrix.hpp.

void mfem::BlockMatrix::Mult ( const Vector x,
Vector y 
) const
virtual

Matrix-Vector Multiplication y = A*x.

Implements mfem::AbstractSparseMatrix.

Definition at line 279 of file blockmatrix.cpp.

void mfem::BlockMatrix::MultTranspose ( const Vector x,
Vector y 
) const
virtual

MatrixTranspose-Vector Multiplication y = A'*x.

Implements mfem::AbstractSparseMatrix.

Definition at line 314 of file blockmatrix.cpp.

int mfem::BlockMatrix::NumColBlocks ( ) const
inline

Return the number of column blocks.

Definition at line 44 of file blockmatrix.hpp.

int mfem::BlockMatrix::NumNonZeroElems ( ) const
virtual

Returns the total number of non zeros in the matrix.

Implements mfem::AbstractSparseMatrix.

Definition at line 95 of file blockmatrix.cpp.

int mfem::BlockMatrix::NumRowBlocks ( ) const
inline

Return the number of row blocks.

Definition at line 42 of file blockmatrix.hpp.

void mfem::BlockMatrix::PrintMatlab ( std::ostream &  os = std::cout) const

Export the monolithic matrix to file.

Definition at line 428 of file blockmatrix.cpp.

Array<int>& mfem::BlockMatrix::RowOffsets ( )
inline

Return the row offsets for block starts.

Definition at line 53 of file blockmatrix.hpp.

const Array<int>& mfem::BlockMatrix::RowOffsets ( ) const
inline

Return the row offsets for block starts (const version)

Definition at line 57 of file blockmatrix.hpp.

int mfem::BlockMatrix::RowSize ( const int  i) const

Return the number of non zeros in row i.

Definition at line 136 of file blockmatrix.cpp.

void mfem::BlockMatrix::SetBlock ( int  i,
int  j,
SparseMatrix mat 
)

Set A(i,j) = mat.

Definition at line 54 of file blockmatrix.cpp.

Member Data Documentation

int mfem::BlockMatrix::owns_blocks

if owns_blocks the SparseMatrix objects Aij will be deallocated.

Definition at line 117 of file blockmatrix.hpp.


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