26 for(
int i = 0; i < 4; i++) {
_pOrderFace[i] = order; }
27 for(
int i = 0; i < 6; i++) {
_pOrderEdge[i] = order; }
43 case(1):
return 0.5 * (1 + v);
44 case(2):
return -0.5 * (1 + u + v + w);
45 case(3):
return 0.5 * (1 + u);
46 case(4):
return 0.5 * (1 + w);
47 default:
throw std::runtime_error(
"j must be : 1<=j<=4");
53 std::vector<double> &vertexBasis,
54 std::vector<double> &edgeBasis,
55 std::vector<double> &faceBasis,
56 std::vector<double> &bubbleBasis)
60 double uc = 2 * u - 1;
61 double vc = 2 * v - 1;
62 double wc = 2 * w - 1;
68 double prod = lambda1 * lambda2 * lambda3 * lambda4;
70 vertexBasis[0] = lambda2;
71 vertexBasis[1] = lambda3;
72 vertexBasis[2] = lambda1;
73 vertexBasis[3] = lambda4;
75 std::vector<double> substraction(
_nedge);
76 substraction[0] = lambda3 - lambda2;
77 substraction[1] = lambda1 - lambda3;
78 substraction[2] = lambda1 - lambda2;
79 substraction[3] = lambda4 - lambda2;
80 substraction[4] = lambda4 - lambda1;
81 substraction[5] = lambda4 - lambda3;
82 std::vector<std::vector<double> > phi(
_nedge);
83 phi[0] = std::vector<double>(
89 phi[2] = std::vector<double>(
93 phi[3] = std::vector<double>(
100 for(
int i = 0; i <
_nedge; i++) {
101 for(
unsigned int j = 0; j < phi[i].size(); j++) {
105 std::vector<double> edgeProduct(
_nedge);
106 edgeProduct[0] = lambda3 * lambda2;
107 edgeProduct[1] = lambda1 * lambda3;
108 edgeProduct[2] = lambda2 * lambda1;
109 edgeProduct[3] = lambda4 * lambda2;
110 edgeProduct[4] = lambda4 * lambda1;
111 edgeProduct[5] = lambda4 * lambda3;
112 std::vector<double> faceProduct(
_nfaceTri);
113 faceProduct[0] = edgeProduct[0] * lambda1;
114 faceProduct[1] = edgeProduct[0] * lambda4;
115 faceProduct[2] = edgeProduct[2] * lambda4;
116 faceProduct[3] = edgeProduct[1] * lambda4;
118 int indexEdgeBasis = 0;
119 for(
int iEdge = 0; iEdge <
_nedge; iEdge++) {
120 for(
int indexEdgeFunc = 0; indexEdgeFunc <
_pOrderEdge[iEdge] - 1;
122 if(iEdge == 2 && indexEdgeFunc % 2 != 0) {
123 edgeBasis[indexEdgeBasis] =
124 (-1) * edgeProduct[iEdge] * phi[iEdge][indexEdgeFunc];
127 edgeBasis[indexEdgeBasis] =
128 edgeProduct[iEdge] * phi[iEdge][indexEdgeFunc];
135 int indexFaceFunction = 0;
136 for(
int iFace = 0; iFace <
_nfaceTri; iFace++) {
137 int indexVectorTarget1 = 0;
138 int indexVectorTarget2 = 0;
141 indexVectorTarget1 = 0;
142 indexVectorTarget2 = 2;
145 indexVectorTarget1 = 0;
146 indexVectorTarget2 = 3;
149 indexVectorTarget1 = 2;
150 indexVectorTarget2 = 3;
153 indexVectorTarget1 = 1;
154 indexVectorTarget2 = 5;
157 for(
int n1 = 0; n1 <
_pOrderFace[iFace] - 2; n1++) {
158 for(
int n2 = 0; n2 <
_pOrderFace[iFace] - 2 - n1; n2++) {
160 if(n2 % 2 != 0) { impact = -1; }
161 faceBasis[indexFaceFunction] = impact * faceProduct[iFace] *
162 phi[indexVectorTarget1][n1] *
163 phi[indexVectorTarget2][n2];
170 int indexBubbleBasis = 0;
171 for(
int n1 = 0; n1 <
_pb - 3; n1++) {
172 for(
int n2 = 0; n2 <
_pb - 3 - n1; n2++) {
173 for(
int n3 = 0; n3 <
_pb - 3 - n2 - n1; n3++) {
174 bubbleBasis[indexBubbleBasis] =
175 phi[2][n1] * phi[0][n2] * phi[3][n3] * prod;
183 int const &flagOrientation,
int const &edgeNumber,
184 std::vector<double> &edgeFunctions,
185 const std::vector<double> &eTablePositiveFlag,
186 const std::vector<double> &eTableNegativeFlag)
188 if(flagOrientation == -1) {
191 for(
int i = 0; i <= edgeNumber; i++) { constant2 +=
_pOrderEdge[i] - 1; }
192 constant2 = constant2 - 1;
193 constant1 = constant2 -
_pOrderEdge[edgeNumber] + 2;
194 for(
int k = constant1; k <= constant2; k++) {
195 edgeFunctions[k] = eTableNegativeFlag[k];
201 for(
int i = 0; i <= edgeNumber; i++) { constant2 +=
_pOrderEdge[i] - 1; }
202 constant2 = constant2 - 1;
203 constant1 = constant2 -
_pOrderEdge[edgeNumber] + 2;
204 for(
int k = constant1; k <= constant2; k++) {
205 edgeFunctions[k] = eTablePositiveFlag[k];
210 int const &flagOrientation,
int const &edgeNumber,
211 std::vector<std::vector<double> > &edgeFunctions,
212 const std::vector<std::vector<double> > &eTablePositiveFlag,
213 const std::vector<std::vector<double> > &eTableNegativeFlag)
215 if(flagOrientation == -1) {
218 for(
int i = 0; i <= edgeNumber; i++) { constant2 +=
_pOrderEdge[i] - 1; }
219 constant2 = constant2 - 1;
220 constant1 = constant2 -
_pOrderEdge[edgeNumber] + 2;
221 for(
int k = constant1; k <= constant2; k++) {
222 edgeFunctions[k][0] = eTableNegativeFlag[k][0];
223 edgeFunctions[k][1] = eTableNegativeFlag[k][1];
224 edgeFunctions[k][2] = eTableNegativeFlag[k][2];
230 for(
int i = 0; i <= edgeNumber; i++) { constant2 +=
_pOrderEdge[i] - 1; }
231 constant2 = constant2 - 1;
232 constant1 = constant2 -
_pOrderEdge[edgeNumber] + 2;
233 for(
int k = constant1; k <= constant2; k++) {
234 edgeFunctions[k][0] = eTablePositiveFlag[k][0];
235 edgeFunctions[k][1] = eTablePositiveFlag[k][1];
236 edgeFunctions[k][2] = eTablePositiveFlag[k][2];
242 std::vector<double> &edgeFunctions)
246 for(
int edgeNumber = 0; edgeNumber <
_nedge; edgeNumber++) {
249 for(
int i = 0; i <= edgeNumber; i++) { constant2 +=
_pOrderEdge[i] - 1; }
250 constant2 = constant2 - 1;
251 constant1 = constant2 -
_pOrderEdge[edgeNumber] + 2;
252 for(
int k = constant1; k <= constant2; k++) {
253 if((k - constant1) % 2 != 0) {
254 edgeFunctions[k] = edgeFunctions[k] * (-1);
261 std::vector<std::vector<double> > &edgeFunctions)
265 for(
int edgeNumber = 0; edgeNumber <
_nedge; edgeNumber++) {
268 for(
int i = 0; i <= edgeNumber; i++) { constant2 +=
_pOrderEdge[i] - 1; }
269 constant2 = constant2 - 1;
270 constant1 = constant2 -
_pOrderEdge[edgeNumber] + 2;
271 for(
int k = constant1; k <= constant2; k++) {
272 if((k - constant1) % 2 != 0) {
273 edgeFunctions[k][0] = edgeFunctions[k][0] * (-1);
274 edgeFunctions[k][1] = edgeFunctions[k][1] * (-1);
275 edgeFunctions[k][2] = edgeFunctions[k][2] * (-1);
281 double const &w,
int const &flag1,
282 int const &flag2,
int const &flag3,
283 int const &faceNumber,
284 std::vector<double> &faceBasis)
286 if(!(flag1 == 0 && flag2 == 1)) {
288 double uc = 2 * u - 1;
289 double vc = 2 * v - 1;
290 double wc = 2 * w - 1;
293 for(
int i = 0; i < faceNumber; i++) {
296 std::vector<double> lambda(3);
319 double product = lambda[0] * lambda[1] * lambda[2];
320 if(flag1 == 1 && flag2 == -1) {
321 double copy = lambda[0];
322 lambda[0] = lambda[1];
325 else if(flag1 == 0 && flag2 == -1) {
326 double copy = lambda[2];
327 lambda[2] = lambda[1];
330 else if(flag1 == 2 && flag2 == -1) {
331 double copy = lambda[2];
332 lambda[2] = lambda[0];
335 else if(flag1 == 1 && flag2 == 1) {
336 double copy = lambda[0];
337 lambda[0] = lambda[1];
338 lambda[1] = lambda[2];
341 else if(flag1 == 2 && flag2 == 1) {
342 double copy = lambda[0];
343 lambda[0] = lambda[2];
344 lambda[2] = lambda[1];
347 double subs1 = lambda[1] - lambda[0];
348 double subs2 = lambda[0] - lambda[2];
349 std::vector<double> phiSubs2(
_pOrderFace[faceNumber] - 2);
350 for(
int it = 0; it <
_pOrderFace[faceNumber] - 2; it++) {
353 for(
int n1 = 0; n1 <
_pOrderFace[faceNumber] - 2; n1++) {
355 for(
int n2 = 0; n2 <
_pOrderFace[faceNumber] - 2 - n1; n2++) {
356 faceBasis[iterator] = product * phiSubs1 * phiSubs2[n2];
363 double const &u,
double const &v,
double const &w,
int const &flag1,
364 int const &flag2,
int const &flag3,
int const &faceNumber,
365 std::vector<std::vector<double> > &gradientFace, std::string typeFunction)
367 if(!(flag1 == 0 && flag2 == 1)) {
369 double uc = 2 * u - 1;
370 double vc = 2 * v - 1;
371 double wc = 2 * w - 1;
374 for(
int i = 0; i < faceNumber; i++) {
377 std::vector<double> lambda(3);
378 std::vector<std::vector<double> > dlambda(3, std::vector<double>(3, 0));
379 std::vector<double> dProduct(3);
390 double pl3l1 = lambda[1] * lambda[2];
391 dProduct[0] = lambda[2] * lambda[0] - pl3l1;
392 dProduct[1] = lambda[0] * lambda[1] - pl3l1;
393 dProduct[2] = -pl3l1;
405 double pl3l4 = lambda[1] * lambda[2];
406 dProduct[0] = lambda[2] * lambda[0] - pl3l4;
407 dProduct[1] = -pl3l4;
408 dProduct[2] = lambda[0] * lambda[1] - pl3l4;
420 double pl1l4 = lambda[1] * lambda[2];
421 dProduct[0] = -pl1l4;
422 dProduct[1] = lambda[0] * lambda[2] - pl1l4;
423 dProduct[2] = lambda[0] * lambda[1] - pl1l4;
433 dProduct[0] = lambda[1] * lambda[2];
434 dProduct[1] = lambda[0] * lambda[2];
435 dProduct[2] = lambda[0] * lambda[1];
439 double product = lambda[0] * lambda[1] * lambda[2];
440 if(flag1 == 1 && flag2 == -1) {
441 double copy = lambda[0];
442 lambda[0] = lambda[1];
444 std::vector<double> dcopy = dlambda[0];
445 dlambda[0] = dlambda[1];
448 else if(flag1 == 0 && flag2 == -1) {
449 double copy = lambda[2];
450 lambda[2] = lambda[1];
452 std::vector<double> dcopy = dlambda[2];
453 dlambda[2] = dlambda[1];
456 else if(flag1 == 2 && flag2 == -1) {
457 double copy = lambda[2];
458 lambda[2] = lambda[0];
460 std::vector<double> dcopy = dlambda[2];
461 dlambda[2] = dlambda[0];
464 else if(flag1 == 1 && flag2 == 1) {
465 double copy = lambda[0];
466 lambda[0] = lambda[1];
467 lambda[1] = lambda[2];
469 std::vector<double> dcopy = dlambda[0];
470 dlambda[0] = dlambda[1];
471 dlambda[1] = dlambda[2];
474 else if(flag1 == 2 && flag2 == 1) {
475 double copy = lambda[0];
476 lambda[0] = lambda[2];
477 lambda[2] = lambda[1];
479 std::vector<double> dcopy = dlambda[0];
480 dlambda[0] = dlambda[2];
481 dlambda[2] = dlambda[1];
484 double subsBA = lambda[1] - lambda[0];
485 double subsAC = lambda[0] - lambda[2];
486 std::vector<double> dsubsBA(3);
487 std::vector<double> dsubsAC(3);
488 for(
int i = 0; i < 3; i++) {
489 dsubsBA[i] = dlambda[1][i] - dlambda[0][i];
490 dsubsAC[i] = dlambda[0][i] - dlambda[2][i];
492 std::vector<double> phiSubsAC(
_pOrderFace[faceNumber] - 2);
493 std::vector<double> dphiSubsAC(
_pOrderFace[faceNumber] - 2);
494 for(
int it = 0; it <
_pOrderFace[faceNumber] - 2; it++) {
498 for(
int n1 = 0; n1 <
_pOrderFace[faceNumber] - 2; n1++) {
501 for(
int n2 = 0; n2 <
_pOrderFace[faceNumber] - 2 - n1; n2++) {
502 for(
int i = 0; i < 3; i++) {
503 gradientFace[iterator][i] =
504 dProduct[i] * phiBA * phiSubsAC[n2] +
505 product * dphiBA * dsubsBA[i] * phiSubsAC[n2] +
506 product * phiBA * dsubsAC[i] * dphiSubsAC[n2];
514 double const &u,
double const &v,
double const &w,
515 std::vector<std::vector<double> > &gradientVertex,
516 std::vector<std::vector<double> > &gradientEdge,
517 std::vector<std::vector<double> > &gradientFace,
518 std::vector<std::vector<double> > &gradientBubble)
522 double uc = 2 * u - 1;
523 double vc = 2 * v - 1;
524 double wc = 2 * w - 1;
531 double prod = lambda1 * lambda2 * lambda3 * lambda4;
533 std::vector<double> dlambda1(3, 0);
534 std::vector<double> dlambda2(3, -0.5);
535 std::vector<double> dlambda3(3, 0);
536 std::vector<double> dlambda4(3, 0);
540 std::vector<double> dprod(3);
541 dprod[0] = jacob * (lambda1 * dlambda2[0] * lambda3 * lambda4 +
542 lambda1 * lambda2 * dlambda3[0] * lambda4);
543 dprod[1] = jacob * (dlambda1[1] * lambda2 * lambda3 * lambda4 +
544 lambda1 * dlambda2[1] * lambda3 * lambda4);
545 dprod[2] = jacob * (lambda1 * dlambda2[2] * lambda3 * lambda4 +
546 lambda1 * lambda2 * lambda3 * dlambda4[2]);
549 gradientVertex[0][0] = -1;
550 gradientVertex[0][1] = -1;
551 gradientVertex[0][2] = -1;
552 gradientVertex[1][0] = 1;
553 gradientVertex[1][1] = 0;
554 gradientVertex[1][2] = 0;
555 gradientVertex[2][0] = 0;
556 gradientVertex[2][1] = 1;
557 gradientVertex[2][2] = 0;
558 gradientVertex[3][0] = 0;
559 gradientVertex[3][1] = 0;
560 gradientVertex[3][2] = 1;
562 std::vector<double> substraction(
_nedge);
563 substraction[0] = lambda3 - lambda2;
564 substraction[1] = lambda1 - lambda3;
565 substraction[2] = lambda1 - lambda2;
566 substraction[3] = lambda4 - lambda2;
567 substraction[4] = lambda4 - lambda1;
568 substraction[5] = lambda4 - lambda3;
569 std::vector<std::vector<double> > dsubstraction(
570 _nedge, std::vector<double>(3, 1));
571 dsubstraction[0][0] = 2;
572 dsubstraction[1][0] = -1;
573 dsubstraction[1][2] = 0;
574 dsubstraction[2][1] = 2.;
575 dsubstraction[3][2] = 2.;
576 dsubstraction[4][0] = 0;
577 dsubstraction[4][1] = -1;
578 dsubstraction[5][0] = -1;
579 dsubstraction[5][1] = 0;
580 std::vector<std::vector<double> > phi(
_nedge);
581 std::vector<std::vector<double> > dphi(
_nedge);
582 for(
int i = 0; i <
_nedge; i++) {
611 phi[i] = std::vector<double>(vectorSize);
612 dphi[i] = std::vector<double>(vectorSize);
613 for(
unsigned int j = 0; j < phi[i].size(); j++) {
618 std::vector<double> edgeProduct(
_nedge);
619 edgeProduct[0] = lambda3 * lambda2;
620 edgeProduct[1] = lambda1 * lambda3;
621 edgeProduct[2] = lambda2 * lambda1;
622 edgeProduct[3] = lambda4 * lambda2;
623 edgeProduct[4] = lambda4 * lambda1;
624 edgeProduct[5] = lambda4 * lambda3;
625 std::vector<std::vector<double> > dEdgeProduct(
_nedge,
626 std::vector<double>(3));
627 for(
int i = 0; i < 3; i++) {
629 jacob * (dlambda3[i] * lambda2 + lambda3 * dlambda2[i]);
631 jacob * (dlambda1[i] * lambda3 + lambda1 * dlambda3[i]);
633 jacob * (dlambda2[i] * lambda1 + lambda2 * dlambda1[i]);
635 jacob * (dlambda4[i] * lambda2 + lambda4 * dlambda2[i]);
637 jacob * (dlambda4[i] * lambda1 + lambda4 * dlambda1[i]);
639 jacob * (dlambda4[i] * lambda3 + lambda4 * dlambda3[i]);
641 std::vector<double> faceProduct(
_nfaceTri);
642 faceProduct[0] = edgeProduct[0] * lambda1;
643 faceProduct[1] = edgeProduct[0] * lambda4;
644 faceProduct[2] = edgeProduct[2] * lambda4;
645 faceProduct[3] = edgeProduct[1] * lambda4;
646 std::vector<std::vector<double> > dfaceProduct(
_nfaceTri,
647 std::vector<double>(3));
648 for(
int i = 0; i < 3; i++) {
650 jacob * (edgeProduct[0] * dlambda1[i]) + dEdgeProduct[0][i] * lambda1;
652 jacob * (edgeProduct[0] * dlambda4[i]) + dEdgeProduct[0][i] * lambda4;
654 jacob * (edgeProduct[2] * dlambda4[i]) + dEdgeProduct[2][i] * lambda4;
656 jacob * (edgeProduct[1] * dlambda4[i]) + dEdgeProduct[1][i] * lambda4;
659 int indexEdgeBasis = 0;
660 for(
int iEdge = 0; iEdge <
_nedge; iEdge++) {
661 for(
int indexEdgeFunc = 0; indexEdgeFunc <
_pOrderEdge[iEdge] - 1;
666 if(indexEdgeFunc % 2 != 0) { impact1 = -1; }
668 for(
int i = 0; i < 3; i++) {
669 gradientEdge[indexEdgeBasis][i] =
670 impact1 * (dEdgeProduct[iEdge][i] * phi[iEdge][indexEdgeFunc] +
671 edgeProduct[iEdge] * dphi[iEdge][indexEdgeFunc] *
672 dsubstraction[iEdge][i]);
678 int indexFaceFunction = 0;
679 for(
int iFace = 0; iFace <
_nfaceTri; iFace++) {
680 int indexVectorTarget1 = 0;
681 int indexVectorTarget2 = 0;
684 indexVectorTarget1 = 0;
685 indexVectorTarget2 = 2;
688 indexVectorTarget1 = 0;
689 indexVectorTarget2 = 3;
692 indexVectorTarget1 = 2;
693 indexVectorTarget2 = 3;
696 indexVectorTarget1 = 1;
697 indexVectorTarget2 = 5;
700 for(
int n1 = 0; n1 <
_pOrderFace[iFace] - 2; n1++) {
701 for(
int n2 = 0; n2 <
_pOrderFace[iFace] - 2 - n1; n2++) {
703 if(n2 % 2 != 0) { impact = -1; }
704 for(
int i = 0; i < 3; i++) {
705 gradientFace[indexFaceFunction][i] =
706 impact * (dfaceProduct[iFace][i] * phi[indexVectorTarget1][n1] *
707 phi[indexVectorTarget2][n2] +
708 faceProduct[iFace] * dphi[indexVectorTarget1][n1] *
709 dsubstraction[indexVectorTarget1][i] *
710 phi[indexVectorTarget2][n2] +
711 faceProduct[iFace] * phi[indexVectorTarget1][n1] *
712 dsubstraction[indexVectorTarget2][i] *
713 dphi[indexVectorTarget2][n2]);
720 int indexBubbleBasis = 0;
721 for(
int n1 = 0; n1 <
_pb - 3; n1++) {
722 for(
int n2 = 0; n2 <
_pb - 3 - n1; n2++) {
723 for(
int n3 = 0; n3 <
_pb - 3 - n2 - n1; n3++) {
724 for(
int i = 0; i < 3; i++) {
725 gradientBubble[indexBubbleBasis][i] =
726 phi[2][n1] * phi[0][n2] * phi[3][n3] * dprod[i] +
727 dsubstraction[2][i] * dphi[2][n1] * phi[0][n2] * phi[3][n3] * prod +
728 dsubstraction[0][i] * phi[2][n1] * dphi[0][n2] * phi[3][n3] * prod +
729 dsubstraction[3][i] * phi[2][n1] * phi[0][n2] * dphi[3][n3] * prod;
737 int const &flag1,
int const &flag2,
int const &flag3,
int const &faceNumber,
738 const std::vector<double> &quadFaceFunctionsAllOrientation,
739 const std::vector<double> &triFaceFunctionsAllOrientation,
740 std::vector<double> &fTableCopy)
743 for(
int i = 0; i < faceNumber; i++) {
746 int numFaceFunctions =
750 int offset2 = iterator + numFaceFunctions;
751 for(
int i = iterator; i < offset2; i++) {
752 fTableCopy[i] = triFaceFunctionsAllOrientation[i + offset];
756 int const &flag1,
int const &flag2,
int const &flag3,
int const &faceNumber,
757 const std::vector<std::vector<double> > &quadFaceFunctionsAllOrientation,
758 const std::vector<std::vector<double> > &triFaceFunctionsAllOrientation,
759 std::vector<std::vector<double> > &fTableCopy)
762 for(
int i = 0; i < faceNumber; i++) {
765 int numFaceFunctions =
769 int offset2 = iterator + numFaceFunctions;
770 for(
int i = iterator; i < offset2; i++) {
771 fTableCopy[i][0] = triFaceFunctionsAllOrientation[i + offset][0];
772 fTableCopy[i][1] = triFaceFunctionsAllOrientation[i + offset][1];
773 fTableCopy[i][2] = triFaceFunctionsAllOrientation[i + offset][2];
778 std::vector<int> &orderInfo)
780 functionTypeInfo[0] = 0;
781 functionTypeInfo[1] = 0;
782 functionTypeInfo[2] = 0;
783 functionTypeInfo[3] = 0;
789 for(
int numEdge = 0; numEdge < 6; numEdge++) {
791 functionTypeInfo[it] = 1;
796 for(
int numFace = 0; numFace < 4; numFace++) {
797 for(
int n1 = 1; n1 <
_pOrderFace[numFace] - 1; n1++) {
798 for(
int n2 = 1; n2 <=
_pOrderFace[numFace] - 1 - n1; n2++) {
799 functionTypeInfo[it] = 2;
800 orderInfo[it] = n1 + n2 + 1;
805 for(
int n1 = 1; n1 <
_pb - 2; n1++) {
806 for(
int n2 = 1; n2 <=
_pb - 2 - n1; n2++) {
807 for(
int n3 = 1; n3 <=
_pb - 1 - n2 - n1; n3++) {
808 functionTypeInfo[it] = 3;
809 orderInfo[it] = n1 + n2 + n3 + 1;