OGS
MaterialLib::Solids::MFront::OGSMFrontTangentOperatorBlocksView< DisplacementDim, ForcesGradsCombinations > Class Template Reference

Detailed Description

template<int DisplacementDim, typename ForcesGradsCombinations>
class MaterialLib::Solids::MFront::OGSMFrontTangentOperatorBlocksView< DisplacementDim, ForcesGradsCombinations >

Provides convenient access to the individual blocks of MFront's tangent operator data.

Template Parameters
DisplacementDimthe displacement dimension
ForcesGradsCombinationsa list of pairs types corresponding to the tangent operator blocks' variables. See ForcesGradsCombinations template for details.

MFront's tangent operator blocks are stored in a single vector of double values. The implementer of an MFront behaviour can decide which blocks she wants to provide and in which order.

Definition at line 86 of file TangentOperatorBlocksView.h.

#include <TangentOperatorBlocksView.h>

Public Member Functions

 OGSMFrontTangentOperatorBlocksView (std::vector< std::pair< mgis::behaviour::Variable, mgis::behaviour::Variable > > const &to_blocks)
template<typename Force, typename GradOrExtStateVar>
auto block (Force, GradOrExtStateVar, OGSMFrontTangentOperatorData const &data) const

Static Private Member Functions

static constexpr std::size_t size (mgis::behaviour::Variable::Type vt)
template<typename Force, typename GradOrExtStateVar>
static constexpr std::size_t blockIndex ()
 Computes the index of a tangent operator block in the offsets_ array.

Private Attributes

std::array< std::size_t, boost::mp11::mp_size< ForcesGradsCombinations >::value > offsets_

Static Private Attributes

static constexpr std::size_t invalid_offset_ = -1

Constructor & Destructor Documentation

◆ OGSMFrontTangentOperatorBlocksView()

template<int DisplacementDim, typename ForcesGradsCombinations>
MaterialLib::Solids::MFront::OGSMFrontTangentOperatorBlocksView< DisplacementDim, ForcesGradsCombinations >::OGSMFrontTangentOperatorBlocksView ( std::vector< std::pair< mgis::behaviour::Variable, mgis::behaviour::Variable > > const & to_blocks)
inlineexplicit

Constructs a view for the tangent operator blocks to_blocks of some MFront behaviour.

Definition at line 97 of file TangentOperatorBlocksView.h.

