OGS
ProcessLib::LIE::HydroMechanics::LocalDataInitializer< LocalAssemblerInterface, LocalAssemblerDataMatrix, LocalAssemblerDataMatrixNearFracture, LocalAssemblerDataFracture, GlobalDim, ConstructorArgs > Class Template Referencefinal

Detailed Description

template<typename LocalAssemblerInterface, template< typename, typename, int > class LocalAssemblerDataMatrix, template< typename, typename, int > class LocalAssemblerDataMatrixNearFracture, template< typename, typename, int > class LocalAssemblerDataFracture, int GlobalDim, typename... ConstructorArgs>
class ProcessLib::LIE::HydroMechanics::LocalDataInitializer< LocalAssemblerInterface, LocalAssemblerDataMatrix, LocalAssemblerDataMatrixNearFracture, LocalAssemblerDataFracture, GlobalDim, ConstructorArgs >

The LocalDataInitializer is a functor creating a local assembler data with corresponding to the mesh element type shape functions and calling initialization of the new local assembler data. For example for MeshLib::Quad a local assembler data with template argument NumLib::ShapeQuad4 is created.

Attention
This is modified version of the ProcessLib::LocalDataInitializer class which does not include line elements, allows only shapefunction of order 2, and provides additional template argument GlobalDim.

Definition at line 51 of file LocalDataInitializer.h.

#include <LocalDataInitializer.h>

Collaboration diagram for ProcessLib::LIE::HydroMechanics::LocalDataInitializer< LocalAssemblerInterface, LocalAssemblerDataMatrix, LocalAssemblerDataMatrixNearFracture, LocalAssemblerDataFracture, GlobalDim, ConstructorArgs >:
[legend]

Classes

struct  IsElementEnabled
 

Public Types

using LADataIntfPtr = std::unique_ptr<LocalAssemblerInterface>
 

Public Member Functions

 LocalDataInitializer (NumLib::LocalToGlobalIndexMap const &dof_table, NumLib::IntegrationOrder const integration_order)
 
LADataIntfPtr operator() (std::size_t const id, MeshLib::Element const &mesh_item, ConstructorArgs &&... args) const
 

Private Types

using LADataBuilder
 

Static Private Member Functions

template<typename ShapeFunctionDisplacement , typename ShapeFunctionPressure >
static LADataBuilder makeLocalAssemblerBuilder (NumLib::IntegrationOrder const integration_order)
 

Private Attributes

std::unordered_map< std::type_index, LADataBuilder_builder
 Mapping of element types to local assembler constructors.
 
NumLib::LocalToGlobalIndexMap const & _dof_table
 

Member Typedef Documentation

◆ LADataBuilder

template<typename LocalAssemblerInterface , template< typename, typename, int > class LocalAssemblerDataMatrix, template< typename, typename, int > class LocalAssemblerDataMatrixNearFracture, template< typename, typename, int > class LocalAssemblerDataFracture, int GlobalDim, typename... ConstructorArgs>
using ProcessLib::LIE::HydroMechanics::LocalDataInitializer< LocalAssemblerInterface, LocalAssemblerDataMatrix, LocalAssemblerDataMatrixNearFracture, LocalAssemblerDataFracture, GlobalDim, ConstructorArgs >::LADataBuilder
private
Initial value:
std::function<LADataIntfPtr(
MeshLib::Element const& e,
std::size_t const n_variables,
std::size_t const local_matrix_size,
std::vector<unsigned> const& dofIndex_to_localIndex,
ConstructorArgs&&...)>
std::unique_ptr< LocalAssemblerInterface > LADataIntfPtr

Definition at line 180 of file LocalDataInitializer.h.

◆ LADataIntfPtr

