14#include <boost/mp11.hpp>
41template <
int DisplacementDim,
typename TDynForces>
44 static_assert(boost::mp11::mp_is_set<TDynForces>::value,
45 "The types in the list TDynForces are not unique.");
48 template <
typename Variable>
50 : boost::mp11::mp_size_t<Variable::template size<DisplacementDim>()>
56 template <
typename Force>
60 static_assert(mp_contains<TDynForces, Force>::value,
61 "The type Force is not in the list TDynForces.");
63 using ForceIndex = mp_find<TDynForces, Force>;
65 using ForcesHead = mp_take<TDynForces, ForceIndex>;
67 using Sizes = mp_transform<SizeOf, ForcesHead>;
69 return mp_apply<mp_plus, Sizes>::value;
73 template <
typename Force,
typename DataVector>
76 static_assert(Force::template size<DisplacementDim>() != 1,
77 "Use asDouble for the single component case.");
83 constexpr std::size_t rows = Force::template rows<DisplacementDim>();
84 constexpr std::size_t cols = Force::template cols<DisplacementDim>();
85 constexpr auto order = cols == 1 ? Eigen::ColMajor : Eigen::RowMajor;
88 std::conditional_t<std::is_const_v<DataVector>,
89 const Eigen::Matrix<double, rows, cols, order>,
90 Eigen::Matrix<double, rows, cols, order>>;
92 return Eigen::Map<MatrixType>(data.data() + data_offset);
96 template <
typename Force,
typename DataVector>
97 static constexpr auto&
asDouble(DataVector& data)
99 static_assert(Force::template size<DisplacementDim>() == 1,
100 "Use asEigenMap for the multi component case.");
106 return data[data_offset];
111 template <
typename Force>
118 template <
typename Force>
119 auto block(Force, std::vector<double>
const& data)
const
121 constexpr std::size_t data_size =
122 Force::template size<DisplacementDim>();
124 if constexpr (data_size == 1)
138 template <
typename Force,
139 std::enable_if_t<SizeOf<Force>::value == 1,
bool> =
true>
146 template <
typename Force,
147 std::enable_if_t<SizeOf<Force>::value == 1,
bool> =
true>
148 double&
block(Force, std::vector<double>& data)
const
157 template <
typename Force,
158 std::enable_if_t<SizeOf<Force>::value != 1,
bool> =
true>
165 template <
typename Force,
166 std::enable_if_t<SizeOf<Force>::value != 1,
bool> =
true>
167 auto block(Force, std::vector<double>& data)
const
174 boost::mp11::mp_plus,
175 boost::mp11::mp_transform<SizeOf, TDynForces>>::value;
static constexpr std::size_t data_size_all_forces
The passed data to the block() methods must have this size.
auto block(Force, std::vector< double > &data) const
Overload taking a std::vector.
double & block(Force force, OGSMFrontThermodynamicForcesData &data) const
auto block(Force force, OGSMFrontThermodynamicForcesData &data) const
static constexpr auto & asDouble(DataVector &data)
Access a block of the given data as a double value.
static constexpr std::size_t dataOffset()
double & block(Force, std::vector< double > &data) const
Overload taking a std::vector.
auto block(Force, std::vector< double > const &data) const
Overload taking a std::vector.
static constexpr auto asEigenMap(DataVector &data)
Access a block of the given data as an Eigen::Map.
auto block(Force force, OGSMFrontThermodynamicForcesData const &data) const
Read-only access to the data for the given thermodynamic force Force.
Used for disambiguation with MFront's tangent operator blocks data.
std::vector< double > data
A template metafunction accessing the size of the given Variable.