VTK  9.7.20260922
TriCnGradient.h
Go to the documentation of this file.
1// Gradients of the arbitrary-order Bernstein-Bezier basis on the triangle.
2//
3// See TriCnBasis.h for the basis. Since w_m = lambda^m / m! differentiates to
4// w_{m-1}, the derivative with respect to a barycentric coordinate is just the
5// same product with that factor's index shifted down by one. Applying the chain
6// rule with d(lambda0)/dr = -1, d(lambda1)/dr = 1 and d(lambda2)/dr = 0 (and
7// likewise for s) then gives
8//
9// dB/dr = P_{b2} (P'_{b1} P_{b0} - P'_{b0} P_{b1})
10RealT nfact = 1.;
11for (int mm = 2; mm <= order[0]; ++mm)
12{
13 nfact *= RealT(mm);
14}
15
16WORKSPACE(RealT, bary, 3);
17bary[0] = 1. - rr - ss;
18bary[1] = rr;
19bary[2] = ss;
20
21WORKSPACE(RealT, wval, 3 * (order[0] + 1));
22for (int kk = 0; kk < 3; ++kk)
23{
24 int base = kk * (order[0] + 1);
25 wval[base] = 1.;
26 for (int mm = 1; mm <= order[0]; ++mm)
27 {
28 wval[base + mm] = wval[base + mm - 1] * bary[kk] / RealT(mm);
29 }
30}
31
32int idx = 0;
33for (int i2 = 0; i2 <= order[0]; ++i2)
34{
35 for (int i1 = 0; i1 <= order[0] - i2; ++i1)
36 {
37 int i0 = order[0] - i1 - i2;
38 RealT w0 = wval[i0];
39 RealT w1 = wval[(order[0] + 1) + i1];
40 RealT w2 = wval[2 * (order[0] + 1) + i2];
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 basisGradient[idx++] = nfact * w2 * (d1 * w0 - d0 * w1); // d/dr
45 basisGradient[idx++] = nfact * w1 * (d2 * w0 - d0 * w2); // d/ds
46 basisGradient[idx++] = 0.;
47 }
48}
int idx
Definition HexCnBasis.h:79
RealT nfact
Definition TetCnBasis.h:8
bary[0]
Definition TetCnBasis.h:15
WORKSPACE(RealT, bary, 3)
basisGradient[0]