39 int nb_gauss_pts = pts.size2();
42 auto &ptr = data.getBBAlphaIndicesSharedPtr(
field_name);
56 auto &ptr = data.getBBDiffNSharedPtr(
field_name);
62 auto get_alpha_by_name_ptr =
64 const std::string &
field_name) -> boost::shared_ptr<MatrixInt> & {
65 return data.getBBAlphaIndicesSharedPtr(
field_name);
68 auto get_base_by_name_ptr =
70 const std::string &
field_name) -> boost::shared_ptr<MatrixDouble> & {
74 auto get_diff_base_by_name_ptr =
76 const std::string &
field_name) -> boost::shared_ptr<MatrixDouble> & {
80 auto get_alpha_by_order_ptr =
81 [](
auto &data,
const size_t o) -> boost::shared_ptr<MatrixInt> & {
82 return data.getBBAlphaIndicesByOrderSharedPtr(o);
85 auto get_base_by_order_ptr =
86 [](
auto &data,
const size_t o) -> boost::shared_ptr<MatrixDouble> & {
87 return data.getBBNByOrderSharedPtr(o);
90 auto get_diff_base_by_order_ptr =
91 [](
auto &data,
const size_t o) -> boost::shared_ptr<MatrixDouble> & {
92 return data.getBBDiffNByOrderSharedPtr(o);
96 auto &vert_get_diff_n = get_diff_base(data.
dataOnEntities[MBVERTEX][0]);
97 vert_get_n.resize(nb_gauss_pts, 3,
false);
98 vert_get_diff_n.resize(nb_gauss_pts, 6,
false);
101 (
unsigned int)nb_gauss_pts)
103 "Base functions or nodes has wrong number of integration points "
109 vertex_alpha.resize(3, 3,
false);
110 vertex_alpha.clear();
111 for (
int n = 0;
n != 3; ++
n)
115 1,
lambda.size1(), vertex_alpha.size1(), &vertex_alpha(0, 0),
117 &vert_get_diff_n(0, 0));
118 for (
int n = 0;
n != 3; ++
n) {
119 const int f = boost::math::factorial<double>(
121 for (
int g = 0;
g != nb_gauss_pts; ++
g) {
122 vert_get_n(
g,
n) *=
f;
123 for (
int d = 0;
d != 2; ++
d)
124 vert_get_diff_n(
g, 2 *
n +
d) *=
f;
132 "Wrong size of ent data");
134 constexpr
int edges_nodes[3][2] = {{0, 1}, {1, 2}, {2, 0}};
135 for (
int ee = 0; ee != 3; ++ee) {
138 if (ent_data.getSense() == 0)
140 "Sense of the edge unknown");
142 const int sense = ent_data.getSense();
143 const int order = ent_data.getOrder();
144 const int nb_dofs =
NBEDGE_H1(ent_data.getOrder());
147 if (get_alpha_by_order_ptr(ent_data,
order)) {
149 get_alpha_by_order_ptr(ent_data,
order);
151 get_base_by_order_ptr(ent_data,
order);
152 get_diff_base_by_name_ptr(ent_data,
field_name) =
153 get_diff_base_by_order_ptr(ent_data,
order);
155 auto &get_n = get_base(ent_data);
156 auto &get_diff_n = get_diff_base(ent_data);
157 get_n.resize(nb_gauss_pts, nb_dofs,
false);
158 get_diff_n.resize(nb_gauss_pts, 2 * nb_dofs,
false);
161 edge_alpha.resize(nb_dofs, 3,
false);
165 for (
int i = 0;
i != edge_alpha.size1(); ++
i) {
166 int a = edge_alpha(
i, edges_nodes[ee][0]);
167 edge_alpha(
i, edges_nodes[ee][0]) =
168 edge_alpha(
i, edges_nodes[ee][1]);
169 edge_alpha(
i, edges_nodes[ee][1]) =
a;
173 order,
lambda.size1(), edge_alpha.size1(), &edge_alpha(0, 0),
177 get_alpha_by_order_ptr(ent_data,
order) =
179 get_base_by_order_ptr(ent_data,
order) =
181 get_diff_base_by_order_ptr(ent_data,
order) =
182 get_diff_base_by_name_ptr(ent_data,
field_name);
187 for (
int ee = 0; ee != 3; ++ee) {
189 ent_data.getBBAlphaIndicesSharedPtr(
field_name).reset();
190 auto &get_n = get_base(ent_data);
191 auto &get_diff_n = get_diff_base(ent_data);
192 get_n.resize(nb_gauss_pts, 0,
false);
193 get_diff_n.resize(nb_gauss_pts, 0,
false);
200 "Wrong size ent of ent data");
203 const int order = ent_data.getOrder();
205 if (get_alpha_by_order_ptr(ent_data,
order)) {
207 get_alpha_by_order_ptr(ent_data,
order);
209 get_base_by_order_ptr(ent_data,
order);
210 get_diff_base_by_name_ptr(ent_data,
field_name) =
211 get_diff_base_by_order_ptr(ent_data,
order);
214 auto &get_n = get_base(ent_data);
215 auto &get_diff_n = get_diff_base(ent_data);
216 get_n.resize(nb_gauss_pts, nb_dofs,
false);
217 get_diff_n.resize(nb_gauss_pts, 2 * nb_dofs,
false);
219 auto &tri_alpha = get_alpha(ent_data);
220 tri_alpha.resize(nb_dofs, 3,
false);
224 order,
lambda.size1(), tri_alpha.size1(), &tri_alpha(0, 0),
228 get_alpha_by_order_ptr(ent_data,
order) =
230 get_base_by_order_ptr(ent_data,
order) =
232 get_diff_base_by_order_ptr(ent_data,
order) =
233 get_diff_base_by_name_ptr(ent_data,
field_name);
238 ent_data.getBBAlphaIndicesSharedPtr(
field_name).reset();
239 auto &get_n = get_base(ent_data);
240 auto &get_diff_n = get_diff_base(ent_data);
241 get_n.resize(nb_gauss_pts, 0,
false);
242 get_diff_n.resize(nb_gauss_pts, 0,
false);
256 "Polynomial type not set");
258 PetscErrorCode (*base_polynomials)(
int p,
double s,
double *diff_s,
double *
L,
259 double *diffL,
const int dim) =
262 int nb_gauss_pts = pts.size2();
268 "expected size of data.dataOnEntities[MBEDGE] is 3");
270 int sense[3],
order[3];
271 double *H1edgeN[3], *diffH1edgeN[3];
272 for (
int ee = 0; ee < 3; ee++) {
276 "sense of the edge unknown");
281 data.
dataOnEntities[MBEDGE][ee].getN(base).resize(nb_gauss_pts, nb_dofs,
283 data.
dataOnEntities[MBEDGE][ee].getDiffN(base).resize(nb_gauss_pts,
285 H1edgeN[ee] = &*data.
dataOnEntities[MBEDGE][ee].getN(base).data().begin();
293 H1edgeN, diffH1edgeN, nb_gauss_pts, base_polynomials);
300 "expected that size data.dataOnEntities[MBTRI] is one");
304 data.
dataOnEntities[MBTRI][0].getN(base).resize(nb_gauss_pts, nb_dofs,
308 const int face_nodes[] = {0, 1, 2};
315 nb_gauss_pts, base_polynomials);
347 "Polynomial type not set");
348 PetscErrorCode (*base_polynomials)(
int p,
double s,
double *diff_s,
double *
L,
349 double *diffL,
const int dim) =
352 int nb_gauss_pts = pts.size2();
367 nb_gauss_pts, base_polynomials);
378 int nb_gauss_pts = pts.size2();
381 auto &ptr = data.getBBAlphaIndicesSharedPtr(
field_name);
395 auto &ptr = data.getBBDiffNSharedPtr(
field_name);
401 auto get_alpha_by_name_ptr =
403 const std::string &
field_name) -> boost::shared_ptr<MatrixInt> & {
404 return data.getBBAlphaIndicesSharedPtr(
field_name);
407 auto get_base_by_name_ptr =
409 const std::string &
field_name) -> boost::shared_ptr<MatrixDouble> & {
413 auto get_diff_base_by_name_ptr =
415 const std::string &
field_name) -> boost::shared_ptr<MatrixDouble> & {
419 auto get_alpha_by_order_ptr =
420 [](
auto &data,
const size_t o) -> boost::shared_ptr<MatrixInt> & {
421 return data.getBBAlphaIndicesByOrderSharedPtr(o);
424 auto get_base_by_order_ptr =
425 [](
auto &data,
const size_t o) -> boost::shared_ptr<MatrixDouble> & {
426 return data.getBBNByOrderSharedPtr(o);
429 auto get_diff_base_by_order_ptr =
430 [](
auto &data,
const size_t o) -> boost::shared_ptr<MatrixDouble> & {
431 return data.getBBDiffNByOrderSharedPtr(o);
437 "Wrong size ent of ent data");
440 (
unsigned int)nb_gauss_pts)
442 "Base functions or nodes has wrong number of integration points "
448 const int order = ent_data.getOrder();
451 if (get_alpha_by_order_ptr(ent_data,
order)) {
453 get_alpha_by_order_ptr(ent_data,
order);
455 get_base_by_order_ptr(ent_data,
order);
456 get_diff_base_by_name_ptr(ent_data,
field_name) =
457 get_diff_base_by_order_ptr(ent_data,
order);
460 auto &get_n = get_base(ent_data);
461 auto &get_diff_n = get_diff_base(ent_data);
462 get_n.resize(nb_gauss_pts, nb_dofs,
false);
463 get_diff_n.resize(nb_gauss_pts, 2 * nb_dofs,
false);
470 "Inconsistent number of DOFs");
472 auto &tri_alpha = get_alpha(ent_data);
481 "Inconsistent number of DOFs");
483 auto &tri_alpha = get_alpha(ent_data);
484 tri_alpha.resize(nb_dofs, 3,
false);
491 std::array<int *, 3> face_edge_ptr{
495 face_n.data(), face_edge_ptr.data());
501 order,
lambda.size1(), tri_alpha.size1(), &tri_alpha(0, 0),
506 get_alpha_by_order_ptr(ent_data,
order) =
508 get_base_by_order_ptr(ent_data,
order) =
510 get_diff_base_by_order_ptr(ent_data,
order) =
511 get_diff_base_by_name_ptr(ent_data,
field_name);
516 ent_data.getBBAlphaIndicesSharedPtr(
field_name).reset();
517 auto &get_n = get_base(ent_data);
518 auto &get_diff_n = get_diff_base(ent_data);
519 get_n.resize(nb_gauss_pts, 0,
false);
520 get_diff_n.resize(nb_gauss_pts, 0,
false);
533 "Polynomial type not set");
534 PetscErrorCode (*base_polynomials)(
int p,
double s,
double *diff_s,
double *
L,
535 double *diffL,
const int dim) =
538 int nb_gauss_pts = pts.size2();
546 auto nb_dofs_on_face =
551 if (nb_dofs_on_face) {
555 for (
int ee = 0; ee < 3; ee++) {
556 N_face_edge(0, ee).resize(nb_gauss_pts, 3 * face_edge_dofs,
false);
561 N_face_bubble[0].resize(nb_gauss_pts, 3 * face_bubble_dofs,
false);
564 int face_nodes[3] = {0, 1, 2};
569 &data.
dataOnEntities[MBVERTEX][0].getN(base)(0, 0), NULL, phi_f_e,
570 NULL, nb_gauss_pts, 3, base_polynomials);
571 if (face_bubble_dofs)
575 &data.
dataOnEntities[MBVERTEX][0].getN(base)(0, 0), NULL, phi_f, NULL,
576 nb_gauss_pts, 3, base_polynomials);
585 for (
int oo = 0; oo < face_order; oo++) {
586 for (
int ee = 0; ee < 3; ee++) {
594 for (
int gg = 0; gg < nb_gauss_pts; gg++) {
607 for (
int gg = 0; gg < nb_gauss_pts; gg++) {
629 "This should be used only with DEMKOWICZ_JACOBI_BASE "
634 int nb_gauss_pts = pts.size2();
637 double *phi_f = &*data.
dataOnEntities[MBTRI][0].getN(base).data().begin();
640 int face_nodes[3] = {0, 1, 2};
644 &*data.
dataOnEntities[MBVERTEX][0].getDiffN(base).data().begin(), phi_f,
645 NULL, nb_gauss_pts, 3);
675 PetscErrorCode (*base_polynomials)(
int p,
double s,
double *diff_s,
double *
L,
676 double *diffL,
const int dim) =
679 int nb_gauss_pts = pts.size2();
686 int sense[3],
order[3];
687 double *hcurl_edge_n[3];
688 double *diff_hcurl_edge_n[3];
689 for (
int ee = 0; ee < 3; ee++) {
692 "data inconsistency");
701 nb_gauss_pts, 2 * 3 * nb_dofs,
false);
704 diff_hcurl_edge_n[ee] =
711 hcurl_edge_n, diff_hcurl_edge_n, nb_gauss_pts, base_polynomials);
713 for (
int ee = 0; ee < 3; ee++) {
714 data.
dataOnEntities[MBEDGE][ee].getN(base).resize(nb_gauss_pts, 0,
false);
715 data.
dataOnEntities[MBEDGE][ee].getDiffN(base).resize(nb_gauss_pts, 0,
731 data.
dataOnEntities[MBTRI][0].getN(base).resize(nb_gauss_pts, 3 * nb_dofs,
734 3 * 2 * nb_dofs,
false);
736 int face_nodes[] = {0, 1, 2};
743 nb_gauss_pts, base_polynomials);
746 data.
dataOnEntities[MBTRI][0].getN(base).resize(nb_gauss_pts, 0,
false);
747 data.
dataOnEntities[MBTRI][0].getDiffN(base).resize(nb_gauss_pts, 0,
false);
762 PetscErrorCode (*base_polynomials)(
int p,
double s,
double *diff_s,
double *
L,
763 double *diffL,
const int dim) =
766 int nb_gauss_pts = pts.size2();
780 int nb_dofs = 3 * nb_edge_dofs + nb_dofs_face;
781 data.
dataOnEntities[MBTRI][0].getN(base).resize(nb_gauss_pts, 3 * nb_dofs,
784 3 * 2 * nb_dofs,
false);
791 MatrixDouble(nb_gauss_pts, 3 * 2 * nb_edge_dofs,
false),
792 MatrixDouble(nb_gauss_pts, 3 * 2 * nb_edge_dofs,
false),
793 MatrixDouble(nb_gauss_pts, 3 * 2 * nb_edge_dofs,
false)};
795 std::array<double *, 3>
phi{&*edge_bases[0].data().begin(),
796 &*edge_bases[1].data().begin(),
797 &*edge_bases[2].data().begin()};
798 std::array<double *, 3> diff_phi{&*diff_edge_bases[0].data().begin(),
799 &*diff_edge_bases[1].data().begin(),
800 &*diff_edge_bases[2].data().begin()};
803 std::array<int, 3> edge_sense{1, 1, 1};
805 edge_sense.data(), edge_order.data(),
808 phi.data(), diff_phi.data(), nb_gauss_pts, base_polynomials);
810 MatrixDouble face_bases(nb_gauss_pts, 3 * nb_dofs_face,
false);
811 MatrixDouble diff_face_bases(nb_gauss_pts, 3 * 2 * nb_dofs_face,
false);
812 int face_nodes[] = {0, 1, 2};
817 &*face_bases.data().begin(), &*diff_face_bases.data().begin(),
818 nb_gauss_pts, base_polynomials);
822 getFTensor1FromPtr<3>(&*edge_bases[0].data().begin()),
823 getFTensor1FromPtr<3>(&*edge_bases[1].data().begin()),
824 getFTensor1FromPtr<3>(&*edge_bases[2].data().begin())};
831 auto t_vol_base = getFTensor1FromPtr<3>(&*face_bases.data().begin());
832 auto t_vol_diff_base =
835 auto t_base = getFTensor1FromPtr<3>(
843 for (
int gg = 0; gg != nb_gauss_pts; gg++) {
844 for (
int oo = 0; oo <
order; oo++) {
848 for (
int ee = 0; ee != 3; ++ee) {
849 t_base(
i) = t_edge_base[ee](
i);
852 t_diff_base(
i,
j) = t_edge_diff_base[ee](
i,
j);
854 ++t_edge_diff_base[ee];
860 t_base(
i) = t_vol_base(
i);
863 t_diff_base(
i,
j) = t_vol_diff_base(
i,
j);
871 data.
dataOnEntities[MBTRI][0].getN(base).resize(nb_gauss_pts, 0,
false);
872 data.
dataOnEntities[MBTRI][0].getDiffN(base).resize(nb_gauss_pts, 0,
false);
885 int nb_gauss_pts = pts.size2();
893 "wrong number of data structures on edges, should be three but is %d",
896 int sense[3],
order[3];
897 double *hcurl_edge_n[3];
898 double *diff_hcurl_edge_n[3];
900 for (
int ee = 0; ee != 3; ++ee) {
904 "orientation (sense) of edge is not set");
913 nb_gauss_pts, 2 * 3 * nb_dofs,
false);
917 diff_hcurl_edge_n[ee] =
925 hcurl_edge_n, diff_hcurl_edge_n, nb_gauss_pts);
931 for (
int ee = 0; ee != 3; ++ee) {
932 data.
dataOnEntities[MBEDGE][ee].getN(base).resize(nb_gauss_pts, 0,
false);
933 data.
dataOnEntities[MBEDGE][ee].getDiffN(base).resize(nb_gauss_pts, 0,
943 "No data struture to keep base functions on face");
947 data.
dataOnEntities[MBTRI][0].getN(base).resize(nb_gauss_pts, 3 * nb_dofs,
950 3 * 2 * nb_dofs,
false);
952 int face_nodes[] = {0, 1, 2};
965 data.
dataOnEntities[MBTRI][0].getN(base).resize(nb_gauss_pts, 0,
false);
966 data.
dataOnEntities[MBTRI][0].getDiffN(base).resize(nb_gauss_pts, 0,
false);
979 int nb_gauss_pts = pts.size2();
986 "No data struture to keep base functions on face");
991 int nb_dofs = 3 * nb_edge_dofs + nb_volume_dofs;
992 data.
dataOnEntities[MBTRI][0].getN(base).resize(nb_gauss_pts, 3 * nb_dofs,
995 3 * 2 * nb_dofs,
false);
1002 MatrixDouble(nb_gauss_pts, 3 * 2 * nb_edge_dofs,
false),
1003 MatrixDouble(nb_gauss_pts, 3 * 2 * nb_edge_dofs,
false),
1004 MatrixDouble(nb_gauss_pts, 3 * 2 * nb_edge_dofs,
false)};
1007 std::array<int, 3> edge_sense{1, 1, 1};
1008 std::array<double *, 3>
phi{&*edge_bases[0].data().begin(),
1009 &*edge_bases[1].data().begin(),
1010 &*edge_bases[2].data().begin()};
1011 std::array<double *, 3> diff_phi{&*diff_edge_bases[0].data().begin(),
1012 &*diff_edge_bases[1].data().begin(),
1013 &*diff_edge_bases[2].data().begin()};
1015 edge_sense.data(), edge_order.data(),
1017 &*data.
dataOnEntities[MBVERTEX][0].getDiffN(base).data().begin(),
1018 phi.data(), diff_phi.data(), nb_gauss_pts);
1020 MatrixDouble face_bases(nb_gauss_pts, 3 * nb_volume_dofs,
false);
1021 MatrixDouble diff_face_bases(nb_gauss_pts, 3 * 2 * nb_volume_dofs,
false);
1022 int face_nodes[] = {0, 1, 2};
1026 &*data.
dataOnEntities[MBVERTEX][0].getDiffN(base).data().begin(),
1027 &*face_bases.data().begin(), &*diff_face_bases.data().begin(),
1032 getFTensor1FromPtr<3>(&*edge_bases[0].data().begin()),
1033 getFTensor1FromPtr<3>(&*edge_bases[1].data().begin()),
1034 getFTensor1FromPtr<3>(&*edge_bases[2].data().begin())};
1040 auto t_vol_base = getFTensor1FromPtr<3>(&*face_bases.data().begin());
1041 auto t_vol_diff_base =
1044 auto t_base = getFTensor1FromPtr<3>(
1053 for (
int gg = 0; gg != nb_gauss_pts; gg++) {
1054 for (
int oo = 0; oo <
order; oo++) {
1058 for (
int ee = 0; ee != 3; ++ee) {
1059 t_base(
i) = t_edge_base[ee](
i);
1062 t_diff_base(
i,
j) = t_edge_diff_base[ee](
i,
j);
1064 ++t_edge_diff_base[ee];
1070 t_base(
i) = t_vol_base(
i);
1073 t_diff_base(
i,
j) = t_vol_diff_base(
i,
j);
1084 data.
dataOnEntities[MBTRI][0].getN(base).resize(nb_gauss_pts, 0,
false);
1085 data.
dataOnEntities[MBTRI][0].getDiffN(base).resize(nb_gauss_pts, 0,
false);
1131 boost::shared_ptr<BaseFunctionCtx> ctx_ptr) {
1136 int nb_gauss_pts = pts.size2();
1137 if (!nb_gauss_pts) {
1141 if (pts.size1() < 2)
1144 "Wrong dimension of pts, should be at least 3 rows with coordinates");
1151 data.
dataOnEntities[MBVERTEX][0].getN(base).resize(nb_gauss_pts, 3,
1155 &pts(0, 0), &pts(1, 0), nb_gauss_pts);
1156 data.
dataOnEntities[MBVERTEX][0].getDiffN(base).resize(3, 2,
false);
1158 &*data.
dataOnEntities[MBVERTEX][0].getDiffN(base).data().begin());
1166 (
unsigned int)nb_gauss_pts) {
1168 "Base functions or nodes has wrong number of integration points "
1173 auto set_node_derivative_for_all_gauss_pts = [&]() {
1178 data.
dataOnEntities[MBVERTEX][0].getDiffN(base).resize(nb_gauss_pts, 6,
1180 for (
int gg = 0; gg != nb_gauss_pts; ++gg)
1187 CHKERR set_node_derivative_for_all_gauss_pts();
1236 switch (continuity) {
1251 "Unknown (or not implemented) continuity");
1265 auto set_ainsworth = [&dofs_side_map]() {
1268 dofs_side_map.clear();
1276 for (
int ee = 0; ee != 3; ++ee) {
1292 auto set_demkowicz = [&dofs_side_map]() {
1295 dofs_side_map.clear();
1303 for (
int ee = 0; ee != 3; ++ee) {
1319 switch (continuity) {
1324 return set_ainsworth();
1326 return set_demkowicz();
1334 "Unknown (or not implemented) continuity");