OGS
IntegrationMethodRegistry.cpp File Reference
#include "IntegrationMethodRegistry.h"
#include <unordered_map>
#include "BaseLib/DemangleTypeInfo.h"
#include "BaseLib/Error.h"
#include "GaussLegendreIntegrationPolicy.h"
#include "MeshLib/Elements/Elements.h"
Include dependency graph for IntegrationMethodRegistry.cpp:

Go to the source code of this file.

Namespaces

namespace  NumLib
namespace  NumLib::IntegrationMethodRegistry

Typedefs

template<typename MeshElement>
using IntegrationPolicy = NumLib::GaussLegendreIntegrationPolicy<MeshElement>

Functions

template<typename IntegrationPolicy_>
static NumLib::GenericIntegrationMethod createGenericIntegrationMethod (unsigned const order)
template<typename MeshElement>
static void putIntegrationMethodsFor (std::unordered_map< std::type_index, std::vector< NumLib::GenericIntegrationMethod > > &integration_methods_by_mesh_element_type, unsigned const max_order)
static void putIntegrationMethodsForDim0 (std::unordered_map< std::type_index, std::vector< NumLib::GenericIntegrationMethod > > &integration_methods_by_mesh_element_type)
static void putIntegrationMethodsForDim1 (std::unordered_map< std::type_index, std::vector< NumLib::GenericIntegrationMethod > > &integration_methods_by_mesh_element_type)
static void putIntegrationMethodsForDim2 (std::unordered_map< std::type_index, std::vector< NumLib::GenericIntegrationMethod > > &integration_methods_by_mesh_element_type)
static void putIntegrationMethodsForDim3 (std::unordered_map< std::type_index, std::vector< NumLib::GenericIntegrationMethod > > &integration_methods_by_mesh_element_type)
static std::unordered_map< std::type_index, std::vector< NumLib::GenericIntegrationMethod > > initIntegrationMethods ()
GenericIntegrationMethod const & NumLib::IntegrationMethodRegistry::getIntegrationMethod (std::type_index const mesh_element_type, IntegrationOrder const order)

Variables

static constexpr unsigned MAX_ORDER_REGULAR = 4u

Typedef Documentation

◆ IntegrationPolicy

template<typename MeshElement>
using IntegrationPolicy = NumLib::GaussLegendreIntegrationPolicy<MeshElement>

Definition at line 16 of file IntegrationMethodRegistry.cpp.

Function Documentation

◆ createGenericIntegrationMethod()

template<typename IntegrationPolicy_>
NumLib::GenericIntegrationMethod createGenericIntegrationMethod ( unsigned const order)
static

Definition at line 19 of file IntegrationMethodRegistry.cpp.

21{
22 typename IntegrationPolicy_::IntegrationMethod meth{order};
23 unsigned const np = meth.getNumberOfPoints();
24
25 std::vector<MathLib::WeightedPoint> wps;
26 wps.reserve(np);
27
28 for (unsigned ip = 0; ip < np; ++ip)
29 {
30 wps.emplace_back(meth.getWeightedPoint(ip));
31
32 if (wps.back() != meth.getWeightedPoint(ip))
33 {
34 throw std::runtime_error(
35 "createGenericIntegrationMethod mismatch for ip=" +
36 std::to_string(ip) + ", order=" + std::to_string(order) +
37 ", method=" + BaseLib::typeToString(meth));
38 }
39 }
40
41 return NumLib::GenericIntegrationMethod{order, std::move(wps)};
42}
std::string typeToString()

References NumLib::GenericIntegrationMethod::getNumberOfPoints(), and BaseLib::typeToString().

Referenced by putIntegrationMethodsFor().

◆ initIntegrationMethods()

std::unordered_map< std::type_index, std::vector< NumLib::GenericIntegrationMethod > > initIntegrationMethods ( )
static

Definition at line 154 of file IntegrationMethodRegistry.cpp.

155{
156 std::unordered_map<std::type_index,
157 std::vector<NumLib::GenericIntegrationMethod>>
158 integration_methods_by_mesh_element_type;
159
160 putIntegrationMethodsForDim0(integration_methods_by_mesh_element_type);
161 putIntegrationMethodsForDim1(integration_methods_by_mesh_element_type);
162 putIntegrationMethodsForDim2(integration_methods_by_mesh_element_type);
163 putIntegrationMethodsForDim3(integration_methods_by_mesh_element_type);
164
165 return integration_methods_by_mesh_element_type;
166}
static void putIntegrationMethodsForDim1(std::unordered_map< std::type_index, std::vector< NumLib::GenericIntegrationMethod > > &integration_methods_by_mesh_element_type)
static void putIntegrationMethodsForDim3(std::unordered_map< std::type_index, std::vector< NumLib::GenericIntegrationMethod > > &integration_methods_by_mesh_element_type)
static void putIntegrationMethodsForDim0(std::unordered_map< std::type_index, std::vector< NumLib::GenericIntegrationMethod > > &integration_methods_by_mesh_element_type)
static void putIntegrationMethodsForDim2(std::unordered_map< std::type_index, std::vector< NumLib::GenericIntegrationMethod > > &integration_methods_by_mesh_element_type)

References putIntegrationMethodsForDim0(), putIntegrationMethodsForDim1(), putIntegrationMethodsForDim2(), and putIntegrationMethodsForDim3().