100 {
102
104 to_blocks.size(), false); // checked after creation of all offsets.
105
107 [&to_blocks,
109 this]<typename Force, typename GradOrExtStateVar>(
111 {
113 for (auto [block, is_used] :
115 {
116 auto const& [force, grad] = block;
117 if (force.name == Force::name &&
119 {
120 auto constexpr block_idx =
123 is_used = true;
124 return;
125 }
126
127 data_offset += size(force.type) * size(grad.type);
128 }
129 });
130
131 // Indices of unused blocks.
133 ranges::views::filter([](auto const& pair)
134 { return !pair.second; }) |
136
137 if (!indices.empty())
138 {
139 ERR("There are unused tangent operator blocks provided by MFront. "
140 "Following blocks are unused:");
141
142 for (auto const i : indices)
143 {
144 auto const& [force, grad] = to_blocks[i];
145 ERR("\t{}/{}", force.name, grad.name);
146 }
147 OGS_FATAL("All tangent operator blocks must be used.");
148 }
149 }
#define OGS_FATAL(...)
Definition Error.h:19
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:40
static constexpr std::size_t size(mgis::behaviour::Variable::Type vt)
static constexpr std::size_t blockIndex()
Computes the index of a tangent operator block in the offsets_ array.
std::array< std::size_t, boost::mp11::mp_size< ForcesGradsCombinations >::value > offsets_
auto block(Force, GradOrExtStateVar, OGSMFrontTangentOperatorData const &data) const

References block(), blockIndex(), ERR(), invalid_offset_, offsets_, OGS_FATAL, and size().

Member Function Documentation

◆ block()

template<int DisplacementDim, typename ForcesGradsCombinations>
template<typename Force, typename GradOrExtStateVar>
auto MaterialLib::Solids::MFront::OGSMFrontTangentOperatorBlocksView< DisplacementDim, ForcesGradsCombinations >::block ( Force ,
GradOrExtStateVar ,
OGSMFrontTangentOperatorData const & data ) const
inline

Read access to the block dForce/dGradOrExtStateVar.

Returns an Eigen::Map, or a double value in the 1x1 case.

If the block is not provided by the MFront behavior, the returned data is all zero.

Definition at line 158 of file TangentOperatorBlocksView.h.

161 {
162 static_assert(
166 "Requested tangent block was not created in the "
167 "OGSMFrontTangentOperatorBlocksView.");
168
170 const auto offset = offsets_[index];
171
173 constexpr auto grad_size =
175
176 if constexpr (grad_size == 1 && force_size == 1)
177 {
178 if (offset == invalid_offset_)
179 {
180 return 0.0;
181 }
182
183 return data.data[offset];
184 }
185 else
186 {
187 constexpr auto order =
189
190 using Result = Eigen::Map<
192
193 if (offset == invalid_offset_)
194 {
195 return Result{
197 }
198
199 return Result{data.data.data() + offset};
200 }
201 }

References blockIndex(), MaterialLib::Solids::MFront::OGSMFrontTangentOperatorData::data, invalid_offset_, offsets_, MaterialLib::Solids::MFront::detail::OGSMFrontTangentOperatorBlocksViewZeroes, and size().

Referenced by OGSMFrontTangentOperatorBlocksView().

◆ blockIndex()

template<int DisplacementDim, typename ForcesGradsCombinations>
template<typename Force, typename GradOrExtStateVar>
constexpr std::size_t MaterialLib::Solids::MFront::OGSMFrontTangentOperatorBlocksView< DisplacementDim, ForcesGradsCombinations >::blockIndex ( )
inlinestaticconstexprprivate

Computes the index of a tangent operator block in the offsets_ array.

Definition at line 239 of file TangentOperatorBlocksView.h.

Referenced by OGSMFrontTangentOperatorBlocksView(), and block().

◆ size()

template<int DisplacementDim, typename ForcesGradsCombinations>
constexpr std::size_t MaterialLib::Solids::MFront::OGSMFrontTangentOperatorBlocksView< DisplacementDim, ForcesGradsCombinations >::size ( mgis::behaviour::Variable::Type vt)
inlinestaticconstexprprivate

Definition at line 204 of file TangentOperatorBlocksView.h.

205 {
207
208 switch (vt)
209 {
210 case VT::SCALAR:
211 return 1;
212 case VT::STENSOR:
215 case VT::VECTOR:
216 return DisplacementDim;
217 case VT::TENSOR:
219 case VT::VECTOR_1D:
220 case VT::VECTOR_2D:
221 case VT::VECTOR_3D:
222 case VT::STENSOR_1D:
223 case VT::STENSOR_2D:
224 case VT::STENSOR_3D:
225 case VT::TENSOR_1D:
226 case VT::TENSOR_2D:
227 case VT::TENSOR_3D:
229 case VT::ARRAY:
230 break; // Unsupported variable types
231 }
232
233 OGS_FATAL("Unsupported MGIS variable type {}.",
235 }
constexpr int tensorSize(int dim)
See Tensor type for details.
Definition Tensor.h:13
constexpr int kelvin_vector_dimensions(int const displacement_dim)
Kelvin vector dimensions for given displacement dimension.

References MathLib::KelvinVector::kelvin_vector_dimensions(), OGS_FATAL, MaterialPropertyLib::tensorSize(), and BaseLib::to_underlying().

Referenced by OGSMFrontTangentOperatorBlocksView(), and block().

Member Data Documentation

◆ invalid_offset_

template<int DisplacementDim, typename ForcesGradsCombinations>
std::size_t MaterialLib::Solids::MFront::OGSMFrontTangentOperatorBlocksView< DisplacementDim, ForcesGradsCombinations >::invalid_offset_ = -1
staticconstexprprivate

Indicates that the associated tangent operator block is not present in the data.

Definition at line 92 of file TangentOperatorBlocksView.h.

Referenced by OGSMFrontTangentOperatorBlocksView(), and block().

◆ offsets_

template<int DisplacementDim, typename ForcesGradsCombinations>
std::array<std::size_t, boost::mp11::mp_size<ForcesGradsCombinations>::value> MaterialLib::Solids::MFront::OGSMFrontTangentOperatorBlocksView< DisplacementDim, ForcesGradsCombinations >::offsets_
private

Stores the data offsets of each tangent operator block.

A value of invalid_offset_ indicates that the tangent operator block is not provided by the MFront behaviour.

Definition at line 252 of file TangentOperatorBlocksView.h.

Referenced by OGSMFrontTangentOperatorBlocksView(), and block().


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