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);
98 const auto&
finiteElements()
const {
return Dune::resolveRef(feContainer_); }
116 const auto&
gridView()
const {
return Dune::resolveRef(dirichletValues_.basis().gridView()); }
141 return dirichletValues_.basis().gridView().size(GridView::dimension) * 8;
152 req_ = std::make_optional<std::reference_wrapper<const FERequirement>>(std::ref(req));
154 dBCOption_ = std::make_optional<DBCOption>(dbcOption);
163 req_ = std::make_optional<std::reference_wrapper<const FERequirement>>(std::ref(req));
180 void bind(
DBCOption dbcOption) { dBCOption_ = std::make_optional<DBCOption>(dbcOption); }
192 DUNE_THROW(Dune::InvalidStateException,
"The assembler is not bound to a requirement, affordance or dBCOption.");
202 return req_.has_value();
212 return affordances_.has_value();
222 return dBCOption_.has_value();
230 if (req_.has_value())
231 return req_.value().get();
233 DUNE_THROW(Dune::InvalidStateException,
"The requirement can only be obtained after binding");
241 if (affordances_.has_value())
242 return affordances_.value();
244 DUNE_THROW(Dune::InvalidStateException,
"The affordance can only be obtained after binding");
252 if (dBCOption_.has_value())
253 return dBCOption_.value();
255 DUNE_THROW(Dune::InvalidStateException,
"The dBCOption can only be obtained after binding");
261 std::optional<std::reference_wrapper<const FERequirement>> req_;
262 std::optional<AffordanceCollectionType> affordances_;
263 std::vector<size_t> constraintsBelow_{};
265 std::optional<DBCOption> dBCOption_;
270template <
class FEV,
class DirichletValuesType>
271FlatAssemblerBase(
const FEV& fes,
272 const DirichletValuesType&
dirichletValues) -> FlatAssemblerBase<FEV, DirichletValuesType>;
282template <
typename SA,
typename FEC,
typename DV,
typename ST>
301 return underlying().getScalarImpl(feRequirements, affordance);
310 return underlying().getScalarImpl(underlying().requirement(),
327template <
typename VA,
typename FEC,
typename DV,
typename VT>
337 using GlobalIndex =
typename FEContainerRaw::value_type::GlobalIndex;
358 return underlying().getRawVectorImpl(feRequirements, affordance);
360 return underlying().getReducedVectorImpl(feRequirements, affordance);
362 return underlying().getVectorImpl(feRequirements, affordance);
364 __builtin_unreachable();
378 return vector(underlying().requirement(), underlying().affordanceCollection().
vectorAffordance(), dbcOption);
404template <
typename MA,
typename FEC,
typename DV,
typename MT>
414 using GlobalIndex =
typename FEContainerRaw::value_type::GlobalIndex;
433 return underlying().getRawMatrixImpl(feRequirements, affordance);
435 return underlying().getReducedMatrixImpl(feRequirements, affordance);
437 return underlying().getMatrixImpl(feRequirements, affordance);
439 __builtin_unreachable();
451 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:178
MatrixAffordance
A strongly typed enum class representing the matrix affordance.
Definition: ferequirements.hh:65
auto scalarAffordance(MatrixAffordance affordanceM)
Definition: ferequirements.hh:187
DBCOption
Definition: dirichletbcenforcement.hh:8
VectorAffordance
A strongly typed enum class representing the vector affordance.
Definition: ferequirements.hh:50
ScalarAffordance
A strongly typed enum class representing the scalar affordance.
Definition: ferequirements.hh:39
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:171
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:150
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:180
void bind(const FERequirement &req)
Binds the assembler to a finite element requirement.
Definition: assembler/interface.hh:162
bool boundToAffordanceCollection() const
Returns true if the assembler is bound to an affordance collection.
Definition: assembler/interface.hh:211
FEC FEContainer
Type of the finite element container (reference or by value).
Definition: assembler/interface.hh:39
const FERequirement & requirement()
Returns the requirement.
Definition: assembler/interface.hh:229
const auto & dirichletValues() const
Returns the dirichlet value object.
Definition: assembler/interface.hh:110
Eigen::VectorXd createFullVector(Eigen::Ref< const Eigen::VectorXd > reducedVector)
Creates the full-sized vector of size size() and inserts the values of a reduced vector at the "free"...
Definition: simpleassemblers.inl:27
FlatAssemblerBase(FEContainer_ &&fes, DirichletValuesType_ &&dirichletValues)
Constructor for FlatAssemblerBase.
Definition: assembler/interface.hh:51
bool boundToRequirement() const
Returns true if the assembler is bound to a finite element requirement.
Definition: assembler/interface.hh:201
const auto & finiteElements() const
Returns the container of finite elements.
Definition: assembler/interface.hh:98
bool boundToDBCOption() const
Returns true if the assembler is bound to an affordance collection.
Definition: assembler/interface.hh:221
size_t constraintsBelow(SizeType i) const
Returns the number of constraints below a given degrees of freedom index.
Definition: assembler/interface.hh:124
DBCOption dBCOption() const
Returns the dirichlet boundary condition enforcement option.
Definition: assembler/interface.hh:251
bool isConstrained(SizeType i) const
Returns true if a given degree of freedom is fixed by a Dirichlet boundary condition.
Definition: assembler/interface.hh:132
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
Eigen::VectorXd createReducedVector(Eigen::Ref< const Eigen::VectorXd > fullVector)
Creates the reduzed-sized vector of size reducedSize() and inserts the values of a full vector at the...
Definition: simpleassemblers.inl:44
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:188
size_t estimateOfConnectivity() const
Coarse estimate of node connectivity, i.e., this relates to the bandwidth of a sparse matrix....
Definition: assembler/interface.hh:140
AffordanceCollectionType affordanceCollection() const
Returns the affordance.
Definition: assembler/interface.hh:240
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:116
auto & finiteElements()
Returns the container of finite elements.
Definition: assembler/interface.hh:104
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:284
typename FEContainerRaw::value_type::Requirement FERequirement
Definition: assembler/interface.hh:291
ST ScalarType
Definition: assembler/interface.hh:287
std::remove_cvref_t< FEC > FEContainerRaw
Type of the raw finite element container.
Definition: assembler/interface.hh:290
SA ScalarAssemblerType
Definition: assembler/interface.hh:286
ScalarType & scalar()
Calculates the scalar quantity requested by the bound feRequirements and returns a reference.
Definition: assembler/interface.hh:309
DV DirichletValuesType
Definition: assembler/interface.hh:288
ScalarType & scalar(const FERequirement &feRequirements, ScalarAffordance affordance)
Calculates the scalar quantity requested by feRequirements and affordance.
Definition: assembler/interface.hh:300
FEC FEContainer
Definition: assembler/interface.hh:289
The VectorAssembler provides an interface for an assembler that assembles vector quantities.
Definition: assembler/interface.hh:329
DV DirichletValuesType
Definition: assembler/interface.hh:339
VA VectorAssemblerType
Definition: assembler/interface.hh:331
typename FEContainerRaw::value_type::Requirement FERequirement
Type of the finite element requirement.
Definition: assembler/interface.hh:336
VT VectorType
Definition: assembler/interface.hh:332
std::remove_cvref_t< FEC > FEContainerRaw
Type of the raw finite element container.
Definition: assembler/interface.hh:334
VectorType & vector(DBCOption dbcOption)
Calculates the vectorial quantity requested by the bound feRequirements and the affordance....
Definition: assembler/interface.hh:377
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:355
FEC FEContainer
Definition: assembler/interface.hh:340
VectorType & vector()
Calculates the vectorial quantity requested by the bound feRequirements, the affordance and the dBCOp...
Definition: assembler/interface.hh:389
typename FEContainerRaw::value_type::GlobalIndex GlobalIndex
Type of the global index.
Definition: assembler/interface.hh:337
The MatrixAssembler provides an interface for an assembler that assembles matrix quantities.
Definition: assembler/interface.hh:406
MatrixType & matrix()
Calculates the matrix quantity requested by the bound feRequirements, the affordance and the dBCOptio...
Definition: assembler/interface.hh:462
DV DirichletValuesType
Definition: assembler/interface.hh:416
typename FEContainerRaw::value_type::GlobalIndex GlobalIndex
Type of the global index.
Definition: assembler/interface.hh:414
typename FEContainerRaw::value_type::Requirement FERequirement
Type of the finite element requirement.
Definition: assembler/interface.hh:413
std::remove_cvref_t< FEC > FEContainerRaw
Type of the raw finite element container.
Definition: assembler/interface.hh:411
MT MatrixType
Definition: assembler/interface.hh:409
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:430
FEC FEContainer
Definition: assembler/interface.hh:417
MA MatrixAssemblerType
Definition: assembler/interface.hh:408
MatrixType & matrix(DBCOption dbcOption)
Calculates the matrix quantity requested by the bound feRequirements and the affordance.
Definition: assembler/interface.hh:450
Struct representing a collection of affordances.
Definition: ferequirements.hh:107
Definition of DirichletValues class for handling Dirichlet boundary conditions.