LehrFEM++ 1.0.0
A simple Finite Element Library for teaching
Loading...
Searching...
No Matches
Functions
Cell-Oriented Assembly of Galerkin Matrices

Detailed Description

Based on helper objects that provide element matrices these functions rely on the distribute assembly policy to set the entries of global Galerkin matrices.

All the functions have the name AssembleMatrixLocally, but they differ in their arguments. What they have in common is that they are all templated with two types:

The principles of local cell-oriented assembly of Galerkin matrices are explained in Lecture Document Subsection 2.7.4.3, in particular Lecture Document Paragraph 2.7.4.19. An example for the use of local assembly is given in Lecture Document Example 2.7.4.39.

Functions

std::shared_ptr< spdlog::logger > & lf::assemble::AssembleMatrixLogger ()
 The logger that is used by AssembleMatrixLocally() to log additional information. (for logging levels trace + debug)
 
template<typename TMPMATRIX , EntityMatrixProvider ENTITY_MATRIX_PROVIDER>
void lf::assemble::AssembleMatrixLocally (dim_t codim, const DofHandler &dof_handler_trial, const DofHandler &dof_handler_test, ENTITY_MATRIX_PROVIDER &entity_matrix_provider, TMPMATRIX &matrix)
 Assembly function for standard assembly of finite element matrices.
 
template<typename TMPMATRIX , EntityMatrixProvider ENTITY_MATRIX_PROVIDER>
TMPMATRIX lf::assemble::AssembleMatrixLocally (dim_t codim, const DofHandler &dof_handler_trial, const DofHandler &dof_handler_test, ENTITY_MATRIX_PROVIDER &entity_matrix_provider)
 Entity-wise local assembly of a matrix from local matrices.
 
template<typename TMPMATRIX , EntityMatrixProvider ENTITY_MATRIX_PROVIDER>
TMPMATRIX lf::assemble::AssembleMatrixLocally (dim_t codim, const DofHandler &dof_handler, ENTITY_MATRIX_PROVIDER &entity_matrix_provider)
 Entity-wise local assembly of a matrix from local matrices.
 

Function Documentation

◆ AssembleMatrixLocally() [1/3]

template<typename TMPMATRIX , EntityMatrixProvider ENTITY_MATRIX_PROVIDER>
TMPMATRIX lf::assemble::AssembleMatrixLocally ( dim_t codim,
const DofHandler & dof_handler,
ENTITY_MATRIX_PROVIDER & entity_matrix_provider )

Entity-wise local assembly of a matrix from local matrices.

Template Parameters
TMPMATRIXa type fitting the concept of COOMatrix
ENTITY_MATRIX_PROVIDERa type providing the computation of element matrices, must model the concept EntityMatrixProvider
Returns
assembled matrix in a format determined by the template argument TPMATRIX

This special version of the function should be used whenever test and trial space are the same.

See also
AssembleMatrixLocally(const DofHandler &dof_handler_trial,const DofHandler &dof_handler_test,ENTITY_MATRIX_PROVIDER &element_matrix_provider, TMPMATRIX &matrix)

Logger

This function logs additional information to AssembleMatrixLogger(). See Loggers and Debug output for more information.

Definition at line 244 of file assembler.h.

References lf::assemble::AssembleMatrixLocally().

◆ AssembleMatrixLocally() [2/3]

template<typename TMPMATRIX , EntityMatrixProvider ENTITY_MATRIX_PROVIDER>
TMPMATRIX lf::assemble::AssembleMatrixLocally ( dim_t codim,
const DofHandler & dof_handler_trial,
const DofHandler & dof_handler_test,
ENTITY_MATRIX_PROVIDER & entity_matrix_provider )

Entity-wise local assembly of a matrix from local matrices.

Template Parameters
TMPMATRIXa type fitting the concept of COOMatrix
ENTITY_MATRIX_PROVIDERa type providing the computation of element matrices, must model the concept EntityMatrixProvider
Returns
assembled matrix in a format determined by the template argument TPMATRIX
See also
AssembleMatrixLocally(const DofHandler &dof_handler_trial,const DofHandler &dof_handler_test,ENTITY_MATRIX_PROVIDER &entity_matrix_provider, TMPMATRIX &matrix)
Note
Extra requirements for the type TMPMATRIX is imposed; it must provide the method setZero() for setting all entries of the matrix to zero. It must also possess a constructor that takes row and column numbers and creates an (empty) matrix of that size.

Logger

This function logs additional information to AssembleMatrixLogger(). See Loggers and Debug output for more information.

Definition at line 210 of file assembler.h.

References lf::assemble::AssembleMatrixLocally(), and lf::assemble::DofHandler::NumDofs().

◆ AssembleMatrixLocally() [3/3]

template<typename TMPMATRIX , EntityMatrixProvider ENTITY_MATRIX_PROVIDER>
void lf::assemble::AssembleMatrixLocally ( dim_t codim,
const DofHandler & dof_handler_trial,
const DofHandler & dof_handler_test,
ENTITY_MATRIX_PROVIDER & entity_matrix_provider,
TMPMATRIX & matrix )

Assembly function for standard assembly of finite element matrices.

