IFEM  90A354
Public Member Functions | Protected Member Functions | Private Types | Private Attributes | List of all members
SPRMatrix Class Reference

Class for representing the system matrix on the SPR-format. More...

#include <SPRMatrix.h>

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

Public Member Functions

 SPRMatrix ()
 Default constructor.
 
 SPRMatrix (const SPRMatrix &A)
 Copy constructor.
 
virtual ~SPRMatrix ()
 The destructor frees the dynamically allocated arrays.
 
virtual LinAlg::MatrixType getType () const
 Returns the matrix type.
 
virtual SystemMatrixcopy () const
 Creates a copy of the system matrix and returns a pointer to it.
 
SPRMatrixoperator= (const SPRMatrix &)=delete
 This class is not copyable.
 
virtual size_t dim (int idim) const
 Returns the dimension of the system matrix.
 
virtual void initAssembly (const SAM &sam, char)
 Initializes the element assembly process. More...
 
virtual void init ()
 Initializes the matrix to zero assuming it is properly dimensioned.
 
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...
 
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.
 
virtual bool solve (SystemVector &B, Real *)
 Solves the linear system of equations for a given right-hand-side. More...
 
bool solveEig (SPRMatrix &B, RealArray &val, Matrix &vec, int nev, Real shift=0.0, int iop=1)
 Solves a generalized symmetric-definite eigenproblem. More...
 
virtual Real Linfnorm () const
 Returns the L-infinity norm of the matrix.
 
bool convert (Matrix &fullMat) const
 Converts to a dense matrix.
 
virtual void dump (std::ostream &os, LinAlg::StorageFormat fmt, const char *)
 Dumps the system matrix on a specified format.
 
virtual bool load (const char *fileName, bool binary)
 Loads the system matrix from specified file.
 
virtual bool assemble (const Matrix &eM, const SAM &sam, int e)=0
 Adds an element matrix into the associated system matrix. More...
 
virtual bool assemble (const Matrix &eM, const SAM &sam, SystemVector &B, int e)=0
 Adds an element matrix into the associated system matrix. More...
 
virtual bool assemble (const Matrix &eM, const SAM &sam, SystemVector &B, const IntVec &meq)=0
 Adds an element matrix into the associated system matrix. More...
 
virtual bool assemble (const Matrix &eM, const IntVec &meq)=0
 Adds an element matrix into the associated system matrix. More...
 
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 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 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.
 
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 bool endAssembly ()
 Finalizes the system matrix assembly. More...
 
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 bool solve (const SystemVector &b, SystemVector &x)
 Solves the linear system of equations for a given right-hand-side. More...
 
virtual void dump (const char *fileName, std::streamsize precision=0, LinAlg::StorageFormat format=LinAlg::FLAT)
 Dumps the system matrix to 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

bool assemble (int e, const Matrix &eM, const SAM &sam, Real *B=nullptr)
 Adds an element matrix into the associated system matrix. More...
 
bool multiply (size_t n, const Real *b, Real *c)
 Performs the matrix-vector multiplication c = *this * b.
 
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.
 

Private Types

using SAM64 = SAM
 Convenience alias when using 32-bit int version.
 

Private Attributes

Int_ ierr
 Internal error flag.
 
Int_ mpar [NS]
 Matrix of sparse PARameters.
 
Int_ * msica
 Matrix of Storage Information for CA.
 
Int_ * msifa
 Matrix of Storage Information for FA.
 
Int_ * mtrees
 Matrix of elimination assembly TREES.
 
Int_ * mvarnc
 Matrix of VARiable to Node Correspondence.
 
Realvalues
 The actual matrix VALUES.
 
std::vector< Int_ > iWork
 Integer work array.
 
std::vector< Int_ > * jWork
 Integer work arrays for multi-threaded assembly.
 
std::vector< RealrWork
 Real work array.
 
SAM64mySam
 Possibly 64-bit integer version of SAM arrays.
 

Additional Inherited Members

- 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.
 

Detailed Description

Class for representing the system matrix on the SPR-format.

It is an interface to a Fortran module for assembling and solving linear systems of equations.

Member Function Documentation

◆ add()

bool SPRMatrix::add ( const SystemMatrix B,
Real  alpha 
)
virtual

Adds a matrix with similar sparsity pattern to the current matrix.

Parameters
[in]BThe matrix to be added
[in]alphaScale factor for matrix B

Reimplemented from SystemMatrix.

References SystemMatrix::flagNonZeroEqs(), SystemMatrix::isZero(), mpar, and values.

◆ assemble() [1/9]

bool SPRMatrix::assemble ( const Matrix eM,
const IntVec meq 
)
virtual

Adds an element matrix into the associated system matrix.

Parameters
[in]eMThe element matrix
[in]meqMatrix of element equation numbers (0 based)
Returns
true on successful assembly, otherwise false

To be used when there is no underlying SAM

Implements SystemMatrix.

◆ assemble() [2/9]

virtual bool SystemMatrix::assemble

Adds an element matrix into the associated system matrix.

Parameters
[in]eMThe element matrix
[in]meqMatrix of element equation numbers (0 based)
Returns
true on successful assembly, otherwise false

To be used when there is no underlying SAM

◆ assemble() [3/9]

bool SPRMatrix::assemble ( const Matrix eM,
const SAM sam,
int  e 
)
virtual

Adds an element matrix into the associated system matrix.

Parameters
[in]eMThe element matrix
[in]samAuxiliary data for FE assembly management
[in]eIdentifier for the element that eM belongs to
Returns
true on successful assembly, otherwise false

Implements SystemMatrix.

References assemble().

◆ assemble() [4/9]

