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

Class for representing a diagonal system matrix. More...

#include <DiagMatrix.h>

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

Public Member Functions

 DiagMatrix (size_t m=0)
 Default constructor.
 
 DiagMatrix (const DiagMatrix &A)
 Copy constructor.
 
 DiagMatrix (const RealArray &data, size_t nrows=0)
 Special constructor taking data from a one-dimensional array.
 
virtual ~DiagMatrix ()
 Empty destructor.
 
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.
 
bool redim (size_t r)
 Resizes the matrix to dimension \(r \times r\). More...
 
virtual size_t dim (int) const
 Returns the dimension of the system matrix.
 
VectorgetMat ()
 Access to the matrix itself.
 
Realoperator() (size_t r)
 Index-1 based element access.
 
const Realoperator() (size_t r) const
 Index-1 based element reference.
 
virtual void dump (std::ostream &os, LinAlg::StorageFormat format, const char *label)
 Dumps the system matrix on a specified format.
 
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...
 
bool assembleStruct (int val, const SAM &sam, const IntVec &meq)
 Assembles a validation matrix assuming unit element contributions. More...
 
virtual void mult (Real alpha)
 Multiplication with a scalar.
 
virtual bool add (const SystemMatrix &B, Real alpha)
 Adds a matrix with similar dimension to the current matrix. More...
 
virtual bool add (Real sigma, int ieq)
 Adds the constant σ to the diagonal 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...
 
virtual Real Linfnorm () const
 Returns the L-infinity norm of the matrix.
 
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.
 
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

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 Attributes

Vector myMat
 The actual diagonal matrix.
 

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 a diagonal system matrix.

Member Function Documentation

◆ add()

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

Adds a matrix with similar dimension to the current matrix.

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

Reimplemented from SystemMatrix.

References utl::vector< T >::add(), SystemMatrix::flagNonZeroEqs(), myMat, and utl::vector< T >::size().

◆ assemble() [1/4]

bool DiagMatrix::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/4]

bool DiagMatrix::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 SAM::getElmEqns(), myMat, SAM::neq, utl::matrix< T >::rows(), and utl::vector< T >::size().

Referenced by assemble().

◆ assemble() [3/4]

bool DiagMatrix::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.

References utl::matrix< T >::cols(), SystemMatrix::flagNonZeroEqs(), SAM::meqn, SAM::mmceq, SAM::mpmceq, myMat, utl::matrix< T >::rows(), and SAM::ttcc.

◆ assemble() [4/4]

bool DiagMatrix::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().

◆ assembleStruct()

bool DiagMatrix::assembleStruct ( int  val,
const SAM sam,
const IntVec meq 
)

Assembles a validation matrix assuming unit element contributions.

Parameters
[in]valValue identifying current threading group
[in]samAuxiliary data for FE assembly management
[in]meqMatrix of element equation numbers

For validation of threading groups.

This method is doing the same as the above assemble() method, but where all element matrices are assumed identity matrices. The purpose is to verify that each equation only gets a single contribution within each threading group.

References SystemMatrix::flagNonZeroEqs(), SAM::meqn, SAM::mmceq, SAM::mpmceq, and myMat.

Referenced by ASMs2D::validateThreadGroups().

◆ initAssembly()

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

Initializes the element assembly process.

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

Implements SystemMatrix.

References myMat, SAM::neq, and utl::vector< T >::resize().

◆ redim()

bool DiagMatrix::redim ( size_t  r)
inline

Resizes the matrix to dimension \(r \times r\).

Will preserve existing matrix content within the new dimension.

References myMat, utl::vector< T >::resize(), and utl::RETAIN.

◆ 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 DiagMatrix::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 utl::vector< T >::empty(), SystemVector::getPtr(), myMat, and Real.

◆ 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)

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