OGS
ShapeHex20-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
4namespace
5{
6inline double ShapeFunctionHexHQ_Corner(const double r, const double s,
7 const double t)
8{
9 return 0.125 * (r - 1) * (s - 1) * (t - 1) * (r + s + t + 2.0);
10}
11
12inline double ShapeFunctionHexHQ_Middle(const double r, const double s,
13 const double t)
14{
15 return 0.25 * (1 - r * r) * (s - 1) * (t - 1);
16}
17
18inline double dShapeFunctionHexHQ_Corner(const double r, const double s,
19 const double t, const int ty)
20{
21 switch (ty)
22 {
23 case 0:
24 return 0.125 * (s - 1) * (t - 1) * (2.0 * r + s + t + 1.0);
25 case 1:
26 return 0.125 * (t - 1) * (r - 1) * (2.0 * s + r + t + 1.0);
27 case 2:
28 return 0.125 * (r - 1) * (s - 1) * (2.0 * t + s + r + 1.0);
29 }
30 return 0.0;
31}
32
33inline double dShapeFunctionHexHQ_Middle(const double r, const double s,
34 const double t, const int ty)
35{
36 switch (ty)
37 {
38 case 0:
39 return -0.5 * r * (s - 1) * (t - 1);
40 case 1:
41 return 0.25 * (1 - r * r) * (t - 1);
42 case 2:
43 return 0.25 * (1 - r * r) * (s - 1);
44 }
45 return 0.0;
46}
47
48} // namespace
49
50namespace NumLib
51{
52template <class T_X, class T_N>
53void ShapeHex20::computeShapeFunction(const T_X& rst, T_N& N)
54{
55 const double r = rst[0];
56 const double s = rst[1];
57 const double t = rst[2];
58
59 N[0] = ShapeFunctionHexHQ_Corner(r, s, t);
60 N[1] = ShapeFunctionHexHQ_Corner(-r, s, t);
61 N[2] = ShapeFunctionHexHQ_Corner(-r, -s, t);
62 N[3] = ShapeFunctionHexHQ_Corner(r, -s, t);
63 N[4] = ShapeFunctionHexHQ_Corner(r, s, -t);
64 N[5] = ShapeFunctionHexHQ_Corner(-r, s, -t);
65 N[6] = ShapeFunctionHexHQ_Corner(-r, -s, -t);
66 N[7] = ShapeFunctionHexHQ_Corner(r, -s, -t);
67
68 N[8] = ShapeFunctionHexHQ_Middle(r, s, t);
69 N[10] = ShapeFunctionHexHQ_Middle(r, -s, t);
70 N[14] = ShapeFunctionHexHQ_Middle(r, -s, -t);
71 N[12] = ShapeFunctionHexHQ_Middle(r, s, -t);
72
73 N[11] = ShapeFunctionHexHQ_Middle(s, t, r);
74 N[15] = ShapeFunctionHexHQ_Middle(s, -t, r);
75 N[13] = ShapeFunctionHexHQ_Middle(s, -t, -r);
76 N[9] = ShapeFunctionHexHQ_Middle(s, t, -r);
77
78 N[16] = ShapeFunctionHexHQ_Middle(t, r, s);
79 N[17] = ShapeFunctionHexHQ_Middle(t, -r, s);
80 N[18] = ShapeFunctionHexHQ_Middle(t, -r, -s);
81 N[19] = ShapeFunctionHexHQ_Middle(t, r, -s);
82}
83
84template <class T_X, class T_N>
85void ShapeHex20::computeGradShapeFunction(const T_X& rst, T_N& dN)
86{
87 const double r = rst[0];
88 const double s = rst[1];
89 const double t = rst[2];
90 const static double sign1[] = {-1.0, 1.0, 1.0};
91 const static double sign2[] = {1.0, -1.0, 1.0};
92 const static double sign3[] = {1.0, 1.0, -1.0};
93 for (int i = 0; i < 3; i++)
94 {
95 dN[20 * i + 0] = dShapeFunctionHexHQ_Corner(r, s, t, i);
96 dN[20 * i + 1] = sign1[i] * dShapeFunctionHexHQ_Corner(-r, s, t, i);
97 dN[20 * i + 2] =
98 sign1[i] * sign2[i] * dShapeFunctionHexHQ_Corner(-r, -s, t, i);
99 dN[20 * i + 3] = sign2[i] * dShapeFunctionHexHQ_Corner(r, -s, t, i);
100 dN[20 * i + 4] = sign3[i] * dShapeFunctionHexHQ_Corner(r, s, -t, i);
101 dN[20 * i + 5] =
102 sign1[i] * sign3[i] * dShapeFunctionHexHQ_Corner(-r, s, -t, i);
103 dN[20 * i + 6] = sign1[i] * sign2[i] * sign3[i] *
104 dShapeFunctionHexHQ_Corner(-r, -s, -t, i);
105 dN[20 * i + 7] =
106 sign2[i] * sign3[i] * dShapeFunctionHexHQ_Corner(r, -s, -t, i);
107
108 dN[20 * i + 8] = dShapeFunctionHexHQ_Middle(r, s, t, i);
109 dN[20 * i + 10] = sign2[i] * dShapeFunctionHexHQ_Middle(r, -s, t, i);
110 dN[20 * i + 14] =
111 sign2[i] * sign3[i] * dShapeFunctionHexHQ_Middle(r, -s, -t, i);
112 dN[20 * i + 12] = sign3[i] * dShapeFunctionHexHQ_Middle(r, s, -t, i);
113
114 {
115 int const co = (i + 2) % 3;
116 dN[20 * i + 11] = dShapeFunctionHexHQ_Middle(s, t, r, co);
117 dN[20 * i + 15] =
118 sign3[i] * dShapeFunctionHexHQ_Middle(s, -t, r, co);
119 dN[20 * i + 13] =
120 sign1[i] * sign3[i] * dShapeFunctionHexHQ_Middle(s, -t, -r, co);
121 dN[20 * i + 9] =
122 sign1[i] * dShapeFunctionHexHQ_Middle(s, t, -r, co);
123 }
124
125 {
126 int const co = (i + 1) % 3;
127 dN[20 * i + 16] = dShapeFunctionHexHQ_Middle(t, r, s, co);
128 dN[20 * i + 17] =
129 sign1[i] * dShapeFunctionHexHQ_Middle(t, -r, s, co);
130 dN[20 * i + 18] =
131 sign1[i] * sign2[i] * dShapeFunctionHexHQ_Middle(t, -r, -s, co);
132 dN[20 * i + 19] =
133 sign2[i] * dShapeFunctionHexHQ_Middle(t, r, -s, co);
134 }
135 }
136}
137
138} // namespace NumLib
static void computeShapeFunction(const T_X &rst, T_N &N)
static void computeGradShapeFunction(const T_X &rst, T_N &dN)
double dShapeFunctionHexHQ_Corner(const double r, const double s, const double t, const int ty)
double dShapeFunctionHexHQ_Middle(const double r, const double s, const double t, const int ty)
double ShapeFunctionHexHQ_Corner(const double r, const double s, const double t)
double ShapeFunctionHexHQ_Middle(const double r, const double s, const double t)