Template Parameters
TMPMATRIXa type fitting the concept of COOMatrix
ENTITY_MATRIX_PROVIDERa type providing the computation of element matrices, must model the concept EntityMatrixProvider
Parameters
codimco-dimension of mesh entities which should be traversed in the course of assembly
dof_handler_triala dof handler object for column space, see DofHandler
dof_handler_testa dof handler object for row space, see DofHandler
entity_matrix_providerEntityMatrixProvider object for passing all kinds of data
matrixmatrix object to which the assembled matrix will be added.

The rationale for passing two different DofHandler objects for trial and test space is given in Lecture Document Remark 2.7.4.24.

Note
The matrix object passed in matrix is not set to zero in the beginning! This makes is possible to assemble a matrix piecemeal via several successive calls to AssembleMatrixLocally(), see Lecture Document Code 2.7.4.46.

This method performs cell-oriented assembly controlled by a local-to-global index map ("dof handler").

Logger

This function logs additional information to AssembleMatrixLogger(). See Loggers and Debug output for more information.

type requirements of template arguments

  • TMPMATRIX is a rudimentary matrix type and must
  • provide a constructor taking two matrix dimension arguments
  • have a method AddtoEntry(i,j,value_to_add) for adding to a matrix entry A model type is COOMatrix.
  • ENTITY_MATRIX_PROVIDER is a EntityMatrixProvider
Note
The element matrix returned by the Eval() method of entity_matrix_provider may have a size larger than that suggested by the number of local shape functions. In this case only its upper left block is accessed.

Example Usage

// initialize triangular 2d mesh somehow
std::shared_ptr<mesh::Mesh> mesh;
// create a dof handler which assigns one global dof to every node of the mesh
assemble::UniformFEDofHandler dofh(mesh, {{base::RefEl::kPoint(), 1}});
// initialize EntityMatrixProvider that defines the local Laplace element
// matrix (only for triangular meshes):
uscalfe::LinearFELaplaceElementMatrix entity_matrix_provider;
// setup a COOMatrix into which the global matrix will be assembled:
assemble::COOMatrix<double> lhs(dofh.NumDofs(), dofh.NumDofs());
// increase logging level for AssembleMatrixLocally():
assemble::AssembleMatrixLogger()->set_level(spdlog::level::debug);
// assemble the global Laplace matrix (iterate over all entities with
// codim=2):
2, dofh, dofh, entity_matrix_provider, lhs);

Definition at line 115 of file assembler.h.

References lf::assemble::AssembleMatrixLogger(), lf::assemble::DofHandler::GlobalDofIndices(), lf::assemble::DofHandler::Mesh(), and lf::assemble::DofHandler::NumLocalDofs().

Referenced by lf::assemble::COOMatrix< SCALAR >::AddToEntry(), lf::assemble::AssembleMatrixLocally(), lf::assemble::AssembleMatrixLocally(), lf::assemble::AssembleVectorLocally(), lf::assemble::AssembleVectorLocally(), lf::assemble::DynamicFEDofHandler::DynamicFEDofHandler(), lf::assemble::UniformFEDofHandler::Entity(), lf::assemble::DynamicFEDofHandler::Entity(), lf::assemble::FixFlaggedSolutionCompAlt(), lf::assemble::FixFlaggedSolutionComponents(), lf::assemble::FixSolutionComponentsLse(), lf::assemble::UniformFEDofHandler::GetNumLocalDofs(), lf::assemble::UniformFEDofHandler::GlobalDofIndices(), lf::assemble::DynamicFEDofHandler::GlobalDofIndices(), lf::assemble::UniformFEDofHandler::GlobalDofIndices(), lf::assemble::UniformFEDofHandler::initIndexArrays(), lf::assemble::UniformFEDofHandler::InteriorGlobalDofIndices(), lf::assemble::DynamicFEDofHandler::InteriorGlobalDofIndices(), lf::assemble::UniformFEDofHandler::InteriorGlobalDofIndices(), lf::assemble::COOMatrix< SCALAR >::makeDense(), lf::assemble::COOMatrix< SCALAR >::MatVecMult(), lf::assemble::COOMatrix< SCALAR >::MatVecMult(), lf::assemble::UniformFEDofHandler::NumCoveredDofs(), lf::assemble::UniformFEDofHandler::NumInteriorDofs(), lf::assemble::DynamicFEDofHandler::NumInteriorDofs(), lf::assemble::UniformFEDofHandler::NumInteriorDofs(), lf::assemble::UniformFEDofHandler::NumLocalDofs(), lf::assemble::DynamicFEDofHandler::NumLocalDofs(), lf::assemble::operator<<(), lf::assemble::COOMatrix< SCALAR >::PrintInfo(), lf::assemble::PrintInfo(), lf::assemble::COOMatrix< SCALAR >::setZero(), and lf::assemble::UniformFEDofHandler::UniformFEDofHandler().

◆ AssembleMatrixLogger()

std::shared_ptr< spdlog::logger > & lf::assemble::AssembleMatrixLogger ( )

The logger that is used by AssembleMatrixLocally() to log additional information. (for logging levels trace + debug)

Definition at line 19 of file assembler.cc.

References lf::base::InitLogger().

Referenced by lf::assemble::AssembleMatrixLocally().