virtual bool SystemMatrix::assemble

Adds an element matrix into the associated system matrix.

Parameters
[in]eMThe element matrix
[in]samAuxiliary data for FE assembly management
[in]eIdentifier for the element that eM belongs to
Returns
true on successful assembly, otherwise false

Referenced by assemble().

◆ assemble() [5/9]

bool SPRMatrix::assemble ( const Matrix eM,
const SAM sam,
SystemVector B,
const IntVec meq 
)
virtual

Adds an element matrix into the associated system matrix.

Parameters
[in]eMThe element matrix
[in]samAuxiliary data for FE assembly management
BThe system right-hand-side vector
[in]meqMatrix of element equation numbers
Returns
true on successful assembly, otherwise false

When multi-point constraints are present, contributions from these are also added into the system right-hand-side vector, B.

Implements SystemMatrix.

◆ assemble() [6/9]

virtual bool SystemMatrix::assemble

Adds an element matrix into the associated system matrix.

Parameters
[in]eMThe element matrix
[in]samAuxiliary data for FE assembly management
BThe system right-hand-side vector
[in]meqMatrix of element equation numbers
Returns
true on successful assembly, otherwise false

When multi-point constraints are present, contributions from these are also added into the system right-hand-side vector, B.

◆ assemble() [7/9]

bool SPRMatrix::assemble ( const Matrix eM,
const SAM sam,
SystemVector B,
int  e 
)
virtual

Adds an element matrix into the associated system matrix.

Parameters
[in]eMThe element matrix
[in]samAuxiliary data for FE assembly management
BThe system right-hand-side vector
[in]eIdentifier for the element that eM belongs to
Returns
true on successful assembly, otherwise false

When multi-point constraints are present, contributions from these are also added into the system right-hand-side vector, B.

Implements SystemMatrix.

References assemble(), LinAlg::DENSE, SystemVector::getPtr(), and SystemVector::getType().

◆ assemble() [8/9]

virtual bool SystemMatrix::assemble

Adds an element matrix into the associated system matrix.

Parameters
[in]eMThe element matrix
[in]samAuxiliary data for FE assembly management
BThe system right-hand-side vector
[in]eIdentifier for the element that eM belongs to
Returns
true on successful assembly, otherwise false

When multi-point constraints are present, contributions from these are also added into the system right-hand-side vector, B.

◆ assemble() [9/9]

bool SPRMatrix::assemble ( int  e,
const Matrix eM,
const SAM sam,
Real B = nullptr 
)
protected

Adds an element matrix into the associated system matrix.

Parameters
[in]eMThe element matrix
[in]samAuxiliary data for FE assembly management
BPointer to the system right-hand-side vector
[in]eIdentifier for the element that eM belongs to
Returns
true on successful assembly, otherwise false

References SystemMatrix::flagNonZeroEqs(), ierr, jWork, SAM::madof, SAM::meqn, SAM::mmceq, SAM::mmnpc, SAM::mpar, mpar, SAM::mpmceq, SAM::mpmnpc, msica, msifa, mtrees, mvarnc, mySam, utl::matrixBase< T >::ptr(), utl::matrix< T >::rows(), rWork, spradm_(), SAM::ttcc, and values.

◆ initAssembly()

void SPRMatrix::initAssembly ( const SAM sam,
char   
)
virtual

Initializes the element assembly process.

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

Must be called once before the element assembly loop. The SPR data structures are initialized and the all symbolic operations that are need before the actual assembly can start are performed.

Implements SystemMatrix.

References ierr, iWork, SAM::madof, SAM::meqn, SAM::minex, SAM::mmceq, SAM::mmnpc, SAM::mpar, mpar, SAM::mpmceq, SAM::mpmnpc, SAM::msc, msica, msifa, mtrees, mvarnc, mySam, SAM::ndof, SAM::neq, SAM::nnod, Real, sprpmp_(), sprprp_(), sprrnm_(), sprsas_(), sprsmb_(), sprtrs_(), and values.

◆ solve() [1/3]

virtual bool SystemMatrix::solve
inline

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

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

◆ solve() [2/3]

bool SPRMatrix::solve ( SystemVector B,
Real  
)
virtual

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

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

Implements SystemMatrix.

References LinAlg::DENSE, SystemVector::dim(), SAM::getNodeAndLocalDof(), SystemVector::getPtr(), SystemVector::getType(), ierr, iWork, mpar, msifa, mtrees, mySam, Real, rWork, sprsol_(), and values.

◆ solve() [3/3]

virtual bool SystemMatrix::solve

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

Parameters
bRight-hand-side vector on input, solution vector on output
[out]rcReciprocal condition number of the LHS-matrix (optional)

◆ solveEig()

bool SPRMatrix::solveEig ( SPRMatrix B,
RealArray val,
Matrix vec,
int  nev,
Real  shift = 0.0,
int  iop = 1 
)

Solves a generalized symmetric-definite eigenproblem.

Parameters
BSymmetric and positive definite mass matrix.
[out]valComputed eigenvalues
[out]vecComputed eigenvectors stored column by column
[in]nevThe number of eigenvalues and eigenvectors to compute
[in]shiftEigenvalue shift
[in]iopOption telling whether to factorize matrix A or B.

The eigenproblem is assumed to be on the form A x = λ B x where A ( = *this ) and B both are assumed to be symmetric and B also to be positive definite. The eigenproblem is solved by the SAM library subroutine SPRLAN.

See also
SAM library documentation.

References ierr, iWork, mpar, msifa, mtrees, utl::matrixBase< T >::ptr(), Real, utl::matrix< T >::resize(), rWork, sprlax_(), and values.

Referenced by eig::solve().


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