PolyFEM
Loading...
Searching...
No Matches
auto_q_bases_2d_grad.cpp
Go to the documentation of this file.
2
3
4namespace polyfem {
5namespace autogen {
6namespace {
7void q_0_basis_grad_value_2d(const int local_index, const Eigen::MatrixXd &uv, Eigen::MatrixXd &val){
8
9auto x=uv.col(0).array();
10auto y=uv.col(1).array();
11
12val.resize(uv.rows(), uv.cols());
13 Eigen::ArrayXd result_0(uv.rows());
14switch(local_index){
15 case 0: {{result_0.setZero();val.col(0) = result_0; }{result_0.setZero();val.col(1) = result_0; }} break;
16 default: assert(false);
17}}
18
19void q_1_basis_grad_value_2d(const int local_index, const Eigen::MatrixXd &uv, Eigen::MatrixXd &val){
20
21auto x=uv.col(0).array();
22auto y=uv.col(1).array();
23
24val.resize(uv.rows(), uv.cols());
25 Eigen::ArrayXd result_0(uv.rows());
26switch(local_index){
27 case 0: {{result_0 = 1.0*(y - 1);val.col(0) = result_0; }{result_0 = 1.0*(x - 1);val.col(1) = result_0; }} break;
28 case 1: {{result_0 = 1.0*(1 - y);val.col(0) = result_0; }{result_0 = -1.0*x;val.col(1) = result_0; }} break;
29 case 2: {{result_0 = 1.0*y;val.col(0) = result_0; }{result_0 = 1.0*x;val.col(1) = result_0; }} break;
30 case 3: {{result_0 = -1.0*y;val.col(0) = result_0; }{result_0 = 1.0*(1 - x);val.col(1) = result_0; }} break;
31 default: assert(false);
32}}
33
34void q_2_basis_grad_value_2d(const int local_index, const Eigen::MatrixXd &uv, Eigen::MatrixXd &val){
35
36auto x=uv.col(0).array();
37auto y=uv.col(1).array();
38
39val.resize(uv.rows(), uv.cols());
40 Eigen::ArrayXd result_0(uv.rows());
41switch(local_index){
42 case 0: {{result_0 = (4.0*x - 3.0)*(y - 1)*(2.0*y - 1.0);val.col(0) = result_0; }{result_0 = (x - 1)*(2.0*x - 1.0)*(4.0*y - 3.0);val.col(1) = result_0; }} break;
43 case 1: {{result_0 = (4.0*x - 1.0)*(y - 1)*(2.0*y - 1.0);val.col(0) = result_0; }{result_0 = x*(2.0*x - 1.0)*(4.0*y - 3.0);val.col(1) = result_0; }} break;
44 case 2: {{result_0 = y*(4.0*x - 1.0)*(2.0*y - 1.0);val.col(0) = result_0; }{result_0 = x*(2.0*x - 1.0)*(4.0*y - 1.0);val.col(1) = result_0; }} break;
45 case 3: {{result_0 = y*(4.0*x - 3.0)*(2.0*y - 1.0);val.col(0) = result_0; }{result_0 = (x - 1)*(2.0*x - 1.0)*(4.0*y - 1.0);val.col(1) = result_0; }} break;
46 case 4: {{result_0 = -4.0*(2*x - 1)*(y - 1)*(2.0*y - 1.0);val.col(0) = result_0; }{result_0 = -x*(x - 1)*(16.0*y - 12.0);val.col(1) = result_0; }} break;
47 case 5: {{result_0 = -y*(16.0*x - 4.0)*(y - 1);val.col(0) = result_0; }{result_0 = -4.0*x*(2.0*x - 1.0)*(2*y - 1);val.col(1) = result_0; }} break;
48 case 6: {{result_0 = -4.0*y*(2*x - 1)*(2.0*y - 1.0);val.col(0) = result_0; }{result_0 = -x*(x - 1)*(16.0*y - 4.0);val.col(1) = result_0; }} break;
49 case 7: {{result_0 = -y*(16.0*x - 12.0)*(y - 1);val.col(0) = result_0; }{result_0 = -4.0*(x - 1)*(2.0*x - 1.0)*(2*y - 1);val.col(1) = result_0; }} break;
50 case 8: {{result_0 = 16.0*y*(2*x - 1)*(y - 1);val.col(0) = result_0; }{result_0 = 16.0*x*(x - 1)*(2*y - 1);val.col(1) = result_0; }} break;
51 default: assert(false);
52}}
53
54void q_3_basis_grad_value_2d(const int local_index, const Eigen::MatrixXd &uv, Eigen::MatrixXd &val){
55
56auto x=uv.col(0).array();
57auto y=uv.col(1).array();
58
59val.resize(uv.rows(), uv.cols());
60 Eigen::ArrayXd result_0(uv.rows());
61switch(local_index){
62 case 0: {{const auto helper_0 = x - 1;
63const auto helper_1 = 1.5*x - 1.0;
64const auto helper_2 = 3.0*x - 1.0;
65result_0 = (y - 1)*(1.5*y - 1.0)*(3.0*y - 1.0)*(3.0*helper_0*helper_1 + 1.5*helper_0*helper_2 + 1.0*helper_1*helper_2);val.col(0) = result_0; }{const auto helper_0 = y - 1;
66const auto helper_1 = 1.5*y - 1.0;
67const auto helper_2 = 3.0*y - 1.0;
68result_0 = (x - 1)*(1.5*x - 1.0)*(3.0*x - 1.0)*(3.0*helper_0*helper_1 + 1.5*helper_0*helper_2 + 1.0*helper_1*helper_2);val.col(1) = result_0; }} break;
69 case 1: {{const auto helper_0 = 1.4999999999999998*x;
70const auto helper_1 = helper_0 - 0.49999999999999989;
71const auto helper_2 = 2.9999999999999996*x;
72const auto helper_3 = helper_2 - 1.9999999999999996;
73result_0 = -(y - 1)*(1.5*y - 1.0)*(3.0*y - 1.0)*(helper_0*helper_3 + helper_1*helper_2 + 1.0*helper_1*helper_3);val.col(0) = result_0; }{const auto helper_0 = y - 1;
74const auto helper_1 = 1.5*y - 1.0;
75const auto helper_2 = 3.0*y - 1.0;
76result_0 = -x*(1.4999999999999998*x - 0.49999999999999989)*(2.9999999999999996*x - 1.9999999999999996)*(3.0*helper_0*helper_1 + 1.5*helper_0*helper_2 + 1.0*helper_1*helper_2);val.col(1) = result_0; }} break;
77 case 2: {{const auto helper_0 = 1.4999999999999998*x;
78const auto helper_1 = helper_0 - 0.49999999999999989;
79const auto helper_2 = 2.9999999999999996*x;
80const auto helper_3 = helper_2 - 1.9999999999999996;
81result_0 = y*(1.4999999999999998*y - 0.49999999999999989)*(2.9999999999999996*y - 1.9999999999999996)*(helper_0*helper_3 + helper_1*helper_2 + 1.0*helper_1*helper_3);val.col(0) = result_0; }{const auto helper_0 = 1.4999999999999998*y;
82const auto helper_1 = helper_0 - 0.49999999999999989;
83const auto helper_2 = 2.9999999999999996*y;
84const auto helper_3 = helper_2 - 1.9999999999999996;
85result_0 = x*(1.4999999999999998*x - 0.49999999999999989)*(2.9999999999999996*x - 1.9999999999999996)*(helper_0*helper_3 + helper_1*helper_2 + 1.0*helper_1*helper_3);val.col(1) = result_0; }} break;
86 case 3: {{const auto helper_0 = x - 1;
87const auto helper_1 = 1.5*x - 1.0;
88const auto helper_2 = 3.0*x - 1.0;
89result_0 = -y*(1.4999999999999998*y - 0.49999999999999989)*(2.9999999999999996*y - 1.9999999999999996)*(3.0*helper_0*helper_1 + 1.5*helper_0*helper_2 + 1.0*helper_1*helper_2);val.col(0) = result_0; }{const auto helper_0 = 1.4999999999999998*y;
90const auto helper_1 = helper_0 - 0.49999999999999989;
91const auto helper_2 = 2.9999999999999996*y;
92const auto helper_3 = helper_2 - 1.9999999999999996;
93result_0 = -(x - 1)*(1.5*x - 1.0)*(3.0*x - 1.0)*(helper_0*helper_3 + helper_1*helper_2 + 1.0*helper_1*helper_3);val.col(1) = result_0; }} break;
94 case 4: {{const auto helper_0 = x - 1;
95const auto helper_1 = 13.499999999999996*x - 8.9999999999999982;
96result_0 = -(y - 1)*(1.5*y - 1.0)*(3.0*y - 1.0)*(helper_0*helper_1 + 13.499999999999998*helper_0*x + helper_1*x);val.col(0) = result_0; }{const auto helper_0 = y - 1;
97const auto helper_1 = 1.5*y - 1.0;
98const auto helper_2 = 3.0*y - 1.0;
99result_0 = -x*(x - 1)*(3.0*x - 2.0)*(13.499999999999998*helper_0*helper_1 + 6.7499999999999991*helper_0*helper_2 + 4.4999999999999991*helper_1*helper_2);val.col(1) = result_0; }} break;
100 case 5: {{const auto helper_0 = x - 1;
101const auto helper_1 = 13.499999999999996*x - 4.4999999999999991;
102result_0 = (y - 1)*(1.5*y - 1.0)*(3.0*y - 1.0)*(helper_0*helper_1 + 13.499999999999998*helper_0*x + helper_1*x);val.col(0) = result_0; }{const auto helper_0 = y - 1;
103const auto helper_1 = 1.5*y - 1.0;
104const auto helper_2 = 3.0*y - 1.0;
105result_0 = x*(x - 1)*(3.0*x - 1.0)*(13.499999999999998*helper_0*helper_1 + 6.7499999999999991*helper_0*helper_2 + 4.4999999999999991*helper_1*helper_2);val.col(1) = result_0; }} break;
106 case 6: {{const auto helper_0 = 1.4999999999999998*x - 0.49999999999999989;
107const auto helper_1 = 2.9999999999999996*x - 1.9999999999999996;
108result_0 = y*(y - 1)*(3.0*y - 2.0)*(4.4999999999999991*helper_0*helper_1 + 13.499999999999995*helper_0*x + 6.7499999999999973*helper_1*x);val.col(0) = result_0; }{const auto helper_0 = y - 1;
109const auto helper_1 = 13.499999999999996*y - 8.9999999999999982;
110result_0 = x*(1.4999999999999998*x - 0.49999999999999989)*(2.9999999999999996*x - 1.9999999999999996)*(helper_0*helper_1 + 13.499999999999998*helper_0*y + helper_1*y);val.col(1) = result_0; }} break;
111 case 7: {{const auto helper_0 = 1.4999999999999998*x - 0.49999999999999989;
112const auto helper_1 = 2.9999999999999996*x - 1.9999999999999996;
113result_0 = -y*(y - 1)*(3.0*y - 1.0)*(4.4999999999999991*helper_0*helper_1 + 13.499999999999995*helper_0*x + 6.7499999999999973*helper_1*x);val.col(0) = result_0; }{const auto helper_0 = y - 1;
114const auto helper_1 = 13.499999999999996*y - 4.4999999999999991;
115result_0 = -x*(1.4999999999999998*x - 0.49999999999999989)*(2.9999999999999996*x - 1.9999999999999996)*(helper_0*helper_1 + 13.499999999999998*helper_0*y + helper_1*y);val.col(1) = result_0; }} break;
116 case 8: {{const auto helper_0 = x - 1;
117const auto helper_1 = 13.499999999999996*x - 4.4999999999999991;
118result_0 = -y*(1.4999999999999998*y - 0.49999999999999989)*(2.9999999999999996*y - 1.9999999999999996)*(helper_0*helper_1 + 13.499999999999998*helper_0*x + helper_1*x);val.col(0) = result_0; }{const auto helper_0 = 1.4999999999999998*y - 0.49999999999999989;
119const auto helper_1 = 2.9999999999999996*y - 1.9999999999999996;
120result_0 = -x*(x - 1)*(3.0*x - 1.0)*(4.4999999999999991*helper_0*helper_1 + 13.499999999999995*helper_0*y + 6.7499999999999973*helper_1*y);val.col(1) = result_0; }} break;
121 case 9: {{const auto helper_0 = x - 1;
122const auto helper_1 = 13.499999999999996*x - 8.9999999999999982;
123result_0 = y*(1.4999999999999998*y - 0.49999999999999989)*(2.9999999999999996*y - 1.9999999999999996)*(helper_0*helper_1 + 13.499999999999998*helper_0*x + helper_1*x);val.col(0) = result_0; }{const auto helper_0 = 1.4999999999999998*y - 0.49999999999999989;
124const auto helper_1 = 2.9999999999999996*y - 1.9999999999999996;
125result_0 = x*(x - 1)*(3.0*x - 2.0)*(4.4999999999999991*helper_0*helper_1 + 13.499999999999995*helper_0*y + 6.7499999999999973*helper_1*y);val.col(1) = result_0; }} break;
126 case 10: {{const auto helper_0 = x - 1;
127const auto helper_1 = 1.5*x - 1.0;
128const auto helper_2 = 3.0*x - 1.0;
129result_0 = y*(y - 1)*(3.0*y - 1.0)*(13.499999999999998*helper_0*helper_1 + 6.7499999999999991*helper_0*helper_2 + 4.4999999999999991*helper_1*helper_2);val.col(0) = result_0; }{const auto helper_0 = y - 1;
130const auto helper_1 = 13.499999999999996*y - 4.4999999999999991;
131result_0 = (x - 1)*(1.5*x - 1.0)*(3.0*x - 1.0)*(helper_0*helper_1 + 13.499999999999998*helper_0*y + helper_1*y);val.col(1) = result_0; }} break;
132 case 11: {{const auto helper_0 = x - 1;
133const auto helper_1 = 1.5*x - 1.0;
134const auto helper_2 = 3.0*x - 1.0;
135result_0 = -y*(y - 1)*(3.0*y - 2.0)*(13.499999999999998*helper_0*helper_1 + 6.7499999999999991*helper_0*helper_2 + 4.4999999999999991*helper_1*helper_2);val.col(0) = result_0; }{const auto helper_0 = y - 1;
136const auto helper_1 = 13.499999999999996*y - 8.9999999999999982;
137result_0 = -(x - 1)*(1.5*x - 1.0)*(3.0*x - 1.0)*(helper_0*helper_1 + 13.499999999999998*helper_0*y + helper_1*y);val.col(1) = result_0; }} break;
138 case 12: {{const auto helper_0 = x - 1;
139const auto helper_1 = 60.749999999999979*x - 40.499999999999986;
140result_0 = y*(y - 1)*(3.0*y - 2.0)*(helper_0*helper_1 + 60.749999999999979*helper_0*x + helper_1*x);val.col(0) = result_0; }{const auto helper_0 = y - 1;
141const auto helper_1 = 60.749999999999979*y - 40.499999999999986;
142result_0 = x*(x - 1)*(3.0*x - 2.0)*(helper_0*helper_1 + 60.749999999999979*helper_0*y + helper_1*y);val.col(1) = result_0; }} break;
143 case 13: {{const auto helper_0 = x - 1;
144const auto helper_1 = 60.749999999999979*x - 40.499999999999986;
145result_0 = -y*(y - 1)*(3.0*y - 1.0)*(helper_0*helper_1 + 60.749999999999979*helper_0*x + helper_1*x);val.col(0) = result_0; }{const auto helper_0 = y - 1;
146const auto helper_1 = 60.749999999999979*y - 20.249999999999993;
147result_0 = -x*(x - 1)*(3.0*x - 2.0)*(helper_0*helper_1 + 60.749999999999979*helper_0*y + helper_1*y);val.col(1) = result_0; }} break;
148 case 14: {{const auto helper_0 = x - 1;
149const auto helper_1 = 60.749999999999979*x - 20.249999999999993;
150result_0 = -y*(y - 1)*(3.0*y - 2.0)*(helper_0*helper_1 + 60.749999999999979*helper_0*x + helper_1*x);val.col(0) = result_0; }{const auto helper_0 = y - 1;
151const auto helper_1 = 60.749999999999979*y - 40.499999999999986;
152result_0 = -x*(x - 1)*(3.0*x - 1.0)*(helper_0*helper_1 + 60.749999999999979*helper_0*y + helper_1*y);val.col(1) = result_0; }} break;
153 case 15: {{const auto helper_0 = x - 1;
154const auto helper_1 = 60.749999999999979*x - 20.249999999999993;
155result_0 = y*(y - 1)*(3.0*y - 1.0)*(helper_0*helper_1 + 60.749999999999979*helper_0*x + helper_1*x);val.col(0) = result_0; }{const auto helper_0 = y - 1;
156const auto helper_1 = 60.749999999999979*y - 20.249999999999993;
157result_0 = x*(x - 1)*(3.0*x - 1.0)*(helper_0*helper_1 + 60.749999999999979*helper_0*y + helper_1*y);val.col(1) = result_0; }} break;
158 default: assert(false);
159}}
160
161void q_m2_basis_grad_value_2d(const int local_index, const Eigen::MatrixXd &uv, Eigen::MatrixXd &val){
162
163auto x=uv.col(0).array();
164auto y=uv.col(1).array();
165
166val.resize(uv.rows(), uv.cols());
167 Eigen::ArrayXd result_0(uv.rows());
168switch(local_index){
169 case 0: {{result_0 = -(y - 1)*(4.0*x + 2.0*y - 3.0);val.col(0) = result_0; }{result_0 = -(x - 1)*(2.0*x + 4.0*y - 3.0);val.col(1) = result_0; }} break;
170 case 1: {{result_0 = (y - 1)*(-4.0*x + 2*y + 1);val.col(0) = result_0; }{result_0 = -x*(2.0*x - 4.0*y + 1.0);val.col(1) = result_0; }} break;
171 case 2: {{result_0 = y*(4.0*x + 2.0*y - 3.0);val.col(0) = result_0; }{result_0 = x*(2.0*x + 4.0*y - 3.0);val.col(1) = result_0; }} break;
172 case 3: {{result_0 = -y*(-4.0*x + 2.0*y + 1.0);val.col(0) = result_0; }{result_0 = (x - 1)*(2.0*x - 4.0*y + 1.0);val.col(1) = result_0; }} break;
173 case 4: {{result_0 = 4*(2*x - 1)*(y - 1);val.col(0) = result_0; }{result_0 = 4*x*(x - 1);val.col(1) = result_0; }} break;
174 case 5: {{result_0 = -4*y*(y - 1);val.col(0) = result_0; }{result_0 = -4*x*(2*y - 1);val.col(1) = result_0; }} break;
175 case 6: {{result_0 = -4*y*(2*x - 1);val.col(0) = result_0; }{result_0 = -4*x*(x - 1);val.col(1) = result_0; }} break;
176 case 7: {{result_0 = 4*y*(y - 1);val.col(0) = result_0; }{result_0 = 4*(x - 1)*(2*y - 1);val.col(1) = result_0; }} break;
177 default: assert(false);
178}}
179
180}
181
182void q_grad_basis_value_2d(const int q, const int local_index, const Eigen::MatrixXd &uv, Eigen::MatrixXd &val){
183switch(q){
184 case 0: q_0_basis_grad_value_2d(local_index, uv, val); break;
185 case 1: q_1_basis_grad_value_2d(local_index, uv, val); break;
186 case 2: q_2_basis_grad_value_2d(local_index, uv, val); break;
187 case 3: q_3_basis_grad_value_2d(local_index, uv, val); break;
188 case -2: q_m2_basis_grad_value_2d(local_index, uv, val); break;
189 default: assert(false);
190}}
191}}
double val
Definition Assembler.cpp:86
int y
int x
void q_grad_basis_value_2d(const int q, const int local_index, const Eigen::MatrixXd &uv, Eigen::MatrixXd &val)