IFEM  90A354
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ISTLMatrix Class Reference

Class for representing the system matrix in ISTL format. More...

#include <ISTLMatrix.h>

Inheritance diagram for ISTLMatrix:
Inheritance graph
[legend]
Collaboration diagram for ISTLMatrix:
Collaboration graph
[legend]

Public Member Functions

 ISTLMatrix (const ProcessAdm &padm, const LinSolParams &spar)
 Constructor.
 
 ISTLMatrix (const ISTLMatrix &A)
 Copy constructor.
 
 ~ISTLMatrix () override
 The destructor frees the dynamically allocated arrays.
 
LinAlg::MatrixType getType () const override
 Returns the matrix type.
 
size_t dim (int=1) const override
 Returns the dimension of the system matrix.
 
SystemMatrixcopy () const override
 Creates a copy of the system matrix and returns a pointer to it.
 
void initAssembly (const SAM &sam, char) override
 Initializes the element assembly process. that are needed before the actual assembly can start are performed. More...
 
void init () override
 Initializes the matrix to zero assuming it is properly dimensioned.
 
bool endAssembly () override
 Copies the assembled matrix into iA.
 
bool solve (SystemVector &B, Real *) override
 Solves the linear system of equations for a given right-hand-side. More...
 
bool solve (const SystemVector &B, SystemVector &x) override
 Solves the linear system of equations for a given right-hand-side. More...
 
Real Linfnorm () const override
 Returns the L-infinity norm of the matrix.
 
ISTL::Mat & getMatrix ()
 Returns the ISTL matrix (for assignment).
 
const ISTL::Mat & getMatrix () const
 Returns the ISTL matrix (for read access).
 
- Public Member Functions inherited from SparseMatrix
 SparseMatrix (SparseSolver eqSolver=NONE, int nt=1)
 Default constructor creating an empty matrix.
 
 SparseMatrix (size_t m, size_t n=0, SparseSolver eqsolver=NONE)
 Constructor creating a \(m \times n\) matrix.
 
 SparseMatrix (const SparseMatrix &B)
 Copy constructor.
 
virtual ~SparseMatrix ()
 The destructor frees the dynamically allocated arrays.
 
virtual bool lockPattern (bool doLock)
 Locks or unlocks the sparsity pattern. More...
 
void resize (size_t r, size_t c=0, bool forceEditable=false)
 Resizes the matrix to dimension \(r \times c\). More...
 
bool redim (size_t r, size_t c)
 Resizes the matrix to dimension \(r \times c\). More...
 
size_t rows () const
 Query number of matrix rows.
 
size_t cols () const
 Query number of matrix columns.
 
size_t size () const
 Query total matrix size in terms of number of non-zero elements.
 
Realoperator() (size_t r, size_t c)
 Index-1 based element access.
 
const Realoperator() (size_t r, size_t c) const
 Index-1 based element reference.
 
const ValueMapgetValues () const
 For traversal of the non-zero elements of an editable matrix.
 
void printSparsity (std::ostream &os) const
 Print sparsity pattern - for inspection purposes.
 
void printFull (std::ostream &os) const
 Print the matrix in full rectangular form. More...
 
virtual void dump (std::ostream &os, LinAlg::StorageFormat format, const char *label)
 Dumps the system matrix on a specified format.
 
void preAssemble (const SAM &sam, bool delayLocking)
 Initializes the element sparsity pattern based on node connections. More...
 
virtual void preAssemble (const std::vector< IntVec > &MMNPC, size_t nel=0)
 Initializes the element sparsity pattern based on node connections. More...
 
virtual void compressPattern ()
 Compresses the sparsity pattern.
 
virtual bool assemble (const Matrix &eM, const SAM &sam, int e)
 Adds an element matrix into the associated system matrix. More...
 
virtual bool assemble (const Matrix &eM, const SAM &sam, SystemVector &B, int e)
 Adds an element matrix into the associated system matrix. More...
 
virtual bool assemble (const Matrix &eM, const SAM &sam, SystemVector &B, const IntVec &meq)
 Adds an element matrix into the associated system matrix. More...
 
virtual bool assemble (const Matrix &eM, const IntVec &meq)
 Adds an element matrix into the associated system matrix. More...
 
bool assembleCol (const RealArray &V, const SAM &sam, int n, size_t col)
 Adds a nodal vector into columns of a non-symmetric sparse matrix. More...
 
bool assembleCol (Real val, const SAM &sam, int n, size_t col)
 Adds a scalar value into columns of a non-symmetric sparse matrix. More...
 
virtual bool augment (const SystemMatrix &B, size_t r0, size_t c0)
 Augments a similar matrix symmetrically to the current matrix. More...
 
virtual bool truncate (Real threshold=Real(1.0e-16))
 Truncates all small matrix elements to zero. More...
 
virtual void mult (Real alpha)
 Multiplication with a scalar.
 
virtual bool add (const SystemMatrix &B, Real alpha)
 Adds a matrix with similar sparsity pattern to the current matrix. More...
 
virtual bool add (Real sigma, int ieq)
 Adds the constant σ to the diagonal of this matrix.
 
virtual bool multiply (const SystemVector &B, SystemVector &C) const
 Performs the matrix-vector multiplication C = *this * B.
 
void calcCSR (IntVec &iA, IntVec &jA) const
 Calculates compressed-sparse-row arrays from the element map. More...
 
