The StructMatrix hierarchy

The TPZStructMatrix hierarchy is responsible for creating the interface between the Linear Algebra and the Finite Element. It is the set of classes responsible for creating the Finite Element matrix and coordinating its assembly. The available Structural Matrices are listed in Available Structural Matrices, and the Parallel Schemes in Available Parallel Interfaces.

The Structural Matrix Template

This is the class from which the structural matrices should derive. It defines how to implement a structural matrix for an arbitrary matrix storage format. See its subclasses in Available Structural Matrices

template<class TVar>
class TPZStructMatrixT : public TPZStructMatrix

Describes the interface that should be implemented for a given structural matrix, taking into account its type.

It is expected that the child classes will be created as:

template <
  typename TVar=STATE,
  typename TPar=TPZStructMatrixOR<TVar>
  >
class TPZStrDerived :
                  public TPZStructMatrixT<TVar>,
                  public TPar
{
    ...
};
Meaning that it will have one template parameter corresponding to its type and one template parameter corresponding to its Parallel Strategy, a class derived from TPZStrMatParInterface.

Public Functions

virtual TPZStructMatrix *Clone() override = 0

Clone method.

virtual TPZMatrix<TVar> *Create() override = 0

Creates a matrix for assembling.

inline virtual int ClassId() const override

Creates a unique identifier for the class.

TPZStructMatrix() = default

Default constructor.

TPZStructMatrix(const TPZStructMatrix&)

Copy constructor.

TPZStructMatrix(TPZStructMatrix&&) = delete

Move constructor (deleted)

TPZStructMatrix(TPZCompMesh*)

Constructor taking the non-managed mesh as a raw pointer.

TPZStructMatrix(TPZAutoPointer<TPZCompMesh>)

Constructor taking the mesh as a TPZAutoPointer.

The Parallel Layer Interface

This class defines the interface for a custom parallel strategy for the assembly of a structural matrices. Users that wish to implement a custom parallel strategy should do so in a derived class. See its available derived classes in Available Parallel Interfaces.

class TPZStrMatParInterface : public virtual TPZSavable

Describes the interface that should be implemented in a parallel scheme for TPZStructMatrix so anyone can implement a custom parallel interface. Write it such as:

template<class TVar>
class TPZStrMyParInterface: public virtual TPZStrMatParInterface{
  ...
}
where TVar stands for STATE and CSTATE.

Subclassed by TPZStructMatrixOR< STATE >, TPZStructMatrix, TPZStructMatrixOR< TVar >, TPZStructMatrixOT< TVar >, TPZStructMatrixTBBFlow< TVar >

Public Functions

virtual void Assemble(TPZBaseMatrix &stiffness, TPZBaseMatrix &rhs, TPZAutoPointer<TPZGuiInterface> guiInterface) = 0

Methods to be derived in parallel schemes implementations.

Assemble the global system of equations into a matrix that has already been created.

virtual void Assemble(TPZBaseMatrix &rhs, TPZAutoPointer<TPZGuiInterface> guiInterface) = 0

Assemble the global right hand side vector.

inline virtual void InitCreateAssemble()

Operations to be performed at the beginning of CreateAssemble.

inline virtual void EndCreateAssemble(TPZBaseMatrix *stiff)

Operations to be performed at the end of CreateAssemble.

virtual TPZBaseMatrix *CreateAssemble(TPZBaseMatrix &rhs, TPZAutoPointer<TPZGuiInterface> guiInterface)

Creates solver matrix and assembles it alongside global rhs. Avoid overriding it unless there are no other options

inline void SetNumThreads(int n)

Set number of threads to be used in the assembly.

inline int GetNumThreads() const

Get number of threads to be used in the assembly.

inline bool ComputeRhs() const

Whether the rhs vector will be computed or not.

inline void SetComputeRhs(bool rhs)

Set whether to compute the rhs vector.

virtual int ClassId() const override

Unique identifier for each class.

virtual void Read(TPZStream &buf, void *context) override

Reads an objects from the TPZStream buffer.

virtual void Write(TPZStream &buf, int withclassid) const override

Writes this object to the TPZStream buffer.

Include the classid if withclassid = true

The Structural Matrix Base Class

In order to provide an insight of its members and functionalities that will be transmitted to the derived classes, here we present TPZStructMatrix.

class TPZStructMatrix : public virtual TPZStrMatParInterface

Describes the type-agnostic interface that should be implemented for a given structural matrix.

Note

The class TPZStructMatrixT is the one that structural matrices should inherit from.

Subclassed by TPZStructMatrixT< STATE >, TPZStructMatrixT< TVar >

Public Functions

TPZStructMatrix() = default

Default constructor.

~TPZStructMatrix()

Destructor.

TPZStructMatrix(const TPZStructMatrix&)

Copy constructor.

TPZStructMatrix(TPZStructMatrix&&) = delete

Move constructor (deleted)

TPZStructMatrix &operator=(const TPZStructMatrix&) = default

Copy assignment operator.

TPZStructMatrix &operator=(TPZStructMatrix&&) = delete

Move assignment operator.

TPZStructMatrix(TPZCompMesh*)

Constructor taking the non-managed mesh as a raw pointer.

TPZStructMatrix(TPZAutoPointer<TPZCompMesh>)

Constructor taking the mesh as a TPZAutoPointer.

virtual TPZStructMatrix *Clone() = 0

Methods to be overriden in child classes.

Clone method

virtual TPZBaseMatrix *Create() = 0

Creates a matrix for assembling.

void SetMesh(TPZCompMesh*)

Sets the computational mesh via raw pointer.

void SetMesh(TPZAutoPointer<TPZCompMesh>)

Sets the computational mesh via TPZAutoPointer.

inline TPZCompMesh *Mesh() const

Access method for the mesh pointer.

void SetMaterialIds(const std::set<int> &materialids)

Set the set of material ids which will be considered when assembling the system.

inline const std::set<int> &MaterialIds()

Returns the material ids to be computed.

inline bool ShouldCompute(int matid) const

Establish whether a given material id should be computed.

inline void FilterEquations(TPZVec<int64_t> &origindex, TPZVec<int64_t> &destindex) const

Filter out the equations which are out of the range.

inline void SetEquationRange(int64_t mineq, int64_t maxeq)

Set range of equations to be solved.

inline bool HasRange() const

Verify if a range of equations has been specified.

inline TPZEquationFilter &EquationFilter()

Access method for the equation filter.

inline int64_t NReducedEquations() const

Number of equations after applying the filter.

int ComputeElementColors(TPZVec<int> &elementcolors)

Computes a color for each element.

Returns

Number of colors for parallel assembly and the color -1 when the element should not be computed

virtual int ClassId() const override

Unique identifier for each class.

virtual void Read(TPZStream &buf, void *context) override

Reads an objects from the TPZStream buffer.

virtual void Write(TPZStream &buf, int withclassid) const override

Writes this object to the TPZStream buffer.

Include the classid if withclassid = true