OGS
MaterialLib::Solids::MFront::OGSMFrontThermodynamicForcesView< DisplacementDim, TDynForces > Class Template Reference

Detailed Description

template<int DisplacementDim, typename TDynForces>
class MaterialLib::Solids::MFront::OGSMFrontThermodynamicForcesView< DisplacementDim, TDynForces >

Provides convenient access to the individual blocks of MFront's thermodynamic forces data.

Template Parameters
DisplacementDimthe displacement dimension
TDynForcesa list (of types) of thermodynamic forces

"Thermodynamic forces" is MFront nomenclature for the data an MFront behaviour computes.

TDynForces is a list of types. Each is expected to behave like Strain and the other classes in Variable.h.

MFront's thermodynamic forces are stored in a single vector of double values. The data of forces that come earlier in TDynForces are stored earlier in MFront's data.

Definition at line 42 of file ThermodynamicForcesView.h.

#include <ThermodynamicForcesView.h>

Classes

struct  SizeOf
 A template metafunction accessing the size of the given Variable. More...
 

Public Member Functions

template<typename Force >
auto block (Force force, OGSMFrontThermodynamicForcesData const &data) const
 Read-only access to the data for the given thermodynamic force Force.
 
template<typename Force >
auto block (Force, std::vector< double > const &data) const
 Overload taking a std::vector.
 
template<typename Force , std::enable_if_t< SizeOf< Force >::value==1, bool > = true>
double & block (Force force, OGSMFrontThermodynamicForcesData &data) const
 
template<typename Force , std::enable_if_t< SizeOf< Force >::value==1, bool > = true>
double & block (Force, std::vector< double > &data) const
 Overload taking a std::vector.
 
template<typename Force , std::enable_if_t< SizeOf< Force >::value !=1, bool > = true>
auto block (Force force, OGSMFrontThermodynamicForcesData &data) const
 
template<typename Force , std::enable_if_t< SizeOf< Force >::value !=1, bool > = true>
auto block (Force, std::vector< double > &data) const
 Overload taking a std::vector.
 

Static Public Attributes

static constexpr std::size_t data_size_all_forces
 The passed data to the block() methods must have this size.
 

Static Private Member Functions

template<typename Force >
static constexpr std::size_t dataOffset ()
 
template<typename Force , typename DataVector >
static constexpr auto asEigenMap (DataVector &data)
 Access a block of the given data as an Eigen::Map.
 
template<typename Force , typename DataVector >
static constexpr auto & asDouble (DataVector &data)
 Access a block of the given data as a double value.
 

Member Function Documentation

◆ asDouble()

template<int DisplacementDim, typename TDynForces >
template<typename Force , typename DataVector >
static constexpr auto & MaterialLib::Solids::MFront::OGSMFrontThermodynamicForcesView< DisplacementDim, TDynForces >::asDouble ( DataVector & data)
inlinestaticconstexprprivate

Access a block of the given data as a double value.

Definition at line 97 of file ThermodynamicForcesView.h.

98 {
99 static_assert(Force::template size<DisplacementDim>() == 1,
100 "Use asEigenMap for the multi component case.");
101
102 assert(data.size() == data_size_all_forces);
103
104 constexpr std::size_t data_offset = dataOffset<Force>();
105
106 return data[data_offset];
107 }
static constexpr std::size_t data_size_all_forces
The passed data to the block() methods must have this size.

References MaterialLib::Solids::MFront::OGSMFrontThermodynamicForcesView< DisplacementDim, TDynForces >::data_size_all_forces, and MaterialLib::Solids::MFront::OGSMFrontThermodynamicForcesView< DisplacementDim, TDynForces >::dataOffset().

Referenced by MaterialLib::Solids::MFront::OGSMFrontThermodynamicForcesView< DisplacementDim, TDynForces >::block(), and MaterialLib::Solids::MFront::OGSMFrontThermodynamicForcesView< DisplacementDim, TDynForces >::block().

◆ asEigenMap()

