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 181 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 =
79 std::declval<IsElementEnabled>()));
80
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.
void foreach(Function &&f)
Definition TMP.h:157
decltype(auto) filter(Pred pred)
Definition TMP.h:78

References BaseLib::TMP::filter(), and BaseLib::TMP::foreach().

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 196 of file LocalDataInitializer.h.

198 {
199 return [integration_order](
200 MeshLib::Element const& e,
201 std::size_t const n_variables,
202 std::size_t const local_matrix_size,
203 std::vector<unsigned> const& dofIndex_to_localIndex,
204 ConstructorArgs&&... args)
205 {
206 auto const& integration_method = NumLib::IntegrationMethodRegistry::
207 template getIntegrationMethod<
208 typename ShapeFunctionDisplacement::MeshElement>(
209 integration_order);
210
211 if (e.getDimension() == GlobalDim)
212 {
213 if (n_variables == 2)
214 {
215 return LADataIntfPtr{new LocalAssemblerDataMatrix<
216 ShapeFunctionDisplacement, ShapeFunctionPressure,
217 GlobalDim>{e, n_variables, local_matrix_size,
218 dofIndex_to_localIndex, integration_method,
219 std::forward<ConstructorArgs>(args)...}};
220 }
221 return LADataIntfPtr{new LocalAssemblerDataMatrixNearFracture<
222 ShapeFunctionDisplacement, ShapeFunctionPressure,
223 GlobalDim>{e, n_variables, local_matrix_size,
224 dofIndex_to_localIndex, integration_method,
225 std::forward<ConstructorArgs>(args)...}};
226 }
227 return LADataIntfPtr{new LocalAssemblerDataFracture<
228 ShapeFunctionDisplacement, ShapeFunctionPressure, GlobalDim>{
229 e, local_matrix_size, dofIndex_to_localIndex,
230 integration_method, std::forward<ConstructorArgs>(args)...}};
231 };
232 }
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 dof_id < n_local_dof)
167 {
168 dofIndex_to_localIndex[dof_id++] = local_id;
169 }
170 local_id++;
171 }
172 }
173 }
174
175 return it->second(mesh_item, involved_varIDs.size(), n_local_dof,
176 dofIndex_to_localIndex,
177 std::forward<ConstructorArgs>(args)...);
178 }
#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 235 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 237 of file LocalDataInitializer.h.


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