45 if(order == 0)
return points;
46 points.
scale(2. / order);
54 if(order == 0)
return points;
55 points.
scale(1. / order);
62 if(order == 0)
return points;
63 points.
scale(2. / order);
71 if(order == 0)
return points;
72 points.
scale(1. / order);
79 if(order == 0)
return points;
80 points.
scale(2. / order);
88 if(order == 0)
return points;
91 tmp.
scale(1. / order);
93 tmp.
scale(2. / order);
101 if(order == 0)
return points;
102 for(
int i = 0; i < points.
size1(); ++i) {
103 points(i, 2) = 1 - points(i, 2) / order;
104 const double duv = -1. + points(i, 2);
105 points(i, 0) = duv + points(i, 0) * 2. / order;
106 points(i, 1) = duv + points(i, 1) * 2. / order;
112 bool forSerendipPoints)
123 if(points.
size1() == 1)
return points;
124 const int div = pyr ? nk + nij : std::max(nij, nk);
125 double scale = 2. / div;
126 for(
int i = 0; i < points.
size1(); ++i) {
127 points(i, 2) = (nk - points(i, 2)) / div;
128 const double duv = 1. - points(i, 2);
129 if(!pyr)
scale = 2. / nij * duv;
130 points(i, 0) = -duv + points(i, 0) *
scale;
131 points(i, 1) = -duv + points(i, 1) *
scale;
165 Msg::Error(
"Unknown element type %d for monomials generation",
176 monomials(1, 0) = order;
177 for(
int i = 2; i < order + 1; i++) monomials(i, 0) = i - 1;
184 int nbMonomials = serendip ? 3 * order : (order + 1) * (order + 2) / 2;
185 if(serendip && !order) nbMonomials = 1;
192 monomials(1, 0) = order;
196 monomials(2, 1) = order;
200 for(
int iedge = 0; iedge < 3; ++iedge) {
204 int u_0 = (monomials(i1, 0) - monomials(i0, 0)) / order;
205 int u_1 = (monomials(i1, 1) - monomials(i0, 1)) / order;
207 for(
int i = 1; i < order; ++i, ++index) {
208 monomials(index, 0) = monomials(i0, 0) + u_0 * i;
209 monomials(index, 1) = monomials(i0, 1) + u_1 * i;
212 if(!serendip && order > 2) {
215 monomials.
copy(inner, 0, nbMonomials - index, 0, 2, index, 0);
223 bool forSerendipPoints)
225 int nbMonomials = forSerendipPoints ? order * 4 : (order + 1) * (order + 1);
226 if(forSerendipPoints && !order) nbMonomials = 1;
233 monomials(1, 0) = order;
236 monomials(2, 0) = order;
237 monomials(2, 1) = order;
240 monomials(3, 1) = order;
244 for(
int iedge = 0; iedge < 4; ++iedge) {
248 int u_0 = (monomials(i1, 0) - monomials(i0, 0)) / order;
249 int u_1 = (monomials(i1, 1) - monomials(i0, 1)) / order;
251 for(
int i = 1; i < order; ++i, ++index) {
252 monomials(index, 0) = monomials(i0, 0) + u_0 * i;
253 monomials(index, 1) = monomials(i0, 1) + u_1 * i;
257 if(!forSerendipPoints) {
260 monomials.
copy(inner, 0, nbMonomials - index, 0, 2, index, 0);
278 int nbMonomials = order ? order * 4 : 1;
296 for(
int p = 2; p <= order; ++p) {
297 monomials(++index, 0) = p;
298 monomials(index, 1) = 0;
300 monomials(++index, 0) = p;
301 monomials(index, 1) = 1;
303 monomials(++index, 0) = 1;
304 monomials(index, 1) = p;
306 monomials(++index, 0) = 0;
307 monomials(index, 1) = p;
319 int nbMonomials = serendip ? 4 + (order - 1) * 6 :
320 (order + 1) * (order + 2) * (order + 3) / 6;
321 if(serendip && !order) nbMonomials = 1;
329 monomials(1, 0) = order;
334 monomials(2, 1) = order;
339 monomials(3, 2) = order;
346 for(
int iedge = 0; iedge < 6; ++iedge) {
351 u[0] = (monomials(i1, 0) - monomials(i0, 0)) / order;
352 u[1] = (monomials(i1, 1) - monomials(i0, 1)) / order;
353 u[2] = (monomials(i1, 2) - monomials(i0, 2)) / order;
355 for(
int i = 1; i < order; ++i, ++index) {
356 monomials(index, 0) = monomials(i0, 0) + u[0] * i;
357 monomials(index, 1) = monomials(i0, 1) + u[1] * i;
358 monomials(index, 2) = monomials(i0, 2) + u[2] * i;
362 if(!serendip && order > 2) {
366 for(
int iface = 0; iface < 4; ++iface) {
372 u[0] = (monomials(i1, 0) - monomials(i0, 0)) / order;
373 u[1] = (monomials(i1, 1) - monomials(i0, 1)) / order;
374 u[2] = (monomials(i1, 2) - monomials(i0, 2)) / order;
376 v[0] = (monomials(i2, 0) - monomials(i0, 0)) / order;
377 v[1] = (monomials(i2, 1) - monomials(i0, 1)) / order;
378 v[2] = (monomials(i2, 2) - monomials(i0, 2)) / order;
380 for(
int i = 0; i < dudv.
size1(); ++i, ++index) {
381 monomials(index, 0) =
382 monomials(i0, 0) + u[0] * dudv(i, 0) + v[0] * dudv(i, 1);
383 monomials(index, 1) =
384 monomials(i0, 1) + u[1] * dudv(i, 0) + v[1] * dudv(i, 1);
385 monomials(index, 2) =
386 monomials(i0, 2) + u[2] * dudv(i, 0) + v[2] * dudv(i, 1);
394 monomials.
copy(inner, 0, nbMonomials - index, 0, 3, index, 0);
404 int nbMonomials = forSerendipPoints ?
405 6 + (order - 1) * 9 :
406 (order + 1) * (order + 1) * (order + 2) / 2;
407 if(forSerendipPoints && !order) nbMonomials = 1;
415 monomials(1, 0) = order;
420 monomials(2, 1) = order;
425 monomials(3, 2) = order;
427 monomials(4, 0) = order;
429 monomials(4, 2) = order;
432 monomials(5, 1) = order;
433 monomials(5, 2) = order;
437 for(
int iedge = 0; iedge < 9; ++iedge) {
441 int u_1 = (monomials(i1, 0) - monomials(i0, 0)) / order;
442 int u_2 = (monomials(i1, 1) - monomials(i0, 1)) / order;
443 int u_3 = (monomials(i1, 2) - monomials(i0, 2)) / order;
445 for(
int i = 1; i < order; ++i, ++index) {
446 monomials(index, 0) = monomials(i0, 0) + i * u_1;
447 monomials(index, 1) = monomials(i0, 1) + i * u_2;
448 monomials(index, 2) = monomials(i0, 2) + i * u_3;
452 if(!forSerendipPoints) {
462 for(
int iface = 0; iface < 5; ++iface) {
479 u[0] = (monomials(i1, 0) - monomials(i0, 0)) / order;
480 u[1] = (monomials(i1, 1) - monomials(i0, 1)) / order;
481 u[2] = (monomials(i1, 2) - monomials(i0, 2)) / order;
483 v[0] = (monomials(i2, 0) - monomials(i0, 0)) / order;
484 v[1] = (monomials(i2, 1) - monomials(i0, 1)) / order;
485 v[2] = (monomials(i2, 2) - monomials(i0, 2)) / order;
487 for(
int i = 0; i < dudv.
size1(); ++i, ++index) {
488 monomials(index, 0) =
489 monomials(i0, 0) + u[0] * dudv(i, 0) + v[0] * dudv(i, 1);
490 monomials(index, 1) =
491 monomials(i0, 1) + u[1] * dudv(i, 0) + v[1] * dudv(i, 1);
492 monomials(index, 2) =
493 monomials(i0, 2) + u[2] * dudv(i, 0) + v[2] * dudv(i, 1);
503 for(
int i = 0; i < triMonomials.
size1(); ++i) {
504 for(
int j = 0; j < lineMonomials.
size1(); ++j, ++index) {
505 monomials(index, 0) = 1 + triMonomials(i, 0);
506 monomials(index, 1) = 1 + triMonomials(i, 1);
507 monomials(index, 2) = 1 + lineMonomials(j, 0);
519 int nbMonomials = order ? 6 + (order - 1) * 9 : 1;
548 const int ind[7][3] = {{2, 0, 0}, {2, 0, 1},
550 {0, 2, 0}, {0, 2, 1},
552 {0, 0, 2}, {1, 0, 2}, {0, 1, 2}};
553 int val[3] = {0, 1, -1};
555 for(
int p = 2; p <= order; ++p) {
557 for(
int i = 0; i < 7; ++i) {
558 monomials(++index, 0) = val[ind[i][0]];
559 monomials(index, 1) = val[ind[i][1]];
560 monomials(index, 2) = val[ind[i][2]];
565 int val1 = order - 1;
566 for(
int p = 2; p <= order; ++p) {
567 monomials(++index, 0) = val0;
568 monomials(index, 1) = val1;
569 monomials(index, 2) = 0;
571 monomials(++index, 0) = val0;
572 monomials(index, 1) = val1;
573 monomials(index, 2) = 1;
584 bool forSerendipPoints)
586 int nbMonomials = forSerendipPoints ? 8 + (order - 1) * 12 :
587 (order + 1) * (order + 1) * (order + 1);
588 if(forSerendipPoints && !order) nbMonomials = 1;
596 monomials(1, 0) = order;
600 monomials(2, 0) = order;
601 monomials(2, 1) = order;
605 monomials(3, 1) = order;
610 monomials(4, 2) = order;
612 monomials(5, 0) = order;
614 monomials(5, 2) = order;
616 monomials(6, 0) = order;
617 monomials(6, 1) = order;
618 monomials(6, 2) = order;
621 monomials(7, 1) = order;
622 monomials(7, 2) = order;
626 for(
int iedge = 0; iedge < 12; ++iedge) {
630 int u_1 = (monomials(i1, 0) - monomials(i0, 0)) / order;
631 int u_2 = (monomials(i1, 1) - monomials(i0, 1)) / order;
632 int u_3 = (monomials(i1, 2) - monomials(i0, 2)) / order;
634 for(
int i = 1; i < order; ++i, ++index) {
635 monomials(index, 0) = monomials(i0, 0) + i * u_1;
636 monomials(index, 1) = monomials(i0, 1) + i * u_2;
637 monomials(index, 2) = monomials(i0, 2) + i * u_3;
641 if(!forSerendipPoints) {
645 for(
int iface = 0; iface < 6; ++iface) {
651 u[0] = (monomials(i1, 0) - monomials(i0, 0)) / order;
652 u[1] = (monomials(i1, 1) - monomials(i0, 1)) / order;
653 u[2] = (monomials(i1, 2) - monomials(i0, 2)) / order;
655 v[0] = (monomials(i3, 0) - monomials(i0, 0)) / order;
656 v[1] = (monomials(i3, 1) - monomials(i0, 1)) / order;
657 v[2] = (monomials(i3, 2) - monomials(i0, 2)) / order;
659 for(
int i = 0; i < dudv.
size1(); ++i, ++index) {
660 monomials(index, 0) =
661 monomials(i0, 0) + u[0] * dudv(i, 0) + v[0] * dudv(i, 1);
662 monomials(index, 1) =
663 monomials(i0, 1) + u[1] * dudv(i, 0) + v[1] * dudv(i, 1);
664 monomials(index, 2) =
665 monomials(i0, 2) + u[2] * dudv(i, 0) + v[2] * dudv(i, 1);
671 monomials.
copy(inner, 0, nbMonomials - index, 0, 3, index, 0);
680 int nbMonomials = order ? 8 + (order - 1) * 12 : 1;
717 const int ind[12][3] = {{2, 0, 0}, {2, 0, 1}, {2, 1, 1}, {2, 1, 0},
719 {0, 2, 0}, {0, 2, 1}, {1, 2, 1}, {1, 2, 0},
721 {0, 0, 2}, {0, 1, 2}, {1, 1, 2}, {1, 0, 2}};
722 int val[3] = {0, 1, -1};
724 for(
int p = 2; p <= order; ++p) {
726 for(
int i = 0; i < 12; ++i) {
727 monomials(++index, 0) = val[ind[i][0]];
728 monomials(index, 1) = val[ind[i][1]];
729 monomials(index, 2) = val[ind[i][2]];
738 bool forSerendipPoints)
740 int nbMonomials = forSerendipPoints ? 5 + (order - 1) * 8 :
741 (order + 1) * ((order + 1) + 1) *
742 (2 * (order + 1) + 1) / 6;
743 if(forSerendipPoints && !order) nbMonomials = 1;
749 monomials(0, 2) = order;
752 monomials(1, 0) = order;
754 monomials(1, 2) = order;
756 monomials(2, 0) = order;
757 monomials(2, 1) = order;
758 monomials(2, 2) = order;
761 monomials(3, 1) = order;
762 monomials(3, 2) = order;
770 for(
int iedge = 0; iedge < 8; ++iedge) {
774 int u_1 = (monomials(i1, 0) - monomials(i0, 0)) / order;
775 int u_2 = (monomials(i1, 1) - monomials(i0, 1)) / order;
776 int u_3 = (monomials(i1, 2) - monomials(i0, 2)) / order;
778 for(
int i = 1; i < order; ++i, ++index) {
779 monomials(index, 0) = monomials(i0, 0) + i * u_1;
780 monomials(index, 1) = monomials(i0, 1) + i * u_2;
781 monomials(index, 2) = monomials(i0, 2) + i * u_3;
785 if(!forSerendipPoints) {
795 for(
int iface = 0; iface < 5; ++iface) {
812 u[0] = (monomials(i1, 0) - monomials(i0, 0)) / order;
813 u[1] = (monomials(i1, 1) - monomials(i0, 1)) / order;
814 u[2] = (monomials(i1, 2) - monomials(i0, 2)) / order;
816 v[0] = (monomials(i2, 0) - monomials(i0, 0)) / order;
817 v[1] = (monomials(i2, 1) - monomials(i0, 1)) / order;
818 v[2] = (monomials(i2, 2) - monomials(i0, 2)) / order;
820 for(
int i = 0; i < dudv.
size1(); ++i, ++index) {
821 monomials(index, 0) =
822 monomials(i0, 0) + u[0] * dudv(i, 0) + v[0] * dudv(i, 1);
823 monomials(index, 1) =
824 monomials(i0, 1) + u[1] * dudv(i, 0) + v[1] * dudv(i, 1);
825 monomials(index, 2) =
826 monomials(i0, 2) + u[2] * dudv(i, 0) + v[2] * dudv(i, 1);
837 monomials.
copy(inner, 0, nbMonomials - index, 0, 3, index, 0);
848 int nbMonomials = order ? 5 + (order - 1) * 8 : 1;
876 for(
int i = 2; i <= order; ++i, ++idx) {
877 monomials(idx, 0) = 0;
878 monomials(idx, 1) = 0;
879 monomials(idx, 2) = i;
881 for(
int i = 2; i <= order; ++i, ++idx) {
882 monomials(idx, 0) = i;
883 monomials(idx, 1) = 0;
884 monomials(idx, 2) = i;
886 for(
int i = 2; i <= order; ++i, ++idx) {
887 monomials(idx, 0) = 0;
888 monomials(idx, 1) = i;
889 monomials(idx, 2) = i;
891 for(
int i = 1; i < order; ++i, ++idx) {
892 monomials(idx, 0) = i;
893 monomials(idx, 1) = 0;
894 monomials(idx, 2) = order;
896 for(
int i = 1; i < order; ++i, ++idx) {
897 monomials(idx, 0) = 0;
898 monomials(idx, 1) = i;
899 monomials(idx, 2) = order;
901 for(
int i = 1; i < order; ++i, ++idx) {
902 monomials(idx, 0) = i;
903 monomials(idx, 1) = order - i;
904 monomials(idx, 2) = order;
906 for(
int i = 2; i <= order; ++i, ++idx) {
907 monomials(idx, 0) = i;
908 monomials(idx, 1) = 1;
909 monomials(idx, 2) = i;
911 for(
int i = 2; i <= order; ++i, ++idx) {
912 monomials(idx, 0) = 1;
913 monomials(idx, 1) = i;
914 monomials(idx, 2) = i;
923 bool forSerendipPoints)
925 if(nij < 0 || nk < 0) {
926 Msg::Error(
"Wrong arguments for pyramid's monomials generation ! (%d & %d)",
930 if(!pyr && nk > 0 && nij == 0) {
931 Msg::Error(
"Wrong argument association for pyramid's monomials generation! "
937 if(forSerendipPoints || (pyr && nij == 0))
946 for(
int k = 0; k <= nk; ++k) {
947 nbMonomials += (k + nij + 1) * (k + nij + 1);
951 nbMonomials = (nij + 1) * (nij + 1) * (nk + 1);
957 monomials(0, 2) = nk;
959 if(nk == 0 && nij == 0)
return monomials;
962 int nijBase = pyr ? nk + nij : nij;
965 monomials(1, 0) = nijBase;
967 monomials(1, 2) = nk;
969 monomials(2, 0) = nijBase;
970 monomials(2, 1) = nijBase;
971 monomials(2, 2) = nk;
974 monomials(3, 1) = nijBase;
975 monomials(3, 2) = nk;
984 monomials(5, 0) = nij;
988 monomials(6, 0) = nij;
989 monomials(6, 1) = nij;
993 monomials(7, 1) = nij;
1001 for(
int iedge = 0; iedge < 4; ++iedge) {
1003 int i1 = (iedge + 1) % 4;
1006 static_cast<int>((monomials(i1, 0) - monomials(i0, 0)) / nijBase);
1008 static_cast<int>((monomials(i1, 1) - monomials(i0, 1)) / nijBase);
1010 for(
int i = 1; i < nijBase; ++i, ++index) {
1011 monomials(index, 0) = monomials(i0, 0) + i * u0;
1012 monomials(index, 1) = monomials(i0, 1) + i * u1;
1013 monomials(index, 2) = nk;
1017 for(
int i = 1; i < nijBase; ++i) {
1018 for(
int j = 1; j < nijBase; ++j, ++index) {
1019 monomials(index, 0) = i;
1020 monomials(index, 1) = j;
1021 monomials(index, 2) = nk;
1030 for(
int iedge = 0; iedge < 4; ++iedge) {
1032 int i1 = 4 + (iedge + 1) % 4;
1034 int u0 =
static_cast<int>((monomials(i1, 0) - monomials(i0, 0)) / nij);
1035 int u1 =
static_cast<int>((monomials(i1, 1) - monomials(i0, 1)) / nij);
1037 for(
int i = 1; i < nij; ++i, ++index) {
1038 monomials(index, 0) = monomials(i0, 0) + i * u0;
1039 monomials(index, 1) = monomials(i0, 1) + i * u1;
1040 monomials(index, 2) = 0;
1044 for(
int i = 1; i < nij; ++i) {
1045 for(
int j = 1; j < nij; ++j, ++index) {
1046 monomials(index, 0) = i;
1047 monomials(index, 1) = j;
1048 monomials(index, 2) = 0;
1054 for(
int k = nk - 1; k > 0; --k) {
1055 int currentnij = pyr ? k + nij : nij;
1056 for(
int i = 0; i <= currentnij; ++i) {
1057 for(
int j = 0; j <= currentnij; ++j, ++index) {
1058 monomials(index, 0) = i;
1059 monomials(index, 1) = j;
1060 monomials(index, 2) = k;
1073 points.
resize(order + 1);
1074 for(
int i = 0; i < order + 1; ++i) {
1075 points(i) = i /
static_cast<double>(order);
1081 bool onBezierDomain)
1084 if(points.
size1() == 1)
return;
1086 const int type = data.
getType();
1090 if(onBezierDomain) {
1092 points.
scale(1. / order);
1105 const int nij = data.
getNij();
1106 const int nk = data.
getNk();
1107 const int div = pyr ? nij + nk : std::max(nij, nk);
1108 double scale = 1. / nij;
1109 for(
int i = 0; i < points.
size1(); ++i) {
1110 points(i, 2) = (nk - points(i, 2)) / div;
1111 if(pyr)
scale = 1. / div / (1 - points(i, 2));
1112 points(i, 0) = points(i, 0) *
scale;
1113 points(i, 1) = points(i, 1) *
scale;
1124 points.
scale(2. / order);
1132 tmp.
scale(1. / order);
1134 tmp.
scale(2. / order);
1148 const int nij = data.
getNij();
1149 const int nk = data.
getNk();
1150 const int div = pyr ? nij + nk : std::max(nij, nk);
1151 double scale = 2. / div;
1152 for(
int i = 0; i < points.
size1(); ++i) {
1153 points(i, 2) = (nk - points(i, 2)) / div;
1154 const double duv = 1. - points(i, 2);
1155 if(!pyr)
scale = 2. / nij * duv;
1156 points(i, 0) = -duv + points(i, 0) *
scale;
1157 points(i, 1) = -duv + points(i, 1) *
scale;
1169 Msg::Warning(
"Ordered monomials for serendipity elements not implemented");
1175 monomials.
resize(order + 1, 1);
1177 for(
int i = 0; i < order + 1; ++i) {
1178 monomials(idx, 0) = i;
1183 monomials.
resize((order + 1) * (order + 2) / 2, 2);
1185 for(
int j = 0; j < order + 1; ++j) {
1186 for(
int i = 0; i < order + 1 - j; ++i) {
1187 monomials(idx, 0) = i;
1188 monomials(idx, 1) = j;
1194 monomials.
resize((order + 1) * (order + 1), 2);
1196 for(
int j = 0; j < order + 1; ++j) {
1197 for(
int i = 0; i < order + 1; ++i) {
1198 monomials(idx, 0) = i;
1199 monomials(idx, 1) = j;
1205 monomials.
resize((order + 1) * (order + 2) * (order + 3) / 6, 3);
1207 for(
int k = 0; k < order + 1; ++k) {
1208 for(
int j = 0; j < order + 1 - k; ++j) {
1209 for(
int i = 0; i < order + 1 - j - k; ++i) {
1210 monomials(idx, 0) = i;
1211 monomials(idx, 1) = j;
1212 monomials(idx, 2) = k;
1219 monomials.
resize((order + 1) * (order + 1) * (order + 2) / 2, 3);
1221 for(
int k = 0; k < order + 1; ++k) {
1222 for(
int j = 0; j < order + 1; ++j) {
1223 for(
int i = 0; i < order + 1 - j; ++i) {
1224 monomials(idx, 0) = i;
1225 monomials(idx, 1) = j;
1226 monomials(idx, 2) = k;
1233 monomials.
resize((order + 1) * (order + 1) * (order + 1), 3);
1235 for(
int k = 0; k < order + 1; ++k) {
1236 for(
int j = 0; j < order + 1; ++j) {
1237 for(
int i = 0; i < order + 1; ++i) {
1238 monomials(idx, 0) = i;
1239 monomials(idx, 1) = j;
1240 monomials(idx, 2) = k;
1247 const int nij = data.
getNij();
1248 const int nk = data.
getNk();
1251 int numMonomials = (n + 1) * (n + 2) * (2 * n + 3) / 6;
1252 numMonomials -= nij * (nij + 1) * (2 * nij + 1) / 6;
1253 monomials.
resize(numMonomials, 3);
1255 for(
int k = nk; k >= 0; --k) {
1256 for(
int j = 0; j < k + nij + 1; ++j) {
1257 for(
int i = 0; i < k + nij + 1; ++i) {
1258 monomials(idx, 0) = i;
1259 monomials(idx, 1) = j;
1260 monomials(idx, 2) = k;
1267 monomials.
resize((nij + 1) * (nij + 1) * (nk + 1), 3);
1269 for(
int k = nk; k >= 0; --k) {
1270 for(
int j = 0; j < nij + 1; ++j) {
1271 for(
int i = 0; i < nij + 1; ++i) {
1272 monomials(idx, 0) = i;
1273 monomials(idx, 1) = j;
1274 monomials(idx, 2) = k;
1283 Msg::Error(
"Unknown element type for ordered monomials: %d",