30 2 * (order - 2) * (order - 1);
33 for(
int i = 0; i < 4; i++) {
_pOrderFace[i] = order; }
34 for(
int i = 0; i < 6; i++) {
_pOrderEdge[i] = order; }
50 case(1):
return 0.5 * (1 + v);
51 case(2):
return -0.5 * (1 + u + v + w);
52 case(3):
return 0.5 * (1 + u);
53 case(4):
return 0.5 * (1 + w);
54 default:
throw std::runtime_error(
"j must be : 1<=j<=4");
59 const std::vector<double> &v)
61 return u[0] * v[0] + u[1] * v[1] + u[2] * v[2];
65 double const &u,
double const &v,
double const &w,
66 std::vector<std::vector<double> > &edgeBasis,
67 std::vector<std::vector<double> > &faceBasis,
68 std::vector<std::vector<double> > &bubbleBasis)
72 double uc = 2 * u - 1;
73 double vc = 2 * v - 1;
74 double wc = 2 * w - 1;
82 std::vector<double> n1 = std::vector<double>(3, 0);
84 std::vector<double> n2 = std::vector<double>(3, 0);
85 n2[0] = -1. / sqrt(3);
86 n2[1] = -1. / sqrt(3);
87 n2[2] = -1. / sqrt(3);
88 std::vector<double> n3 = std::vector<double>(3, 0);
90 std::vector<double> n4 = std::vector<double>(3, 0);
92 std::vector<double> t1 = std::vector<double>(3, 0);
94 std::vector<double> t2 = std::vector<double>(3, 0);
97 std::vector<double> t3 = std::vector<double>(3, 0);
99 std::vector<double> t4 = std::vector<double>(3, 0);
101 std::vector<double> t5 = std::vector<double>(3, 0);
104 std::vector<double> t6 = std::vector<double>(3, 0);
108 std::vector<std::vector<double> > psie_0(6, std::vector<double>(3, 0));
109 std::vector<std::vector<double> > psie_1(6, std::vector<double>(3, 0));
110 for(
int i = 0; i < 3; i++) {
111 psie_0[0][i] = lambda3 * n2[i] /
dotProduct(n2, t1) +
113 psie_0[1][i] = lambda1 * n3[i] /
dotProduct(n3, t2) +
115 psie_0[2][i] = lambda2 * n1[i] /
dotProduct(n1, t3) +
117 psie_0[3][i] = lambda4 * n2[i] /
dotProduct(n2, t4) +
119 psie_0[4][i] = lambda4 * n1[i] /
dotProduct(n1, t6) +
121 psie_0[5][i] = lambda4 * n3[i] /
dotProduct(n3, t5) +
124 psie_1[0][i] = lambda3 * n2[i] /
dotProduct(n2, t1) -
126 psie_1[1][i] = lambda1 * n3[i] /
dotProduct(n3, t2) -
128 psie_1[2][i] = lambda2 * n1[i] /
dotProduct(n1, t3) -
130 psie_1[3][i] = lambda4 * n2[i] /
dotProduct(n2, t4) -
132 psie_1[4][i] = lambda4 * n1[i] /
dotProduct(n1, t6) -
134 psie_1[5][i] = lambda4 * n3[i] /
dotProduct(n3, t5) -
138 std::vector<double> sub(9, 0);
139 sub[0] = lambda3 - lambda2;
140 sub[1] = lambda1 - lambda3;
141 sub[2] = lambda2 - lambda1;
142 sub[3] = lambda4 - lambda2;
143 sub[4] = lambda4 - lambda1;
144 sub[5] = lambda4 - lambda3;
145 sub[6] = lambda2 - lambda4;
146 sub[7] = -lambda2 + lambda1;
147 sub[8] = lambda3 - lambda4;
148 std::vector<std::vector<double> > legendreVector(9);
149 legendreVector[0] = std::vector<double>(std::max(
152 legendreVector[1] = std::vector<double>(std::max(
155 legendreVector[2] = std::vector<double>(std::max(
158 legendreVector[3] = std::vector<double>(
_pOrderEdge[3], 0);
159 legendreVector[4] = std::vector<double>(std::max(
162 legendreVector[5] = std::vector<double>(
164 legendreVector[6] = std::vector<double>(
166 legendreVector[7] = std::vector<double>(std::max(
_pOrderFace[2] - 1, 0));
167 legendreVector[8] = std::vector<double>(std::max(
_pOrderFace[3] - 1, 0));
168 for(
int i = 0; i < 9; i++) {
169 for(
unsigned int j = 0; j < legendreVector[i].size(); j++) {
175 for(
int i = 0; i <
_nedge; i++) {
176 for(
int j = 0; j < 3; j++) { edgeBasis[edgeIt][j] = jacob * psie_0[i][j]; }
179 for(
int j = 0; j < 3; j++) {
180 edgeBasis[edgeIt][j] = jacob * psie_1[i][j];
183 for(
int iedge = 2; iedge <=
_pOrderEdge[i]; iedge++) {
184 for(
int j = 0; j < 3; j++) {
185 edgeBasis[edgeIt][j] =
186 jacob * ((2 * float(iedge) - 1) /
float(iedge) *
187 legendreVector[i][iedge - 1] * psie_1[i][j] -
188 (float(iedge) - 1) /
float(iedge) *
189 legendreVector[i][iedge - 2] * psie_0[i][j]);
200 for(
int nFace = 0; nFace <
_nfaceTri; nFace++) {
201 int indexVector1 = 0;
202 int indexVector2 = 0;
203 std::vector<double> vecTangent1(3, 0);
204 std::vector<double> vecTangent2(3, 0);
205 std::vector<double> niT(3, 0);
206 double faceProduct = 0;
209 for(
int i = 0; i < 3; i++) {
211 std::vector<double> nD(3, 0);
215 product = lambda3 * lambda2;
220 product = lambda1 * lambda3;
227 product = lambda1 * lambda2;
233 for(
int j = 0; j < 3; j++) {
234 faceBasis[faceIt][j] =
235 jacob * product * legendreVector[index][i1 - 2] * nD[j];
242 vecTangent1[0] = 0.5;
244 vecTangent2[1] = 0.5;
246 faceProduct = lambda1 * lambda2 * lambda3;
249 for(
int i = 0; i < 3; i++) {
251 std::vector<double> nD(3, 0);
255 product = lambda3 * lambda2;
260 product = lambda4 * lambda3;
267 product = lambda4 * lambda2;
273 for(
int j = 0; j < 3; j++) {
274 faceBasis[faceIt][j] =
275 jacob * product * legendreVector[index][i1 - 2] * nD[j];
281 vecTangent1[0] = 0.5;
283 vecTangent2[2] = 0.5;
285 faceProduct = lambda4 * lambda2 * lambda3;
288 for(
int i = 0; i < 3; i++) {
290 std::vector<double> nD(3, 0);
294 product = lambda1 * lambda2;
299 product = lambda4 * lambda1;
306 product = lambda4 * lambda2;
312 for(
int j = 0; j < 3; j++) {
313 faceBasis[faceIt][j] =
314 jacob * product * legendreVector[index][i1 - 2] * nD[j];
320 vecTangent1[1] = 0.5;
322 vecTangent2[2] = 0.5;
324 faceProduct = lambda1 * lambda4 * lambda2;
327 for(
int i = 0; i < 3; i++) {
329 std::vector<double> nD(3, 0);
333 product = lambda1 * lambda3;
338 product = lambda4 * lambda1;
343 product = lambda4 * lambda3;
349 for(
int j = 0; j < 3; j++) {
350 faceBasis[faceIt][j] =
351 jacob * product * legendreVector[index][i1 - 2] * nD[j];
357 vecTangent1[1] = 0.5;
359 vecTangent2[2] = 0.5;
363 faceProduct = lambda1 * lambda3 * lambda4;
366 std::vector<double>
copy(
369 for(
int n1 = 0; n1 <
_pOrderFace[nFace] - 2; n1++) {
370 for(
int n2 = 0; n2 <
_pOrderFace[nFace] - 2 - n1; n2++) {
371 copy[itCopy] = jacob * faceProduct * legendreVector[indexVector1][n1] *
372 legendreVector[indexVector2][n2];
373 for(
int i = 0; i < 3; i++) {
374 faceBasis[faceIt][i] =
copy[itCopy] * vecTangent1[i];
381 for(
int n1 = 0; n1 <
_pOrderFace[nFace] - 2; n1++) {
382 for(
int n2 = 0; n2 <
_pOrderFace[nFace] - 2 - n1; n2++) {
383 for(
int i = 0; i < 3; i++) {
384 faceBasis[faceIt][i] =
copy[itCopy] * vecTangent2[i];
391 for(
int n1 = 0; n1 <
_pb - 2; n1++) {
392 for(
int n2 = 0; n2 <
_pb - 2 - n1; n2++) {
393 for(
int i = 0; i < 3; i++) {
394 bubbleBasis[bubbleIt][i] = jacob * faceProduct *
395 legendreVector[indexVector1][n1] *
396 legendreVector[indexVector2][n2] * niT[i];
404 std::vector<double> copyBubbleTerm((
_pb - 3) * (
_pb - 2) * (
_pb - 1) / 6.,
406 for(
int n1 = 0; n1 <
_pb - 3; n1++) {
408 for(
int n2 = 0; n2 <
_pb - 3 - n1; n2++) {
410 for(
int n3 = 0; n3 <
_pb - 3 - n2 - n1; n3++) {
411 copyBubbleTerm[itCopy] =
412 jacob * lambda1 * lambda2 * lambda3 * lambda4 * phi1 * phi2 *
414 bubbleBasis[bubbleIt][0] = copyBubbleTerm[itCopy];
421 for(
int n1 = 0; n1 <
_pb - 3; n1++) {
422 for(
int n2 = 0; n2 <
_pb - 3 - n1; n2++) {
423 for(
int n3 = 0; n3 <
_pb - 3 - n2 - n1; n3++) {
424 bubbleBasis[bubbleIt][1] = copyBubbleTerm[itCopy];
431 for(
int n1 = 0; n1 <
_pb - 3; n1++) {
432 for(
int n2 = 0; n2 <
_pb - 3 - n1; n2++) {
433 for(
int n3 = 0; n3 <
_pb - 3 - n2 - n1; n3++) {
434 bubbleBasis[bubbleIt][2] = copyBubbleTerm[itCopy];
444 int const &flagOrientation,
int const &edgeNumber,
445 std::vector<std::vector<double> > &edgeFunctions,
446 const std::vector<std::vector<double> > &eTablePositiveFlag,
447 const std::vector<std::vector<double> > &eTableNegativeFlag)
449 if(flagOrientation == -1) {
452 for(
int i = 0; i <= edgeNumber; i++) { constant2 +=
_pOrderEdge[i] + 1; }
453 constant2 = constant2 - 1;
455 for(
int k = constant1; k <= constant2; k++) {
456 edgeFunctions[k][0] = eTableNegativeFlag[k][0];
457 edgeFunctions[k][1] = eTableNegativeFlag[k][1];
458 edgeFunctions[k][2] = eTableNegativeFlag[k][2];
464 for(
int i = 0; i <= edgeNumber; i++) { constant2 +=
_pOrderEdge[i] + 1; }
465 constant2 = constant2 - 1;
467 for(
int k = constant1; k <= constant2; k++) {
468 edgeFunctions[k][0] = eTablePositiveFlag[k][0];
469 edgeFunctions[k][1] = eTablePositiveFlag[k][1];
470 edgeFunctions[k][2] = eTablePositiveFlag[k][2];
475 std::vector<std::vector<double> > &edgeFunctions)
479 for(
int edgeNumber = 0; edgeNumber <
_nedge; edgeNumber++) {
482 for(
int i = 0; i <= edgeNumber; i++) { constant2 +=
_pOrderEdge[i] + 1; }
483 constant2 = constant2 - 1;
485 for(
int k = constant1; k <= constant2; k++) {
486 if((k - constant1) % 2 == 0) {
487 edgeFunctions[k][0] = edgeFunctions[k][0] * (-1);
488 edgeFunctions[k][1] = edgeFunctions[k][1] * (-1);
489 edgeFunctions[k][2] = edgeFunctions[k][2] * (-1);
495 double const &u,
double const &v,
double const &w,
int const &flag1,
496 int const &flag2,
int const &flag3,
int const &faceNumber,
497 std::vector<std::vector<double> > &faceFunctions, std::string typeFunction)
499 if(!(flag1 == 0 && flag2 == 1)) {
500 if(typeFunction ==
"HcurlLegendre") {
503 double uc = 2 * u - 1;
504 double vc = 2 * v - 1;
505 double wc = 2 * w - 1;
510 for(
int k = 0; k < faceNumber; k++) {
514 std::vector<double> lambda(3);
515 std::vector<std::vector<double> > dlambda(3, std::vector<double>(3, 0));
521 dlambda[0][0] = -0.5;
522 dlambda[0][1] = -0.5;
523 dlambda[0][2] = -0.5;
531 dlambda[0][0] = -0.5;
532 dlambda[0][1] = -0.5;
533 dlambda[0][2] = -0.5;
541 dlambda[0][0] = -0.5;
542 dlambda[0][1] = -0.5;
543 dlambda[0][2] = -0.5;
556 if(flag1 == 1 && flag2 == -1) {
557 double copy = lambda[0];
558 lambda[0] = lambda[1];
560 std::vector<double> dcopy = dlambda[0];
561 dlambda[0] = dlambda[1];
564 else if(flag1 == 0 && flag2 == -1) {
565 double copy = lambda[2];
566 lambda[2] = lambda[1];
568 std::vector<double> dcopy = dlambda[2];
569 dlambda[2] = dlambda[1];
572 else if(flag1 == 2 && flag2 == -1) {
573 double copy = lambda[2];
574 lambda[2] = lambda[0];
576 std::vector<double> dcopy = dlambda[2];
577 dlambda[2] = dlambda[0];
580 else if(flag1 == 1 && flag2 == 1) {
581 double copy = lambda[0];
582 lambda[0] = lambda[1];
583 lambda[1] = lambda[2];
585 std::vector<double> dcopy = dlambda[0];
586 dlambda[0] = dlambda[1];
587 dlambda[1] = dlambda[2];
590 else if(flag1 == 2 && flag2 == 1) {
591 double copy = lambda[0];
592 lambda[0] = lambda[2];
593 lambda[2] = lambda[1];
595 std::vector<double> dcopy = dlambda[0];
596 dlambda[0] = dlambda[2];
597 dlambda[2] = dlambda[1];
600 std::vector<double> sub(3);
601 sub[0] = lambda[1] - lambda[0];
602 sub[1] = lambda[2] - lambda[1];
603 sub[2] = lambda[0] - lambda[2];
604 std::vector<double> n1 = std::vector<double>(3, 0);
605 n1[0] = dlambda[2][0];
606 n1[1] = dlambda[2][1];
607 n1[2] = dlambda[2][2];
608 std::vector<double> n2 = std::vector<double>(3, 0);
609 n2[0] = dlambda[0][0];
610 n2[1] = dlambda[0][1];
611 n2[2] = dlambda[0][2];
612 std::vector<double> n3 = std::vector<double>(3, 0);
613 n3[0] = dlambda[1][0];
614 n3[1] = dlambda[1][1];
615 n3[2] = dlambda[1][2];
617 for(
int i = 0; i < 3; i++) {
619 std::vector<double> *normal(
nullptr);
622 product2 = lambda[1] * lambda[0];
626 product2 = lambda[1] * lambda[2];
630 product2 = lambda[2] * lambda[0];
634 for(
int i1 = 2; i1 <=
_pOrderFace[faceNumber]; i1++) {
635 faceFunctions[faceIt][0] =
636 jacob * product2 * (*normal)[0] *
638 faceFunctions[faceIt][1] =
639 jacob * product2 * (*normal)[1] *
641 faceFunctions[faceIt][2] =
642 jacob * product2 * (*normal)[2] *
648 double sub1 = sub[0];
649 double sub2 = sub[2];
650 std::vector<double> LSub2(
_pOrderFace[faceNumber] - 2);
651 for(
int it = 0; it <
_pOrderFace[faceNumber] - 2; it++) {
654 double product = lambda[0] * lambda[1] * lambda[2];
659 for(
int n1 = 0; n1 <
_pOrderFace[faceNumber] - 2; n1++) {
661 for(
int n2 = 0; n2 <
_pOrderFace[faceNumber] - 2 - n1; n2++) {
662 copy[it1] = jacob * product * LSub1 * LSub2[n2];
663 for(
int i = 0; i < 3; i++) {
664 faceFunctions[faceIt][i] =
copy[it1] * dlambda[1][i];
671 for(
int n1 = 0; n1 <
_pOrderFace[faceNumber] - 2; n1++) {
672 for(
int n2 = 0; n2 <
_pOrderFace[faceNumber] - 2 - n1; n2++) {
673 for(
int i = 0; i < 3; i++) {
674 faceFunctions[faceIt][i] =
copy[it1] * dlambda[2][i];
682 else if(
"CurlHcurlLegendre" == typeFunction) {
684 double uc = 2 * u - 1;
685 double vc = 2 * v - 1;
686 double wc = 2 * w - 1;
690 for(
int k = 0; k < faceNumber; k++) {
694 std::vector<double> lambda(3);
695 std::vector<std::vector<double> > dlambda(3, std::vector<double>(3, 0));
701 dlambda[0][0] = -0.5;
702 dlambda[0][1] = -0.5;
703 dlambda[0][2] = -0.5;
711 dlambda[0][0] = -0.5;
712 dlambda[0][1] = -0.5;
713 dlambda[0][2] = -0.5;
721 dlambda[0][0] = -0.5;
722 dlambda[0][1] = -0.5;
723 dlambda[0][2] = -0.5;
736 if(flag1 == 1 && flag2 == -1) {
737 double copy = lambda[0];
738 lambda[0] = lambda[1];
740 std::vector<double> dcopy = dlambda[0];
741 dlambda[0] = dlambda[1];
744 else if(flag1 == 0 && flag2 == -1) {
745 double copy = lambda[2];
746 lambda[2] = lambda[1];
748 std::vector<double> dcopy = dlambda[2];
749 dlambda[2] = dlambda[1];
752 else if(flag1 == 2 && flag2 == -1) {
753 double copy = lambda[2];
754 lambda[2] = lambda[0];
756 std::vector<double> dcopy = dlambda[2];
757 dlambda[2] = dlambda[0];
760 else if(flag1 == 1 && flag2 == 1) {
761 double copy = lambda[0];
762 lambda[0] = lambda[1];
763 lambda[1] = lambda[2];
765 std::vector<double> dcopy = dlambda[0];
766 dlambda[0] = dlambda[1];
767 dlambda[1] = dlambda[2];
770 else if(flag1 == 2 && flag2 == 1) {
771 double copy = lambda[0];
772 lambda[0] = lambda[2];
773 lambda[2] = lambda[1];
775 std::vector<double> dcopy = dlambda[0];
776 dlambda[0] = dlambda[2];
777 dlambda[2] = dlambda[1];
780 std::vector<double> sub(3);
781 sub[0] = lambda[1] - lambda[0];
782 sub[1] = lambda[2] - lambda[1];
783 sub[2] = lambda[0] - lambda[2];
784 std::vector<double> n1 = std::vector<double>(3, 0);
785 n1[0] = dlambda[2][0];
786 n1[1] = dlambda[2][1];
787 n1[2] = dlambda[2][2];
788 std::vector<double> n2 = std::vector<double>(3, 0);
789 n2[0] = dlambda[0][0];
790 n2[1] = dlambda[0][1];
791 n2[2] = dlambda[0][2];
792 std::vector<double> n3 = std::vector<double>(3, 0);
793 n3[0] = dlambda[1][0];
794 n3[1] = dlambda[1][1];
795 n3[2] = dlambda[1][2];
797 std::vector<std::vector<double> > dsub(3, std::vector<double>(3, 0));
798 for(
int p = 0; p < 3; p++) {
799 dsub[0][p] = dlambda[1][p] - dlambda[0][p];
800 dsub[1][p] = dlambda[2][p] - dlambda[1][p];
801 dsub[2][p] = dlambda[0][p] - dlambda[2][p];
804 double dlambda23U = dlambda[0][0] * lambda[1] + dlambda[1][0] * lambda[0];
805 double dlambda23V = dlambda[0][1] * lambda[1] + dlambda[1][1] * lambda[0];
806 double dlambda23W = dlambda[0][2] * lambda[1] + dlambda[1][2] * lambda[0];
807 double prod32 = lambda[0] * lambda[1];
808 for(
int i1 = 2; i1 <=
_pOrderFace[faceNumber]; i1++) {
818 faceFunctions[faceIt][0] = jacob * (n1[2] * dphiV - n1[1] * dphiW);
819 faceFunctions[faceIt][1] = jacob * (n1[0] * dphiW - n1[2] * dphiU);
820 faceFunctions[faceIt][2] = jacob * (n1[1] * dphiU - n1[0] * dphiV);
823 double dlambda13U = dlambda[2][0] * lambda[1] + dlambda[1][0] * lambda[2];
824 double dlambda13V = dlambda[2][1] * lambda[1] + dlambda[1][1] * lambda[2];
825 double dlambda13W = dlambda[2][2] * lambda[1] + dlambda[1][2] * lambda[2];
826 double prod13 = lambda[2] * lambda[1];
827 for(
int i1 = 2; i1 <=
_pOrderFace[faceNumber]; i1++) {
838 faceFunctions[faceIt][0] = jacob * (n2[2] * dphiV - n2[1] * dphiW);
839 faceFunctions[faceIt][1] = jacob * (n2[0] * dphiW - n2[2] * dphiU);
841 faceFunctions[faceIt][2] = jacob * (n2[1] * dphiU - n2[0] * dphiV);
845 double dlambda12U = dlambda[2][0] * lambda[0] + dlambda[0][0] * lambda[2];
846 double dlambda12V = dlambda[2][1] * lambda[0] + dlambda[0][1] * lambda[2];
847 double dlambda12W = dlambda[2][2] * lambda[0] + dlambda[0][2] * lambda[2];
848 double prod12 = lambda[0] * lambda[2];
849 for(
int i1 = 2; i1 <=
_pOrderFace[faceNumber]; i1++) {
860 faceFunctions[faceIt][0] = jacob * (n3[2] * dphiV - n3[1] * dphiW);
861 faceFunctions[faceIt][1] = jacob * (n3[0] * dphiW - n3[2] * dphiU);
862 faceFunctions[faceIt][2] = jacob * (n3[1] * dphiU - n3[0] * dphiV);
866 double subBA = sub[0];
867 double subAC = sub[2];
868 std::vector<double> dsubBA(3);
869 std::vector<double> dsubAC(3);
870 for(
int i = 0; i < 3; i++) {
871 dsubBA[i] = dsub[0][i];
872 dsubAC[i] = dsub[2][i];
874 std::vector<double> LSubAC(
_pOrderFace[faceNumber] - 2);
875 std::vector<double> dLSubAC(
_pOrderFace[faceNumber] - 2);
876 for(
int it = 0; it <
_pOrderFace[faceNumber] - 2; it++) {
880 std::vector<double> LSubBA(
_pOrderFace[faceNumber] - 2);
881 std::vector<double> dLSubBA(
_pOrderFace[faceNumber] - 2);
882 for(
int it = 0; it <
_pOrderFace[faceNumber] - 2; it++) {
886 std::vector<double> dProduct(3, 0);
887 for(
int i = 0; i < 3; i++) {
888 dProduct[i] = dlambda[0][i] * lambda[1] * lambda[2] +
889 dlambda[1][i] * lambda[0] * lambda[2] +
890 dlambda[2][i] * lambda[1] * lambda[0];
892 double product = lambda[0] * lambda[1] * lambda[2];
893 std::vector<std::vector<double> >
copy(
895 std::vector<double>(3, 0));
897 for(
int n1 = 0; n1 <
_pOrderFace[faceNumber] - 2; n1++) {
898 for(
int n2 = 0; n2 <
_pOrderFace[faceNumber] - 2 - n1; n2++) {
899 std::vector<double> gradFace(3, 0);
901 for(
int i = 0; i < 3; i++) {
902 gradFace[i] = dProduct[i] * LSubAC[n2] * LSubBA[n1] +
903 product * dsubBA[i] * LSubAC[n2] * dLSubBA[n1] +
904 product * dsubAC[i] * dLSubAC[n2] * LSubBA[n1];
905 copy[itCopy][i] = gradFace[i];
908 curlFunction(jacob, dlambda[1], gradFace, faceFunctions[faceIt]);
913 for(
int n1 = 0; n1 <
_pOrderFace[faceNumber] - 2; n1++) {
914 for(
int n2 = 0; n2 <
_pOrderFace[faceNumber] - 2 - n1; n2++) {
922 throw std::runtime_error(
"unknown typeFunction");
927 int const &flag1,
int const &flag2,
int const &flag3,
int const &faceNumber,
928 const std::vector<std::vector<double> > &quadFaceFunctionsAllOrientation,
929 const std::vector<std::vector<double> > &triFaceFunctionsAllOrientation,
930 std::vector<std::vector<double> > &fTableCopy)
933 for(
int i = 0; i < faceNumber; i++) {
937 int numFaceFunctions =
942 int offset2 = iterator + numFaceFunctions;
943 for(
int i = iterator; i < offset2; i++) {
944 fTableCopy[i][0] = triFaceFunctionsAllOrientation[i + offset][0];
945 fTableCopy[i][1] = triFaceFunctionsAllOrientation[i + offset][1];
946 fTableCopy[i][2] = triFaceFunctionsAllOrientation[i + offset][2];
951 const double &a,
const std::vector<double> &nD,
952 const std::vector<double> &grad, std::vector<double> &result)
954 result[0] = a * (nD[2] * grad[1] - nD[1] * grad[2]);
955 result[1] = a * (nD[0] * grad[2] - nD[2] * grad[0]);
956 result[2] = a * (nD[1] * grad[0] - nD[0] * grad[1]);
959 const double &lambda1,
const double &lambda2,
960 const std::vector<double> &dlambda1,
const std::vector<double> &dlambda2,
961 std::vector<double> &result)
963 for(
int i = 0; i < 3; i++) {
964 result[i] = lambda1 * dlambda2[i] + lambda2 * dlambda1[i];
969 double const &u,
double const &v,
double const &w,
970 std::vector<std::vector<double> > &edgeBasis,
971 std::vector<std::vector<double> > &faceBasis,
972 std::vector<std::vector<double> > &bubbleBasis)
976 double uc = 2 * u - 1;
977 double vc = 2 * v - 1;
978 double wc = 2 * w - 1;
987 std::vector<double> dlambda1(3, 0);
988 std::vector<double> dlambda2(3, -0.5);
989 std::vector<double> dlambda3(3, 0);
990 std::vector<double> dlambda4(3, 0);
994 std::vector<double> n1 = std::vector<double>(3, 0);
996 std::vector<double> n2 = std::vector<double>(3, 0);
997 n2[0] = -1. / sqrt(3);
998 n2[1] = -1. / sqrt(3);
999 n2[2] = -1. / sqrt(3);
1000 std::vector<double> n3 = std::vector<double>(3, 0);
1002 std::vector<double> n4 = std::vector<double>(3, 0);
1004 std::vector<double> t1 = std::vector<double>(3, 0);
1006 std::vector<double> t2 = std::vector<double>(3, 0);
1009 std::vector<double> t3 = std::vector<double>(3, 0);
1011 std::vector<double> t4 = std::vector<double>(3, 0);
1013 std::vector<double> t5 = std::vector<double>(3, 0);
1016 std::vector<double> t6 = std::vector<double>(3, 0);
1019 std::vector<double> sub(9, 0);
1020 sub[0] = lambda3 - lambda2;
1021 sub[1] = lambda1 - lambda3;
1022 sub[2] = lambda2 - lambda1;
1023 sub[3] = lambda4 - lambda2;
1024 sub[4] = lambda4 - lambda1;
1025 sub[5] = lambda4 - lambda3;
1026 sub[6] = lambda2 - lambda4;
1027 sub[7] = -lambda2 + lambda1;
1028 sub[8] = lambda3 - lambda4;
1030 std::vector<std::vector<double> > dsubtraction(9, std::vector<double>(3, 0));
1031 for(
int k = 0; k < 3; k++) {
1032 dsubtraction[0][k] = dlambda3[k] - dlambda2[k];
1033 dsubtraction[1][k] = dlambda1[k] - dlambda3[k];
1034 dsubtraction[2][k] = dlambda2[k] - dlambda1[k];
1035 dsubtraction[3][k] = dlambda4[k] - dlambda2[k];
1036 dsubtraction[4][k] = dlambda4[k] - dlambda1[k];
1037 dsubtraction[5][k] = dlambda4[k] - dlambda3[k];
1038 dsubtraction[6][k] = dlambda2[k] - dlambda4[k];
1039 dsubtraction[7][k] = -dlambda2[k] + dlambda1[k];
1040 dsubtraction[8][k] = dlambda3[k] - dlambda4[k];
1042 std::vector<std::vector<double> > legendreVector(9);
1043 std::vector<std::vector<double> > dlegendreVector(9);
1044 legendreVector[0] = std::vector<double>(std::max(
1047 legendreVector[1] = std::vector<double>(std::max(
1050 legendreVector[2] = std::vector<double>(std::max(
1053 legendreVector[3] = std::vector<double>(std::max(
_pOrderEdge[3], 0));
1054 legendreVector[4] = std::vector<double>(std::max(
1057 legendreVector[5] = std::vector<double>(
1059 legendreVector[6] = std::vector<double>(
1061 legendreVector[7] = std::vector<double>(std::max(
_pOrderFace[2] - 1, 0));
1062 legendreVector[8] = std::vector<double>(std::max(
_pOrderFace[3] - 1, 0));
1064 dlegendreVector[0] = std::vector<double>(std::max(
1067 dlegendreVector[1] = std::vector<double>(std::max(
1070 dlegendreVector[2] = std::vector<double>(std::max(
1073 dlegendreVector[3] = std::vector<double>(std::max(
_pOrderEdge[3], 0));
1074 dlegendreVector[4] = std::vector<double>(std::max(
1077 dlegendreVector[5] = std::vector<double>(
1079 dlegendreVector[6] = std::vector<double>(
1081 dlegendreVector[7] = std::vector<double>(std::max(
_pOrderFace[2] - 1, 0));
1082 dlegendreVector[8] = std::vector<double>(std::max(
_pOrderFace[3] - 1, 0));
1083 for(
int i = 0; i < 9; i++) {
1084 for(
unsigned int j = 0; j < legendreVector[i].size(); j++) {
1090 std::vector<std::vector<double> > dfaceProduct(
_nfaceTri,
1091 std::vector<double>(3));
1092 for(
int i = 0; i < 3; i++) {
1093 dfaceProduct[0][i] = lambda3 * lambda2 * dlambda1[i] +
1094 lambda3 * dlambda2[i] * lambda1 +
1095 dlambda3[i] * lambda2 * lambda1;
1096 dfaceProduct[1][i] = lambda3 * lambda2 * dlambda4[i] +
1097 lambda3 * dlambda2[i] * lambda4 +
1098 dlambda3[i] * lambda2 * lambda4;
1099 dfaceProduct[2][i] = lambda1 * lambda2 * dlambda4[i] +
1100 lambda1 * dlambda2[i] * lambda4 +
1101 dlambda1[i] * lambda2 * lambda4;
1102 dfaceProduct[3][i] = lambda1 * lambda3 * dlambda4[i] +
1103 lambda1 * dlambda3[i] * lambda4 +
1104 dlambda1[i] * lambda3 * lambda4;
1107 std::vector<std::vector<double> > psie_0(6, std::vector<double>(3, 0));
1108 std::vector<std::vector<double> > psie_1(6, std::vector<double>(3, 0));
1109 for(
int i = 0; i < 3; i++) {
1110 psie_0[0][i] = lambda3 * n2[i] /
dotProduct(n2, t1) +
1112 psie_0[1][i] = lambda1 * n3[i] /
dotProduct(n3, t2) +
1114 psie_0[2][i] = lambda2 * n1[i] /
dotProduct(n1, t3) +
1116 psie_0[3][i] = lambda4 * n2[i] /
dotProduct(n2, t4) +
1118 psie_0[4][i] = lambda4 * n1[i] /
dotProduct(n1, t6) +
1120 psie_0[5][i] = lambda4 * n3[i] /
dotProduct(n3, t5) +
1123 psie_1[0][i] = lambda3 * n2[i] /
dotProduct(n2, t1) -
1125 psie_1[1][i] = lambda1 * n3[i] /
dotProduct(n3, t2) -
1127 psie_1[2][i] = lambda2 * n1[i] /
dotProduct(n1, t3) -
1129 psie_1[3][i] = lambda4 * n2[i] /
dotProduct(n2, t4) -
1131 psie_1[4][i] = lambda4 * n1[i] /
dotProduct(n1, t6) -
1133 psie_1[5][i] = lambda4 * n3[i] /
dotProduct(n3, t5) -
1137 std::vector<std::vector<double> > curlpsie_0(6, std::vector<double>(3, 0));
1138 curlpsie_0[0][1] = -1;
1139 curlpsie_0[0][2] = 1;
1140 curlpsie_0[1][2] = 1;
1141 curlpsie_0[2][0] = -1;
1142 curlpsie_0[2][2] = 1;
1143 curlpsie_0[3][0] = -1;
1144 curlpsie_0[3][1] = 1;
1145 curlpsie_0[4][0] = 1;
1146 curlpsie_0[5][1] = -1;
1149 for(
int i = 0; i <
_nedge; i++) {
1150 for(
int j = 0; j < 3; j++) {
1151 edgeBasis[edgeIt][j] = det * jacob * curlpsie_0[i][j];
1155 for(
int j = 0; j < 3; j++) { edgeBasis[edgeIt][j] = 0; }
1158 for(
int iedge = 2; iedge <=
_pOrderEdge[i]; iedge++) {
1159 edgeBasis[edgeIt][0] =
1161 ((2 * float(iedge) - 1) /
float(iedge) *
1162 (dsubtraction[i][1] * dlegendreVector[i][iedge - 1] * psie_1[i][2] -
1163 dsubtraction[i][2] * dlegendreVector[i][iedge - 1] * psie_1[i][1]) -
1164 (
float(iedge) - 1) /
float(iedge) *
1165 (curlpsie_0[i][0] * legendreVector[i][iedge - 2] +
1166 dsubtraction[i][1] * dlegendreVector[i][iedge - 2] * psie_0[i][2] -
1167 dsubtraction[i][2] * dlegendreVector[i][iedge - 2] * psie_0[i][1]));
1168 edgeBasis[edgeIt][1] =
1170 ((2 * float(iedge) - 1) /
float(iedge) *
1171 (dsubtraction[i][2] * dlegendreVector[i][iedge - 1] * psie_1[i][0] -
1172 dsubtraction[i][0] * dlegendreVector[i][iedge - 1] * psie_1[i][2]) -
1173 (
float(iedge) - 1) /
float(iedge) *
1174 (curlpsie_0[i][1] * legendreVector[i][iedge - 2] +
1175 dsubtraction[i][2] * dlegendreVector[i][iedge - 2] * psie_0[i][0] -
1176 dsubtraction[i][0] * dlegendreVector[i][iedge - 2] * psie_0[i][2]));
1177 edgeBasis[edgeIt][2] =
1179 ((2 * float(iedge) - 1) /
float(iedge) *
1180 (dsubtraction[i][0] * dlegendreVector[i][iedge - 1] * psie_1[i][1] -
1181 dsubtraction[i][1] * dlegendreVector[i][iedge - 1] * psie_1[i][0]) -
1182 (
float(iedge) - 1) /
float(iedge) *
1183 (curlpsie_0[i][2] * legendreVector[i][iedge - 2] +
1184 dsubtraction[i][0] * dlegendreVector[i][iedge - 2] * psie_0[i][1] -
1185 dsubtraction[i][1] * dlegendreVector[i][iedge - 2] * psie_0[i][0]));
1193 for(
int nFace = 0; nFace <
_nfaceTri; nFace++) {
1194 int indexVector1 = 0;
1195 int indexVector2 = 0;
1196 std::vector<double> vecTangent1(3, 0);
1197 std::vector<double> vecTangent2(3, 0);
1198 std::vector<double> niT(3, 0);
1199 double faceProduct = 0;
1203 vecTangent1[0] = 0.5;
1205 vecTangent2[1] = 0.5;
1207 faceProduct = lambda1 * lambda2 * lambda3;
1208 for(
int i = 0; i < 3; i++) {
1210 std::vector<double> dproduct(3, 0);
1211 std::vector<double> nD(3, 0);
1214 product = lambda3 * lambda2;
1215 gradient(lambda3, lambda2, dlambda3, dlambda2, dproduct);
1219 product = lambda1 * lambda3;
1223 gradient(lambda3, lambda1, dlambda3, dlambda1, dproduct);
1226 product = lambda1 * lambda2;
1227 gradient(lambda1, lambda2, dlambda1, dlambda2, dproduct);
1232 std::vector<double> grad(3, 0);
1233 std::vector<double> gradLegendre(3, 0);
1234 gradLegendre[0] = dsubtraction[i][0] * dlegendreVector[i][i1 - 2];
1235 gradLegendre[1] = dsubtraction[i][1] * dlegendreVector[i][i1 - 2];
1236 gradLegendre[2] = dsubtraction[i][2] * dlegendreVector[i][i1 - 2];
1238 gradient(product, legendreVector[i][i1 - 2], dproduct, gradLegendre,
1240 curlFunction(jacob * det, nD, grad, faceBasis[faceIt]);
1248 vecTangent1[0] = 0.5;
1250 vecTangent2[2] = 0.5;
1252 faceProduct = lambda4 * lambda2 * lambda3;
1254 for(
int i = 0; i < 3; i++) {
1256 std::vector<double> dproduct(3, 0);
1257 std::vector<double> nD(3, 0);
1261 product = lambda3 * lambda2;
1262 gradient(lambda3, lambda2, dlambda3, dlambda2, dproduct);
1267 product = lambda4 * lambda3;
1271 gradient(lambda4, lambda3, dlambda4, dlambda3, dproduct);
1275 product = lambda4 * lambda2;
1276 gradient(lambda4, lambda2, dlambda4, dlambda2, dproduct);
1282 std::vector<double> grad(3, 0);
1283 std::vector<double> gradLegendre(3, 0);
1285 dsubtraction[index][0] * dlegendreVector[index][i1 - 2];
1287 dsubtraction[index][1] * dlegendreVector[index][i1 - 2];
1289 dsubtraction[index][2] * dlegendreVector[index][i1 - 2];
1290 gradient(product, legendreVector[index][i1 - 2], dproduct,
1291 gradLegendre, grad);
1292 curlFunction(jacob * det, nD, grad, faceBasis[faceIt]);
1300 vecTangent1[1] = 0.5;
1302 vecTangent2[2] = 0.5;
1304 faceProduct = lambda1 * lambda2 * lambda4;
1305 for(
int i = 0; i < 3; i++) {
1307 std::vector<double> nD(3, 0);
1308 std::vector<double> dproduct(3, 0);
1312 product = lambda1 * lambda2;
1313 gradient(lambda1, lambda2, dlambda1, dlambda2, dproduct);
1318 product = lambda4 * lambda1;
1319 gradient(lambda4, lambda1, dlambda4, dlambda1, dproduct);
1326 product = lambda4 * lambda2;
1327 gradient(lambda4, lambda2, dlambda4, dlambda2, dproduct);
1333 std::vector<double> grad(3, 0);
1334 std::vector<double> gradLegendre(3, 0);
1336 dsubtraction[index][0] * dlegendreVector[index][i1 - 2];
1338 dsubtraction[index][1] * dlegendreVector[index][i1 - 2];
1340 dsubtraction[index][2] * dlegendreVector[index][i1 - 2];
1341 gradient(product, legendreVector[index][i1 - 2], dproduct,
1342 gradLegendre, grad);
1343 curlFunction(jacob * det, nD, grad, faceBasis[faceIt]);
1350 vecTangent1[1] = 0.5;
1352 vecTangent2[2] = 0.5;
1356 faceProduct = lambda1 * lambda4 * lambda3;
1357 for(
int i = 0; i < 3; i++) {
1358 std::vector<double> dproduct(3, 0);
1360 std::vector<double> nD(3, 0);
1364 product = lambda1 * lambda3;
1365 gradient(lambda3, lambda1, dlambda3, dlambda1, dproduct);
1370 product = lambda4 * lambda1;
1371 gradient(lambda4, lambda1, dlambda4, dlambda1, dproduct);
1376 product = lambda4 * lambda3;
1377 gradient(lambda4, lambda3, dlambda4, dlambda3, dproduct);
1383 std::vector<double> grad(3, 0);
1384 std::vector<double> gradLegendre(3, 0);
1386 dsubtraction[index][0] * dlegendreVector[index][i1 - 2];
1388 dsubtraction[index][1] * dlegendreVector[index][i1 - 2];
1390 dsubtraction[index][2] * dlegendreVector[index][i1 - 2];
1391 gradient(product, legendreVector[index][i1 - 2], dproduct,
1392 gradLegendre, grad);
1393 curlFunction(jacob * det, nD, grad, faceBasis[faceIt]);
1400 std::vector<std::vector<double> >
copy(
1402 std::vector<double>(3, 0));
1404 for(
int n1 = 0; n1 <
_pOrderFace[nFace] - 2; n1++) {
1405 for(
int n2 = 0; n2 <
_pOrderFace[nFace] - 2 - n1; n2++) {
1406 std::vector<double> gradFace(3, 0);
1407 for(
int i = 0; i < 3; i++) {
1409 dfaceProduct[nFace][i] * legendreVector[indexVector1][n1] *
1410 legendreVector[indexVector2][n2] +
1411 faceProduct * dlegendreVector[indexVector1][n1] *
1412 dsubtraction[indexVector1][i] * legendreVector[indexVector2][n2] +
1413 faceProduct * legendreVector[indexVector1][n1] *
1414 dsubtraction[indexVector2][i] * dlegendreVector[indexVector2][n2];
1415 copy[itCopy][i] = gradFace[i];
1418 curlFunction(jacob * det, vecTangent1, gradFace, faceBasis[faceIt]);
1424 for(
int n1 = 0; n1 <
_pOrderFace[nFace] - 2; n1++) {
1425 for(
int n2 = 0; n2 <
_pOrderFace[nFace] - 2 - n1; n2++) {
1431 for(
int n1 = 0; n1 <
_pb - 2; n1++) {
1432 for(
int n2 = 0; n2 <
_pb - 2 - n1; n2++) {
1433 std::vector<double> gradFace(3, 0);
1434 for(
int i = 0; i < 3; i++) {
1436 dfaceProduct[nFace][i] * legendreVector[indexVector1][n1] *
1437 legendreVector[indexVector2][n2] +
1438 faceProduct * dlegendreVector[indexVector1][n1] *
1439 dsubtraction[indexVector1][i] * legendreVector[indexVector2][n2] +
1440 faceProduct * legendreVector[indexVector1][n1] *
1441 dsubtraction[indexVector2][i] * dlegendreVector[indexVector2][n2];
1443 curlFunction(jacob * det, niT, gradFace, bubbleBasis[bubbleIt]);
1449 double l1l2l3l4 = lambda1 * lambda2 * lambda3 * lambda4;
1450 std::vector<double> dl1l2l3l4(3, 0);
1451 for(
int i = 0; i < 3; i++) {
1452 dl1l2l3l4[i] = lambda1 * lambda2 * lambda3 * dlambda4[i] +
1453 lambda1 * lambda2 * dlambda3[i] * lambda4 +
1454 lambda1 * dlambda2[i] * lambda3 * lambda4 +
1455 dlambda1[i] * lambda2 * lambda3 * lambda4;
1458 for(
int n1 = 0; n1 <
_pb - 3; n1++) {
1461 for(
int n2 = 0; n2 <
_pb - 3 - n1; n2++) {
1464 for(
int n3 = 0; n3 <
_pb - 3 - n2 - n1; n3++) {
1465 bubbleBasis[bubbleIt][0] = 0;
1466 bubbleBasis[bubbleIt][1] =
1468 (dl1l2l3l4[2] * phi1 * phi2 *
1470 l1l2l3l4 * phi2 * dsubtraction[7][2] * dphi1 *
1472 l1l2l3l4 * dphi2 * dsubtraction[0][2] * phi1 *
1474 l1l2l3l4 * phi2 * dsubtraction[3][2] * phi1 *
1476 bubbleBasis[bubbleIt][2] =
1478 (dl1l2l3l4[1] * phi1 * phi2 *
1480 l1l2l3l4 * phi2 * dsubtraction[7][1] * dphi1 *
1482 l1l2l3l4 * dphi2 * dsubtraction[0][1] * phi1 *
1484 l1l2l3l4 * phi2 * dsubtraction[3][1] * phi1 *
1492 for(
int n1 = 0; n1 <
_pb - 3; n1++) {
1495 for(
int n2 = 0; n2 <
_pb - 3 - n1; n2++) {
1498 for(
int n3 = 0; n3 <
_pb - 3 - n2 - n1; n3++) {
1499 bubbleBasis[bubbleIt][0] =
1501 (dl1l2l3l4[2] * phi1 * phi2 *
1503 l1l2l3l4 * phi2 * dsubtraction[7][2] * dphi1 *
1505 l1l2l3l4 * dphi2 * dsubtraction[0][2] * phi1 *
1507 l1l2l3l4 * phi2 * dsubtraction[3][2] * phi1 *
1509 bubbleBasis[bubbleIt][1] = 0;
1510 bubbleBasis[bubbleIt][2] =
1512 (dl1l2l3l4[0] * phi1 * phi2 *
1514 l1l2l3l4 * phi2 * dsubtraction[7][0] * dphi1 *
1516 l1l2l3l4 * dphi2 * dsubtraction[0][0] * phi1 *
1518 l1l2l3l4 * phi2 * dsubtraction[3][0] * phi1 *
1526 for(
int n1 = 0; n1 <
_pb - 3; n1++) {
1529 for(
int n2 = 0; n2 <
_pb - 3 - n1; n2++) {
1532 for(
int n3 = 0; n3 <
_pb - 3 - n2 - n1; n3++) {
1533 bubbleBasis[bubbleIt][0] =
1535 (dl1l2l3l4[1] * phi1 * phi2 *
1537 l1l2l3l4 * phi2 * dsubtraction[7][1] * dphi1 *
1539 l1l2l3l4 * dphi2 * dsubtraction[0][1] * phi1 *
1541 l1l2l3l4 * phi2 * dsubtraction[3][1] * phi1 *
1543 bubbleBasis[bubbleIt][1] =
1545 (dl1l2l3l4[0] * phi1 * phi2 *
1547 l1l2l3l4 * phi2 * dsubtraction[7][0] * dphi1 *
1549 l1l2l3l4 * dphi2 * dsubtraction[0][0] * phi1 *
1551 l1l2l3l4 * phi2 * dsubtraction[3][0] * phi1 *
1553 bubbleBasis[bubbleIt][2] = 0;
1563 std::vector<int> &functionTypeInfo, std::vector<int> &orderInfo)
1566 for(
int numEdge = 0; numEdge < 6; numEdge++) {
1568 functionTypeInfo[it] = 1;
1573 for(
int numFace = 0; numFace < 4; numFace++) {
1574 for(
int i = 0; i < 3; i++) {
1575 for(
int i1 = 2; i1 <=
_pOrderFace[numFace]; i1++) {
1576 functionTypeInfo[it] = 2;
1581 for(
int n1 = 1; n1 <
_pOrderFace[numFace] - 1; n1++) {
1582 for(
int n2 = 1; n2 <=
_pOrderFace[numFace] - 1 - n1; n2++) {
1583 functionTypeInfo[it] = 2;
1584 orderInfo[it] = n1 + n2 + 1;
1588 for(
int n1 = 1; n1 <
_pOrderFace[numFace] - 1; n1++) {
1589 for(
int n2 = 1; n2 <=
_pOrderFace[numFace] - 1 - n1; n2++) {
1590 functionTypeInfo[it] = 2;
1591 orderInfo[it] = n1 + n2 + 1;
1596 for(
int numFace = 0; numFace < 4; numFace++) {
1597 for(
int n1 = 1; n1 <
_pb - 1; n1++) {
1598 for(
int n2 = 1; n2 <=
_pb - 1 - n1; n2++) {
1599 functionTypeInfo[it] = 3;
1600 orderInfo[it] = n1 + n2 + 1;
1605 for(
int i = 0; i < 3; i++) {
1606 for(
int n1 = 1; n1 <
_pb - 2; n1++) {
1607 for(
int n2 = 1; n2 <=
_pb - 2 - n1; n2++) {
1608 for(
int n3 = 1; n3 <=
_pb - 1 - n2 - n1; n3++) {
1609 functionTypeInfo[it] = 3;
1610 orderInfo[it] = n1 + n2 + n3 + 1;