17#include <dune/common/exceptions.hh>
32 mechanicalPotentialEnergy,
33 microMagneticPotentialEnergy
83 magnetizationAndVectorPotential
94 gradientNormOfMagnetization,
96 divergenceOfVectorPotential,
119 template <
typename Type>
121 = std::is_same_v<std::remove_cvref_t<Type>,
ScalarAffordances> or std::is_same_v<std::remove_cvref_t<Type>,
123 is_same_v<std::remove_cvref_t<Type>,
MatrixAffordances> or std::is_same_v<std::remove_cvref_t<Type>,
124 AffordanceCollectionImpl>;
134 namespace AffordanceCollections {
140 template <
typename T>
141 struct DeduceRawVectorType {
142 static_assert(!std::is_same<T, T>::value,
"You should end up in the provided specializations");
145 template <
typename T>
146 struct DeduceRawVectorType<std::reference_wrapper<T>> {
150 template <
typename T>
151 struct DeduceRawVectorType<
Eigen::Ref<T>> {
152 using Type = Eigen::Ref<T>;
168 template <
typename SolutionVectorType_ = std::reference_wrapper<Eigen::VectorXd>,
169 typename ParameterType_ = std::reference_wrapper<
double>>
186 template <FEAffordance Affordance>
188 if constexpr (std::is_same_v<Affordance, ScalarAffordances>)
190 else if constexpr (std::is_same_v<Affordance, VectorAffordances>)
192 else if constexpr (std::is_same_v<Affordance, MatrixAffordances>)
194 else if constexpr (std::is_same_v<Affordance, AffordanceCollectionImpl>)
195 affordances = affordance;
209 parameter.insert_or_assign(key, val);
223 sols.insert_or_assign(key, sol);
239 if constexpr (std::is_same_v<SolutionVectorType, std::reference_wrapper<Eigen::VectorXd>>)
240 return sols.at(key).get();
243 }
catch (std::out_of_range& oor) {
244 DUNE_THROW(Dune::RangeError, std::string(
"Out of Range error: ") + std::string(oor.what())
245 +
" in getGlobalSolution with key" +
toString(key));
262 return parameter.at(key).get();
263 }
catch (std::out_of_range& oor) {
264 DUNE_THROW(Dune::RangeError, std::string(
"Out of Range error: ") + std::string(oor.what())
265 +
" in getParameter with key" +
toString(key));
279 template <FEAffordance Affordance>
281 if constexpr (std::is_same_v<Affordance, ScalarAffordances>)
283 else if constexpr (std::is_same_v<Affordance, VectorAffordances>)
285 else if constexpr (std::is_same_v<Affordance, MatrixAffordances>)
287 else if constexpr (std::is_same_v<Affordance, AffordanceCollectionImpl>)
288 return affordances == affordance;
292 std::map<FESolutions, SolutionVectorType> sols;
293 std::map<FEParameter, ParameterType> parameter;
310 template <
typename SolutionVectorType_ = std::reference_wrapper<Eigen::VectorXd>,
311 typename ParameterType_ = std::reference_wrapper<
double>>
322 Base::operator=(base);
326 Base::operator=(std::forward<Base>(base));
341 template <
typename ParameterType =
double>
344 using ResultArray = Eigen::Matrix<ParameterType, Eigen::Dynamic, Eigen::Dynamic, 0, 9, 3>;
355 results.insert_or_assign(resultType, resultArray);
380 if (results.size() != 1)
381 DUNE_THROW(Dune::RangeError,
"getSingleResult can only be called when a single result was inserted");
383 return *(results.begin());
387 std::map<ResultType, ResultArray> results;
390 template <
typename Type>
404 template <
typename FERequirements = FERequirements<>>
420 : reqB{req}, resType(std::move(p_resType)) {}
457 template <FEAffordance Affordance>
502 resType.insert({std::move(keys)...});
547 if (resType.size() == 1)
548 return *(resType.begin());
550 DUNE_THROW(Dune::InvalidStateException,
"This function can only be called when a single result is requested");
555 std::set<ResultType> resType;
Implementation of the make enum macro.
VectorAffordances
A strongly typed enum class representing the vector affordance.
Definition: ferequirements.hh:45
MatrixAffordances
A strongly typed enum class representing the matrix affordance.
Definition: ferequirements.hh:60
ScalarAffordances
A strongly typed enum class representing the scalar affordance.
Definition: ferequirements.hh:34
@ stiffnessdiffBucklingVector
@ mechanicalPotentialEnergy
FEParameter
A strongly typed enum class representing the FE parameter.
Definition: ferequirements.hh:71
ResultType
A strongly typed enum class representing the type of the result request.
Definition: ferequirements.hh:103
FESolutions
A strongly typed enum class representing the type of the solutions vectors.
Definition: ferequirements.hh:84
#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: simpleassemblers.hh:21
constexpr std::string toString(ScalarAffordances _e)
Definition: ferequirements.hh:34
constexpr MatrixAffordances stiffness
Definition: ferequirements.hh:128
constexpr ScalarAffordances potentialEnergy
Definition: ferequirements.hh:132
constexpr MatrixAffordances mass
Definition: ferequirements.hh:130
constexpr MatrixAffordances stiffnessdiffBucklingVector
Definition: ferequirements.hh:129
constexpr VectorAffordances forces
Definition: ferequirements.hh:126
constexpr AffordanceCollectionImpl elastoStatics
Definition: ferequirements.hh:136
Definition: truncatedconjugategradient.hh:24
Struct representing a collection of affordances.
Definition: ferequirements.hh:110
VectorAffordances vectorAffordances
Definition: ferequirements.hh:112
ScalarAffordances scalarAffordances
Definition: ferequirements.hh:111
MatrixAffordances matrixAffordances
Definition: ferequirements.hh:113
Class representing the requirements for finite element calculations.
Definition: ferequirements.hh:170
typename Impl::DeduceRawVectorType< std::remove_cvref_t< SolutionVectorType_ > >::Type SolutionVectorTypeRaw
Definition: ferequirements.hh:173
FERequirements & addAffordance(Affordance &&affordance)
Add an affordance to the requirements.
Definition: ferequirements.hh:187
bool hasAffordance(Affordance &&affordance) const
Check if a specific affordance is present in the requirements.
Definition: ferequirements.hh:280
FERequirements & insertParameter(const FEParameter &key, ParameterTypeRaw &val)
Insert a parameter into the requirements.
Definition: ferequirements.hh:208
FERequirements & insertGlobalSolution(const FESolutions &key, SolutionVectorTypeRaw &sol)
Insert a global solution vector into the requirements.
Definition: ferequirements.hh:222
ParameterType_ ParameterType
Definition: ferequirements.hh:174
typename ParameterType_::type ParameterTypeRaw
Definition: ferequirements.hh:175
const SolutionVectorTypeRaw & getGlobalSolution(const FESolutions &key) const
Get the raw global solution vector for a specific type.
Definition: ferequirements.hh:237
const ParameterTypeRaw & getParameter(FEParameter &&key) const
Get the raw parameter value for a specific key.
Definition: ferequirements.hh:260
SolutionVectorType_ SolutionVectorType
Definition: ferequirements.hh:172
Class representing the requirements for finite element calculations.
Definition: ferequirements.hh:314
FErequirements & operator=(Base &&base)
Definition: ferequirements.hh:325
FErequirements(Base &&base)
Definition: ferequirements.hh:319
FErequirements & operator=(const Base &base)
Definition: ferequirements.hh:321
FErequirements(const Base &base)
Definition: ferequirements.hh:320
Class representing a map of result types to result arrays.
Definition: ferequirements.hh:342
auto & getSingleResult()
Get the result array for a single result type.
Definition: ferequirements.hh:379
Eigen::Matrix< ParameterType, Eigen::Dynamic, Eigen::Dynamic, 0, 9, 3 > ResultArray
Definition: ferequirements.hh:344
ResultArray & getResult(const ResultType &resultType)
Get the result array for a specific result type.
Definition: ferequirements.hh:368
void insertOrAssignResult(ResultType &&resultType, const ResultArray &resultArray)
Insert or assign a result to the map.
Definition: ferequirements.hh:354
Class representing the requirements for obtaining specific results.
Definition: ferequirements.hh:405
ResultRequirements & addAffordance(Affordance &&affordance)
Add an affordance to the finite element requirements.
Definition: ferequirements.hh:458
const SolutionVectorTypeRaw & getGlobalSolution(FESolutions &&key) const
Get the global solution for a specific global solution type.
Definition: ferequirements.hh:514
ResultRequirements & addResultRequest(ResultTypes &&... keys)
Add one or more result types to the set of requested results.
Definition: ferequirements.hh:501
auto getRequestedResult() const
Get the requested result type.
Definition: ferequirements.hh:546
ResultRequirements & insertParameter(FEParameter &&key, ParameterTypeRaw &val)
Insert a parameter into the finite element requirements.
Definition: ferequirements.hh:472
const FERequirements & getFERequirements() const
Get the associated finite element requirements.
Definition: ferequirements.hh:535
typename FERequirements::SolutionVectorType SolutionVectorType
Definition: ferequirements.hh:408
ResultRequirements()=default
Default constructor.
ResultRequirements & insertGlobalSolution(FESolutions &&key, SolutionVectorTypeRaw &sol)
Insert a global solution into the finite element requirements.
Definition: ferequirements.hh:486
typename FERequirements::SolutionVectorTypeRaw SolutionVectorTypeRaw
Definition: ferequirements.hh:409
const ParameterTypeRaw & getParameter(FEParameter &&key) const
Get the value of a specific parameter.
Definition: ferequirements.hh:526
bool isResultRequested(ResultType &&key) const
Check if a specific result type is requested.
Definition: ferequirements.hh:446
ResultRequirements(const FERequirements &req)
Constructor with only FERequirements.
Definition: ferequirements.hh:429
typename FERequirements::ParameterTypeRaw ParameterTypeRaw
Definition: ferequirements.hh:407
ResultRequirements(FERequirements &&req, std::set< ResultType > &&p_resType)
Constructor with FERequirements and result types.
Definition: ferequirements.hh:419
Concept to check if a given type is one of the predefined affordance enums or the AffordanceCollectio...
Definition: ferequirements.hh:121
Definition: ferequirements.hh:391