VTK  9.7.20260922
HexCnGradient.h
Go to the documentation of this file.
1// Gradients of the arbitrary-order Bernstein-Bezier basis on the hexahedron.
2//
3// Each 1-d Bernstein polynomial and its derivative are computed along each
4// parametric axis (see EdgeCnBasis.h and EdgeCnGradient.h, including the
5// dx/dr = 1/2 factor the change of variables introduces), then combined by the
6// product rule.
7WORKSPACE(RealT, rtmp, order[0] + 1);
8WORKSPACE(RealT, drtmp, order[0] + 1);
9WORKSPACE(RealT, stmp, order[1] + 1);
10WORKSPACE(RealT, dstmp, order[1] + 1);
11WORKSPACE(RealT, ttmp, order[2] + 1);
12WORKSPACE(RealT, dttmp, order[2] + 1);
13
14{
15 RealT xx = 0.5 * (rr + 1.);
16 RealT yy = 1. - xx;
17 WORKSPACE(RealT, xpow, order[0] + 1);
18 WORKSPACE(RealT, ypow, order[0] + 1);
19 xpow[0] = 1.;
20 for (int kk = 1; kk <= order[0]; ++kk)
21 {
22 xpow[kk] = xpow[kk - 1] * xx;
23 }
24 ypow[order[0]] = 1.;
25 for (int kk = order[0] - 1; kk >= 0; --kk)
26 {
27 ypow[kk] = ypow[kk + 1] * yy;
28 }
29 RealT coeff = 1.;
30 for (int kk = 0; kk <= order[0]; ++kk)
31 {
32 rtmp[kk] = coeff * xpow[kk] * ypow[kk];
33 RealT ddx = 0.;
34 if (kk > 0)
35 {
36 ddx += RealT(kk) * xpow[kk - 1] * ypow[kk];
37 }
38 if (kk < order[0])
39 {
40 ddx -= RealT(order[0] - kk) * xpow[kk] * ypow[kk + 1];
41 }
42 drtmp[kk] = 0.5 * coeff * ddx;
43 coeff = coeff * RealT(order[0] - kk) / RealT(kk + 1);
44 }
45}
46{
47 RealT xx = 0.5 * (ss + 1.);
48 RealT yy = 1. - xx;
49 WORKSPACE(RealT, xpow, order[1] + 1);
50 WORKSPACE(RealT, ypow, order[1] + 1);
51 xpow[0] = 1.;
52 for (int kk = 1; kk <= order[1]; ++kk)
53 {
54 xpow[kk] = xpow[kk - 1] * xx;
55 }
56 ypow[order[1]] = 1.;
57 for (int kk = order[1] - 1; kk >= 0; --kk)
58 {
59 ypow[kk] = ypow[kk + 1] * yy;
60 }
61 RealT coeff = 1.;
62 for (int kk = 0; kk <= order[1]; ++kk)
63 {
64 stmp[kk] = coeff * xpow[kk] * ypow[kk];
65 RealT ddx = 0.;
66 if (kk > 0)
67 {
68 ddx += RealT(kk) * xpow[kk - 1] * ypow[kk];
69 }
70 if (kk < order[1])
71 {
72 ddx -= RealT(order[1] - kk) * xpow[kk] * ypow[kk + 1];
73 }
74 dstmp[kk] = 0.5 * coeff * ddx;
75 coeff = coeff * RealT(order[1] - kk) / RealT(kk + 1);
76 }
77}
78{
79 RealT xx = 0.5 * (tt + 1.);
80 RealT yy = 1. - xx;
81 WORKSPACE(RealT, xpow, order[2] + 1);
82 WORKSPACE(RealT, ypow, order[2] + 1);
83 xpow[0] = 1.;
84 for (int kk = 1; kk <= order[2]; ++kk)
85 {
86 xpow[kk] = xpow[kk - 1] * xx;
87 }
88 ypow[order[2]] = 1.;
89 for (int kk = order[2] - 1; kk >= 0; --kk)
90 {
91 ypow[kk] = ypow[kk + 1] * yy;
92 }
93 RealT coeff = 1.;
94 for (int kk = 0; kk <= order[2]; ++kk)
95 {
96 ttmp[kk] = coeff * xpow[kk] * ypow[kk];
97 RealT ddx = 0.;
98 if (kk > 0)
99 {
100 ddx += RealT(kk) * xpow[kk - 1] * ypow[kk];
101 }
102 if (kk < order[2])
103 {
104 ddx -= RealT(order[2] - kk) * xpow[kk] * ypow[kk + 1];
105 }
106 dttmp[kk] = 0.5 * coeff * ddx;
107 coeff = coeff * RealT(order[2] - kk) / RealT(kk + 1);
108 }
109}
110
111// Compute the tensor product of basis derivatives as (d/dr, d/ds, d/dt) tuples:
112int idx = 0;
113for (int qq = 0; qq <= order[2]; ++qq)
114{
115 for (int pp = 0; pp <= order[1]; ++pp)
116 {
117 for (int oo = 0; oo <= order[0]; ++oo)
118 {
119 basisGradient[idx++] = drtmp[oo] * stmp[pp] * ttmp[qq]; // d/dr
120 basisGradient[idx++] = rtmp[oo] * dstmp[pp] * ttmp[qq]; // d/ds
121 basisGradient[idx++] = rtmp[oo] * stmp[pp] * dttmp[qq]; // d/dt
122 }
123 }
124}
ypow[order[0]]
Definition EdgeCnBasis.h:27
xpow[0]
Definition EdgeCnBasis.h:22
RealT xx
Definition EdgeCnBasis.h:16
RealT coeff
Definition EdgeCnBasis.h:34
RealT yy
Definition EdgeCnBasis.h:17
int idx
Definition HexCnBasis.h:79
WORKSPACE(RealT, rtmp, order[0]+1)
basisGradient[0]
@ order
Definition vtkX3D.h:441