12 #ifndef MFEM_BLOCKMATRIX
13 #define MFEM_BLOCKMATRIX
15 #include "../config/config.hpp"
16 #include "../general/array.hpp"
51 int IsZeroBlock(
int i,
int j)
const {
return (Aij(i,j)==NULL) ? 1 : 0; }
74 void PrintMatlab(std::ostream & os = std::cout)
const;
78 virtual double&
Elem (
int i,
int j);
81 virtual const double&
Elem (
int i,
int j)
const;
85 mfem_error(
"BlockMatrix::Inverse not implemented \n");
121 inline void findGlobalRow(
int iglobal,
int & iblock,
int & iloc)
const;
123 inline void findGlobalCol(
int jglobal,
int & jblock,
int & jloc)
const;
143 inline void BlockMatrix::findGlobalRow(
int iglobal,
int & iblock,
int & iloc)
const
145 if(iglobal > row_offsets[nRowBlocks])
148 for(iblock = 0; iblock < nRowBlocks; ++iblock)
149 if(row_offsets[iblock+1] > iglobal)
152 iloc = iglobal - row_offsets[iblock];
155 inline void BlockMatrix::findGlobalCol(
int jglobal,
int & jblock,
int & jloc)
const
157 if(jglobal > col_offsets[nColBlocks])
160 for(jblock = 0; jblock < nColBlocks; ++jblock)
161 if(col_offsets[jblock+1] > jglobal)
164 jloc = jglobal - col_offsets[jblock];
void PrintMatlab(std::ostream &os=std::cout) const
Export the monolithic matrix to file.
virtual MatrixInverse * Inverse() const
Returns a pointer to (approximation) of the matrix inverse.
SparseMatrix * CreateMonolithic() const
Returns a monolithic CSR matrix that represents this operator.
int owns_blocks
if owns_blocks the SparseMatrix objects Aij will be deallocated.
void Mult(const Table &A, const Table &B, Table &C)
C = A * B (as boolean matrices)
Abstract data type for sparse matrices.
Abstract data type for matrix inverse.
BlockMatrix(const Array< int > &offsets)
Constructor for square block matrices.
virtual void AddMultTranspose(const Vector &x, Vector &y, const double val=1.) const
MatrixTranspose-Vector Multiplication y = y + val*A'*x.
virtual int GetRow(const int row, Array< int > &cols, Vector &srow) const
void SetBlock(int i, int j, SparseMatrix *mat)
Set A(i,j) = mat.
virtual double & Elem(int i, int j)
Returns reference to a_{ij}.
virtual void EliminateZeroRows()
int IsZeroBlock(int i, int j) const
Check if block (i,j) is a zero block.
int NumRowBlocks() const
Return the number of row blocks.
Array< int > & ColOffsets()
Return the columns offsets for block starts.
void Transpose(const Table &A, Table &At, int _ncols_A)
Transpose a Table.
Array< int > & RowOffsets()
Return the row offsets for block starts.
void EliminateRowCol(Array< int > &ess_bc_dofs, Vector &sol, Vector &rhs)
Symmetric elimination of the marked degree of freedom.
virtual int NumNonZeroElems() const
Returns the total number of non zeros in the matrix.
virtual ~BlockMatrix()
Destructor.
virtual void MultTranspose(const Vector &x, Vector &y) const
MatrixTranspose-Vector Multiplication y = A'*x.
virtual void Mult(const Vector &x, Vector &y) const
Matrix-Vector Multiplication y = A*x.
void mfem_error(const char *msg)
int NumColBlocks() const
Return the number of column blocks.
virtual void AddMult(const Vector &x, Vector &y, const double val=1.) const
Matrix-Vector Multiplication y = y + val*A*x.
const Array< int > & ColOffsets() const
Return the row offsets for block starts (const version)
SparseMatrix & GetBlock(int i, int j)
Return a reference to block (i,j). Reference may be invalid if Aij(i,j) == NULL.
const Array< int > & RowOffsets() const
Return the row offsets for block starts (const version)
int RowSize(const int i) const
Return the number of non zeros in row i.