VTK  9.7.20260922
QuadCnGradient.h
Go to the documentation of this file.
1// Gradients of the arbitrary-order Bernstein-Bezier basis on the quadrilateral.
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);
11
12{
13 RealT xx = 0.5 * (rr + 1.);
14 RealT yy = 1. - xx;
15 WORKSPACE(RealT, xpow, order[0] + 1);
16 WORKSPACE(RealT, ypow, order[0] + 1);
17 xpow[0] = 1.;
18 for (int kk = 1; kk <= order[0]; ++kk)
19 {
20 xpow[kk] = xpow[kk - 1] * xx;
21 }
22 ypow[order[0]] = 1.;
23 for (int kk = order[0] - 1; kk >= 0; --kk)
24 {
25 ypow[kk] = ypow[kk + 1] * yy;
26 }
27 RealT coeff = 1.;
28 for (int kk = 0; kk <= order[0]; ++kk)
29 {
30 rtmp[kk] = coeff * xpow[kk] * ypow[kk];
31 RealT ddx = 0.;
32 if (kk > 0)
33 {
34 ddx += RealT(kk) * xpow[kk - 1] * ypow[kk];
35 }
36 if (kk < order[0])
37 {
38 ddx -= RealT(order[0] - kk) * xpow[kk] * ypow[kk + 1];
39 }
40 drtmp[kk] = 0.5 * coeff * ddx;
41 coeff = coeff * RealT(order[0] - kk) / RealT(kk + 1);
42 }
43}
44{
45 RealT xx = 0.5 * (ss + 1.);
46 RealT yy = 1. - xx;
47 WORKSPACE(RealT, xpow, order[1] + 1);
48 WORKSPACE(RealT, ypow, order[1] + 1);
49 xpow[0] = 1.;
50 for (int kk = 1; kk <= order[1]; ++kk)
51 {
52 xpow[kk] = xpow[kk - 1] * xx;
53 }
54 ypow[order[1]] = 1.;
55 for (int kk = order[1] - 1; kk >= 0; --kk)
56 {
57 ypow[kk] = ypow[kk + 1] * yy;
58 }
59 RealT coeff = 1.;
60 for (int kk = 0; kk <= order[1]; ++kk)
61 {
62 stmp[kk] = coeff * xpow[kk] * ypow[kk];
63 RealT ddx = 0.;
64 if (kk > 0)
65 {
66 ddx += RealT(kk) * xpow[kk - 1] * ypow[kk];
67 }
68 if (kk < order[1])
69 {
70 ddx -= RealT(order[1] - kk) * xpow[kk] * ypow[kk + 1];
71 }
72 dstmp[kk] = 0.5 * coeff * ddx;
73 coeff = coeff * RealT(order[1] - kk) / RealT(kk + 1);
74 }
75}
76
77// Compute the tensor product of basis derivatives. Like the fixed-order HGrad
78// gradients, store a full 3-tuple per basis function and zero the axes the cell
79// does not parameterize.
80int idx = 0;
81for (int pp = 0; pp <= order[1]; ++pp)
82{
83 for (int oo = 0; oo <= order[0]; ++oo)
84 {
85 basisGradient[idx++] = drtmp[oo] * stmp[pp]; // d/dr
86 basisGradient[idx++] = rtmp[oo] * dstmp[pp]; // d/ds
87 basisGradient[idx++] = 0.;
88 }
89}
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