12 #ifndef MFEM_BLOCKMATRIX
13 #define MFEM_BLOCKMATRIX
15 #include "../config/config.hpp"
16 #include "../general/array.hpp"
17 #include "../general/globals.hpp"
52 int IsZeroBlock(
int i,
int j)
const {
return (Aij(i,j)==NULL) ? 1 : 0; }
80 virtual double&
Elem (
int i,
int j);
82 virtual const double&
Elem (
int i,
int j)
const;
86 mfem_error(
"BlockMatrix::Inverse not implemented \n");
113 const double val = 1.)
const;
123 inline void findGlobalRow(
int iglobal,
int & iblock,
int & iloc)
const;
125 inline void findGlobalCol(
int jglobal,
int & jblock,
int & jloc)
const;
145 inline void BlockMatrix::findGlobalRow(
int iglobal,
int & iblock,
148 if (iglobal > row_offsets[nRowBlocks])
153 for (iblock = 0; iblock < nRowBlocks; ++iblock)
154 if (row_offsets[iblock+1] > iglobal)
159 iloc = iglobal - row_offsets[iblock];
162 inline void BlockMatrix::findGlobalCol(
int jglobal,
int & jblock,
165 if (jglobal > col_offsets[nColBlocks])
170 for (jblock = 0; jblock < nColBlocks; ++jblock)
171 if (col_offsets[jblock+1] > jglobal)
176 jloc = jglobal - col_offsets[jblock];
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.
void PrintMatlab(std::ostream &os=mfem::out) const
Export the monolithic matrix to file.
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.
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...