VTK  9.7.20260922
EdgeCnGradient.h
Go to the documentation of this file.
1// Gradients of the arbitrary-order Bernstein-Bezier basis on the edge.
2//
3// See EdgeCnBasis.h for the basis and the change of variables. Differentiating
4// the monomials directly, and remembering that d(1-x)/dx = -1,
5//
6// d/dx [x^k (1-x)^(n-k)] = k x^(k-1) (1-x)^(n-k) - (n-k) x^k (1-x)^(n-k-1),
7//
8// which the tables below supply with a shift of index. The reference edge is
9// parameterized over [-1, 1] and the Bernstein polynomials over [0, 1], so
10// every derivative also picks up the factor dx/dr = 1/2.
11RealT xx = 0.5 * (rr + 1.);
12RealT yy = 1. - xx;
13
14WORKSPACE(RealT, xpow, order[0] + 1);
15WORKSPACE(RealT, ypow, order[0] + 1);
16xpow[0] = 1.;
17for (int kk = 1; kk <= order[0]; ++kk)
18{
19 xpow[kk] = xpow[kk - 1] * xx;
20}
21ypow[order[0]] = 1.;
22for (int kk = order[0] - 1; kk >= 0; --kk)
23{
24 ypow[kk] = ypow[kk + 1] * yy;
25}
26
27RealT coeff = 1.;
28for (int kk = 0; kk <= order[0]; ++kk)
29{
30 RealT ddx = 0.;
31 if (kk > 0)
32 {
33 ddx += RealT(kk) * xpow[kk - 1] * ypow[kk];
34 }
35 if (kk < order[0])
36 {
37 ddx -= RealT(order[0] - kk) * xpow[kk] * ypow[kk + 1];
38 }
39 // Like the fixed-order HGrad gradients, store a full 3-tuple per basis
40 // function and zero the axes the cell does not parameterize.
41 basisGradient[3 * kk + 0] = 0.5 * coeff * ddx; // d/dr
42 basisGradient[3 * kk + 1] = 0.;
43 basisGradient[3 * kk + 2] = 0.;
44 coeff = coeff * RealT(order[0] - kk) / RealT(kk + 1);
45}
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
WORKSPACE(RealT, xpow, order[0]+1)
basisGradient[0]