bool split (std::array< SparseMatrix, 4 > &Asub, const IntVec &meqn2) const
 Splits the matrix into four sub-matrices, A11, A12, A21, A22. More...
 
bool getColumn (size_t c, Vector &col) const
 Extracts a specified column from the matrix. More...
 
bool isFactored () const
 Returns whether the matrix has been factored or not.
 
virtual bool solve (SystemVector &b, Real *rc=nullptr)=0
 Solves the linear system of equations for a given right-hand-side. More...
 
virtual bool solve (const SystemVector &b, SystemVector &x)
 Solves the linear system of equations for a given right-hand-side. More...
 
- Public Member Functions inherited from SystemMatrix
virtual ~SystemMatrix ()
 Empty destructor.
 
virtual bool empty () const
 Checks if the matrix is empty.
 
bool isZero () const
 Checks if the matrix have no non-zero contributions.
 
void initNonZeroEqs ()
 Initializes the nonZeroEqs flags.
 
bool flagNonZeroEqs (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 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.
 

Protected Member Functions

void handleSolverReset ()
 Handles solver resets.
 
- Protected Member Functions inherited from SparseMatrix
bool optimiseRows (bool transposed=false)
 Converts the matrix to an optimized row-oriented format.
 
bool optimiseCols ()
 Converts the matrix to an optimized column-oriented format. More...
 
bool optimiseCols (const std::vector< std::set< int > > &dofc)
 Converts the matrix to an optimized column-oriented format. More...
 
bool solveSAMG (Vector &B)
 Invokes the SAMG equation solver for a given right-hand-side. More...
 
bool solveSLU (Vector &B)
 Invokes the SuperLU equation solver for a given right-hand-side. More...
 
bool solveSLUx (Vector &B, Real *rcond)
 Invokes the SuperLU equation solver for a given right-hand-side. More...
 
bool solveUMF (Vector &B, Real *rcond)
 Invokes the UMFPACK equation solver for a given right-hand-side. More...
 
virtual std::ostream & write (std::ostream &os) const
 Writes the system matrix to the given output stream.
 
- Protected Member Functions inherited from SystemMatrix
 SystemMatrix ()
 Default constructor.
 
 SystemMatrix (const SystemMatrix &a)
 Copy constructor.
 

Protected Attributes

std::unique_ptr< ISTL::Operator > op
 The matrix adapter.
 
std::unique_ptr< ISTL::InverseOperator > solver
 Solver to use.
 
std::unique_ptr< ISTL::Preconditioner > pre
 Preconditioner to use.
 
ISTL::Mat iA
 The actual ISTL matrix.
 
const ProcessAdmadm
 Process administrator.
 
ISTLSolParams solParams
 Linear solver parameters.
 
int nLinSolves = 0
 Number of linear solves.
 
- Protected Attributes inherited from SparseMatrix
bool factored
 Set to true when the matrix is factorized.
 
IntVec IA
 Identifies the beginning of each row or column.
 
IntVec JA
 Specifies column/row index of each nonzero element.
 
Vector A
 Stores the nonzero matrix elements.
 

Additional Inherited Members

- Public Types inherited from SparseMatrix
enum  SparseSolver { NONE , SUPERLU , S_A_M_G , UMFPACK }
 Available equation solvers for this matrix type.
 
- Static Public Member Functions inherited from SystemMatrix
static SystemMatrixcreate (const ProcessAdm *adm, LinAlg::MatrixType mType, int num_thread_SLU=1)
 Static method creating a matrix of the given type.
 
static SystemMatrixcreate (const ProcessAdm *adm, LinAlg::MatrixType mType, const LinSolParams &spar)
 Static method creating a matrix of the given type.
 
- Static Public Attributes inherited from SparseMatrix
static bool printSLUstat = false
 Print solution statistics for SuperLU?
 

Detailed Description

Class for representing the system matrix in ISTL format.

Member Function Documentation

◆ initAssembly()

void ISTLMatrix::initAssembly ( const SAM sam,
char   
)
overridevirtual

Initializes the element assembly process. that are needed before the actual assembly can start are performed.

Parameters
[in]samAuxiliary data describing the FE model topology, etc.

Reimplemented from SparseMatrix.

References SparseMatrix::cols(), SAM::getDofCouplings(), SAM::getNoEquations(), iA, SparseMatrix::preAssemble(), SparseMatrix::resize(), and SparseMatrix::rows().

◆ solve() [1/2]

bool ISTLMatrix::solve ( const SystemVector B,
SystemVector x 
)
overridevirtual

Solves the linear system of equations for a given right-hand-side.

Parameters
[in]BRight-hand-side vector
[out]xSolution vector

Reimplemented from SystemMatrix.

References ISTLVector::getVector(), handleSolverReset(), iA, nLinSolves, op, pre, SparseMatrix::rows(), ISTLSolParams::setupPC(), solParams, and solver.

◆ solve() [2/2]

bool ISTLMatrix::solve ( SystemVector B,
Real  
)
overridevirtual

Solves the linear system of equations for a given right-hand-side.

Parameters
BRight-hand-side vector on input, solution vector on output

Reimplemented from SparseMatrix.

References ISTLVector::getVector(), handleSolverReset(), iA, nLinSolves, op, pre, SparseMatrix::rows(), ISTLSolParams::setupPC(), solParams, and solver.


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