template<typename LocalAssemblerInterface , template< typename, typename, int > class LocalAssemblerDataMatrix, template< typename, typename, int > class LocalAssemblerDataMatrixNearFracture, template< typename, typename, int > class LocalAssemblerDataFracture, int GlobalDim, typename... ConstructorArgs>
using ProcessLib::LIE::HydroMechanics::LocalDataInitializer< LocalAssemblerInterface, LocalAssemblerDataMatrix, LocalAssemblerDataMatrixNearFracture, LocalAssemblerDataFracture, GlobalDim, ConstructorArgs >::LADataIntfPtr = std::unique_ptr<LocalAssemblerInterface>

Definition at line 70 of file LocalDataInitializer.h.

Constructor & Destructor Documentation

◆ LocalDataInitializer()

template<typename LocalAssemblerInterface , template< typename, typename, int > class LocalAssemblerDataMatrix, template< typename, typename, int > class LocalAssemblerDataMatrixNearFracture, template< typename, typename, int > class LocalAssemblerDataFracture, int GlobalDim, typename... ConstructorArgs>
ProcessLib::LIE::HydroMechanics::LocalDataInitializer< LocalAssemblerInterface, LocalAssemblerDataMatrix, LocalAssemblerDataMatrixNearFracture, LocalAssemblerDataFracture, GlobalDim, ConstructorArgs >::LocalDataInitializer ( NumLib::LocalToGlobalIndexMap const & dof_table,
NumLib::IntegrationOrder const integration_order )
inlineexplicit

Definition at line 72 of file LocalDataInitializer.h.

75 : _dof_table(dof_table)
76 {
77 using EnabledElementTraits =
78 decltype(BaseLib::TMP::filter<EnabledElementTraitsLagrange>(
79 std::declval<IsElementEnabled>()));
80
81 BaseLib::TMP::foreach<EnabledElementTraits>(
82 [this, integration_order]<typename ET>(ET*)
83 {
84 using MeshElement = typename ET::Element;
85 using ShapeFunction = typename ET::ShapeFunction;
86 using LowerOrderShapeFunction =
87 typename ET::LowerOrderShapeFunction;
88
89 _builder[std::type_index(typeid(MeshElement))] =
90 makeLocalAssemblerBuilder<ShapeFunction,
91 LowerOrderShapeFunction>(
92 integration_order);
93 });
94 }
static LADataBuilder makeLocalAssemblerBuilder(NumLib::IntegrationOrder const integration_order)
std::unordered_map< std::type_index, LADataBuilder > _builder
Mapping of element types to local assembler constructors.

Member Function Documentation

◆ makeLocalAssemblerBuilder()

template<typename LocalAssemblerInterface , template< typename, typename, int > class LocalAssemblerDataMatrix, template< typename, typename, int > class LocalAssemblerDataMatrixNearFracture, template< typename, typename, int > class LocalAssemblerDataFracture, int GlobalDim, typename... ConstructorArgs>
template<typename ShapeFunctionDisplacement , typename ShapeFunctionPressure >
static LADataBuilder ProcessLib::LIE::HydroMechanics::LocalDataInitializer< LocalAssemblerInterface, LocalAssemblerDataMatrix, LocalAssemblerDataMatrixNearFracture, LocalAssemblerDataFracture, GlobalDim, ConstructorArgs >::makeLocalAssemblerBuilder ( NumLib::IntegrationOrder const integration_order)
inlinestaticprivate

Generates a function that creates a new LocalAssembler of type LAData<ShapeFunctionDisplacement>. Only functions with shape function's dimension less or equal to the global dimension are instantiated, e.g. following combinations of shape functions and global dimensions: (Line2, 1), (Line2, 2), (Line2, 3), (Hex20, 3) but not (Hex20, 2) or (Hex20, 1).

Definition at line 195 of file LocalDataInitializer.h.

