17#include <dune/common/exceptions.hh>
36 mechanicalPotentialEnergy,
37 microMagneticPotentialEnergy
87 magnetizationAndVectorPotential
104requires(
sizeof...(Affordances) <= 3)
107 using Base = std::tuple<Affordances...>;
111 :
Base(affordances...) {}
125 template <FEAffordance Affordance>
127 using AffordanceRaw = std::remove_cvref_t<Affordance>;
128 if constexpr (std::is_same_v<AffordanceRaw, AffordanceCollection>)
129 return affordances == *
this;
131 if constexpr (std::is_same_v<AffordanceRaw, ScalarAffordance>) {
132 if constexpr (hasScalarAffordance)
133 return affordances == std::get<ScalarAffordance>(*
this);
137 if constexpr (std::is_same_v<AffordanceRaw, VectorAffordance>) {
138 if constexpr (hasVectorAffordance)
139 return affordances == std::get<VectorAffordance>(*
this);
143 if constexpr (std::is_same_v<AffordanceRaw, MatrixAffordance>) {
144 if constexpr (hasMatrixAffordance)
145 return affordances == std::get<MatrixAffordance>(*
this);
154 requires hasScalarAffordance
156 return std::get<ScalarAffordance>(*
this);
159 requires hasVectorAffordance
161 return std::get<VectorAffordance>(*
this);
164 requires hasMatrixAffordance
166 return std::get<MatrixAffordance>(*
this);
204namespace AffordanceCollections {
221template <FESolutions sol, FEParameter para,
typename SV = Eigen::VectorXd,
typename PM =
double>
239 template <
typename SV2 = SV,
typename PM2 = PM>
241 : sol_(std::make_unique<SV>(std::forward<SV2>(solVec))),
242 parameter_(std::make_unique<PM>(std::forward<PM2>(
parameter))) {}
249 template <
typename PB>
251 : sol_(std::make_unique<SV>(SV::Zero(
basis.flat().size()))),
252 parameter_(std::make_unique<PM>(0.0)) {}
262 : sol_(other.sol_ ? std::make_unique<SV>(*other.sol_) : nullptr),
263 parameter_(other.parameter_ ? std::make_unique<PM>(*other.parameter_) : nullptr) {}
274 if (
this != &other) {
275 sol_ = other.sol_ ? std::make_unique<SV>(*other.sol_) :
nullptr;
276 parameter_ = other.parameter_ ? std::make_unique<PM>(*other.parameter_) :
nullptr;
290 parameter_ = std::make_unique<PM>(val);
302 template <
typename SV2 = SolutionVectorType>
304 sol_ = std::make_unique<SV>(std::forward<SV2>(solVec));
315 DUNE_THROW(Dune::InvalidStateException,
"Solution vector is not initialized.");
326 DUNE_THROW(Dune::InvalidStateException,
"Solution vector is not initialized.");
338 DUNE_THROW(Dune::InvalidStateException,
"Parameter is not initialized.");
350 DUNE_THROW(Dune::InvalidStateException,
"Parameter is not initialized.");
369 template <
typename T>
372 DUNE_THROW(Dune::InvalidStateException,
"Solution vector is not initialized.");
378 std::unique_ptr<SV> sol_;
379 std::unique_ptr<PM> parameter_;
Implementation of the make enum macro.
Definitions of ResultTypes used for finite element results.
FEParameter
A strongly typed enum class representing the FE parameter.
Definition: ferequirements.hh:75
FESolutions
A strongly typed enum class representing the type of the solutions vectors.
Definition: ferequirements.hh:88
#define MAKE_ENUM(type,...)
Macro to create an enumeration with a string conversion function.The macro creates an enum class with...
Definition: makeenum.hh:40
Definition: assemblermanipulatorbuildingblocks.hh:22
constexpr MatrixAffordance stiffnessdiffBucklingVector
Definition: ferequirements.hh:173
auto vectorAffordance(MatrixAffordance affordanceM)
Definition: ferequirements.hh:177
MatrixAffordance
A strongly typed enum class representing the matrix affordance.
Definition: ferequirements.hh:64
@ stiffnessdiffBucklingVector
constexpr MatrixAffordance stiffness
Definition: ferequirements.hh:172
constexpr VectorAffordance forces
Definition: ferequirements.hh:170
constexpr ScalarAffordance potentialEnergy
Definition: ferequirements.hh:175
auto scalarAffordance(MatrixAffordance affordanceM)
Definition: ferequirements.hh:186
VectorAffordance
A strongly typed enum class representing the vector affordance.
Definition: ferequirements.hh:49
constexpr MatrixAffordance mass
Definition: ferequirements.hh:174
ScalarAffordance
A strongly typed enum class representing the scalar affordance.
Definition: ferequirements.hh:38
@ mechanicalPotentialEnergy
@ microMagneticPotentialEnergy
constexpr AffordanceCollection elastoStatics(ScalarAffordance::mechanicalPotentialEnergy, VectorAffordance::forces, MatrixAffordance::stiffness)
def basis(gv, tree)
Definition: basis.py:10
Struct representing a collection of affordances.
Definition: ferequirements.hh:106
std::tuple< Affordances... > Base
Definition: ferequirements.hh:107
auto vectorAffordance() const
Definition: ferequirements.hh:158
constexpr AffordanceCollection(Affordances... affordances)
Definition: ferequirements.hh:110
auto scalarAffordance() const
Definition: ferequirements.hh:153
AffordanceCollection()=default
constexpr bool hasAffordance(Affordance &&affordances) const
Check if a specific affordance is present in the requirements.
Definition: ferequirements.hh:126
auto matrixAffordance() const
Definition: ferequirements.hh:163
Class representing the requirements for finite element calculations.
Definition: ferequirements.hh:223
FERequirements()=default
Default constructor.
bool populated() const
Tells if the class contains all needed values.
Definition: ferequirements.hh:360
FERequirements & operator=(const FERequirements &other)
Copy assignment operator.
Definition: ferequirements.hh:273
FERequirements(const FERequirements &other)
Copy constructor.
Definition: ferequirements.hh:261
SV SolutionVectorType
Type of the solution vector.
Definition: ferequirements.hh:225
FERequirements(SV2 &&solVec, PM2 &¶meter)
Constructor initializing the solution vector and parameter.
Definition: ferequirements.hh:240
PM ParameterType
Type of the parameter.
Definition: ferequirements.hh:226
SV & globalSolution()
Get the global solution vector.
Definition: ferequirements.hh:324
FERequirements & insertGlobalSolution(SV2 &&solVec)
Insert a global solution vector into the requirements.
Definition: ferequirements.hh:303
const SolutionVectorType & globalSolution() const
Get the global solution vector.
Definition: ferequirements.hh:313
FERequirements & insertParameter(const PM &val)
Insert a parameter into the requirements.
Definition: ferequirements.hh:289
const PM & parameter() const
Get the parameter value.
Definition: ferequirements.hh:336
PM & parameter()
Get the parameter value.
Definition: ferequirements.hh:348
FERequirements(const Ikarus::BasisHandler< PB > &basis)
Constructor from a basis.
Definition: ferequirements.hh:250
SV & operator+=(const T &rhs)
Enables the usage of the class as a solution vector.
Definition: ferequirements.hh:370
Wrapper class for a hierarchical basis constructed from a pre-basis.
Definition: utils/basis.hh:30
Type trait to check if a specified type is present in a tuple.
Definition: traits.hh:88
Concept to check if a given type is one of the predefined affordance enums or the AffordanceCollectio...
Definition: ferequirements.hh:96
Wrapper around Dune-functions global basis.