12#include <dune/common/referencehelper.hh>
28template <
typename FEC,
typename DV>
35 using GlobalIndex =
typename FEContainerRaw::value_type::GlobalIndex;
36 using Basis =
typename DV::Basis;
41 using SizeType =
typename DirichletValuesType::SizeType;
50 template <
typename FEContainer_ = FEContainer,
typename DirichletValuesType_ = DirichletValuesType>
52 : feContainer_{
std::forward<FEContainer_>(fes)},
54 constraintsBelow_.reserve(dirichletValues_.size());
56 for (
auto iv : std::ranges::iota_view{
decltype(dirichletValues_.size())(0), dirichletValues_.size()}) {
57 constraintsBelow_.emplace_back(counter);
58 if (dirichletValues_.isConstrained(iv))
61 fixedDofs_ = dirichletValues_.fixedDOFsize();
68 size_t reducedSize() {
return dirichletValues_.size() - fixedDofs_; }
74 size_t size() {
return dirichletValues_.size(); }
83 Eigen::VectorXd
createFullVector(Eigen::Ref<const Eigen::VectorXd> reducedVector);
95 const auto&
dirichletValues()
const {
return Dune::resolveRef(dirichletValues_); }
101 const auto&
gridView()
const {
return Dune::resolveRef(dirichletValues_.basis().gridView()); }
126 return dirichletValues_.basis().gridView().size(GridView::dimension) * 8;
137 req_ = std::make_optional<FERequirement>(req);
139 dBCOption_ = std::make_optional<DBCOption>(dbcOption);
163 void bind(
DBCOption dbcOption) { dBCOption_ = std::make_optional<DBCOption>(dbcOption); }
175 DUNE_THROW(Dune::InvalidStateException,
"The assembler is not bound to a requirement, affordance or dBCOption.");
185 return req_.has_value();
195 return affordances_.has_value();
205 return dBCOption_.has_value();
213 if (req_.has_value())
216 DUNE_THROW(Dune::InvalidStateException,
"The requirement can only be obtained after binding");
224 if (affordances_.has_value())
225 return affordances_.value();
227 DUNE_THROW(Dune::InvalidStateException,
"The affordance can only be obtained after binding");
235 if (dBCOption_.has_value())
236 return dBCOption_.value();
238 DUNE_THROW(Dune::InvalidStateException,
"The dBCOption can only be obtained after binding");
244 std::optional<FERequirement> req_;
245 std::optional<AffordanceCollectionType> affordances_;
246 std::vector<size_t> constraintsBelow_{};
248 std::optional<DBCOption> dBCOption_;
253template <
class FEV,
class DirichletValuesType>
254FlatAssemblerBase(
const FEV& fes,
255 const DirichletValuesType&
dirichletValues) -> FlatAssemblerBase<FEV, DirichletValuesType>;
265template <
typename SA,
typename FEC,
typename DV,
typename ST>
284 return underlying().getScalarImpl(feRequirements, affordance);
293 return underlying().getScalarImpl(underlying().requirement(),
310template <
typename VA,
typename FEC,
typename DV,
typename VT>
320 using GlobalIndex =
typename FEContainerRaw::value_type::GlobalIndex;
341 return underlying().getRawVectorImpl(feRequirements, affordance);
343 return underlying().getReducedVectorImpl(feRequirements, affordance);
345 return underlying().getVectorImpl(feRequirements, affordance);
347 __builtin_unreachable();
361 return vector(underlying().requirement(), underlying().affordanceCollection().
vectorAffordance(), dbcOption);
387template <
typename MA,
typename FEC,
typename DV,
typename MT>
397 using GlobalIndex =
typename FEContainerRaw::value_type::GlobalIndex;
416 return underlying().getRawMatrixImpl(feRequirements, affordance);
418 return underlying().getReducedMatrixImpl(feRequirements, affordance);
420 return underlying().getMatrixImpl(feRequirements, affordance);
422 __builtin_unreachable();
434 return matrix(underlying().requirement(), underlying().affordanceCollection().matrixAffordance(), dbcOption);
Definition of the LinearElastic class for finite element mechanics computations.
Definition: assemblermanipulatorbuildingblocks.hh:22
auto vectorAffordance(MatrixAffordance affordanceM)
Definition: ferequirements.hh:176
MatrixAffordance
A strongly typed enum class representing the matrix affordance.
Definition: ferequirements.hh:63
auto scalarAffordance(MatrixAffordance affordanceM)
Definition: ferequirements.hh:185
DBCOption
Definition: dirichletbcenforcement.hh:7
VectorAffordance
A strongly typed enum class representing the vector affordance.
Definition: ferequirements.hh:48
ScalarAffordance
A strongly typed enum class representing the scalar affordance.
Definition: ferequirements.hh:37
def dirichletValues(basis)
Definition: dirichlet_values.py:38
The FlatAssemblerBase takes care of common subtasks done by flat assemblers.
Definition: assembler/interface.hh:30
void bind(AffordanceCollectionType affordanceCollection)
Binds the assembler to an affordance collection.
Definition: assembler/interface.hh:154
std::remove_cvref_t< FEC > FEContainerRaw
Type of the raw finite element container.
Definition: assembler/interface.hh:32
void bind(const FERequirement &req, AffordanceCollectionType affordanceCollection, DBCOption dbcOption=DBCOption::Full)
Binds the assembler to a set of finite element requirement and affordance.
Definition: assembler/interface.hh:135
typename FEContainerRaw::value_type::Requirement FERequirement
Type of the finite element requirement.
Definition: assembler/interface.hh:34
typename DirichletValuesType::SizeType SizeType
size_type of the container storing Dirichlet flags
Definition: assembler/interface.hh:41
void bind(DBCOption dbcOption)
Binds the assembler to an affordance collection.
Definition: assembler/interface.hh:163
void bind(const FERequirement &req)
Binds the assembler to a finite element requirement.
Definition: assembler/interface.hh:147
bool boundToAffordanceCollection() const
Returns true if the assembler is bound to an affordance collection.
Definition: assembler/interface.hh:194
FEC FEContainer
Type of the finite element container (reference or by value).
Definition: assembler/interface.hh:39
const auto & dirichletValues() const
Returns the dirichlet value object.
Definition: assembler/interface.hh:95
Eigen::VectorXd createFullVector(Eigen::Ref< const Eigen::VectorXd > reducedVector)
Creates the full-sized vector of size Dof and inserts the values of a reduced vector at the "free" de...
Definition: simpleassemblers.inl:25
FlatAssemblerBase(FEContainer_ &&fes, DirichletValuesType_ &&dirichletValues)
Constructor for FlatAssemblerBase.
Definition: assembler/interface.hh:51
FERequirement & requirement()
Returns the requirement.
Definition: assembler/interface.hh:212
bool boundToRequirement() const
Returns true if the assembler is bound to a finite element requirement.
Definition: assembler/interface.hh:184
bool boundToDBCOption() const
Returns true if the assembler is bound to an affordance collection.
Definition: assembler/interface.hh:204
size_t constraintsBelow(SizeType i) const
Returns the number of constraints below a given degrees of freedom index.
Definition: assembler/interface.hh:109
DBCOption dBCOption() const
Returns the dirichlet boundary condition enforcement option.
Definition: assembler/interface.hh:234
bool isConstrained(SizeType i) const
Returns true if a given degree of freedom is fixed by a Dirichlet boundary condition.
Definition: assembler/interface.hh:117
size_t reducedSize()
Returns the size of the free degrees of freedom, which are not fixed by a Dirichlet boundary conditio...
Definition: assembler/interface.hh:68
typename FEContainerRaw::value_type::GlobalIndex GlobalIndex
Type of the global index.
Definition: assembler/interface.hh:35
auto & finiteElements() const
Returns the container of finite elements.
Definition: assembler/interface.hh:89
DV DirichletValuesType
Type of the Dirichlet values.
Definition: assembler/interface.hh:40
typename Basis::GridView GridView
Type of the grid view.
Definition: assembler/interface.hh:37
bool bound() const
Returns true if the assembler is bound to a finite element requirement and affordance.
Definition: assembler/interface.hh:171
size_t estimateOfConnectivity() const
Coarse estimate of node connectivity, i.e., this relates to the bandwidth of a sparse matrix....
Definition: assembler/interface.hh:125
AffordanceCollectionType affordanceCollection() const
Returns the affordance.
Definition: assembler/interface.hh:223
size_t size()
Returns the size of nodes, i.e., the number of degrees of freedom.
Definition: assembler/interface.hh:74
const auto & gridView() const
Returns the gridView object.
Definition: assembler/interface.hh:101
typename DV::Basis Basis
Type of the basis.
Definition: assembler/interface.hh:36
The ScalarAssembler provides an interface for an assembler that assembles scalar quantities.
Definition: assembler/interface.hh:267
const ScalarType & scalar()
Calculates the scalar quantity requested by the bound feRequirements and returns a reference.
Definition: assembler/interface.hh:292
typename FEContainerRaw::value_type::Requirement FERequirement
Definition: assembler/interface.hh:274
ST ScalarType
Definition: assembler/interface.hh:270
std::remove_cvref_t< FEC > FEContainerRaw
Type of the raw finite element container.
Definition: assembler/interface.hh:273
SA ScalarAssemblerType
Definition: assembler/interface.hh:269
DV DirichletValuesType
Definition: assembler/interface.hh:271
FEC FEContainer
Definition: assembler/interface.hh:272
const ScalarType & scalar(const FERequirement &feRequirements, ScalarAffordance affordance)
Calculates the scalar quantity requested by feRequirements and affordance.
Definition: assembler/interface.hh:283
The VectorAssembler provides an interface for an assembler that assembles vector quantities.
Definition: assembler/interface.hh:312
const VectorType & vector(DBCOption dbcOption)
Calculates the vectorial quantity requested by the bound feRequirements and the affordance....
Definition: assembler/interface.hh:360
DV DirichletValuesType
Definition: assembler/interface.hh:322
VA VectorAssemblerType
Definition: assembler/interface.hh:314
typename FEContainerRaw::value_type::Requirement FERequirement
Type of the finite element requirement.
Definition: assembler/interface.hh:319
VT VectorType
Definition: assembler/interface.hh:315
std::remove_cvref_t< FEC > FEContainerRaw
Type of the raw finite element container.
Definition: assembler/interface.hh:317
const VectorType & vector(const FERequirement &feRequirements, VectorAffordance affordance, DBCOption dbcOption=DBCOption::Full)
Calculates the vectorial quantity requested by the feRequirements and the affordance....
Definition: assembler/interface.hh:338
FEC FEContainer
Definition: assembler/interface.hh:323
const VectorType & vector()
Calculates the vectorial quantity requested by the bound feRequirements, the affordance and the dBCOp...
Definition: assembler/interface.hh:372
typename FEContainerRaw::value_type::GlobalIndex GlobalIndex
Type of the global index.
Definition: assembler/interface.hh:320
The MatrixAssembler provides an interface for an assembler that assembles matrix quantities.
Definition: assembler/interface.hh:389
DV DirichletValuesType
Definition: assembler/interface.hh:399
const MatrixType & matrix(DBCOption dbcOption)
Calculates the matrix quantity requested by the bound feRequirements and the affordance.
Definition: assembler/interface.hh:433
typename FEContainerRaw::value_type::GlobalIndex GlobalIndex
Type of the global index.
Definition: assembler/interface.hh:397
typename FEContainerRaw::value_type::Requirement FERequirement
Type of the finite element requirement.
Definition: assembler/interface.hh:396
const MatrixType & matrix(const FERequirement &feRequirements, MatrixAffordance affordance, DBCOption dbcOption=DBCOption::Full)
Calculates the matrix quantity requested by feRequirements and the affordance. For DBCOption::Full a ...
Definition: assembler/interface.hh:413
std::remove_cvref_t< FEC > FEContainerRaw
Type of the raw finite element container.
Definition: assembler/interface.hh:394
MT MatrixType
Definition: assembler/interface.hh:392
FEC FEContainer
Definition: assembler/interface.hh:400
MA MatrixAssemblerType
Definition: assembler/interface.hh:391
const MatrixType & matrix()
Calculates the matrix quantity requested by the bound feRequirements, the affordance and the dBCOptio...
Definition: assembler/interface.hh:445
Struct representing a collection of affordances.
Definition: ferequirements.hh:105
Definition of DirichletValues class for handling Dirichlet boundary conditions.