28 if(pe0 > pf ||
pe2 > pf || pe1 > pf) {
29 throw std::runtime_error(
"pe0, pe1 and pe2 must be <=pf");
62 case(1):
return 0.5 * (1 + v);
63 case(2):
return -0.5 * (u + v);
64 case(3):
return 0.5 * (1 + u);
65 default:
throw std::runtime_error(
"j must be : 1<=j<=3");
71 std::vector<double> &vertexBasis,
72 std::vector<double> &edgeBasis,
73 std::vector<double> &faceBasis,
74 std::vector<double> &bubbleBasis)
78 double uc = 2 * u - 1;
79 double vc = 2 * v - 1;
84 double product32 = lambda2 * lambda3;
85 double subtraction32 = lambda3 - lambda2;
86 double product13 = lambda3 * lambda1;
87 double subtraction13 = lambda1 - lambda3;
88 double product21 = lambda2 * lambda1;
89 double subtraction21 = lambda2 - lambda1;
90 double product = lambda1 * lambda2 * lambda3;
92 vertexBasis[0] = lambda2;
93 vertexBasis[1] = lambda3;
94 vertexBasis[2] = lambda1;
99 edgeBasis[k] = product32 * kernel;
101 while(iterator <=
_pf - 3 - k) {
102 faceBasis[iterator2 + iterator] = product * kernel;
105 iterator2 = iterator2 +
_pf - 2 - k;
110 while(iterator <=
_pf - 3 - k) {
111 faceBasis[iterator2 + iterator] = product * kernel;
114 iterator2 = iterator2 +
_pf - 2 - k;
127 int iterator3 =
_pf - 2;
128 while(iterator1 <=
_pf - 3 - k) {
129 faceBasis[iterator2] = faceBasis[iterator2] * kernel;
130 iterator2 = iterator2 + iterator3;
139 int iterator3 =
_pf - 2;
140 while(iterator1 <=
_pf - 3 - k) {
141 faceBasis[iterator2] = faceBasis[iterator2] * kernel;
142 iterator2 = iterator2 + iterator3;
150 double const &u,
double const &v,
double const &w,
151 std::vector<std::vector<double> > &gradientVertex,
152 std::vector<std::vector<double> > &gradientEdge,
153 std::vector<std::vector<double> > &gradientFace,
154 std::vector<std::vector<double> > &gradientBubble)
158 double uc = 2 * u - 1;
159 double vc = 2 * v - 1;
162 double dlambda1U = 0;
163 double dlambda1V = 0.5;
164 double dlambda2U = -0.5;
165 double dlambda2V = -0.5;
166 double dlambda3U = 0.5;
167 double dlambda3V = 0;
171 double product32 = lambda2 * lambda3;
172 double subtraction32 = lambda3 - lambda2;
173 double product13 = lambda3 * lambda1;
174 double subtraction13 = lambda1 - lambda3;
175 double product21 = lambda2 * lambda1;
176 double subtraction21 = lambda2 - lambda1;
177 double product = lambda1 * lambda2 * lambda3;
179 gradientVertex[0][0] = jacob * dlambda2U;
180 gradientVertex[0][1] = jacob * dlambda2V;
181 gradientVertex[1][0] = jacob * dlambda3U;
182 gradientVertex[1][1] = jacob * dlambda3V;
183 gradientVertex[2][0] = jacob * dlambda1U;
184 gradientVertex[2][1] = jacob * dlambda1V;
193 (gradientVertex[1][0] * lambda2 + gradientVertex[0][0] * lambda3) *
195 product32 * (gradientVertex[1][0] - gradientVertex[0][0]) * dKernel;
197 (gradientVertex[1][1] * lambda2 + gradientVertex[0][1] * lambda3) *
199 product32 * (gradientVertex[1][1] - gradientVertex[0][1]) * dKernel;
201 while(iterator <=
_pf - 3 - k) {
202 gradientFace[iterator2 + iterator][0] =
203 (gradientVertex[1][0] * product21 + gradientVertex[0][0] * product13 +
204 gradientVertex[2][0] * product32) *
206 product * (gradientVertex[1][0] - gradientVertex[0][0]) * dKernel;
207 gradientFace[iterator2 + iterator][1] =
208 (gradientVertex[1][1] * product21 + gradientVertex[0][1] * product13 +
209 gradientVertex[2][1] * product32) *
211 product * (gradientVertex[1][1] - gradientVertex[0][1]) * dKernel;
212 tablIntermU[iterator2 + iterator] =
213 product * (gradientVertex[0][0] - gradientVertex[2][0]) * kernel;
214 tablIntermV[iterator2 + iterator] =
215 product * (gradientVertex[0][1] - gradientVertex[2][1]) * kernel;
219 iterator2 = iterator2 +
_pf - 2 - k;
225 while(iterator <=
_pf - 3 - k) {
226 gradientFace[iterator2 + iterator][0] =
227 (gradientVertex[1][0] * product21 + gradientVertex[0][0] * product13 +
228 gradientVertex[2][0] * product32) *
230 product * (gradientVertex[1][0] - gradientVertex[0][0]) * dKernel;
231 gradientFace[iterator2 + iterator][1] =
232 (gradientVertex[1][1] * product21 + gradientVertex[0][1] * product13 +
233 gradientVertex[2][1] * product32) *
235 product * (gradientVertex[1][1] - gradientVertex[0][1]) * dKernel;
236 tablIntermU[iterator2 + iterator] =
237 product * (gradientVertex[0][0] - gradientVertex[2][0]) * kernel;
238 tablIntermV[iterator2 + iterator] =
239 product * (gradientVertex[0][1] - gradientVertex[2][1]) * kernel;
243 iterator2 = iterator2 +
_pf - 2 - k;
250 (lambda3 * gradientVertex[2][0] + lambda1 * gradientVertex[1][0]) *
252 product13 * (gradientVertex[2][0] - gradientVertex[1][0]) * dKernel;
254 (lambda3 * gradientVertex[2][1] + lambda1 * gradientVertex[1][1]) *
256 product13 * (gradientVertex[2][1] - gradientVertex[1][1]) * dKernel;
263 (lambda2 * gradientVertex[2][0] + lambda1 * gradientVertex[0][0]) *
265 product21 * (gradientVertex[0][0] - gradientVertex[2][0]) * dKernel;
267 (lambda2 * gradientVertex[2][1] + lambda1 * gradientVertex[0][1]) *
269 product21 * (gradientVertex[0][1] - gradientVertex[2][1]) * dKernel;
272 int iterator3 =
_pf - 2;
273 while(iterator1 <=
_pf - 3 - k) {
274 gradientFace[iterator2][0] =
275 gradientFace[iterator2][0] * kernel + tablIntermU[iterator2] * dKernel;
276 gradientFace[iterator2][1] =
277 gradientFace[iterator2][1] * kernel + tablIntermV[iterator2] * dKernel;
278 iterator2 = iterator2 + iterator3;
288 int iterator3 =
_pf - 2;
289 while(iterator1 <=
_pf - 3 - k) {
290 gradientFace[iterator2][0] =
291 gradientFace[iterator2][0] * kernel + tablIntermU[iterator2] * dKernel;
292 gradientFace[iterator2][1] =
293 gradientFace[iterator2][1] * kernel + tablIntermV[iterator2] * dKernel;
294 iterator2 = iterator2 + iterator3;
302 int const &flagOrientation,
int const &edgeNumber,
303 std::vector<double> &edgeFunctions,
304 const std::vector<double> &eTablePositiveFlag,
305 const std::vector<double> &eTableNegativeFlag)
307 if(flagOrientation == -1) {
310 for(
int i = 0; i <= edgeNumber; i++) { constant2 +=
_pOrderEdge[i] - 1; }
311 constant2 = constant2 - 1;
312 constant1 = constant2 -
_pOrderEdge[edgeNumber] + 2;
313 for(
int k = constant1; k <= constant2; k++) {
314 edgeFunctions[k] = eTableNegativeFlag[k];
320 for(
int i = 0; i <= edgeNumber; i++) { constant2 +=
_pOrderEdge[i] - 1; }
321 constant2 = constant2 - 1;
322 constant1 = constant2 -
_pOrderEdge[edgeNumber] + 2;
323 for(
int k = constant1; k <= constant2; k++) {
324 edgeFunctions[k] = eTablePositiveFlag[k];
330 int const &flagOrientation,
int const &edgeNumber,
331 std::vector<std::vector<double> > &edgeFunctions,
332 const std::vector<std::vector<double> > &eTablePositiveFlag,
333 const std::vector<std::vector<double> > &eTableNegativeFlag)
335 if(flagOrientation == -1) {
338 for(
int i = 0; i <= edgeNumber; i++) { constant2 +=
_pOrderEdge[i] - 1; }
339 constant2 = constant2 - 1;
340 constant1 = constant2 -
_pOrderEdge[edgeNumber] + 2;
341 for(
int k = constant1; k <= constant2; k++) {
342 edgeFunctions[k][0] = eTableNegativeFlag[k][0];
343 edgeFunctions[k][1] = eTableNegativeFlag[k][1];
349 for(
int i = 0; i <= edgeNumber; i++) { constant2 +=
_pOrderEdge[i] - 1; }
350 constant2 = constant2 - 1;
351 constant1 = constant2 -
_pOrderEdge[edgeNumber] + 2;
352 for(
int k = constant1; k <= constant2; k++) {
353 edgeFunctions[k][0] = eTablePositiveFlag[k][0];
354 edgeFunctions[k][1] = eTablePositiveFlag[k][1];
359 std::vector<double> &edgeFunctions)
363 for(
int edgeNumber = 0; edgeNumber <
_nedge; edgeNumber++) {
366 for(
int i = 0; i <= edgeNumber; i++) { constant2 +=
_pOrderEdge[i] - 1; }
367 constant2 = constant2 - 1;
368 constant1 = constant2 -
_pOrderEdge[edgeNumber] + 2;
369 for(
int k = constant1; k <= constant2; k++) {
370 if((k - constant1) % 2 != 0) {
371 edgeFunctions[k] = edgeFunctions[k] * (-1);
378 std::vector<std::vector<double> > &edgeFunctions)
382 for(
int edgeNumber = 0; edgeNumber <
_nedge; edgeNumber++) {
385 for(
int i = 0; i <= edgeNumber; i++) { constant2 +=
_pOrderEdge[i] - 1; }
386 constant2 = constant2 - 1;
387 constant1 = constant2 -
_pOrderEdge[edgeNumber] + 2;
388 for(
int k = constant1; k <= constant2; k++) {
389 if((k - constant1) % 2 != 0) {
390 edgeFunctions[k][0] = edgeFunctions[k][0] * (-1);
391 edgeFunctions[k][1] = edgeFunctions[k][1] * (-1);
392 edgeFunctions[k][2] = edgeFunctions[k][2] * (-1);
398 double const &w,
int const &flag1,
399 int const &flag2,
int const &flag3,
400 int const &faceNumber,
401 std::vector<double> &faceBasis)
403 if(!(flag1 == 0 && flag2 == 1)) {
405 double uc = 2 * u - 1;
406 double vc = 2 * v - 1;
409 std::vector<double> lambda(3);
415 double product = lambda[0] * lambda[1] * lambda[2];
416 if(flag1 == 1 && flag2 == -1) {
417 double copy = lambda[0];
418 lambda[0] = lambda[1];
421 else if(flag1 == 0 && flag2 == -1) {
422 double copy = lambda[2];
423 lambda[2] = lambda[1];
426 else if(flag1 == 2 && flag2 == -1) {
427 double copy = lambda[2];
428 lambda[2] = lambda[0];
431 else if(flag1 == 1 && flag2 == 1) {
432 double copy = lambda[0];
433 lambda[0] = lambda[1];
434 lambda[1] = lambda[2];
437 else if(flag1 == 2 && flag2 == 1) {
438 double copy = lambda[0];
439 lambda[0] = lambda[2];
440 lambda[2] = lambda[1];
443 double subs1 = lambda[1] - lambda[0];
444 double subs2 = lambda[0] - lambda[2];
445 std::vector<double> phiSubs2(
_pf - 2);
446 for(
int it = 0; it <
_pf - 2; it++) {
449 for(
int n1 = 0; n1 <
_pf - 2; n1++) {
451 for(
int n2 = 0; n2 <
_pf - 2 - n1; n2++) {
452 faceBasis[iterator] = product * phiSubs1 * phiSubs2[n2];
459 double const &u,
double const &v,
double const &w,
int const &flag1,
460 int const &flag2,
int const &flag3,
int const &faceNumber,
461 std::vector<std::vector<double> > &gradientFace, std::string typeFunction)
463 if(!(flag1 == 0 && flag2 == 1)) {
465 double uc = 2 * u - 1;
466 double vc = 2 * v - 1;
469 std::vector<double> lambda(3);
470 std::vector<std::vector<double> > dlambda(3, std::vector<double>(2, 0));
471 std::vector<double> dProduct(2);
480 double pl3l1 = lambda[1] * lambda[2];
481 dProduct[0] = lambda[2] * lambda[0] - pl3l1;
482 dProduct[1] = lambda[0] * lambda[1] - pl3l1;
483 double product = lambda[0] * lambda[1] * lambda[2];
484 if(flag1 == 1 && flag2 == -1) {
485 double copy = lambda[0];
486 lambda[0] = lambda[1];
488 std::vector<double> dcopy = dlambda[0];
489 dlambda[0] = dlambda[1];
492 else if(flag1 == 0 && flag2 == -1) {
493 double copy = lambda[2];
494 lambda[2] = lambda[1];
496 std::vector<double> dcopy = dlambda[2];
497 dlambda[2] = dlambda[1];
500 else if(flag1 == 2 && flag2 == -1) {
501 double copy = lambda[2];
502 lambda[2] = lambda[0];
504 std::vector<double> dcopy = dlambda[2];
505 dlambda[2] = dlambda[0];
508 else if(flag1 == 1 && flag2 == 1) {
509 double copy = lambda[0];
510 lambda[0] = lambda[1];
511 lambda[1] = lambda[2];
513 std::vector<double> dcopy = dlambda[0];
514 dlambda[0] = dlambda[1];
515 dlambda[1] = dlambda[2];
518 else if(flag1 == 2 && flag2 == 1) {
519 double copy = lambda[0];
520 lambda[0] = lambda[2];
521 lambda[2] = lambda[1];
523 std::vector<double> dcopy = dlambda[0];
524 dlambda[0] = dlambda[2];
525 dlambda[2] = dlambda[1];
528 double subsBA = lambda[1] - lambda[0];
529 double subsAC = lambda[0] - lambda[2];
530 std::vector<double> dsubsBA(2);
531 std::vector<double> dsubsAC(2);
532 for(
int i = 0; i < 2; i++) {
533 dsubsBA[i] = dlambda[1][i] - dlambda[0][i];
534 dsubsAC[i] = dlambda[0][i] - dlambda[2][i];
536 std::vector<double> phiSubsAC(
_pf - 2);
537 std::vector<double> dphiSubsAC(
_pf - 2);
538 for(
int it = 0; it <
_pf - 2; it++) {
542 for(
int n1 = 0; n1 <
_pf - 2; n1++) {
545 for(
int n2 = 0; n2 <
_pf - 2 - n1; n2++) {
546 for(
int i = 0; i < 2; i++) {
547 gradientFace[iterator][i] =
548 dProduct[i] * phiBA * phiSubsAC[n2] +
549 product * dphiBA * dsubsBA[i] * phiSubsAC[n2] +
550 product * phiBA * dsubsAC[i] * dphiSubsAC[n2];
558 int const &flag1,
int const &flag2,
int const &flag3,
int const &faceNumber,
559 const std::vector<double> &quadFaceFunctionsAllOrientation,
560 const std::vector<double> &triFaceFunctionsAllOrientation,
561 std::vector<double> &fTableCopy)
566 fTableCopy[i] = triFaceFunctionsAllOrientation[i + offset];
570 int const &flag1,
int const &flag2,
int const &flag3,
int const &faceNumber,
571 const std::vector<std::vector<double> > &quadFaceFunctionsAllOrientation,
572 const std::vector<std::vector<double> > &triFaceFunctionsAllOrientation,
573 std::vector<std::vector<double> > &fTableCopy)
578 fTableCopy[i][0] = triFaceFunctionsAllOrientation[i + offset][0];
579 fTableCopy[i][1] = triFaceFunctionsAllOrientation[i + offset][1];
580 fTableCopy[i][2] = triFaceFunctionsAllOrientation[i + offset][2];
585 std::vector<int> &orderInfo)
587 functionTypeInfo[0] = 0;
588 functionTypeInfo[1] = 0;
589 functionTypeInfo[2] = 0;
594 for(
int numEdge = 0; numEdge < 3; numEdge++) {
596 functionTypeInfo[it] = 1;
601 for(
int n1 = 1; n1 <
_pf - 1; n1++) {
602 for(
int n2 = 1; n2 <=
_pf - 1 - n1; n2++) {
603 functionTypeInfo[it] = 2;
604 orderInfo[it] = n1 + n2 + 1;