OGS
NumLib::IntegrationMethodRegistry Namespace Reference

Functions

GenericIntegrationMethod const & getIntegrationMethod (std::type_index const mesh_element_type, IntegrationOrder const order)
template<typename MeshElement>
GenericIntegrationMethod const & getIntegrationMethod (IntegrationOrder const order)
 Templated version of above method. Provided for convenience.

Function Documentation

◆ getIntegrationMethod() [1/2]

template<typename MeshElement>
GenericIntegrationMethod const & NumLib::IntegrationMethodRegistry::getIntegrationMethod ( IntegrationOrder const order)

Templated version of above method. Provided for convenience.

Definition at line 30 of file IntegrationMethodRegistry.h.

32{
33 return getIntegrationMethod(std::type_index(typeid(MeshElement)), order);
34}
GenericIntegrationMethod const & getIntegrationMethod(std::type_index const mesh_element_type, IntegrationOrder const order)

References getIntegrationMethod().

◆ getIntegrationMethod() [2/2]

GenericIntegrationMethod const & NumLib::IntegrationMethodRegistry::getIntegrationMethod ( std::type_index const mesh_element_type,
IntegrationOrder const order )

Provides the default integration method for a given mesh element type and a given integration order.

Definition at line 170 of file IntegrationMethodRegistry.cpp.

172{
173 if (order.order == 0)
174 {
175 // For 0D elements (points) the order does not matter, still we don't
176 // want order zero there. For all other element types integration order
177 // does matter.
178 OGS_FATAL("An integration order of 0 is not supported.");
179 }
180
181 // The actual integration method registry.
182 //
183 // A mapping \code [mesh element type] -> [list of integration
184 // methods]\endcode, where each entry in the list corresponds to integration
185 // order 0, 1, 2, ...
186 //
187 // Having this as a static __local__ variable circumvents the static
188 // initialization order fiasco we would have if this was a static __global__
189 // variable. The fiasco arises, because this registry uses static global
190 // data from MathLib. Currently (Feb 2022) we cannot circumvent the problem
191 // with constinit due to lack of compiler support.
192 static const std::unordered_map<
193 std::type_index,
194 std::vector<NumLib::GenericIntegrationMethod>>
195 integration_methods_by_mesh_element_type = initIntegrationMethods();
196
197 if (auto it =
198 integration_methods_by_mesh_element_type.find(mesh_element_type);
199 it != integration_methods_by_mesh_element_type.end())
200 {
201 auto& integration_methods = it->second;
202
203 if (order.order >= integration_methods.size())
204 {
205 OGS_FATAL(
206 "Integration order {} is not supported for mesh elements of "
207 "type {}",
208 order.order,
209 mesh_element_type.name());
210 }
211
212 return integration_methods[order.order];
213 }
214
215 OGS_FATAL(
216 "No integration methods are available for mesh elements of type {}",
217 mesh_element_type.name());
218}
#define OGS_FATAL(...)
Definition Error.h:19
static std::unordered_map< std::type_index, std::vector< NumLib::GenericIntegrationMethod > > initIntegrationMethods()

References initIntegrationMethods(), OGS_FATAL, and NumLib::IntegrationOrder::order.

Referenced by getIntegrationMethod(), and anonymous_namespace{ShapeMatrixCache.cpp}::initShapeMatrices().