OGS
IntegrationGaussLegendreRegular-impl.h
Go to the documentation of this file.
1
13#include <cassert>
14
15namespace NumLib
16{
17template <>
18inline std::array<unsigned, 1>
20 unsigned igp)
21{
22 std::array<unsigned, 1> result;
23 result[0] = igp;
24 return result;
25}
26
27template <>
28inline std::array<unsigned, 2>
30 unsigned igp)
31{
32 assert(igp < order * order);
33 std::array<unsigned, 2> result;
34 result[0] = igp / order;
35 result[1] = igp % order;
36 return result;
37}
38
39template <>
40inline std::array<unsigned, 3>
42 unsigned igp)
43{
44 assert(igp < order * order * order);
45 unsigned const gp_r = igp / (order * order);
46 unsigned const gp_s = igp % (order * order);
47 std::array<unsigned, 3> result;
48 result[0] = gp_r;
49 result[1] = gp_s / order;
50 result[2] = gp_s % order;
51 return result;
52}
53
54template <unsigned N_DIM>
57 unsigned const igp)
58{
59 assert(igp < std::pow(order, N_DIM));
60 std::array<unsigned, N_DIM> const pos = getPositionIndices(order, igp);
61
62 switch (order)
63 {
64 case 1:
65 return getWeightedPoint<MathLib::GaussLegendre<1>>(pos);
66 case 2:
67 return getWeightedPoint<MathLib::GaussLegendre<2>>(pos);
68 case 3:
69 return getWeightedPoint<MathLib::GaussLegendre<3>>(pos);
70 case 4:
71 return getWeightedPoint<MathLib::GaussLegendre<4>>(pos);
72 }
73 OGS_FATAL("Integration order {:d} not implemented.", order);
74}
75
76template <unsigned N_DIM>
77template <typename Method>
80 std::array<unsigned, N_DIM> const& pos)
81{
82 std::array<double, N_DIM> coords;
83 double weight = 1;
84 for (unsigned d = 0; d < N_DIM; d++)
85 {
86 coords[d] = Method::X[pos[d]];
87 weight *= Method::W[pos[d]];
88 }
89
90 return MathLib::WeightedPoint(coords, weight);
91}
92} // namespace NumLib
#define OGS_FATAL(...)
Definition Error.h:26
static std::array< unsigned, N_DIM > getPositionIndices(unsigned order, unsigned igp)
MathLib::WeightedPoint getWeightedPoint(unsigned const igp) const