197 {
198 return [integration_order](
199 MeshLib::Element const& e,
200 std::size_t const n_variables,
201 std::size_t const local_matrix_size,
202 std::vector<unsigned> const& dofIndex_to_localIndex,
203 ConstructorArgs&&... args)
204 {
205 auto const& integration_method = NumLib::IntegrationMethodRegistry::
206 template getIntegrationMethod<
207 typename ShapeFunctionDisplacement::MeshElement>(
208 integration_order);
209
210 if (e.getDimension() == GlobalDim)
211 {
212 if (n_variables == 2)
213 {
214 return LADataIntfPtr{new LocalAssemblerDataMatrix<
215 ShapeFunctionDisplacement, ShapeFunctionPressure,
216 GlobalDim>{e, n_variables, local_matrix_size,
217 dofIndex_to_localIndex, integration_method,
218 std::forward<ConstructorArgs>(args)...}};
219 }
220 return LADataIntfPtr{new LocalAssemblerDataMatrixNearFracture<
221 ShapeFunctionDisplacement, ShapeFunctionPressure,
222 GlobalDim>{e, n_variables, local_matrix_size,
223 dofIndex_to_localIndex, integration_method,
224 std::forward<ConstructorArgs>(args)...}};
225 }
226 return LADataIntfPtr{new LocalAssemblerDataFracture<
227 ShapeFunctionDisplacement, ShapeFunctionPressure, GlobalDim>{
228 e, local_matrix_size, dofIndex_to_localIndex,
229 integration_method, std::forward<ConstructorArgs>(args)...}};
230 };
231 }
virtual constexpr unsigned getDimension() const =0
Get dimension of the mesh element.
GenericIntegrationMethod const & getIntegrationMethod(std::type_index const mesh_element_type, IntegrationOrder const order)

References MeshLib::Element::getDimension().

◆ operator()()

template<typename LocalAssemblerInterface , template< typename, typename, int > class LocalAssemblerDataMatrix, template< typename, typename, int > class LocalAssemblerDataMatrixNearFracture, template< typename, typename, int > class LocalAssemblerDataFracture, int GlobalDim, typename... ConstructorArgs>
LADataIntfPtr ProcessLib::LIE::HydroMechanics::LocalDataInitializer< LocalAssemblerInterface, LocalAssemblerDataMatrix, LocalAssemblerDataMatrixNearFracture, LocalAssemblerDataFracture, GlobalDim, ConstructorArgs >::operator() ( std::size_t const id,
MeshLib::Element const & mesh_item,
ConstructorArgs &&... args ) const
inline

Returns data pointer to the newly created local assembler data.

Attention
The index id is not necessarily the mesh item's id. Especially when having multiple meshes it will differ from the latter.

Definition at line 101 of file LocalDataInitializer.h.

