OGS
IntegrationGaussLegendreRegular-impl.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#include <cassert>
5
6namespace NumLib
7{
8template <>
9inline std::array<unsigned, 1>
11 unsigned igp)
12{
13 std::array<unsigned, 1> result;
14 result[0] = igp;
15 return result;
16}
17
18template <>
19inline std::array<unsigned, 2>
21 unsigned igp)
22{
23 assert(igp < order * order);
24 std::array<unsigned, 2> result;
25 result[0] = igp / order;
26 result[1] = igp % order;
27 return result;
28}
29
30template <>
31inline std::array<unsigned, 3>
33 unsigned igp)
34{
35 assert(igp < order * order * order);
36 unsigned const gp_r = igp / (order * order);
37 unsigned const gp_s = igp % (order * order);
38 std::array<unsigned, 3> result;
39 result[0] = gp_r;
40 result[1] = gp_s / order;
41 result[2] = gp_s % order;
42 return result;
43}
44
45template <unsigned N_DIM>
48 unsigned const igp)
49{
50 assert(igp < std::pow(order, N_DIM));
51 std::array<unsigned, N_DIM> const pos = getPositionIndices(order, igp);
52
53 switch (order)
54 {
55 case 1:
57 case 2:
59 case 3:
61 case 4:
63 }
64 OGS_FATAL("Integration order {:d} not implemented.", order);
65}
66
67template <unsigned N_DIM>
68template <typename Method>
71 std::array<unsigned, N_DIM> const& pos)
72{
73 std::array<double, N_DIM> coords;
74 double weight = 1;
75 for (unsigned d = 0; d < N_DIM; d++)
76 {
77 coords[d] = Method::X[pos[d]];
78 weight *= Method::W[pos[d]];
79 }
80
81 return MathLib::WeightedPoint(coords, weight);
82}
83} // namespace NumLib
#define OGS_FATAL(...)
Definition Error.h:19
static std::array< unsigned, N_DIM > getPositionIndices(unsigned order, unsigned igp)
MathLib::WeightedPoint getWeightedPoint(unsigned const igp) const