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 36 of file IntegrationMethodRegistry.h.

38{
39 return getIntegrationMethod(std::type_index(typeid(MeshElement)), order);
40}
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 175 of file IntegrationMethodRegistry.cpp.

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

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

Referenced by getIntegrationMethod().