15 #include "../../mesh/nurbs.hpp"
24 order = kv[0]->GetOrder();
34 kv[0]->CalcShape(shape, ijk[0], ip.
x);
37 for (
int i = 0; i <= order; i++)
39 sum += (shape(i) *= weights(i));
50 kv[0]->CalcShape (shape_x, ijk[0], ip.
x);
51 kv[0]->CalcDShape(grad, ijk[0], ip.
x);
53 double sum = 0.0, dsum = 0.0;
54 for (
int i = 0; i <= order; i++)
56 sum += (shape_x(i) *= weights(i));
57 dsum += ( grad(i) *= weights(i));
61 add(sum, grad, -dsum*sum*sum, shape_x, grad);
70 kv[0]->CalcShape (shape_x, ijk[0], ip.
x);
71 kv[0]->CalcDShape(grad, ijk[0], ip.
x);
72 kv[0]->CalcD2Shape(hess, ijk[0], ip.
x);
74 double sum = 0.0, dsum = 0.0, d2sum = 0.0;
75 for (
int i = 0; i <= order; i++)
77 sum += (shape_x(i) *= weights(i));
78 dsum += ( grad(i) *= weights(i));
79 d2sum += ( hess(i) *= weights(i));
83 add(sum, hess, -2*dsum*sum*sum, grad, hess);
84 add(1.0, hess, (-d2sum + 2*dsum*dsum*sum)*sum*sum, shape_x, hess);
90 orders[0] = kv[0]->GetOrder();
91 orders[1] = kv[1]->GetOrder();
92 shape_x.SetSize(orders[0]+1);
93 shape_y.SetSize(orders[1]+1);
94 dshape_x.SetSize(orders[0]+1);
95 dshape_y.SetSize(orders[1]+1);
96 d2shape_x.SetSize(orders[0]+1);
97 d2shape_y.SetSize(orders[1]+1);
99 order = max(orders[0], orders[1]);
100 dof = (orders[0] + 1)*(orders[1] + 1);
103 weights.SetSize(dof);
109 kv[0]->CalcShape(shape_x, ijk[0], ip.
x);
110 kv[1]->CalcShape(shape_y, ijk[1], ip.
y);
113 for (
int o = 0, j = 0; j <= orders[1]; j++)
115 const double sy = shape_y(j);
116 for (
int i = 0; i <= orders[0]; i++, o++)
118 sum += ( shape(o) = shape_x(i)*sy*weights(o) );
130 kv[0]->CalcShape ( shape_x, ijk[0], ip.
x);
131 kv[1]->CalcShape ( shape_y, ijk[1], ip.
y);
133 kv[0]->CalcDShape(dshape_x, ijk[0], ip.
x);
134 kv[1]->CalcDShape(dshape_y, ijk[1], ip.
y);
136 sum = dsum[0] = dsum[1] = 0.0;
137 for (
int o = 0, j = 0; j <= orders[1]; j++)
139 const double sy = shape_y(j), dsy = dshape_y(j);
140 for (
int i = 0; i <= orders[0]; i++, o++)
142 sum += (
u(o) = shape_x(i)*sy*weights(o) );
144 dsum[0] += ( dshape(o,0) = dshape_x(i)*sy *weights(o) );
145 dsum[1] += ( dshape(o,1) = shape_x(i)*dsy*weights(o) );
153 for (
int o = 0; o < dof; o++)
155 dshape(o,0) = dshape(o,0)*sum -
u(o)*dsum[0];
156 dshape(o,1) = dshape(o,1)*sum -
u(o)*dsum[1];
163 double sum, dsum[2], d2sum[3];
165 kv[0]->CalcShape ( shape_x, ijk[0], ip.
x);
166 kv[1]->CalcShape ( shape_y, ijk[1], ip.
y);
168 kv[0]->CalcDShape(dshape_x, ijk[0], ip.
x);
169 kv[1]->CalcDShape(dshape_y, ijk[1], ip.
y);
171 kv[0]->CalcD2Shape(d2shape_x, ijk[0], ip.
x);
172 kv[1]->CalcD2Shape(d2shape_y, ijk[1], ip.
y);
174 sum = dsum[0] = dsum[1] = 0.0;
175 d2sum[0] = d2sum[1] = d2sum[2] = 0.0;
176 for (
int o = 0, j = 0; j <= orders[1]; j++)
178 const double sy = shape_y(j), dsy = dshape_y(j), d2sy = d2shape_y(j);
179 for (
int i = 0; i <= orders[0]; i++, o++)
181 const double sx = shape_x(i), dsx = dshape_x(i), d2sx = d2shape_x(i);
182 sum += (
u(o) = sx*sy*weights(o) );
184 dsum[0] += ( du(o,0) = dsx*sy*weights(o) );
185 dsum[1] += ( du(o,1) = sx*dsy*weights(o) );
187 d2sum[0] += ( hessian(o,0) = d2sx*sy*weights(o) );
188 d2sum[1] += ( hessian(o,1) = dsx*dsy*weights(o) );
189 d2sum[2] += ( hessian(o,2) = sx*d2sy*weights(o) );
201 for (
int o = 0; o < dof; o++)
203 hessian(o,0) = hessian(o,0)*sum
204 - 2*du(o,0)*sum*dsum[0]
205 +
u[o]*sum*(2*dsum[0]*dsum[0] - d2sum[0]);
207 hessian(o,1) = hessian(o,1)*sum
208 - du(o,0)*sum*dsum[1]
209 - du(o,1)*sum*dsum[0]
210 +
u[o]*sum*(2*dsum[0]*dsum[1] - d2sum[1]);
212 hessian(o,2) = hessian(o,2)*sum
213 - 2*du(o,1)*sum*dsum[1]
214 +
u[o]*sum*(2*dsum[1]*dsum[1] - d2sum[2]);
221 orders[0] = kv[0]->GetOrder();
222 orders[1] = kv[1]->GetOrder();
223 orders[2] = kv[2]->GetOrder();
224 shape_x.SetSize(orders[0]+1);
225 shape_y.SetSize(orders[1]+1);
226 shape_z.SetSize(orders[2]+1);
228 dshape_x.SetSize(orders[0]+1);
229 dshape_y.SetSize(orders[1]+1);
230 dshape_z.SetSize(orders[2]+1);
232 d2shape_x.SetSize(orders[0]+1);
233 d2shape_y.SetSize(orders[1]+1);
234 d2shape_z.SetSize(orders[2]+1);
236 order = max(max(orders[0], orders[1]), orders[2]);
237 dof = (orders[0] + 1)*(orders[1] + 1)*(orders[2] + 1);
240 weights.SetSize(dof);
246 kv[0]->CalcShape(shape_x, ijk[0], ip.
x);
247 kv[1]->CalcShape(shape_y, ijk[1], ip.
y);
248 kv[2]->CalcShape(shape_z, ijk[2], ip.
z);
251 for (
int o = 0, k = 0; k <= orders[2]; k++)
253 const double sz = shape_z(k);
254 for (
int j = 0; j <= orders[1]; j++)
256 const double sy_sz = shape_y(j)*sz;
257 for (
int i = 0; i <= orders[0]; i++, o++)
259 sum += ( shape(o) = shape_x(i)*sy_sz*weights(o) );
272 kv[0]->CalcShape ( shape_x, ijk[0], ip.
x);
273 kv[1]->CalcShape ( shape_y, ijk[1], ip.
y);
274 kv[2]->CalcShape ( shape_z, ijk[2], ip.
z);
276 kv[0]->CalcDShape(dshape_x, ijk[0], ip.
x);
277 kv[1]->CalcDShape(dshape_y, ijk[1], ip.
y);
278 kv[2]->CalcDShape(dshape_z, ijk[2], ip.
z);
280 sum = dsum[0] = dsum[1] = dsum[2] = 0.0;
281 for (
int o = 0, k = 0; k <= orders[2]; k++)
283 const double sz = shape_z(k), dsz = dshape_z(k);
284 for (
int j = 0; j <= orders[1]; j++)
286 const double sy_sz = shape_y(j)* sz;
287 const double dsy_sz = dshape_y(j)* sz;
288 const double sy_dsz = shape_y(j)*dsz;
289 for (
int i = 0; i <= orders[0]; i++, o++)
291 sum += (
u(o) = shape_x(i)*sy_sz*weights(o) );
293 dsum[0] += ( dshape(o,0) = dshape_x(i)* sy_sz *weights(o) );
294 dsum[1] += ( dshape(o,1) = shape_x(i)*dsy_sz *weights(o) );
295 dsum[2] += ( dshape(o,2) = shape_x(i)* sy_dsz*weights(o) );
305 for (
int o = 0; o < dof; o++)
307 dshape(o,0) = dshape(o,0)*sum -
u(o)*dsum[0];
308 dshape(o,1) = dshape(o,1)*sum -
u(o)*dsum[1];
309 dshape(o,2) = dshape(o,2)*sum -
u(o)*dsum[2];
316 double sum, dsum[3], d2sum[6];
318 kv[0]->CalcShape ( shape_x, ijk[0], ip.
x);
319 kv[1]->CalcShape ( shape_y, ijk[1], ip.
y);
320 kv[2]->CalcShape ( shape_z, ijk[2], ip.
z);
322 kv[0]->CalcDShape(dshape_x, ijk[0], ip.
x);
323 kv[1]->CalcDShape(dshape_y, ijk[1], ip.
y);
324 kv[2]->CalcDShape(dshape_z, ijk[2], ip.
z);
326 kv[0]->CalcD2Shape(d2shape_x, ijk[0], ip.
x);
327 kv[1]->CalcD2Shape(d2shape_y, ijk[1], ip.
y);
328 kv[2]->CalcD2Shape(d2shape_z, ijk[2], ip.
z);
330 sum = dsum[0] = dsum[1] = dsum[2] = 0.0;
331 d2sum[0] = d2sum[1] = d2sum[2] = d2sum[3] = d2sum[4] = d2sum[5] = 0.0;
333 for (
int o = 0, k = 0; k <= orders[2]; k++)
335 const double sz = shape_z(k), dsz = dshape_z(k), d2sz = d2shape_z(k);
336 for (
int j = 0; j <= orders[1]; j++)
338 const double sy = shape_y(j), dsy = dshape_y(j), d2sy = d2shape_y(j);
339 for (
int i = 0; i <= orders[0]; i++, o++)
341 const double sx = shape_x(i), dsx = dshape_x(i), d2sx = d2shape_x(i);
342 sum += (
u(o) = sx*sy*sz*weights(o) );
344 dsum[0] += ( du(o,0) = dsx*sy*sz*weights(o) );
345 dsum[1] += ( du(o,1) = sx*dsy*sz*weights(o) );
346 dsum[2] += ( du(o,2) = sx*sy*dsz*weights(o) );
348 d2sum[0] += ( hessian(o,0) = d2sx*sy*sz*weights(o) );
349 d2sum[1] += ( hessian(o,1) = dsx*dsy*sz*weights(o) );
350 d2sum[2] += ( hessian(o,2) = dsx*sy*dsz*weights(o) );
352 d2sum[3] += ( hessian(o,3) = sx*dsy*dsz*weights(o) );
354 d2sum[4] += ( hessian(o,4) = sx*sy*d2sz*weights(o) );
355 d2sum[5] += ( hessian(o,5) = sx*d2sy*sz*weights(o) );
373 for (
int o = 0; o < dof; o++)
375 hessian(o,0) = hessian(o,0)*sum
376 - 2*du(o,0)*sum*dsum[0]
377 +
u[o]*sum*(2*dsum[0]*dsum[0] - d2sum[0]);
379 hessian(o,1) = hessian(o,1)*sum
380 - du(o,0)*sum*dsum[1]
381 - du(o,1)*sum*dsum[0]
382 +
u[o]*sum*(2*dsum[0]*dsum[1] - d2sum[1]);
384 hessian(o,2) = hessian(o,2)*sum
385 - du(o,0)*sum*dsum[2]
386 - du(o,2)*sum*dsum[0]
387 +
u[o]*sum*(2*dsum[0]*dsum[2] - d2sum[2]);
389 hessian(o,3) = hessian(o,3)*sum
390 - du(o,1)*sum*dsum[2]
391 - du(o,2)*sum*dsum[1]
392 +
u[o]*sum*(2*dsum[1]*dsum[2] - d2sum[3]);
394 hessian(o,4) = hessian(o,4)*sum
395 - 2*du(o,2)*sum*dsum[2]
396 +
u[o]*sum*(2*dsum[2]*dsum[2] - d2sum[4]);
398 hessian(o,5) = hessian(o,5)*sum
399 - 2*du(o,1)*sum*dsum[1]
400 +
u[o]*sum*(2*dsum[1]*dsum[1] - d2sum[5]);
virtual void CalcHessian(const IntegrationPoint &ip, DenseMatrix &hessian) const
Evaluate the Hessians of all shape functions of a scalar finite element in reference space at the giv...
virtual void CalcDShape(const IntegrationPoint &ip, DenseMatrix &dshape) const
Evaluate the gradients of all shape functions of a scalar finite element in reference space at the gi...
virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const
Evaluate the values of all shape functions of a scalar finite element in reference space at the given...
Data type dense matrix using column-major storage.
virtual void CalcDShape(const IntegrationPoint &ip, DenseMatrix &dshape) const
Evaluate the gradients of all shape functions of a scalar finite element in reference space at the gi...
virtual void SetOrder() const
Update the NURBSFiniteElement according to the currently set knot vectors.
void add(const Vector &v1, const Vector &v2, Vector &v)
virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const
Evaluate the values of all shape functions of a scalar finite element in reference space at the given...
virtual void CalcDShape(const IntegrationPoint &ip, DenseMatrix &dshape) const
Evaluate the gradients of all shape functions of a scalar finite element in reference space at the gi...
double * Data() const
Returns the matrix data array.
virtual void SetOrder() const
Update the NURBSFiniteElement according to the currently set knot vectors.
Class for integration point with weight.
virtual void CalcHessian(const IntegrationPoint &ip, DenseMatrix &hessian) const
Evaluate the Hessians of all shape functions of a scalar finite element in reference space at the giv...
virtual void SetOrder() const
Update the NURBSFiniteElement according to the currently set knot vectors.
double u(const Vector &xvec)
virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const
Evaluate the values of all shape functions of a scalar finite element in reference space at the given...
virtual void CalcHessian(const IntegrationPoint &ip, DenseMatrix &hessian) const
Evaluate the Hessians of all shape functions of a scalar finite element in reference space at the giv...