Referenced by NumLib::IntegrationMethodRegistry::getIntegrationMethod().

◆ putIntegrationMethodsFor()

template<typename MeshElement>
void putIntegrationMethodsFor ( std::unordered_map< std::type_index, std::vector< NumLib::GenericIntegrationMethod > > & integration_methods_by_mesh_element_type,
unsigned const max_order )
static

Definition at line 45 of file IntegrationMethodRegistry.cpp.

50{
51 std::vector<NumLib::GenericIntegrationMethod> integration_methods;
52 integration_methods.reserve(max_order + 1);
53
54 // order 0 -> no valid weighted points
55 NumLib::GenericIntegrationMethod invalidMethod{0, {}};
56 integration_methods.push_back(std::move(invalidMethod));
57
58 for (unsigned order = 1; order <= max_order; ++order)
59 {
60 integration_methods.push_back(
62 order));
63 }
64
65 integration_methods_by_mesh_element_type.emplace(
66 std::type_index(typeid(MeshElement)), std::move(integration_methods));
67}
static NumLib::GenericIntegrationMethod createGenericIntegrationMethod(unsigned const order)
NumLib::GaussLegendreIntegrationPolicy< MeshElement > IntegrationPolicy

References createGenericIntegrationMethod().

Referenced by putIntegrationMethodsForDim0(), putIntegrationMethodsForDim1(), putIntegrationMethodsForDim2(), and putIntegrationMethodsForDim3().

◆ putIntegrationMethodsForDim0()

void putIntegrationMethodsForDim0 ( std::unordered_map< std::type_index, std::vector< NumLib::GenericIntegrationMethod > > & integration_methods_by_mesh_element_type)
static

Definition at line 69 of file IntegrationMethodRegistry.cpp.

73{
75 integration_methods_by_mesh_element_type,
76 MAX_ORDER_REGULAR /* arbitrary cutoff */);
77}
static void putIntegrationMethodsFor(std::unordered_map< std::type_index, std::vector< NumLib::GenericIntegrationMethod > > &integration_methods_by_mesh_element_type, unsigned const max_order)
static constexpr unsigned MAX_ORDER_REGULAR

References MAX_ORDER_REGULAR, and putIntegrationMethodsFor().

Referenced by initIntegrationMethods().

◆ putIntegrationMethodsForDim1()

void putIntegrationMethodsForDim1 ( std::unordered_map< std::type_index, std::vector< NumLib::GenericIntegrationMethod > > & integration_methods_by_mesh_element_type)
static

Definition at line 79 of file IntegrationMethodRegistry.cpp.

83{
85 integration_methods_by_mesh_element_type, MAX_ORDER_REGULAR);
86
88 integration_methods_by_mesh_element_type, MAX_ORDER_REGULAR);
89}

References MAX_ORDER_REGULAR, and putIntegrationMethodsFor().

Referenced by initIntegrationMethods().

◆ putIntegrationMethodsForDim2()

void putIntegrationMethodsForDim2 ( std::unordered_map< std::type_index, std::vector< NumLib::GenericIntegrationMethod > > & integration_methods_by_mesh_element_type)
static

Definition at line 91 of file IntegrationMethodRegistry.cpp.

95{
97 integration_methods_by_mesh_element_type, MAX_ORDER_REGULAR);
98
100 integration_methods_by_mesh_element_type, MAX_ORDER_REGULAR);
101
103 integration_methods_by_mesh_element_type, MAX_ORDER_REGULAR);
104
106 integration_methods_by_mesh_element_type, 4);
107
109 integration_methods_by_mesh_element_type, 4);
110}

References MAX_ORDER_REGULAR, and putIntegrationMethodsFor().

Referenced by initIntegrationMethods().

◆ putIntegrationMethodsForDim3()

void putIntegrationMethodsForDim3 ( std::unordered_map< std::type_index, std::vector< NumLib::GenericIntegrationMethod > > & integration_methods_by_mesh_element_type)
static

Definition at line 112 of file IntegrationMethodRegistry.cpp.

116{
118 integration_methods_by_mesh_element_type, MAX_ORDER_REGULAR);
119
121 integration_methods_by_mesh_element_type, MAX_ORDER_REGULAR);
122
124 integration_methods_by_mesh_element_type, 4);
125
127 integration_methods_by_mesh_element_type, 4);
128
130 integration_methods_by_mesh_element_type, 4);
131
133 integration_methods_by_mesh_element_type, 4);
134
135 /* Note: Currently (July 22) OGS has pyramid integration schemes only up to
136 * order 3 (see MathLib/Integration/GaussLegendrePyramid.h), and for order 4
137 * the third order is reused (see
138 * NumLib/Fem/Integration/IntegrationGaussLegendrePyramid.h).
139 * I.e., a user can request 4th order integration on pyramids and OGS will
140 * just run fine, albeit with a lower integration order.
141 * To keep that behavior, in particular not crash if a user requests 4th
142 * order pyramid integration, we set the limit to 4, here.
143 */
144
146 integration_methods_by_mesh_element_type, 4 /* see note above */);
147
149 integration_methods_by_mesh_element_type, 4 /* see note above */);
150}

References MAX_ORDER_REGULAR, and putIntegrationMethodsFor().

Referenced by initIntegrationMethods().

Variable Documentation

◆ MAX_ORDER_REGULAR

unsigned MAX_ORDER_REGULAR = 4u
staticconstexpr