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 93 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 104 of file TangentOperatorBlocksView.h.

107 {
109
111 to_blocks.size(), false); // checked after creation of all offsets.
112
114 [&to_blocks,
116 this]<typename Force, typename GradOrExtStateVar>(
118 {
120 for (auto [block, is_used] :
122 {
123 auto const& [force, grad] = block;
124 if (force.name == Force::name &&
126 {
127 auto constexpr block_idx =
130 is_used = true;
131 return;
132 }
133
134 data_offset += size(force.type) * size(grad.type);
135 }
136 });
137
138 // Indices of unused blocks.
140 ranges::views::filter([](auto const& pair)
141 { return !pair.second; }) |
143
144 if (!indices.empty())
145 {
146 ERR("There are unused tangent operator blocks provided by MFront. "
147 "Following blocks are unused:");
148
149 for (auto const i : indices)
150 {
151 auto const& [force, grad] = to_blocks[i];
152 ERR("\t{}/{}", force.name, grad.name);
153 }
154 OGS_FATAL("All tangent operator blocks must be used.");
155 }
156 }
#define OGS_FATAL(...)
Definition Error.h:26
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:48
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 165 of file TangentOperatorBlocksView.h.

168 {
169 static_assert(
173 "Requested tangent block was not created in the "
174 "OGSMFrontTangentOperatorBlocksView.");
175
177 const auto offset = offsets_[index];
178
180 constexpr auto grad_size =
182
183 if constexpr (grad_size == 1 && force_size == 1)
184 {
185 if (offset == invalid_offset_)
186 {
187 return 0.0;
188 }
189
190 return data.data[offset];
191 }
192 else
193 {
194 constexpr auto order =
196
197 using Result = Eigen::Map<
199
200 if (offset == invalid_offset_)
201 {
202 return Result{
204 }
205
206 return Result{data.data.data() + offset};
207 }
208 }

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 246 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 211 of file TangentOperatorBlocksView.h.

212 {
214
215 switch (vt)
216 {
217 case VT::SCALAR:
218 return 1;
219 case VT::STENSOR:
222 case VT::VECTOR:
223 return DisplacementDim;
224 case VT::TENSOR:
226 case VT::VECTOR_1D:
227 case VT::VECTOR_2D:
228 case VT::VECTOR_3D:
229 case VT::STENSOR_1D:
230 case VT::STENSOR_2D:
231 case VT::STENSOR_3D:
232 case VT::TENSOR_1D:
233 case VT::TENSOR_2D:
234 case VT::TENSOR_3D:
236 case VT::ARRAY:
237 break; // Unsupported variable types
238 }
239
240 OGS_FATAL("Unsupported MGIS variable type {}.",
242 }
constexpr int tensorSize(int dim)
See Tensor type for details.
Definition Tensor.h:19
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 99 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 259 of file TangentOperatorBlocksView.h.

Referenced by OGSMFrontTangentOperatorBlocksView(), and block().


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