template<int DisplacementDim, typename TDynForces >
template<typename Force , typename DataVector >
static constexpr auto MaterialLib::Solids::MFront::OGSMFrontThermodynamicForcesView< DisplacementDim, TDynForces >::asEigenMap ( DataVector & data)
inlinestaticconstexprprivate

Access a block of the given data as an Eigen::Map.

Definition at line 74 of file ThermodynamicForcesView.h.

75 {
76 static_assert(Force::template size<DisplacementDim>() != 1,
77 "Use asDouble for the single component case.");
78
79 assert(data.size() == data_size_all_forces);
80
81 constexpr std::size_t data_offset = dataOffset<Force>();
82
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;
86
87 using MatrixType =
88 std::conditional_t<std::is_const_v<DataVector>,
89 const Eigen::Matrix<double, rows, cols, order>,
90 Eigen::Matrix<double, rows, cols, order>>;
91
92 return Eigen::Map<MatrixType>(data.data() + data_offset);
93 }

References MaterialLib::Solids::MFront::OGSMFrontThermodynamicForcesView< DisplacementDim, TDynForces >::data_size_all_forces, and MaterialLib::Solids::MFront::OGSMFrontThermodynamicForcesView< DisplacementDim, TDynForces >::dataOffset().

Referenced by MaterialLib::Solids::MFront::OGSMFrontThermodynamicForcesView< DisplacementDim, TDynForces >::block(), and MaterialLib::Solids::MFront::OGSMFrontThermodynamicForcesView< DisplacementDim, TDynForces >::block().

◆ block() [1/6]

template<int DisplacementDim, typename TDynForces >
template<typename Force , std::enable_if_t< SizeOf< Force >::value==1, bool > = true>
double & MaterialLib::Solids::MFront::OGSMFrontThermodynamicForcesView< DisplacementDim, TDynForces >::block ( Force force,
OGSMFrontThermodynamicForcesData & data ) const
inline

Read-write access to the data for the given thermodynamic force Force.

This overload is chosen if Force has one component.

Definition at line 140 of file ThermodynamicForcesView.h.

141 {
142 return block(force, data.data);
143 }
auto block(Force force, OGSMFrontThermodynamicForcesData const &data) const
Read-only access to the data for the given thermodynamic force Force.

References MaterialLib::Solids::MFront::OGSMFrontThermodynamicForcesView< DisplacementDim, TDynForces >::block(), and MaterialLib::Solids::MFront::OGSMFrontThermodynamicForcesData::data.

◆ block() [2/6]

template<int DisplacementDim, typename TDynForces >
template<typename Force , std::enable_if_t< SizeOf< Force >::value !=1, bool > = true>
auto MaterialLib::Solids::MFront::OGSMFrontThermodynamicForcesView< DisplacementDim, TDynForces >::block ( Force force,
OGSMFrontThermodynamicForcesData & data ) const
inline

Read-write access to the data for the given thermodynamic force Force.

This overload is chosen if Force has more than one component.

Definition at line 159 of file ThermodynamicForcesView.h.

160 {
161 return block(force, data.data);
162 }

References MaterialLib::Solids::MFront::OGSMFrontThermodynamicForcesView< DisplacementDim, TDynForces >::block(), and MaterialLib::Solids::MFront::OGSMFrontThermodynamicForcesData::data.

◆ block() [3/6]

template<int DisplacementDim, typename TDynForces >
template<typename Force >
auto MaterialLib::Solids::MFront::OGSMFrontThermodynamicForcesView< DisplacementDim, TDynForces >::block ( Force force,
OGSMFrontThermodynamicForcesData const & data ) const
inline

◆ block() [4/6]

template<int DisplacementDim, typename TDynForces >
template<typename Force , std::enable_if_t< SizeOf< Force >::value==1, bool > = true>
double & MaterialLib::Solids::MFront::OGSMFrontThermodynamicForcesView< DisplacementDim, TDynForces >::block ( Force ,
std::vector< double > & data ) const
inline

Overload taking a std::vector.

Definition at line 148 of file ThermodynamicForcesView.h.

