7#include <boost/mp11.hpp>
34template <
int DisplacementDim,
typename TDynForces>
37 static_assert(boost::mp11::mp_is_set<TDynForces>::value,
38 "The types in the list TDynForces are not unique.");
41 template <
typename Variable>
43 : boost::mp11::mp_size_t<Variable::template size<DisplacementDim>()>
49 template <
typename Force>
53 static_assert(mp_contains<TDynForces, Force>::value,
54 "The type Force is not in the list TDynForces.");
56 using ForceIndex = mp_find<TDynForces, Force>;
58 using ForcesHead = mp_take<TDynForces, ForceIndex>;
60 using Sizes = mp_transform<SizeOf, ForcesHead>;
62 return mp_apply<mp_plus, Sizes>::value;
66 template <
typename Force,
typename DataVector>
69 static_assert(Force::template size<DisplacementDim>() != 1,
70 "Use asDouble for the single component case.");
76 constexpr std::size_t rows = Force::template rows<DisplacementDim>();
77 constexpr std::size_t cols = Force::template cols<DisplacementDim>();
78 constexpr auto order = cols == 1 ? Eigen::ColMajor : Eigen::RowMajor;
81 std::conditional_t<std::is_const_v<DataVector>,
82 const Eigen::Matrix<double, rows, cols, order>,
83 Eigen::Matrix<double, rows, cols, order>>;
85 return Eigen::Map<MatrixType>(data.data() + data_offset);
89 template <
typename Force,
typename DataVector>
90 static constexpr auto&
asDouble(DataVector& data)
92 static_assert(Force::template size<DisplacementDim>() == 1,
93 "Use asEigenMap for the multi component case.");
99 return data[data_offset];
104 template <
typename Force>
111 template <
typename Force>
112 auto block(Force, std::vector<double>
const& data)
const
114 constexpr std::size_t data_size =
115 Force::template size<DisplacementDim>();
117 if constexpr (data_size == 1)
131 template <
typename Force,
132 std::enable_if_t<SizeOf<Force>::value == 1,
bool> =
true>
139 template <
typename Force,
140 std::enable_if_t<SizeOf<Force>::value == 1,
bool> =
true>
141 double&
block(Force, std::vector<double>& data)
const
150 template <
typename Force,
151 std::enable_if_t<SizeOf<Force>::value != 1,
bool> =
true>
158 template <
typename Force,
159 std::enable_if_t<SizeOf<Force>::value != 1,
bool> =
true>
160 auto block(Force, std::vector<double>& data)
const
167 boost::mp11::mp_plus,
168 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.