|
IFEM 90A354
|
Base class for representing a system matrix on different formats. More...
#include <SystemMatrix.h>


Public Member Functions | |
| virtual | ~SystemMatrix () |
| Empty destructor. | |
| virtual LinAlg::MatrixType | getType () const =0 |
| Returns the matrix type. | |
| virtual SystemMatrix * | copy () const =0 |
| Creates a copy of the system matrix and returns a pointer to it. | |
| virtual bool | lockPattern (bool) |
| Locks or unlocks the sparsity pattern. | |
| virtual bool | empty () const |
| Checks if the matrix is empty. | |
| bool | isZero () const |
| Checks if the matrix have no non-zero contributions. | |
| virtual size_t | dim (int idim=1) const =0 |
| Returns the dimension of the system matrix. | |
| virtual void | initAssembly (const SAM &sam, char=0)=0 |
| Initializes the element assembly process. | |
| virtual void | preAssemble (const std::vector< IntVec > &, size_t=0) |
| Initializes the element sparsity pattern based on node connections. | |
| virtual void | compressPattern () |
| Compresses the sparsity pattern. | |
| virtual void | init ()=0 |
| Initializes the matrix to zero assuming it is properly dimensioned. | |
| void | initNonZeroEqs () |
| Initializes the nonZeroEqs flags. | |
| bool | flagNonZeroEq (int ieq=0) |
| Flags equation ieq as pivot element with non-zero contributions. | |
| bool | flagNonZeroEqs (const SAM &sam, const IntVec &meq) |
| Flags the equations meq as pivots with non-zero contributions. | |
| bool | flagNonZeroEqs (const SystemMatrix &B) |
| Flags the non-zero equations from B as non-zero pivots in this. | |
| virtual bool | endAssembly () |
| Finalizes the system matrix assembly. | |
| virtual bool | assemble (const Matrix &eM, const SAM &sam, int e)=0 |
| Adds an element matrix into the associated system matrix. | |
| virtual bool | assemble (const Matrix &eM, const SAM &sam, SystemVector &B, int e)=0 |
| Adds an element matrix into the associated system matrix. | |
| virtual bool | assemble (const Matrix &eM, const SAM &sam, SystemVector &B, const IntVec &meq)=0 |
| Adds an element matrix into the associated system matrix. | |
| virtual bool | assemble (const Matrix &eM, const IntVec &meq)=0 |
| Adds an element matrix into the associated system matrix. | |
| virtual bool | augment (const SystemMatrix &, size_t, size_t) |
| Augments a similar matrix symmetrically to the current matrix. | |
| virtual bool | truncate (Real=Real(1.0e-16)) |
| Truncates all small matrix elements to zero. | |
| virtual void | mult (Real alpha)=0 |
| Multiplication with a scalar. | |
| virtual bool | add (const SystemMatrix &, Real=Real(1)) |
| Adds a matrix with similar structure to the current matrix. | |
| virtual bool | add (Real, int=0) |
| Adds a constant to the diagonal of current matrix. | |
| virtual bool | multiply (const SystemVector &, SystemVector &) const |
| Performs a matrix-vector multiplication. | |
| virtual bool | solve (SystemVector &b, Real *rc=nullptr)=0 |
| Solves the linear system of equations for a given right-hand-side. | |
| virtual bool | solve (const SystemVector &b, SystemVector &x) |
| Solves the linear system of equations for a given right-hand-side. | |
| virtual bool | solve (SystemVector &b, Matrix &x) |
| Solves a linear system of equations for multiple right-hand-sides. | |
| virtual Real | Linfnorm () const =0 |
| Returns the L-infinity norm of the matrix. | |
| virtual void | dump (std::ostream &, LinAlg::StorageFormat, const char *=nullptr) |
| Dumps the system matrix on a specified format. | |
| virtual void | dump (const char *fileName, std::streamsize precision=0, LinAlg::StorageFormat format=LinAlg::FLAT) |
| Dumps the system matrix to specified file. | |
| virtual bool | load (const char *, bool=false) |
| Loads the system matrix from specified file. | |
| StdVector | operator* (const SystemVector &b) const |
| Calculates a matrix-vector product. | |
| StdVector | operator/ (const SystemVector &b) |
| Solves a linear equation system. | |
Static Public Member Functions | |
| static SystemMatrix * | create (const ProcessAdm *adm, LinAlg::MatrixType mType, int num_thread_SLU=1) |
| Static method creating a matrix of the given type. | |
| static SystemMatrix * | create (const ProcessAdm *adm, LinAlg::MatrixType mType, const LinSolParams &spar) |
| Static method creating a matrix of the given type. | |
Protected Member Functions | |
| SystemMatrix () | |
| Default constructor. | |
| SystemMatrix (const SystemMatrix &a) | |
| Copy constructor. | |
| virtual std::ostream & | write (std::ostream &os) const |
| Writes the system matrix to the given output stream. | |
Private Attributes | |
| std::vector< bool > | nonZeroEqs |
| Flags equations with non-zero contributions. | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const SystemMatrix &A) |
| Global stream operator printing the matrix contents. | |
Base class for representing a system matrix on different formats.
The purpose of this class is to define a clean interface for the system matrix and underlying equation solvers, such that the finite element implementation can be performed without paying attention to the actual solver being used.
|
inlinevirtual |
Adds a matrix with similar structure to the current matrix.
Reimplemented in DenseMatrix, DiagMatrix, SparseMatrix, and SPRMatrix.
Referenced by endAssembly(), SIMbase::getRayleighDampingMatrix(), and eig::solve().
|
inlinevirtual |
Adds a constant to the diagonal of current matrix.
Reimplemented in DenseMatrix, DiagMatrix, SparseMatrix, SPRMatrix, and PETScMatrix.
Adds an element matrix into the associated system matrix.
| [in] | eM | The element matrix |
| [in] | meq | Matrix of element equation numbers (0 based) |
To be used when there is no associated SAM object.
Implemented in DenseMatrix, DiagMatrix, SparseMatrix, SPRMatrix, PETScMatrix, and SPRMatrix.
Adds an element matrix into the associated system matrix.
| [in] | eM | The element matrix |
| [in] | sam | Auxiliary data for FE assembly management |
| [in] | e | Identifier for the element that eM belongs to |
Implemented in DenseMatrix, DiagMatrix, SparseMatrix, SPRMatrix, PETScMatrix, and SPRMatrix.
Referenced by ASMs1D::assembleL2matrices(), ASMs2DLag::assembleL2matrices(), ASMs3DLag::assembleL2matrices(), ASMu2D::assembleL2matrices(), ASMu3D::assembleL2matrices(), SAM::assembleSystem(), and SAM::assembleSystem().
|
pure virtual |
Adds an element matrix into the associated system matrix.
| [in] | eM | The element matrix |
| [in] | sam | Auxiliary data for FE assembly management |
| B | The system right-hand-side vector | |
| [in] | meq | Matrix of element equation numbers |
When multi-point constraints are present, contributions from these are also added into the system right-hand-side vector, B.
Implemented in DiagMatrix, SparseMatrix, SPRMatrix, PETScMatrix, SPRMatrix, and DenseMatrix.
|
pure virtual |
Adds an element matrix into the associated system matrix.
| [in] | eM | The element matrix |
| [in] | sam | Auxiliary data for FE assembly management |
| B | The system right-hand-side vector | |
| [in] | e | Identifier for the element that eM belongs to |
When multi-point constraints are present, contributions from these are also added into the system right-hand-side vector, B.
Implemented in DenseMatrix, DiagMatrix, SparseMatrix, SPRMatrix, PETScMatrix, and SPRMatrix.
|
inlinevirtual |
Augments a similar matrix symmetrically to the current matrix.
Reimplemented in DenseMatrix, and SparseMatrix.
|
inlinevirtual |
|
pure virtual |
Creates a copy of the system matrix and returns a pointer to it.
Implemented in DenseMatrix, DiagMatrix, SparseMatrix, SPRMatrix, ISTLMatrix, and PETScMatrix.
Referenced by SIMbase::getLHSmatrix(), and eig::solve().
|
pure virtual |
Returns the dimension of the system matrix.
Implemented in DenseMatrix, SPRMatrix, SparseMatrix, PETScMatrix, DiagMatrix, and ISTLMatrix.
Referenced by _eig_ax(), eig_sol_(), empty(), initNonZeroEqs(), isZero(), eig::solve(), and solve().
|
inlinevirtual |
Dumps the system matrix on a specified format.
Reimplemented in SPRMatrix, DenseMatrix, DiagMatrix, and SparseMatrix.
Referenced by dump(), SIMbase::dumpEqSys(), and NewmarkSIM::solveStep().
|
virtual |
Finalizes the system matrix assembly.
This method will insert 1.0e9 on the diagonal, for all equations without contributions, such that the remaining equations can be solved for, if the method initNonZeroEqs() was invoked before the assembly started.
Reimplemented in ISTLMatrix, and PETScMatrix.
References add(), and nonZeroEqs.
Referenced by ISTLMatrix::endAssembly(), PETScMatrix::endAssembly(), and ASMbase::globalL2projection().
|
pure virtual |
Returns the matrix type.
Implemented in DenseMatrix, DiagMatrix, SparseMatrix, SPRMatrix, ISTLMatrix, and PETScMatrix.
|
pure virtual |
Initializes the matrix to zero assuming it is properly dimensioned.
Implemented in DenseMatrix, DiagMatrix, SparseMatrix, SPRMatrix, ISTLMatrix, and PETScMatrix.
|
pure virtual |
Initializes the element assembly process.
| [in] | sam | Auxiliary data describing the FE model topology, etc. |
This method must be called once before the element assembly loop.
Implemented in SparseMatrix, DenseMatrix, DiagMatrix, SPRMatrix, ISTLMatrix, and PETScMatrix.
|
pure virtual |
Returns the L-infinity norm of the matrix.
Implemented in DenseMatrix, DiagMatrix, SparseMatrix, SPRMatrix, ISTLMatrix, and PETScMatrix.
|
inlinevirtual |
Loads the system matrix from specified file.
Reimplemented in DenseMatrix, and SPRMatrix.
Referenced by NewmarkSIM::solveStep().
|
inlinevirtual |
Locks or unlocks the sparsity pattern.
Reimplemented in SparseMatrix.
|
pure virtual |
Multiplication with a scalar.
Implemented in DenseMatrix, DiagMatrix, SparseMatrix, SPRMatrix, and PETScMatrix.
Referenced by SIMbase::getRayleighDampingMatrix().
|
inlinevirtual |
Performs a matrix-vector multiplication.
Reimplemented in DenseMatrix, DiagMatrix, SparseMatrix, SPRMatrix, and PETScMatrix.
Referenced by _eig_ax(), Mode::computeDamping(), PiolaOperators::Weak::Mass(), operator*(), operator*(), and Mode::orthonormalize().
|
inlinevirtual |
Initializes the element sparsity pattern based on node connections.
Reimplemented in PETScMatrix, and SparseMatrix.
Referenced by ASMs2DLag::assembleL2matrices(), ASMs3DLag::assembleL2matrices(), ASMu2D::assembleL2matrices(), and ASMu3D::assembleL2matrices().
|
inlinevirtual |
Solves the linear system of equations for a given right-hand-side.
| [in] | b | Right-hand-side vector |
| [out] | x | Solution vector |
Reimplemented in DenseMatrix, DiagMatrix, SparseMatrix, SPRMatrix, ISTLMatrix, and PETScMatrix.
References SystemVector::copy(), and solve().
|
virtual |
Solves a linear system of equations for multiple right-hand-sides.
| b | Right-hand-side vectors on input, solution vectors on output | |
| [out] | x | Matrix of solution vectors (row-oriented) |
Reimplemented in PETScMatrix, DenseMatrix, DiagMatrix, SparseMatrix, and SPRMatrix.
References SystemVector::dim(), dim(), SystemVector::getRef(), Real, utl::matrix< T >::resize(), and solve().
|
pure virtual |
Solves the linear system of equations for a given right-hand-side.
| b | Right-hand-side vector on input, solution vector on output | |
| [out] | rc | Reciprocal condition number of the LHS-matrix (optional) |
Implemented in DiagMatrix, SPRMatrix, ISTLMatrix, PETScMatrix, DenseMatrix, SparseMatrix, DenseMatrix, DiagMatrix, SparseMatrix, and SPRMatrix.
Referenced by eig_sol_(), ASMbase::globalL2projection(), operator/(), operator/(), solve(), solve(), and SIMbase::solveEqSystem().
Truncates all small matrix elements to zero.
Reimplemented in SparseMatrix.
|
inlineprotectedvirtual |
Writes the system matrix to the given output stream.
Reimplemented in DenseMatrix, DiagMatrix, SparseMatrix, and SPRMatrix.