15 #include "../coefficient.hpp" 22 const double RT_QuadrilateralElement::nk[8] =
23 { 0., -1., 1., 0., 0., 1., -1., 0. };
31 cp(
poly1d.ClosedPoints(
p + 1, cb_type))
38 const int dof2 =
dof/2;
40 #ifndef MFEM_THREAD_SAFE 51 for (
int i = 0; i <=
p; i++)
53 dof_map[1*dof2 + i + 0*(
p + 1)] = o++;
55 for (
int i = 0; i <=
p; i++)
57 dof_map[0*dof2 + (
p + 1) + i*(
p + 2)] = o++;
59 for (
int i = 0; i <=
p; i++)
61 dof_map[1*dof2 + (
p - i) + (
p + 1)*(
p + 1)] = o++;
63 for (
int i = 0; i <=
p; i++)
65 dof_map[0*dof2 + 0 + (
p - i)*(
p + 2)] = o++;
69 for (
int j = 0; j <=
p; j++)
70 for (
int i = 1; i <=
p; i++)
72 dof_map[0*dof2 + i + j*(
p + 2)] = o++;
74 for (
int j = 1; j <=
p; j++)
75 for (
int i = 0; i <=
p; i++)
77 dof_map[1*dof2 + i + j*(
p + 1)] = o++;
82 for (
int j = 0; j <=
p; j++)
83 for (
int i = 0; i <=
p/2; i++)
85 int idx = 0*dof2 + i + j*(
p + 2);
89 for (
int j =
p/2 + 1; j <=
p; j++)
91 int idx = 0*dof2 + (
p/2 + 1) + j*(
p + 2);
95 for (
int j = 0; j <=
p/2; j++)
96 for (
int i = 0; i <=
p; i++)
98 int idx = 1*dof2 + i + j*(
p + 1);
102 for (
int i = 0; i <=
p/2; i++)
104 int idx = 1*dof2 + i + (
p/2 + 1)*(
p + 1);
109 for (
int j = 0; j <=
p; j++)
110 for (
int i = 0; i <=
p + 1; i++)
124 for (
int j = 0; j <=
p + 1; j++)
125 for (
int i = 0; i <=
p; i++)
144 const int pp1 =
order;
146 #ifdef MFEM_THREAD_SAFE 147 Vector shape_cx(pp1 + 1), shape_ox(pp1), shape_cy(pp1 + 1), shape_oy(pp1);
152 #ifdef MFEM_THREAD_SAFE 153 Vector dshape_cx(pp1 + 1), dshape_cy(pp1 + 1);
170 for (
int j = 0; j < pp1; j++)
171 for (
int i = 0; i <= pp1; i++)
176 idx = -1 - idx,
s = -1;
182 shape(idx,0) =
s*shape_cx(i)*shape_oy(j);
185 for (
int j = 0; j <= pp1; j++)
186 for (
int i = 0; i < pp1; i++)
191 idx = -1 - idx,
s = -1;
198 shape(idx,1) =
s*shape_ox(i)*shape_cy(j);
205 const int pp1 =
order;
207 #ifdef MFEM_THREAD_SAFE 208 Vector shape_cx(pp1 + 1), shape_ox(pp1), shape_cy(pp1 + 1), shape_oy(pp1);
209 Vector dshape_cx(pp1 + 1), dshape_cy(pp1 + 1);
227 for (
int j = 0; j < pp1; j++)
228 for (
int i = 0; i <= pp1; i++)
233 idx = -1 - idx,
s = -1;
239 divshape(idx) =
s*dshape_cx(i)*shape_oy(j);
241 for (
int j = 0; j <= pp1; j++)
242 for (
int i = 0; i < pp1; i++)
247 idx = -1 - idx,
s = -1;
253 divshape(idx) =
s*shape_ox(i)*dshape_cy(j);
271 for (
int c = 0; c < 2; c++)
275 for (
int j = 0; j < jm; j++)
276 for (
int i = 0; i < im; i++)
279 if (idx < 0) { idx = -1 - idx; }
280 int ic = (c == 0) ? j : i;
281 const double h = cp[ic+1] - cp[ic];
283 for (
int k = 0; k < nqpt; k++)
286 if (c == 0) { ip2d.
Set2(cp[i], cp[j] + (h*ip1d.
x)); }
287 else { ip2d.
Set2(cp[i] + (h*ip1d.
x), cp[j]); }
288 Trans.SetIntPoint(&ip2d);
291 const double ipval =
Trans.AdjugateJacobian().InnerProduct(vk,
292 nk + dof2nk[idx]*
dim);
301 const double RT_HexahedronElement::nk[18] =
302 { 0.,0.,-1., 0.,-1.,0., 1.,0.,0., 0.,1.,0., -1.,0.,0., 0.,0.,1. };
310 cp(
poly1d.ClosedPoints(
p + 1, cb_type))
317 const int dof3 =
dof/3;
319 #ifndef MFEM_THREAD_SAFE 333 for (
int j = 0; j <=
p; j++)
334 for (
int i = 0; i <=
p; i++)
336 dof_map[2*dof3 + i + ((
p - j) + 0*(
p + 1))*(
p + 1)] = o++;
338 for (
int j = 0; j <=
p; j++)
339 for (
int i = 0; i <=
p; i++)
341 dof_map[1*dof3 + i + (0 + j*(
p + 2))*(
p + 1)] = o++;
343 for (
int j = 0; j <=
p; j++)
344 for (
int i = 0; i <=
p; i++)
346 dof_map[0*dof3 + (
p + 1) + (i + j*(
p + 1))*(
p + 2)] = o++;
348 for (
int j = 0; j <=
p; j++)
349 for (
int i = 0; i <=
p; i++)
351 dof_map[1*dof3 + (
p - i) + ((
p + 1) + j*(
p + 2))*(
p + 1)] = o++;
353 for (
int j = 0; j <=
p; j++)
354 for (
int i = 0; i <=
p; i++)
356 dof_map[0*dof3 + 0 + ((
p - i) + j*(
p + 1))*(
p + 2)] = o++;
358 for (
int j = 0; j <=
p; j++)
359 for (
int i = 0; i <=
p; i++)
361 dof_map[2*dof3 + i + (j + (
p + 1)*(
p + 1))*(
p + 1)] = o++;
366 for (
int k = 0; k <=
p; k++)
367 for (
int j = 0; j <=
p; j++)
368 for (
int i = 1; i <=
p; i++)
370 dof_map[0*dof3 + i + (j + k*(
p + 1))*(
p + 2)] = o++;
373 for (
int k = 0; k <=
p; k++)
374 for (
int j = 1; j <=
p; j++)
375 for (
int i = 0; i <=
p; i++)
377 dof_map[1*dof3 + i + (j + k*(
p + 2))*(
p + 1)] = o++;
380 for (
int k = 1; k <=
p; k++)
381 for (
int j = 0; j <=
p; j++)
382 for (
int i = 0; i <=
p; i++)
384 dof_map[2*dof3 + i + (j + k*(
p + 1))*(
p + 1)] = o++;
392 for (
int k = 0; k <=
p; k++)
393 for (
int j = 0; j <=
p; j++)
394 for (
int i = 0; i <=
p/2; i++)
396 int idx = 0*dof3 + i + (j + k*(
p + 1))*(
p + 2);
400 for (
int k = 0; k <=
p; k++)
401 for (
int j = 0; j <=
p/2; j++)
402 for (
int i = 0; i <=
p; i++)
404 int idx = 1*dof3 + i + (j + k*(
p + 2))*(
p + 1);
408 for (
int k = 0; k <=
p/2; k++)
409 for (
int j = 0; j <=
p; j++)
410 for (
int i = 0; i <=
p; i++)
412 int idx = 2*dof3 + i + (j + k*(
p + 1))*(
p + 1);
418 for (
int k = 0; k <=
p; k++)
419 for (
int j = 0; j <=
p; j++)
420 for (
int i = 0; i <=
p + 1; i++)
435 for (
int k = 0; k <=
p; k++)
436 for (
int j = 0; j <=
p + 1; j++)
437 for (
int i = 0; i <=
p; i++)
452 for (
int k = 0; k <=
p + 1; k++)
453 for (
int j = 0; j <=
p; j++)
454 for (
int i = 0; i <=
p; i++)
473 const int pp1 =
order;
475 #ifdef MFEM_THREAD_SAFE 476 Vector shape_cx(pp1 + 1), shape_ox(pp1), shape_cy(pp1 + 1), shape_oy(pp1);
477 Vector shape_cz(pp1 + 1), shape_oz(pp1);
482 #ifdef MFEM_THREAD_SAFE 483 Vector dshape_cx(pp1 + 1), dshape_cy(pp1 + 1), dshape_cz(pp1 + 1);
505 for (
int k = 0; k < pp1; k++)
506 for (
int j = 0; j < pp1; j++)
507 for (
int i = 0; i <= pp1; i++)
512 idx = -1 - idx,
s = -1;
518 shape(idx,0) =
s*shape_cx(i)*shape_oy(j)*shape_oz(k);
523 for (
int k = 0; k < pp1; k++)
524 for (
int j = 0; j <= pp1; j++)
525 for (
int i = 0; i < pp1; i++)
530 idx = -1 - idx,
s = -1;
537 shape(idx,1) =
s*shape_ox(i)*shape_cy(j)*shape_oz(k);
541 for (
int k = 0; k <= pp1; k++)
542 for (
int j = 0; j < pp1; j++)
543 for (
int i = 0; i < pp1; i++)
548 idx = -1 - idx,
s = -1;
556 shape(idx,2) =
s*shape_ox(i)*shape_oy(j)*shape_cz(k);
563 const int pp1 =
order;
565 #ifdef MFEM_THREAD_SAFE 566 Vector shape_cx(pp1 + 1), shape_ox(pp1), shape_cy(pp1 + 1), shape_oy(pp1);
567 Vector shape_cz(pp1 + 1), shape_oz(pp1);
568 Vector dshape_cx(pp1 + 1), dshape_cy(pp1 + 1), dshape_cz(pp1 + 1);
590 for (
int k = 0; k < pp1; k++)
591 for (
int j = 0; j < pp1; j++)
592 for (
int i = 0; i <= pp1; i++)
597 idx = -1 - idx,
s = -1;
603 divshape(idx) =
s*dshape_cx(i)*shape_oy(j)*shape_oz(k);
606 for (
int k = 0; k < pp1; k++)
607 for (
int j = 0; j <= pp1; j++)
608 for (
int i = 0; i < pp1; i++)
613 idx = -1 - idx,
s = -1;
619 divshape(idx) =
s*shape_ox(i)*dshape_cy(j)*shape_oz(k);
622 for (
int k = 0; k <= pp1; k++)
623 for (
int j = 0; j < pp1; j++)
624 for (
int i = 0; i < pp1; i++)
629 idx = -1 - idx,
s = -1;
635 divshape(idx) =
s*shape_ox(i)*shape_oy(j)*dshape_cz(k);
653 for (
int c = 0; c < 3; c++)
658 for (
int k = 0; k < km; k++)
659 for (
int j = 0; j < jm; j++)
660 for (
int i = 0; i < im; i++)
663 if (idx < 0) { idx = -1 - idx; }
665 if (c == 0) { ic1 = j; ic2 = k; }
666 else if (c == 1) { ic1 = i; ic2 = k; }
667 else { ic1 = i; ic2 = j; }
668 const double h1 = cp[ic1+1] - cp[ic1];
669 const double h2 = cp[ic2+1] - cp[ic2];
671 for (
int q = 0; q < nqpt; q++)
674 if (c == 0) { ip3d.
Set3(cp[i], cp[j] + h1*ip2d.
x, cp[k] + h2*ip2d.
y); }
675 else if (c == 1) { ip3d.
Set3(cp[i] + h1*ip2d.
x, cp[j], cp[k] + h2*ip2d.
y); }
676 else { ip3d.
Set3(cp[i] + h1*ip2d.
x, cp[j] + h2*ip2d.
y, cp[k]); }
677 Trans.SetIntPoint(&ip3d);
681 =
Trans.AdjugateJacobian().InnerProduct(vq, nk + dof2nk[idx]*
dim);
684 dofs(idx) = val*h1*h2;
690 const double RT_TriangleElement::nk[6] =
691 { 0., -1., 1., 1., -1., 0. };
693 const double RT_TriangleElement::c = 1./3.;
703 #ifndef MFEM_THREAD_SAFE 713 Vector shape_x(
p + 1), shape_y(
p + 1), shape_l(
p + 1);
718 for (
int i = 0; i <=
p; i++)
723 for (
int i = 0; i <=
p; i++)
728 for (
int i = 0; i <=
p; i++)
735 for (
int j = 0; j <
p; j++)
736 for (
int i = 0; i + j <
p; i++)
738 double w = iop[i] + iop[j] + iop[
p-1-i-j];
746 for (
int k = 0; k <
dof; k++)
752 const double *n_k = nk + 2*dof2nk[k];
755 for (
int j = 0; j <=
p; j++)
756 for (
int i = 0; i + j <=
p; i++)
758 double s = shape_x(i)*shape_y(j)*shape_l(
p-i-j);
759 T(o++, k) =
s*n_k[0];
760 T(o++, k) =
s*n_k[1];
762 for (
int i = 0; i <=
p; i++)
764 double s = shape_x(i)*shape_y(
p-i);
765 T(o++, k) =
s*((ip.
x - c)*n_k[0] + (ip.
y - c)*n_k[1]);
778 #ifdef MFEM_THREAD_SAFE 779 Vector shape_x(
p + 1), shape_y(
p + 1), shape_l(
p + 1);
788 for (
int j = 0; j <=
p; j++)
789 for (
int i = 0; i + j <=
p; i++)
791 double s = shape_x(i)*shape_y(j)*shape_l(
p-i-j);
792 u(o,0) =
s;
u(o,1) = 0; o++;
793 u(o,0) = 0;
u(o,1) =
s; o++;
795 for (
int i = 0; i <=
p; i++)
797 double s = shape_x(i)*shape_y(
p-i);
798 u(o,0) = (ip.
x - c)*
s;
799 u(o,1) = (ip.
y - c)*
s;
811 #ifdef MFEM_THREAD_SAFE 812 Vector shape_x(
p + 1), shape_y(
p + 1), shape_l(
p + 1);
813 Vector dshape_x(
p + 1), dshape_y(
p + 1), dshape_l(
p + 1);
822 for (
int j = 0; j <=
p; j++)
823 for (
int i = 0; i + j <=
p; i++)
826 divu(o++) = (dshape_x(i)*shape_l(k) -
827 shape_x(i)*dshape_l(k))*shape_y(j);
828 divu(o++) = (dshape_y(j)*shape_l(k) -
829 shape_y(j)*dshape_l(k))*shape_x(i);
831 for (
int i = 0; i <=
p; i++)
834 divu(o++) = ((shape_x(i) + (ip.
x - c)*dshape_x(i))*shape_y(j) +
835 (shape_y(j) + (ip.
y - c)*dshape_y(j))*shape_x(i));
838 Ti.
Mult(divu, divshape);
842 const double RT_TetrahedronElement::nk[12] =
843 { 1,1,1, -1,0,0, 0,-1,0, 0,0,-1 };
846 const double RT_TetrahedronElement::c = 1./4.;
856 #ifndef MFEM_THREAD_SAFE 868 Vector shape_x(
p + 1), shape_y(
p + 1), shape_z(
p + 1), shape_l(
p + 1);
874 for (
int j = 0; j <=
p; j++)
875 for (
int i = 0; i + j <=
p; i++)
877 double w = bop[i] + bop[j] + bop[
p-i-j];
881 for (
int j = 0; j <=
p; j++)
882 for (
int i = 0; i + j <=
p; i++)
884 double w = bop[i] + bop[j] + bop[
p-i-j];
888 for (
int j = 0; j <=
p; j++)
889 for (
int i = 0; i + j <=
p; i++)
891 double w = bop[i] + bop[j] + bop[
p-i-j];
895 for (
int j = 0; j <=
p; j++)
896 for (
int i = 0; i + j <=
p; i++)
898 double w = bop[i] + bop[j] + bop[
p-i-j];
904 for (
int k = 0; k <
p; k++)
905 for (
int j = 0; j + k <
p; j++)
906 for (
int i = 0; i + j + k <
p; i++)
908 double w = iop[i] + iop[j] + iop[k] + iop[
p-1-i-j-k];
918 for (
int m = 0; m <
dof; m++)
925 const double *nm = nk + 3*dof2nk[m];
928 for (
int k = 0; k <=
p; k++)
929 for (
int j = 0; j + k <=
p; j++)
930 for (
int i = 0; i + j + k <=
p; i++)
932 double s = shape_x(i)*shape_y(j)*shape_z(k)*shape_l(
p-i-j-k);
933 T(o++, m) =
s * nm[0];
934 T(o++, m) =
s * nm[1];
935 T(o++, m) =
s * nm[2];
937 for (
int j = 0; j <=
p; j++)
938 for (
int i = 0; i + j <=
p; i++)
940 double s = shape_x(i)*shape_y(j)*shape_z(
p-i-j);
941 T(o++, m) =
s*((ip.
x - c)*nm[0] + (ip.
y - c)*nm[1] +
955 #ifdef MFEM_THREAD_SAFE 956 Vector shape_x(
p + 1), shape_y(
p + 1), shape_z(
p + 1), shape_l(
p + 1);
966 for (
int k = 0; k <=
p; k++)
967 for (
int j = 0; j + k <=
p; j++)
968 for (
int i = 0; i + j + k <=
p; i++)
970 double s = shape_x(i)*shape_y(j)*shape_z(k)*shape_l(
p-i-j-k);
971 u(o,0) =
s;
u(o,1) = 0;
u(o,2) = 0; o++;
972 u(o,0) = 0;
u(o,1) =
s;
u(o,2) = 0; o++;
973 u(o,0) = 0;
u(o,1) = 0;
u(o,2) =
s; o++;
975 for (
int j = 0; j <=
p; j++)
976 for (
int i = 0; i + j <=
p; i++)
978 double s = shape_x(i)*shape_y(j)*shape_z(
p-i-j);
979 u(o,0) = (ip.
x - c)*
s;
u(o,1) = (ip.
y - c)*
s;
u(o,2) = (ip.
z - c)*
s;
991 #ifdef MFEM_THREAD_SAFE 992 Vector shape_x(
p + 1), shape_y(
p + 1), shape_z(
p + 1), shape_l(
p + 1);
993 Vector dshape_x(
p + 1), dshape_y(
p + 1), dshape_z(
p + 1), dshape_l(
p + 1);
1003 for (
int k = 0; k <=
p; k++)
1004 for (
int j = 0; j + k <=
p; j++)
1005 for (
int i = 0; i + j + k <=
p; i++)
1007 int l =
p - i - j - k;
1008 divu(o++) = (dshape_x(i)*shape_l(l) -
1009 shape_x(i)*dshape_l(l))*shape_y(j)*shape_z(k);
1010 divu(o++) = (dshape_y(j)*shape_l(l) -
1011 shape_y(j)*dshape_l(l))*shape_x(i)*shape_z(k);
1012 divu(o++) = (dshape_z(k)*shape_l(l) -
1013 shape_z(k)*dshape_l(l))*shape_x(i)*shape_y(j);
1015 for (
int j = 0; j <=
p; j++)
1016 for (
int i = 0; i + j <=
p; i++)
1020 (shape_x(i) + (ip.
x - c)*dshape_x(i))*shape_y(j)*shape_z(k) +
1021 (shape_y(j) + (ip.
y - c)*dshape_y(j))*shape_x(i)*shape_z(k) +
1022 (shape_z(k) + (ip.
z - c)*dshape_z(k))*shape_x(i)*shape_y(j);
1025 Ti.
Mult(divu, divshape);
1028 const double RT_WedgeElement::nk[15] =
1029 { 0,0,-1, 0,0,1, 0,-1,0, 1,1,0, -1,0,0};
1033 (
p + 2) * ((
p + 1) * (
p + 2)) / 2 +
1034 (
p + 1) * (
p + 1) * (
p + 3),
p + 1,
1044 MFEM_ASSERT(L2TriangleFE.
GetDof() * H1SegmentFE.
GetDof() +
1046 "Mismatch in number of degrees of freedom " 1047 "when building RT_WedgeElement!");
1049 const int pm1 =
p - 1;
1051 #ifndef MFEM_THREAD_SAFE 1069 for (
int j = 0; j <=
p; j++)
1070 for (
int i = 0; i + j <=
p; i++)
1072 l = j + i * (2 *
p + 3 - i) / 2;
1073 t_dof[o] = l; s_dof[o] = 0; dof2nk[o] = 0;
1080 for (
int j = 0; j <=
p; j++)
1081 for (
int i = 0; i + j <=
p; i++)
1083 t_dof[o] = l; s_dof[o] = 1; dof2nk[o] = 1; l++;
1089 for (
int j = 0; j <=
p; j++)
1090 for (
int i = 0; i <=
p; i++)
1092 t_dof[o] = i; s_dof[o] = j; dof2nk[o] = 2;
1098 for (
int j = 0; j <=
p; j++)
1099 for (
int i = 0; i <=
p; i++)
1101 t_dof[o] =
p + 1 + i; s_dof[o] = j; dof2nk[o] = 3;
1107 for (
int j = 0; j <=
p; j++)
1108 for (
int i = 0; i <=
p; i++)
1110 t_dof[o] = 2 *
p + 2 + i; s_dof[o] = j; dof2nk[o] = 4;
1117 for (
int k = 0; k < L2SegmentFE.
GetDof(); k++)
1120 for (
int j = 0; j <= pm1; j++)
1121 for (
int i = 0; i + j <= pm1; i++)
1123 t_dof[o] = 3 * (
p + 1) + 2 * l; s_dof[o] = k;
1129 t_dof[o] = 3 * (
p + 1) + 2 * l + 1; s_dof[o] = k;
1137 for (
int k = 2; k < H1SegmentFE.
GetDof(); k++)
1139 for (l = 0; l < L2TriangleFE.
GetDof(); l++)
1141 t_dof[o] = l; s_dof[o] = k; dof2nk[o] = 1;
1152 #ifdef MFEM_THREAD_SAFE 1166 for (
int i=0; i<
dof; i++)
1168 if ( dof2nk[i] >= 2 )
1170 shape(i, 0) = trt_shape(t_dof[i], 0) * sl2_shape[s_dof[i]];
1171 shape(i, 1) = trt_shape(t_dof[i], 1) * sl2_shape[s_dof[i]];
1176 double s = (dof2nk[i] == 0) ? -1.0 : 1.0;
1179 shape(i, 2) =
s * tl2_shape[t_dof[i]] * sh1_shape(s_dof[i]);
1187 #ifdef MFEM_THREAD_SAFE 1202 for (
int i=0; i<
dof; i++)
1204 if ( dof2nk[i] >= 2 )
1206 divshape(i) = trt_dshape(t_dof[i]) * sl2_shape(s_dof[i]);
1210 double s = (dof2nk[i] == 0) ? -1.0 : 1.0;
1211 divshape(i) =
s * tl2_shape(t_dof[i]) * sh1_dshape(s_dof[i], 0);
1216 const double RT_R1D_SegmentElement::nk[9] = { 1.,0.,0., 0.,1.,0., 0.,0.,1. };
1224 cbasis1d(
poly1d.GetBasis(
p + 1, VerifyClosed(cb_type))),
1225 obasis1d(
poly1d.GetBasis(
p, VerifyOpen(ob_type)))
1233 #ifndef MFEM_THREAD_SAFE 1245 dof_map[0] = o; dof2nk[o++] = 0;
1249 dof_map[
p+1] = o; dof2nk[o++] = 0;
1253 for (
int i = 1; i <=
p; i++)
1256 dof_map[i] = o; dof2nk[o++] = 0;
1259 for (
int i = 0; i <=
p; i++)
1262 dof_map[
p+i+2] = o; dof2nk[o++] = 1;
1265 for (
int i = 0; i <=
p; i++)
1268 dof_map[2*
p+3+i] = o; dof2nk[o++] = 2;
1277 #ifdef MFEM_THREAD_SAFE 1278 Vector shape_cx(
p + 1), shape_ox(
p);
1281 cbasis1d.
Eval(ip.
x, shape_cx);
1282 obasis1d.
Eval(ip.
x, shape_ox);
1286 for (
int i = 0; i <=
p; i++)
1288 int idx = dof_map[o++];
1289 shape(idx,0) = shape_cx(i);
1294 for (
int i = 0; i <
p; i++)
1296 int idx = dof_map[o++];
1298 shape(idx,1) = shape_ox(i);
1302 for (
int i = 0; i <
p; i++)
1304 int idx = dof_map[o++];
1307 shape(idx,2) = shape_ox(i);
1316 MFEM_ASSERT(J.Width() == 1 && J.Height() == 1,
1317 "RT_R1D_SegmentElement cannot be embedded in " 1318 "2 or 3 dimensional spaces");
1319 for (
int i=0; i<
dof; i++)
1321 shape(i, 0) *= J(0,0);
1323 shape *= (1.0 /
Trans.Weight());
1331 #ifdef MFEM_THREAD_SAFE 1336 cbasis1d.
Eval(ip.
x, shape_cx, dshape_cx);
1340 for (
int i = 0; i <=
p; i++)
1342 int idx = dof_map[o++];
1343 divshape(idx) = dshape_cx(i);
1346 for (
int i = 0; i <
p; i++)
1348 int idx = dof_map[o++];
1352 for (
int i = 0; i <
p; i++)
1354 int idx = dof_map[o++];
1367 double * nk_ptr =
const_cast<double*
>(nk);
1369 for (
int k = 0; k <
dof; k++)
1375 Vector n1(&nk_ptr[dof2nk[k] * 3], 1);
1376 Vector n3(&nk_ptr[dof2nk[k] * 3], 3);
1378 dofs(k) =
Trans.AdjugateJacobian().InnerProduct(vk1, n1) +
1379 Trans.Weight() * vk3(1) * n3(1) +
1380 Trans.Weight() * vk3(2) * n3(2);
1393 double * nk_ptr =
const_cast<double*
>(nk);
1396 for (
int k = 0; k <
dof; k++)
1400 Vector n1(&nk_ptr[dof2nk[k] * 3], 1);
1401 Vector n3(&nk_ptr[dof2nk[k] * 3], 3);
1404 Trans.SetIntPoint(&ip);
1407 Trans.AdjugateJacobian().MultTranspose(n1, vk);
1408 vk[1] = n3[1] *
Trans.Weight();
1409 vk[2] = n3[2] *
Trans.Weight();
1412 double w = 1.0/
Trans.Weight();
1413 for (
int d = 0; d < 1; d++)
1419 for (
int j = 0; j < shape.Size(); j++)
1421 double s = shape(j);
1422 if (fabs(
s) < 1e-12)
1428 for (
int d = 0; d <
vdim; d++)
1430 I(k,j+d*shape.Size()) =
s*vk[d];
1440 double * nk_ptr =
const_cast<double*
>(nk);
1443 for (
int k = 0; k <
dof; k++)
1447 Vector n1(&nk_ptr[dof2nk[k] * 3], 1);
1448 Vector n3(&nk_ptr[dof2nk[k] * 3], 3);
1450 Trans.SetIntPoint(&ip);
1453 Trans.AdjugateJacobian().MultTranspose(n1, vk);
1460 I(k, j) +=
vshape(j, 0) * vk[0];
1478 double * nk_ptr =
const_cast<double*
>(nk);
1481 for (
int k = 0; k <
dof; k++)
1484 curl_shape.Mult(nk_ptr + dof2nk[k] * 3, curl_k);
1485 for (
int j = 0; j < curl_k.Size(); j++)
1487 curl(k,j) = (fabs(curl_k(j)) < 1e-12) ? 0.0 : curl_k(j);
1492 const double RT_R2D_SegmentElement::nk[2] = { 0.,1.};
1499 obasis1d(
poly1d.GetBasis(
p, VerifyOpen(ob_type)))
1506 #ifndef MFEM_THREAD_SAFE 1515 for (
int i = 0; i <=
p; i++)
1518 dof_map[i] = o; dof2nk[o++] = 0;
1527 #ifdef MFEM_THREAD_SAFE 1531 obasis1d.
Eval(ip.
x, shape_ox);
1535 for (
int i = 0; i <=
p; i++)
1537 int idx = dof_map[o++];
1538 shape(idx,0) = shape_ox(i);
1548 MFEM_ASSERT(J.Width() == 1 && J.Height() == 1,
1549 "RT_R2D_SegmentElement cannot be embedded in " 1550 "2 or 3 dimensional spaces");
1551 for (
int i=0; i<
dof; i++)
1553 shape(i, 0) *= J(0,0);
1555 shape *= (1.0 /
Trans.Weight());
1573 double * nk_ptr =
const_cast<double*
>(nk);
1580 for (
int k = 0; k <
dof; k++)
1582 Vector n2(&nk_ptr[dof2nk[k] * 2], 2);
1600 I(k, j) = (fabs(Ikj) < 1e-12) ? 0.0 : Ikj;
1606 const double *nk_fe)
1622 MFEM_ASSERT(J.Width() == 2 && J.Height() == 2,
1623 "RT_R2D_FiniteElement cannot be embedded in " 1624 "3 dimensional spaces");
1625 for (
int i=0; i<
dof; i++)
1627 double sx = shape(i, 0);
1628 double sy = shape(i, 1);
1629 shape(i, 0) = sx * J(0, 0) + sy * J(0, 1);
1630 shape(i, 1) = sx * J(1, 0) + sy * J(1, 1);
1632 shape *= (1.0 /
Trans.Weight());
1645 double * nk_ptr =
const_cast<double*
>(
nk);
1652 for (
int k = 0; k <
dof; k++)
1666 for (
int i = 0; i <
dim; i++)
1668 Ikj +=
vshape(j, i) * vk[i];
1671 I(k, j) = (fabs(Ikj) < 1e-12) ? 0.0 : Ikj;
1683 #ifdef MFEM_THREAD_SAFE 1687 double * nk_ptr =
const_cast<double*
>(
nk);
1691 const double weight =
Trans.Weight();
1692 for (
int j = 0; j <
dof; j++)
1704 for (
int k = 0; k <
dof; k++)
1707 for (
int d = 0; d <
dim; d++)
1709 R_jk +=
vshape(k,d)*pt_data[d];
1711 R_jk +=
vshape(k,2) * n3(2);
1732 double * nk_ptr =
const_cast<double*
>(
nk);
1734 for (
int k = 0; k <
dof; k++)
1743 dofs(k) =
Trans.AdjugateJacobian().InnerProduct(vk2, n2) +
1744 Trans.Weight() * vk3(2) * n3(2);
1757 double * nk_ptr =
const_cast<double*
>(
nk);
1760 for (
int k = 0; k <
dof; k++)
1768 Trans.SetIntPoint(&ip);
1771 Trans.AdjugateJacobian().MultTranspose(n2, vk);
1772 vk[2] = n3[2] *
Trans.Weight();
1775 double w = 1.0/
Trans.Weight();
1776 for (
int d = 0; d < 2; d++)
1782 for (
int j = 0; j < shape.Size(); j++)
1784 double s = shape(j);
1785 if (fabs(
s) < 1e-12)
1791 for (
int d = 0; d <
vdim; d++)
1793 I(k,j+d*shape.Size()) =
s*vk[d];
1803 double * nk_ptr =
const_cast<double*
>(
nk);
1806 for (
int k = 0; k <
dof; k++)
1813 Trans.SetIntPoint(&ip);
1816 Trans.AdjugateJacobian().MultTranspose(n2, vk);
1823 for (
int i=0; i<2; i++)
1825 I(k, j) +=
vshape(j, i) * vk[i];
1843 double * nk_ptr =
const_cast<double*
>(
nk);
1846 for (
int k = 0; k <
dof; k++)
1849 curl_shape.Mult(nk_ptr +
dof2nk[k] * 3, curl_k);
1850 for (
int j = 0; j < curl_k.Size(); j++)
1852 curl(k,j) = (fabs(curl_k(j)) < 1e-12) ? 0.0 : curl_k(j);
1857 const double RT_R2D_TriangleElement::nk_t[12] =
1858 { 0.,-1.,0., 1.,1.,0., -1.,0.,0., 0.,0.,1. };
1867 #ifndef MFEM_THREAD_SAFE 1878 for (
int e=0; e<3; e++)
1881 for (
int i=0; i<=
p; i++)
1888 for (
int j = 0; j <
p; j++)
1889 for (
int i = 0; i + j <
p; i++)
1896 for (
int j = 0; j <=
p; j++)
1897 for (
int i = 0; i + j <=
p; i++)
1902 MFEM_VERIFY(r == RT_FE.
GetDof(),
1903 "RT_R2D_Triangle incorrect number of RT dofs.");
1904 MFEM_VERIFY(l == L2_FE.
GetDof(),
1905 "RT_R2D_Triangle incorrect number of L2 dofs.");
1906 MFEM_VERIFY(o ==
GetDof(),
1907 "RT_R2D_Triangle incorrect number of dofs.");
1912 for (
int i=0; i<
dof; i++)
1931 #ifdef MFEM_THREAD_SAFE 1939 for (
int i=0; i<
dof; i++)
1944 shape(i, 0) = rt_shape(idx, 0);
1945 shape(i, 1) = rt_shape(idx, 1);
1952 shape(i, 2) = l2_shape(-idx-1);
1960 #ifdef MFEM_THREAD_SAFE 1966 for (
int i=0; i<
dof; i++)
1971 div_shape(i) = rt_dshape(idx);
1980 const double RT_R2D_QuadrilateralElement::nk_q[15] =
1981 { 0., -1., 0., 1., 0., 0., 0., 1., 0., -1., 0., 0., 0., 0., 1. };
1987 cbasis1d(
poly1d.GetBasis(
p + 1, VerifyClosed(cb_type))),
1988 obasis1d(
poly1d.GetBasis(
p, VerifyOpen(ob_type)))
1992 const int dofx = (
p + 1)*(
p + 2);
1993 const int dofy = (
p + 1)*(
p + 2);
1994 const int dofxy = dofx + dofy;
1996 #ifndef MFEM_THREAD_SAFE 2007 for (
int i = 0; i <=
p; i++)
2009 dof_map[dofx + i + 0*(
p + 1)] = o++;
2011 for (
int i = 0; i <=
p; i++)
2015 for (
int i = 0; i <=
p; i++)
2017 dof_map[dofx + (
p - i) + (
p + 1)*(
p + 1)] = o++;
2019 for (
int i = 0; i <=
p; i++)
2025 for (
int j = 0; j <=
p; j++)
2026 for (
int i = 1; i <=
p; i++)
2030 for (
int j = 1; j <=
p; j++)
2031 for (
int i = 0; i <=
p; i++)
2033 dof_map[dofx + i + j*(
p + 1)] = o++;
2035 for (
int j = 0; j <=
p; j++)
2036 for (
int i = 0; i <=
p; i++)
2038 dof_map[dofxy + i + j*(
p + 1)] = o++;
2043 for (
int j = 0; j <=
p; j++)
2044 for (
int i = 0; i <=
p/2; i++)
2046 int idx = i + j*(
p + 2);
2050 for (
int j =
p/2 + 1; j <=
p; j++)
2052 int idx = (
p/2 + 1) + j*(
p + 2);
2056 for (
int j = 0; j <=
p/2; j++)
2057 for (
int i = 0; i <=
p; i++)
2059 int idx = dofx + i + j*(
p + 1);
2063 for (
int i = 0; i <=
p/2; i++)
2065 int idx = dofx + i + (
p/2 + 1)*(
p + 1);
2070 for (
int j = 0; j <=
p; j++)
2071 for (
int i = 0; i <=
p + 1; i++)
2085 for (
int j = 0; j <=
p + 1; j++)
2086 for (
int i = 0; i <=
p; i++)
2100 for (
int j = 0; j <=
p; j++)
2101 for (
int i = 0; i <=
p; i++)
2112 const int pp1 =
order;
2114 #ifdef MFEM_THREAD_SAFE 2115 Vector shape_cx(pp1 + 1), shape_ox(pp1), shape_cy(pp1 + 1), shape_oy(pp1);
2118 cbasis1d.
Eval(ip.
x, shape_cx);
2119 obasis1d.
Eval(ip.
x, shape_ox);
2120 cbasis1d.
Eval(ip.
y, shape_cy);
2121 obasis1d.
Eval(ip.
y, shape_oy);
2124 for (
int j = 0; j < pp1; j++)
2125 for (
int i = 0; i <= pp1; i++)
2130 idx = -1 - idx,
s = -1;
2136 shape(idx,0) =
s*shape_cx(i)*shape_oy(j);
2140 for (
int j = 0; j <= pp1; j++)
2141 for (
int i = 0; i < pp1; i++)
2146 idx = -1 - idx,
s = -1;
2153 shape(idx,1) =
s*shape_ox(i)*shape_cy(j);
2156 for (
int j = 0; j < pp1; j++)
2157 for (
int i = 0; i < pp1; i++)
2162 shape(idx,2) = shape_ox(i)*shape_oy(j);
2169 const int pp1 =
order;
2171 #ifdef MFEM_THREAD_SAFE 2172 Vector shape_cx(pp1 + 1), shape_ox(pp1), shape_cy(pp1 + 1), shape_oy(pp1);
2173 Vector dshape_cx(pp1 + 1), dshape_cy(pp1 + 1);
2176 cbasis1d.
Eval(ip.
x, shape_cx, dshape_cx);
2177 obasis1d.
Eval(ip.
x, shape_ox);
2178 cbasis1d.
Eval(ip.
y, shape_cy, dshape_cy);
2179 obasis1d.
Eval(ip.
y, shape_oy);
2182 for (
int j = 0; j < pp1; j++)
2183 for (
int i = 0; i <= pp1; i++)
2188 idx = -1 - idx,
s = -1;
2194 divshape(idx) =
s*dshape_cx(i)*shape_oy(j);
2196 for (
int j = 0; j <= pp1; j++)
2197 for (
int i = 0; i < pp1; i++)
2202 idx = -1 - idx,
s = -1;
2208 divshape(idx) =
s*shape_ox(i)*dshape_cy(j);
2210 for (
int j = 0; j < pp1; j++)
2211 for (
int i = 0; i < pp1; i++)
Abstract class for all finite elements.
void Set(const double *p, const int dim)
int GetNPoints() const
Returns the number of the points in the integration rule.
bool IsIntegratedType() const
Returns true if the basis is "integrated", false otherwise.
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 CalcVShape(const IntegrationPoint &ip, DenseMatrix &shape) const
Evaluate the values of all shape functions of a vector finite element in reference space at the given...
Class for an integration rule - an Array of IntegrationPoint.
virtual void CalcDivShape(const IntegrationPoint &ip, Vector &divshape) const
Evaluate the divergence of all shape functions of a vector finite element in reference space at the g...
void ScaleIntegrated(bool scale_integrated_)
Set whether the "integrated" basis should be scaled by the subcell sizes. Has no effect for non-integ...
const IntegrationRule & Get(int GeomType, int Order)
Returns an integration rule for given GeomType and Order.
Base class for vector Coefficients that optionally depend on time and space.
void SetRow(int r, const double *row)
virtual void CalcCurlShape(const IntegrationPoint &ip, DenseMatrix &curl_shape) const
Evaluate the curl of all shape functions of a vector finite element in reference space at the given p...
virtual void Eval(Vector &V, ElementTransformation &T, const IntegrationPoint &ip)=0
Evaluate the vector coefficient in the element described by T at the point ip, storing the result in ...
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...
void Mult(const double *x, double *y) const
Matrix vector multiplication with the inverse of dense matrix.
virtual void CalcVShape(const IntegrationPoint &ip, DenseMatrix &shape) const
Evaluate the values of all shape functions of a vector finite element in reference space at the given...
void SetSize(int s)
Resize the vector to size s.
int Width() const
Get the width (size of input) of the Operator. Synonym with NumCols().
int dim
Dimension of reference space.
virtual void CalcVShape(const IntegrationPoint &ip, DenseMatrix &shape) const
Evaluate the values of all shape functions of a vector finite element in reference space at the given...
Data type dense matrix using column-major storage.
void Eval(const double x, Vector &u) const
Evaluate the basis functions at point x in [0,1].
virtual void CalcDivShape(const IntegrationPoint &ip, Vector &div_shape) const
Evaluate the divergence of all shape functions of a vector finite element in reference space at the g...
virtual void GetLocalRestriction(ElementTransformation &Trans, DenseMatrix &R) const
Return a local restriction matrix R (Dof x Dof) mapping fine dofs to coarse dofs. ...
Poly_1D::Basis & obasis1d
void Factor()
Factor the current DenseMatrix, *a.
Geometry::Type geom_type
Geometry::Type of the reference element.
Intermediate class for finite elements whose basis functions return vector values.
const IntegrationPoint & GetCenter(int GeomType)
Return the center of the given Geometry::Type, GeomType.
virtual void CalcVShape(ElementTransformation &Trans, DenseMatrix &shape) const
Evaluate the values of all shape functions of a vector finite element in physical space at the point ...
virtual void ProjectCurl(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &curl) const
Compute the discrete curl matrix from the given FiniteElement onto 'this' FiniteElement. The ElementTransformation is included to support cases when the matrix depends on it.
RT_WedgeElement(const int p)
const double * ClosedPoints(const int p, const int btype=BasisType::GaussLobatto)
Get coordinates of a closed (GaussLegendre) set of points if degree p.
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)
int vdim
Vector dimension of vector-valued basis functions.
static void CalcBasis(const int p, const double x, double *u)
Evaluate the values of a hierarchical 1D basis at point x hierarchical = k-th basis function is degre...
virtual void CalcDivShape(const IntegrationPoint &ip, Vector &divshape) const
Evaluate the divergence of all shape functions of a vector finite element in reference space at the g...
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 CalcVShape(const IntegrationPoint &ip, DenseMatrix &shape) const
Evaluate the values of all shape functions of a vector finite element in reference space at the given...
virtual void CalcVShape(const IntegrationPoint &ip, DenseMatrix &shape) const
Evaluate the values of all shape functions of a vector finite element in reference space at the given...
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
virtual void CalcVShape(const IntegrationPoint &ip, DenseMatrix &shape) const
Evaluate the values of all shape functions of a vector finite element in reference space at the given...
virtual void SetMapType(int M)
Set the FiniteElement::MapType of the element to either VALUE or INTEGRAL. Also sets the FiniteElemen...
RT_R1D_SegmentElement(const int p, const int cb_type=BasisType::GaussLobatto, const int ob_type=BasisType::GaussLegendre)
Construct the RT_R1D_SegmentElement of order p and closed and open BasisType cb_type and ob_type...
virtual void CalcVShape(const IntegrationPoint &ip, DenseMatrix &shape) const
Evaluate the values of all shape functions of a vector finite element in reference space at the given...
void MultTranspose(const double *x, double *y) const
Multiply a vector with the transpose matrix.
RT_R2D_FiniteElement(int p, Geometry::Type G, int Do, const double *nk_fe)
virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const =0
Evaluate the values of all shape functions of a scalar finite element in reference space at the given...
virtual void CalcVShape(const IntegrationPoint &ip, DenseMatrix &shape) const
Evaluate the values of all shape functions of a vector 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...
void Set2(const double x1, const double x2)
int GetVDim()
Returns dimension of the vector.
virtual void CalcDivShape(const IntegrationPoint &ip, Vector &divshape) const
Evaluate the divergence of all shape functions of a vector finite element in reference space at the g...
const double * OpenPoints(const int p, const int btype=BasisType::GaussLegendre)
Get coordinates of an open (GaussLegendre) set of points if degree p.
virtual void CalcDivShape(const IntegrationPoint &ip, Vector &divshape) const
Evaluate the divergence of all shape functions of a vector finite element in reference space at the g...
virtual void CalcDivShape(const IntegrationPoint &ip, Vector &divshape) const
Evaluate the divergence of all shape functions of a vector finite element in reference space at the g...
void EvalIntegrated(const Vector &d, Vector &i) const
Evaluate the "integrated" basis type using pre-computed closed basis derivatives. ...
void Threshold(double eps)
Replace small entries, abs(a_ij) <= eps, with zero.
RT_R2D_TriangleElement(const int p)
Construct the RT_R2D_TriangleElement of order p.
void Set3(const double x1, const double x2, const double x3)
virtual void Project(VectorCoefficient &vc, ElementTransformation &Trans, Vector &dofs) const
Given a vector coefficient and a transformation, compute its projection (approximation) in the local ...
double p(const Vector &x, double t)
RT_R2D_QuadrilateralElement(const int p, const int cb_type=BasisType::GaussLobatto, const int ob_type=BasisType::GaussLegendre)
Construct the RT_QuadrilateralElement of order p and closed and open BasisType cb_type and ob_type...
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
RT_R2D_SegmentElement(const int p, const int ob_type=BasisType::GaussLegendre)
Construct the RT_R2D_SegmentElement of order p and open BasisType ob_type.
int GetDof() const
Returns the number of degrees of freedom in the finite element.
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
Class for integration point with weight.
virtual void CalcDivShape(const IntegrationPoint &ip, Vector &divshape) const
Evaluate the divergence of all shape functions of a vector finite element in reference space at the g...
int dof
Number of degrees of freedom.
int GetVDim() const
Returns the vector dimension for vector-valued finite elements.
virtual void ProjectCurl(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &curl) const
Compute the discrete curl matrix from the given FiniteElement onto 'this' FiniteElement. The ElementTransformation is included to support cases when the matrix depends on it.
RT_TetrahedronElement(const int p)
Construct the RT_TetrahedronElement of order p.
virtual void CalcVShape(const IntegrationPoint &ip, DenseMatrix &shape) const
Evaluate the values of all shape functions of a vector finite element in reference space at the given...
int GetMapType() const
Returns the FiniteElement::MapType of the element describing how reference functions are mapped to ph...
double infinity()
Define a shortcut for std::numeric_limits<double>::infinity()
RT_TriangleElement(const int p)
Construct the RT_TriangleElement of order p.
virtual void CalcDivShape(const IntegrationPoint &ip, Vector &divshape) const
Evaluate the divergence of all shape functions of a vector finite element in reference space at the g...
void InvertLinearTrans(ElementTransformation &trans, const IntegrationPoint &pt, Vector &x)
int GetRangeType() const
Returns the FiniteElement::RangeType of the element, one of {SCALAR, VECTOR}.
virtual void CalcVShape(const IntegrationPoint &ip, DenseMatrix &shape) const
Evaluate the values of all shape functions of a vector finite element in reference space at the given...
static bool CheckPoint(int GeomType, const IntegrationPoint &ip)
Check if the given point is inside the given reference element.
Describes the function space on each element.
virtual void Project(VectorCoefficient &vc, ElementTransformation &Trans, Vector &dofs) const
Given a vector coefficient and a transformation, compute its projection (approximation) in the local ...
RT_HexahedronElement(const int p, const int cb_type=BasisType::GaussLobatto, const int ob_type=BasisType::GaussLegendre)
Construct the RT_HexahedronElement of order p and closed and open BasisType cb_type and ob_type...
void ProjectIntegrated(VectorCoefficient &vc, ElementTransformation &Trans, Vector &dofs) const
double u(const Vector &xvec)
void ProjectIntegrated(VectorCoefficient &vc, ElementTransformation &Trans, Vector &dofs) const
void SetSize(int s)
Change the size of the DenseMatrix to s x s.
RT_QuadrilateralElement(const int p, const int cb_type=BasisType::GaussLobatto, const int ob_type=BasisType::GaussLegendre)
Construct the RT_QuadrilateralElement of order p and closed and open BasisType cb_type and ob_type...
const IntegrationRule & GetNodes() const
Get a const reference to the nodes of the element.
int order
Order/degree of the shape functions.
virtual void CalcDivShape(const IntegrationPoint &ip, Vector &divshape) const
Evaluate the divergence of all shape functions of a vector finite element in reference space at the g...