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
6
namespace
NumLib
7
{
8
template
<>
9
inline
std::array<unsigned, 1>
10
IntegrationGaussLegendreRegular<1>::getPositionIndices
(
unsigned
/*order*/
,
11
unsigned
igp)
12
{
13
std::array<unsigned, 1> result;
14
result[0] = igp;
15
return
result;
16
}
17
18
template
<>
19
inline
std::array<unsigned, 2>
20
IntegrationGaussLegendreRegular<2>::getPositionIndices
(
unsigned
order,
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
30
template
<>
31
inline
std::array<unsigned, 3>
32
IntegrationGaussLegendreRegular<3>::getPositionIndices
(
unsigned
order,
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
45
template
<
unsigned
N_DIM>
46
inline
MathLib::WeightedPoint
47
IntegrationGaussLegendreRegular<N_DIM>::getWeightedPoint
(
unsigned
const
order,
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:
56
return
getWeightedPoint<MathLib::GaussLegendre<1>
>(pos);
57
case
2:
58
return
getWeightedPoint<MathLib::GaussLegendre<2>
>(pos);
59
case
3:
60
return
getWeightedPoint<MathLib::GaussLegendre<3>
>(pos);
61
case
4:
62
return
getWeightedPoint<MathLib::GaussLegendre<4>
>(pos);
63
}
64
OGS_FATAL
(
"Integration order {:d} not implemented."
, order);
65
}
66
67
template
<
unsigned
N_DIM>
68
template
<
typename
Method>
69
inline
MathLib::WeightedPoint
70
IntegrationGaussLegendreRegular<N_DIM>::getWeightedPoint
(
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
OGS_FATAL
#define OGS_FATAL(...)
Definition
Error.h:19
MathLib::WeightedPoint
Definition
WeightedPoint.h:16
NumLib::IntegrationGaussLegendreRegular::getPositionIndices
static std::array< unsigned, N_DIM > getPositionIndices(unsigned order, unsigned igp)
NumLib::IntegrationGaussLegendreRegular::getWeightedPoint
MathLib::WeightedPoint getWeightedPoint(unsigned const igp) const
Definition
IntegrationGaussLegendreRegular.h:49
NumLib
Definition
ProjectData.h:35
NumLib
Fem
Integration
IntegrationGaussLegendreRegular-impl.h
Generated by
1.14.0