104 {
105 auto const type_idx = std::type_index(typeid(mesh_item));
106 auto const it = _builder.find(type_idx);
107
108 if (it == _builder.end())
109 {
110 OGS_FATAL(
111 "You are trying to build a local assembler for an unknown mesh "
112 "element type ({:s})."
113 " Maybe you have disabled this mesh element type in your build "
114 "configuration, or a mesh element order does not match shape "
115 "function order given in the project file.",
116 type_idx.name());
117 }
118
119 auto const n_local_dof = _dof_table.getNumberOfElementDOF(id);
120 auto const varIDs = _dof_table.getElementVariableIDs(id);
121 bool const isPressureDeactivated = (varIDs.front() != 0);
122 std::vector<int> involved_varIDs; // including deactivated elements
123 involved_varIDs.reserve(varIDs.size() + 1);
124 if (isPressureDeactivated)
125 {
126 involved_varIDs.push_back(0); // always pressure come in
127 }
128 involved_varIDs.insert(involved_varIDs.end(), varIDs.begin(),
129 varIDs.end());
130
131 std::vector<unsigned> dofIndex_to_localIndex;
132
133 // matrix and fracture assemblers with enrichments
134 dofIndex_to_localIndex.resize(n_local_dof);
135 std::vector<unsigned> vec_n_element_nodes;
136 // TODO how to get the shape function order for each variable?
137 vec_n_element_nodes.push_back(
138 mesh_item.getNumberOfBaseNodes()); // pressure
139 auto const max_varID = *std::max_element(varIDs.begin(), varIDs.end());
140 for (int i = 1; i < max_varID + 1; i++)
141 {
142 vec_n_element_nodes.push_back(
143 mesh_item.getNumberOfNodes()); // displacements
144 }
145
146 unsigned local_id = 0;
147 unsigned dof_id = 0;
148 for (unsigned i = 0; i < involved_varIDs.size(); i++)
149 {
150 auto const var_id = involved_varIDs[i];
151 auto const n_var_comp =
153 auto const n_var_element_nodes = vec_n_element_nodes[i];
154 for (int var_comp_id = 0; var_comp_id < n_var_comp; var_comp_id++)
155 {
156 auto const& ms = _dof_table.getMeshSubset(var_id, var_comp_id);
157 auto const mesh_id = ms.getMeshID();
158 for (unsigned k = 0; k < n_var_element_nodes; k++)
159 {
160 MeshLib::Location l(mesh_id,
162 getNodeIndex(mesh_item, k));
163 auto global_index =
164 _dof_table.getGlobalIndex(l, var_id, var_comp_id);
165 if (global_index != NumLib::MeshComponentMap::nop)
166 {
167 dofIndex_to_localIndex[dof_id++] = local_id;
168 }
169 local_id++;
170 }
171 }
172 }
173
174 return it->second(mesh_item, involved_varIDs.size(), n_local_dof,
175 dofIndex_to_localIndex,
176 std::forward<ConstructorArgs>(args)...);
177 }
#define OGS_FATAL(...)
Definition Error.h:26
std::size_t getMeshID() const
return this mesh ID
Definition MeshSubset.h:76
std::size_t getNumberOfElementDOF(std::size_t const mesh_item_id) const
GlobalIndexType getGlobalIndex(MeshLib::Location const &l, int const variable_id, int const component_id) const
int getNumberOfVariableComponents(int variable_id) const
MeshLib::MeshSubset const & getMeshSubset(int const variable_id, int const component_id) const
std::vector< int > getElementVariableIDs(std::size_t const mesh_item_id) const
static constexpr NUMLIB_EXPORT GlobalIndexType const nop
std::size_t getNodeIndex(Element const &element, unsigned const idx)
Definition Element.cpp:219

References MeshLib::Element::getNumberOfBaseNodes(), MeshLib::Element::getNumberOfNodes(), MeshLib::Node, NumLib::MeshComponentMap::nop, and OGS_FATAL.

Member Data Documentation

◆ _builder

template<typename LocalAssemblerInterface , template< typename, typename, int > class LocalAssemblerDataMatrix, template< typename, typename, int > class LocalAssemblerDataMatrixNearFracture, template< typename, typename, int > class LocalAssemblerDataFracture, int GlobalDim, typename... ConstructorArgs>
std::unordered_map<std::type_index, LADataBuilder> ProcessLib::LIE::HydroMechanics::LocalDataInitializer< LocalAssemblerInterface, LocalAssemblerDataMatrix, LocalAssemblerDataMatrixNearFracture, LocalAssemblerDataFracture, GlobalDim, ConstructorArgs >::_builder
private

Mapping of element types to local assembler constructors.

Definition at line 234 of file LocalDataInitializer.h.

◆ _dof_table

template<typename LocalAssemblerInterface , template< typename, typename, int > class LocalAssemblerDataMatrix, template< typename, typename, int > class LocalAssemblerDataMatrixNearFracture, template< typename, typename, int > class LocalAssemblerDataFracture, int GlobalDim, typename... ConstructorArgs>
NumLib::LocalToGlobalIndexMap const& ProcessLib::LIE::HydroMechanics::LocalDataInitializer< LocalAssemblerInterface, LocalAssemblerDataMatrix, LocalAssemblerDataMatrixNearFracture, LocalAssemblerDataFracture, GlobalDim, ConstructorArgs >::_dof_table
private

Definition at line 236 of file LocalDataInitializer.h.


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