149 {
150 return asDouble<Force>(data);
151 }
static constexpr auto & asDouble(DataVector &data)
Access a block of the given data as a double value.

References MaterialLib::Solids::MFront::OGSMFrontThermodynamicForcesView< DisplacementDim, TDynForces >::asDouble().

◆ block() [5/6]

template<int DisplacementDim, typename TDynForces >
template<typename Force , std::enable_if_t< SizeOf< Force >::value !=1, bool > = true>
auto MaterialLib::Solids::MFront::OGSMFrontThermodynamicForcesView< DisplacementDim, TDynForces >::block ( Force ,
std::vector< double > & data ) const
inline

Overload taking a std::vector.

Definition at line 167 of file ThermodynamicForcesView.h.

168 {
169 return asEigenMap<Force>(data);
170 }
static constexpr auto asEigenMap(DataVector &data)
Access a block of the given data as an Eigen::Map.

References MaterialLib::Solids::MFront::OGSMFrontThermodynamicForcesView< DisplacementDim, TDynForces >::asEigenMap().

◆ block() [6/6]

template<int DisplacementDim, typename TDynForces >
template<typename Force >
auto MaterialLib::Solids::MFront::OGSMFrontThermodynamicForcesView< DisplacementDim, TDynForces >::block ( Force ,
std::vector< double > const & data ) const
inline

Overload taking a std::vector.

Definition at line 119 of file ThermodynamicForcesView.h.

120 {
121 constexpr std::size_t data_size =
122 Force::template size<DisplacementDim>();
123
124 if constexpr (data_size == 1)
125 {
126 return asDouble<Force>(data);
127 }
128 else
129 {
130 return asEigenMap<Force>(data);
131 }
132 }

References MaterialLib::Solids::MFront::OGSMFrontThermodynamicForcesView< DisplacementDim, TDynForces >::asDouble(), and MaterialLib::Solids::MFront::OGSMFrontThermodynamicForcesView< DisplacementDim, TDynForces >::asEigenMap().

◆ dataOffset()

template<int DisplacementDim, typename TDynForces >
template<typename Force >
static constexpr std::size_t MaterialLib::Solids::MFront::OGSMFrontThermodynamicForcesView< DisplacementDim, TDynForces >::dataOffset ( )
inlinestaticconstexprprivate

Computes the offset of the given Force's data in MFront's thermodynamic forces data.

Definition at line 57 of file ThermodynamicForcesView.h.

58 {
59 using namespace boost::mp11;
60 static_assert(mp_contains<TDynForces, Force>::value,
61 "The type Force is not in the list TDynForces.");
62
63 using ForceIndex = mp_find<TDynForces, Force>;
64
65 using ForcesHead = mp_take<TDynForces, ForceIndex>;
66
67 using Sizes = mp_transform<SizeOf, ForcesHead>;
68
69 return mp_apply<mp_plus, Sizes>::value;
70 }

Referenced by MaterialLib::Solids::MFront::OGSMFrontThermodynamicForcesView< DisplacementDim, TDynForces >::asDouble(), and MaterialLib::Solids::MFront::OGSMFrontThermodynamicForcesView< DisplacementDim, TDynForces >::asEigenMap().

Member Data Documentation

◆ data_size_all_forces

template<int DisplacementDim, typename TDynForces >
std::size_t MaterialLib::Solids::MFront::OGSMFrontThermodynamicForcesView< DisplacementDim, TDynForces >::data_size_all_forces
staticconstexpr
Initial value:
= boost::mp11::mp_apply<
boost::mp11::mp_plus,
boost::mp11::mp_transform<SizeOf, TDynForces>>::value

The passed data to the block() methods must have this size.

Definition at line 173 of file ThermodynamicForcesView.h.

Referenced by MaterialLib::Solids::MFront::OGSMFrontThermodynamicForcesView< DisplacementDim, TDynForces >::asDouble(), and MaterialLib::Solids::MFront::OGSMFrontThermodynamicForcesView< DisplacementDim, TDynForces >::asEigenMap().


The documentation for this class was generated from the following file: