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

Detailed Description

Functions assembleVectorLocally() for setting entries of the vector representing the finite element Galerkin discretization of a linear functional.

Vectors

The functions differ in their arguments, but all are templated with the following types:

Also refer to Lecture Document Example 2.7.4.27 and Lecture Document Example 2.7.4.39.

Functions

template<typename VECTOR, EntityVectorProvider ENTITY_VECTOR_PROVIDER>
void lf::assemble::AssembleVectorLocally (dim_t codim, const DofHandler &dof_handler, ENTITY_VECTOR_PROVIDER &entity_vector_provider, VECTOR &resultvector)
 entity-local assembly of (right-hand-side) vectors from element vectors
 
template<typename VECTOR, class ENTITY_VECTOR_PROVIDER>
VECTOR lf::assemble::AssembleVectorLocally (dim_t codim, const DofHandler &dof_handler, ENTITY_VECTOR_PROVIDER &entity_vector_provider)
 entity-local assembly of (right-hand-side) vectors from element vectors
 

Function Documentation

◆ AssembleVectorLocally() [1/2]

template<typename VECTOR, class ENTITY_VECTOR_PROVIDER>
VECTOR lf::assemble::AssembleVectorLocally ( dim_t codim,
const DofHandler & dof_handler,
ENTITY_VECTOR_PROVIDER & entity_vector_provider )

entity-local assembly of (right-hand-side) vectors from element vectors

Template Parameters
VECTORa generic vector type with component access through []
entity_vector_providerlocal EntityVectorProvider object (passed as non-const!)
Parameters
codimco-dimension of entities over which assembly should be carried out
dof_handlerobject providing local-to-global dof index mapping, see DofHandler
entity_vector_providerlocal EntityVectorProvider object (passed as non-const!)
Returns
assembled vector as an object of a type specified by the VECTOR template argument
See also
AssembleVectorLocally(const DofHandler &dof_handler, ENTITY_VECTOR_PROVIDER &entity_vector_provider, VECTOR &resultvector)

Additional type requirements for VECTOR template argument

VECTOR must supply a setZero method for initialization with zero. All matrix types of Eigen have such a method see Eigen documentation

Definition at line 355 of file assembler.h.

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

◆ AssembleVectorLocally() [2/2]

template<typename VECTOR, EntityVectorProvider ENTITY_VECTOR_PROVIDER>
void lf::assemble::AssembleVectorLocally ( dim_t codim,
const DofHandler & dof_handler,
ENTITY_VECTOR_PROVIDER & entity_vector_provider,
VECTOR & resultvector )

entity-local assembly of (right-hand-side) vectors from element vectors

Template Parameters
VECTORa generic vector type with component access through []
ENTITY_VECTOR_PROVIDERtype for objects computing entity-local vectors, models concept EntityVectorProvider
Parameters
codimco-dimension of entities over which assembly should be carried out
dof_handlerobject providing local-to-global dof index mapping, see DofHandler
entity_vector_providerlocal EntityVectorProvider object (passed as non-const!)
resultvectorgeneric vector for returning the assembled vector

Type requirements for template arguments

  • VECTOR must provide a size() method telling its length and read/write access through the [] operator.
Note
Contributions of element vectors are added to the entries of the resultvector argument. This means that resultvector has to be initialized before calling this function!

Example Usage

// initialize a 2d mesh somehow
std::shared_ptr<lf::mesh::Mesh> mesh;
// define a EntityVectorProvider which returns the volume for every mesh cell
struct VolumeEntityVectorProvider {
bool isActive(const lf::mesh::Entity& e) const { return e.Codim() == 0; }
Eigen::VectorXd Eval(const lf::mesh::Entity& e) const {
return Eigen::VectorXd::Constant(1, lf::geometry::Volume(*e.Geometry()));
}
} entity_vector_provider;
// define a dof handler which assigns a dof to every mesh cell
lf::assemble::UniformFEDofHandler dofh(
// initialize the output vector:
Eigen::VectorXd x(dofh.NumDofs());
// assemble the global vector over entities with codim=0:
lf::assemble::AssembleVectorLocally(0, dofh, entity_vector_provider, x);
// now x[dofh.GlobalDofIndices(e)[0]] will contain the volume of mesh cell e

Definition at line 299 of file assembler.h.

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

Referenced by AssembleVectorLocally().