VTK  9.7.20260922
WdgCnGradient.h
Go to the documentation of this file.
1// Gradients of the arbitrary-order Bernstein-Bezier basis on the wedge.
2//
3// See WdgCnBasis.h for the basis. The r- and s-derivatives come from the
4// triangle factor (TriCnGradient.h) scaled by the edge factor, and the
5// t-derivative from the edge factor (EdgeCnGradient.h, including the dx/dt =
6// 1/2 that the change of variables introduces) scaled by the triangle.
7RealT nfact = 1.;
8for (int mm = 2; mm <= order[0]; ++mm)
9{
10 nfact *= RealT(mm);
11}
12
13WORKSPACE(RealT, bary, 3);
14bary[0] = 1. - rr - ss;
15bary[1] = rr;
16bary[2] = ss;
17
18WORKSPACE(RealT, wval, 3 * (order[0] + 1));
19for (int kk = 0; kk < 3; ++kk)
20{
21 int base = kk * (order[0] + 1);
22 wval[base] = 1.;
23 for (int mm = 1; mm <= order[0]; ++mm)
24 {
25 wval[base + mm] = wval[base + mm - 1] * bary[kk] / RealT(mm);
26 }
27}
28
29WORKSPACE(RealT, ttmp, order[2] + 1);
30WORKSPACE(RealT, dttmp, order[2] + 1);
31{
32 RealT xx = 0.5 * (tt + 1.);
33 RealT yy = 1. - xx;
34 WORKSPACE(RealT, xpow, order[2] + 1);
35 WORKSPACE(RealT, ypow, order[2] + 1);
36 xpow[0] = 1.;
37 for (int kk = 1; kk <= order[2]; ++kk)
38 {
39 xpow[kk] = xpow[kk - 1] * xx;
40 }
41 ypow[order[2]] = 1.;
42 for (int kk = order[2] - 1; kk >= 0; --kk)
43 {
44 ypow[kk] = ypow[kk + 1] * yy;
45 }
46 RealT coeff = 1.;
47 for (int kk = 0; kk <= order[2]; ++kk)
48 {
49 ttmp[kk] = coeff * xpow[kk] * ypow[kk];
50 RealT ddx = 0.;
51 if (kk > 0)
52 {
53 ddx += RealT(kk) * xpow[kk - 1] * ypow[kk];
54 }
55 if (kk < order[2])
56 {
57 ddx -= RealT(order[2] - kk) * xpow[kk] * ypow[kk + 1];
58 }
59 dttmp[kk] = 0.5 * coeff * ddx;
60 coeff = coeff * RealT(order[2] - kk) / RealT(kk + 1);
61 }
62}
63
64int idx = 0;
65for (int it = 0; it <= order[2]; ++it)
66{
67 for (int i2 = 0; i2 <= order[0]; ++i2)
68 {
69 for (int i1 = 0; i1 <= order[0] - i2; ++i1)
70 {
71 int i0 = order[0] - i1 - i2;
72 RealT w0 = wval[i0];
73 RealT w1 = wval[(order[0] + 1) + i1];
74 RealT w2 = wval[2 * (order[0] + 1) + i2];
75 RealT d0 = i0 > 0 ? wval[i0 - 1] : 0.;
76 RealT d1 = i1 > 0 ? wval[(order[0] + 1) + i1 - 1] : 0.;
77 RealT d2 = i2 > 0 ? wval[2 * (order[0] + 1) + i2 - 1] : 0.;
78 basisGradient[idx++] = nfact * ttmp[it] * w2 * (d1 * w0 - d0 * w1); // d/dr
79 basisGradient[idx++] = nfact * ttmp[it] * w1 * (d2 * w0 - d0 * w2); // d/ds
80 basisGradient[idx++] = nfact * dttmp[it] * w0 * w1 * w2; // d/dt
81 }
82 }
83}
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
RealT nfact
Definition TetCnBasis.h:8
bary[0]
Definition TetCnBasis.h:15
WORKSPACE(RealT, bary, 3)
basisGradient[0]