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