VTK  9.7.20261001
QuadCnGradient.h
Go to the documentation of this file.
1// Gradients of the arbitrary-order Lagrange interpolants on the quadrilateral.
2//
3// Each 1-d interpolant and its derivative are computed along each parametric
4// axis (see EdgeCnBasis.h and EdgeCnGradient.h), then combined by the product
5// rule to form the gradient of the tensor-product basis.
6RealT invspcR = RealT(order[0]) / 2.;
7RealT invspcS = RealT(order[1]) / 2.;
8
9WORKSPACE(RealT, rtmp, order[0] + 1);
10WORKSPACE(RealT, stmp, order[1] + 1);
11WORKSPACE(RealT, drtmp, order[0] + 1);
12WORKSPACE(RealT, dstmp, order[1] + 1);
13
14// Compute the basis and its derivative along the r-axis.
15for (int ll = 0; ll <= order[0]; ++ll)
16{
17 RealT termSum = 0.;
18 rtmp[ll] = 1.;
19 for (int kk = 0; kk <= order[0]; ++kk)
20 {
21 if (kk == ll)
22 {
23 continue;
24 }
25 rtmp[ll] *= (rr * invspcR - (RealT(kk) - invspcR)) / RealT(ll - kk);
26 RealT term = invspcR / RealT(ll - kk);
27 for (int ii = 0; ii <= order[0]; ++ii)
28 {
29 if (ii == kk || ii == ll)
30 {
31 continue;
32 }
33 term *= (rr * invspcR - (RealT(ii) - invspcR)) / RealT(ll - ii);
34 }
35 termSum += term;
36 }
37 drtmp[ll] = termSum;
38}
39
40// Compute the basis and its derivative along the s-axis.
41for (int mm = 0; mm <= order[1]; ++mm)
42{
43 RealT termSum = 0.;
44 stmp[mm] = 1.;
45 for (int kk = 0; kk <= order[1]; ++kk)
46 {
47 if (kk == mm)
48 {
49 continue;
50 }
51 stmp[mm] *= (ss * invspcS - (RealT(kk) - invspcS)) / RealT(mm - kk);
52 RealT term = invspcS / RealT(mm - kk);
53 for (int ii = 0; ii <= order[1]; ++ii)
54 {
55 if (ii == kk || ii == mm)
56 {
57 continue;
58 }
59 term *= (ss * invspcS - (RealT(ii) - invspcS)) / RealT(mm - ii);
60 }
61 termSum += term;
62 }
63 dstmp[mm] = termSum;
64}
65
66// Compute the tensor product of basis derivatives. Like the fixed-order HGrad
67// gradients, store a full 3-tuple per basis function and zero the axes the cell
68// does not parameterize.
69int idx = 0;
70for (int mm = 0; mm <= order[1]; ++mm)
71{
72 for (int ll = 0; ll <= order[0]; ++ll)
73 {
74 basisGradient[idx++] = drtmp[ll] * stmp[mm]; // ∂/∂r
75 basisGradient[idx++] = rtmp[ll] * dstmp[mm]; // ∂/∂s
76 basisGradient[idx++] = 0.;
77 }
78}
int idx
Definition HexCnBasis.h:79
WORKSPACE(RealT, rtmp, order[0]+1)
basisGradient[0]
RealT invspcR
Definition HexCnBasis.h:6
RealT invspcS
Definition HexCnBasis.h:7
int term
Definition HexGnBasis.h:23
@ order
Definition vtkX3D.h:441