VTK  9.7.20260922
TetCnGradient.h
Go to the documentation of this file.
1// Gradients of the arbitrary-order Bernstein-Bezier basis on the tetrahedron.
2//
3// See TetCnBasis.h for the basis and TriCnGradient.h for the chain rule; here
4// d(lambda0)/dr = -1, d(lambda1)/dr = 1 and the other barycentric coordinates
5// are constant along r (and likewise for s and t).
6RealT nfact = 1.;
7for (int mm = 2; mm <= order[0]; ++mm)
8{
9 nfact *= RealT(mm);
10}
11
12WORKSPACE(RealT, bary, 4);
13bary[0] = 1. - rr - ss - tt;
14bary[1] = rr;
15bary[2] = ss;
16bary[3] = tt;
17
18WORKSPACE(RealT, wval, 4 * (order[0] + 1));
19for (int kk = 0; kk < 4; ++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
29int idx = 0;
30for (int i3 = 0; i3 <= order[0]; ++i3)
31{
32 for (int i2 = 0; i2 <= order[0] - i3; ++i2)
33 {
34 for (int i1 = 0; i1 <= order[0] - i2 - i3; ++i1)
35 {
36 int i0 = order[0] - i1 - i2 - i3;
37 RealT w0 = wval[i0];
38 RealT w1 = wval[(order[0] + 1) + i1];
39 RealT w2 = wval[2 * (order[0] + 1) + i2];
40 RealT w3 = wval[3 * (order[0] + 1) + i3];
41 RealT d0 = i0 > 0 ? wval[i0 - 1] : 0.;
42 RealT d1 = i1 > 0 ? wval[(order[0] + 1) + i1 - 1] : 0.;
43 RealT d2 = i2 > 0 ? wval[2 * (order[0] + 1) + i2 - 1] : 0.;
44 RealT d3 = i3 > 0 ? wval[3 * (order[0] + 1) + i3 - 1] : 0.;
45 basisGradient[idx++] = nfact * w2 * w3 * (d1 * w0 - d0 * w1); // d/dr
46 basisGradient[idx++] = nfact * w1 * w3 * (d2 * w0 - d0 * w2); // d/ds
47 basisGradient[idx++] = nfact * w1 * w2 * (d3 * w0 - d0 * w3); // d/dt
48 }
49 }
50}
int idx
Definition HexCnBasis.h:79
RealT nfact
Definition TetCnBasis.h:8
bary[0]
Definition TetCnBasis.h:15
WORKSPACE(RealT, bary, 4)
basisGradient[0]