8 static char help[] =
"testing interface inserting algorithm\n\n";
12 for (
unsigned int ii = 0; ii <
m.size1(); ii++) {
13 for (
unsigned int jj = 0; jj <
m.size2(); jj++) {
20 int main(
int argc,
char *argv[]) {
35 INTEGRATEDJACOBIPOLYNOMIAL,
37 H1TET_BERNSTEIN_BEZIER,
44 H1TRI_BERNSTEIN_BEZIER,
52 H1EDGE_BERNSTEIN_BEZIER,
61 const char *list[] = {
"legendre",
66 "h1tet_bernstein_bezier",
73 "h1tri_bernstein_bezier",
81 "h1edge_bernstein_bezier",
82 "hcurledge_ainsworth",
83 "hcurledge_demkowicz",
89 PetscInt choice_value = LEGENDREPOLYNOMIAL;
93 if (flg != PETSC_TRUE) {
102 boost::shared_ptr<MatrixDouble> base_ptr(
new MatrixDouble);
103 boost::shared_ptr<MatrixDouble> diff_base_ptr(
new MatrixDouble);
105 const double eps = 1e-3;
107 if (choice_value == LEGENDREPOLYNOMIAL) {
111 4, &diff_s, 1, base_ptr, diff_base_ptr)));
114 std::cout <<
"LegendrePolynomial\n";
115 std::cout << pts_1d << std::endl;
116 std::cout << *base_ptr << std::endl;
117 std::cout << *diff_base_ptr << std::endl;
120 std::cout << sum << std::endl;
121 std::cout << diff_sum << std::endl;
122 if (fabs(2.04688 - sum) >
eps) {
125 if (fabs(2.25 - diff_sum) >
eps) {
130 pts_1d.resize(1, 11,
false);
131 for (
int ii = 0; ii != 11; ii++) {
132 pts_1d(0, ii) = 2 * ((
double)ii / 10) - 1;
135 boost::shared_ptr<MatrixDouble> kernel_base_ptr(
new MatrixDouble);
136 boost::shared_ptr<MatrixDouble> diff_kernel_base_ptr(
new MatrixDouble);
138 if (choice_value == LOBATTOPOLYNOMIAL) {
142 7 + 2, &diff_s, 1, base_ptr, diff_base_ptr)));
147 7, &diff_s, 1, kernel_base_ptr, diff_kernel_base_ptr)));
149 for (
int ii = 0; ii != 11; ii++) {
150 double s = pts_1d(0, ii);
151 std::cerr <<
"lobatto_plot " << s <<
" " << (*base_ptr)(ii, 1) <<
" "
152 << (*diff_base_ptr)(ii, 1) <<
" " << (*kernel_base_ptr)(ii, 1)
153 <<
" " << (*diff_kernel_base_ptr)(ii, 1) <<
" "
154 << (*kernel_base_ptr)(ii, 1) * (1 - s * s) <<
" "
155 << (*kernel_base_ptr)(ii, 1) * (-2 * s) +
156 (*diff_kernel_base_ptr)(ii, 1) * (1 - s * s)
159 std::cout <<
"LobattoPolynomial\n";
160 std::cout << pts_1d << std::endl;
161 std::cout << *base_ptr << std::endl;
162 std::cout << *diff_base_ptr << std::endl;
166 std::cout << sum << std::endl;
167 std::cout << diff_sum << std::endl;
168 if (fabs(9.39466 - sum) >
eps) {
171 if (fabs(14.0774 - diff_sum) >
eps) {
177 double diff_sum =
sum_matrix(*diff_kernel_base_ptr);
178 std::cout << sum << std::endl;
179 std::cout << diff_sum << std::endl;
180 if (fabs(-13.9906 * 4 - sum) >
eps) {
183 if (fabs(-101.678 * 4 - diff_sum) >
eps) {
189 if (choice_value == JACOBIPOLYNOMIAL) {
193 pts_1d.resize(1,
n,
false);
195 for (
int ii = 0; ii !=
n; ii++) {
196 pts_1d(0, ii) = (
double)ii / (
n - 1);
201 diff_base_ptr->clear();
208 5, &diff_x, &diff_t, 1, 0, base_ptr, diff_base_ptr)));
210 for (
int ii = 0; ii !=
n; ii++) {
211 double s = pts_1d(0, ii);
212 std::cerr <<
"jacobi_plot " << s <<
" " << (*base_ptr)(ii, 4) <<
" "
213 << (*diff_base_ptr)(ii, 4) << std::endl;
215 for (
int ii = 0; ii !=
n - 1; ii++) {
216 double s = (pts_1d(0, ii) + pts_1d(0, ii + 1)) / 2;
217 std::cerr <<
"jacobi_diff_plot_fd " << s <<
" "
218 << ((*base_ptr)(ii + 1, 4) - (*base_ptr)(ii, 4)) /
222 std::cout <<
"JacobiPolynomial\n";
223 std::cout << pts_1d << std::endl;
224 std::cout << *base_ptr << std::endl;
225 std::cout << *diff_base_ptr << std::endl;
229 std::cout << sum << std::endl;
230 std::cout << diff_sum << std::endl;
231 if (fabs(23.2164 - sum) >
eps) {
234 if (fabs(167.995 - diff_sum) >
eps) {
240 if (choice_value == INTEGRATEDJACOBIPOLYNOMIAL) {
244 pts_1d.resize(1,
n,
false);
246 for (
int ii = 0; ii !=
n; ii++) {
247 pts_1d(0, ii) = (
double)ii / 20.;
248 pts_1d_t(0, ii) = 1 - pts_1d(0, ii);
252 diff_base_ptr->clear();
259 6, &diff_x, &diff_t, 1, 1, base_ptr, diff_base_ptr)));
261 for (
int ii = 0; ii !=
n; ii++) {
262 double s = pts_1d(0, ii);
263 std::cerr <<
"integrated_jacobi_plot " << s <<
" " << (
double)ii / 20.
264 <<
" " << (*base_ptr)(ii, 1) <<
" " << (*base_ptr)(ii, 2)
265 <<
" " << (*base_ptr)(ii, 3) <<
" " << (*base_ptr)(ii, 4)
266 <<
" " << (*base_ptr)(ii, 5) << endl;
270 std::cout <<
"IntegratedJacobiPolynomial\n";
271 std::cout << pts_1d << std::endl;
272 std::cout << *base_ptr << std::endl;
273 std::cout << *diff_base_ptr << std::endl;
277 std::cout << sum << std::endl;
278 std::cout << diff_sum << std::endl;
298 for (
int ee = 0; ee < 6; ee++) {
303 for (
int ff = 0; ff < 4; ff++) {
309 tet_data.
dataOnEntities[MBVERTEX][0].getBBNodeOrder().resize(4,
false);
310 std::fill(tet_data.
dataOnEntities[MBVERTEX][0].getBBNodeOrder().begin(),
316 pts_tet.resize(3, nb_gauss_pts,
false);
317 cblas_dcopy(nb_gauss_pts, &
QUAD_3D_TABLE[tet_rule]->points[1], 4,
319 cblas_dcopy(nb_gauss_pts, &
QUAD_3D_TABLE[tet_rule]->points[2], 4,
321 cblas_dcopy(nb_gauss_pts, &
QUAD_3D_TABLE[tet_rule]->points[3], 4,
328 cblas_dcopy(4 * nb_gauss_pts,
QUAD_3D_TABLE[tet_rule]->points, 1,
332 const int cannonical_tet_face[4][3] = {
333 {0, 1, 3}, {1, 2, 3}, {0, 3, 2}, {0, 2, 1}};
334 for (
int ff = 0; ff < 4; ff++) {
335 for (
int nn = 0; nn < 3; nn++) {
336 tet_data.
facesNodes(ff, nn) = cannonical_tet_face[ff][nn];
340 if (choice_value == H1TET_AINSWORTH) {
346 &pts_tet(0, 0), &pts_tet(1, 0), &pts_tet(2, 0), nb_gauss_pts);
359 "Different pointers");
362 double sum = 0, diff_sum = 0;
363 std::cout <<
"Edges\n";
364 for (
int ee = 0; ee < 6; ee++) {
376 std::cout <<
"Faces\n";
377 for (
int ff = 0; ff < 4; ff++) {
389 std::cout <<
"Tets\n";
400 std::cout <<
"sum " << sum << std::endl;
401 std::cout <<
"diff_sum " << diff_sum << std::endl;
402 if (fabs(1.3509 - sum) >
eps) {
405 if (fabs(0.233313 - diff_sum) >
eps) {
410 if (choice_value == H1TET_BERNSTEIN_BEZIER) {
416 &pts_tet(0, 0), &pts_tet(1, 0), &pts_tet(2, 0), nb_gauss_pts);
427 double sum = 0, diff_sum = 0;
428 std::cout <<
"Vertices\n";
429 std::cout << tet_data.
dataOnEntities[MBVERTEX][0].getN(
"TEST_FIELD")
431 std::cout << tet_data.
dataOnEntities[MBVERTEX][0].getDiffN(
"TEST_FIELD")
437 std::cout <<
"Edges\n";
438 for (
int ee = 0; ee < 6; ee++) {
439 std::cout << tet_data.
dataOnEntities[MBEDGE][ee].getN(
"TEST_FIELD")
441 std::cout << tet_data.
dataOnEntities[MBEDGE][ee].getDiffN(
"TEST_FIELD")
448 std::cout <<
"Faces\n";
449 for (
int ff = 0; ff < 4; ff++) {
450 std::cout << tet_data.
dataOnEntities[MBTRI][ff].getN(
"TEST_FIELD")
452 std::cout << tet_data.
dataOnEntities[MBTRI][ff].getDiffN(
"TEST_FIELD")
459 std::cout <<
"Tets\n";
462 std::cout << tet_data.
dataOnEntities[MBTET][0].getDiffN(
"TEST_FIELD")
467 std::cout <<
"sum " << sum << std::endl;
468 std::cout <<
"diff_sum " << diff_sum << std::endl;
469 if (fabs(4.38395 - sum) >
eps) {
472 if (fabs(diff_sum) >
eps) {
477 if (choice_value == HDIVTET_AINSWORTH) {
482 double sum = 0, diff_sum = 0;
483 std::cout <<
"Faces\n";
484 for (
int ff = 0; ff < 4; ff++) {
496 std::cout <<
"Tets\n";
507 std::cout <<
"sum " << 1e8 * sum << std::endl;
508 std::cout <<
"diff_sum " << 1e8 * diff_sum << std::endl;
509 if (fabs(0.188636 - sum) >
eps) {
512 if (fabs(32.9562 - diff_sum) >
eps) {
517 if (choice_value == HDIVTET_DEMKOWICZ) {
522 double sum = 0, diff_sum = 0;
523 std::cout <<
"Faces\n";
524 for (
int ff = 0; ff < 4; ff++) {
536 std::cout <<
"Tets\n";
546 std::cout <<
"sum " << sum << std::endl;
547 std::cout <<
"diff_sum " << diff_sum << std::endl;
548 const double expected_result = -2.70651;
549 const double expected_diff_result = 289.421;
550 if (fabs((expected_result - sum) / expected_result) >
eps) {
553 if (fabs((expected_diff_result - diff_sum) / expected_diff_result) >
559 if (choice_value == HCURLTET_AINSWORTH) {
564 double sum = 0, diff_sum = 0;
565 std::cout <<
"Edges\n";
566 for (
int ee = 0; ee < 6; ee++) {
578 std::cout <<
"Faces\n";
579 for (
int ff = 0; ff < 4; ff++) {
591 std::cout <<
"Tets\n";
602 std::cout <<
"sum " << sum << std::endl;
603 std::cout <<
"diff_sum " << diff_sum << std::endl;
604 if (fabs(-1.7798 - sum) >
eps) {
607 if (fabs(-67.1793 - diff_sum) >
eps) {
612 if (choice_value == HCURLTET_DEMKOWICZ) {
616 double sum = 0, diff_sum = 0;
617 std::cout <<
"Edges\n";
618 for (
int ee = 0; ee < 6; ee++) {
630 std::cout <<
"Faces\n";
631 for (
int ff = 0; ff < 4; ff++) {
643 std::cout <<
"Tets\n";
653 std::cout <<
"sum " << sum << std::endl;
654 std::cout <<
"diff_sum " << diff_sum << std::endl;
655 if (fabs(7.35513 - sum) >
eps) {
658 if (fabs(62.4549 - diff_sum) >
eps) {
663 if (choice_value == L2TET) {
668 double sum = 0, diff_sum = 0;
669 std::cout <<
"Tets\n";
680 std::cout <<
"sum " << sum << std::endl;
681 std::cout <<
"diff_sum " << diff_sum << std::endl;
682 if (fabs(3.60352 - sum) >
eps) {
685 if (fabs(-36.9994 - diff_sum) >
eps) {
700 for (
int ee = 0; ee < 3; ee++) {
706 tri_data.
dataOnEntities[MBVERTEX][0].getBBNodeOrder().resize(3,
false);
707 std::fill(tri_data.
dataOnEntities[MBVERTEX][0].getBBNodeOrder().begin(),
713 pts_tri.resize(2, nb_gauss_pts,
false);
714 cblas_dcopy(nb_gauss_pts, &
QUAD_2D_TABLE[tri_rule]->points[1], 3,
716 cblas_dcopy(nb_gauss_pts, &
QUAD_2D_TABLE[tri_rule]->points[2], 3,
723 cblas_dcopy(3 * nb_gauss_pts,
QUAD_2D_TABLE[tri_rule]->points, 1,
731 if (choice_value == H1TRI_AINSWORTH) {
740 "Different pointers");
742 double sum = 0, diff_sum = 0;
743 std::cout <<
"Edges\n";
744 for (
int ee = 0; ee < 3; ee++) {
756 std::cout <<
"Face\n";
767 std::cout <<
"sum " << sum << std::endl;
768 std::cout <<
"diff_sum " << diff_sum << std::endl;
769 if (fabs(0.805556 - sum) >
eps)
772 if (fabs(0.0833333 - diff_sum) >
eps)
776 if (choice_value == H1TRI_BERNSTEIN_BEZIER) {
786 "Pointers should be diffrent");
788 double sum = 0, diff_sum = 0;
789 std::cout <<
"Vertex\n";
790 std::cout << tri_data.
dataOnEntities[MBVERTEX][0].getN(
"TET_FIELD")
792 std::cout << tri_data.
dataOnEntities[MBVERTEX][0].getDiffN(
"TET_FIELD")
797 std::cout <<
"Edges\n";
798 for (
int ee = 0; ee < 3; ee++) {
799 std::cout << tri_data.
dataOnEntities[MBEDGE][ee].getN(
"TET_FIELD")
801 std::cout << tri_data.
dataOnEntities[MBEDGE][ee].getDiffN(
"TET_FIELD")
808 std::cout <<
"Face\n";
811 std::cout << tri_data.
dataOnEntities[MBTRI][0].getDiffN(
"TET_FIELD")
816 std::cout <<
"sum " << sum << std::endl;
817 std::cout <<
"diff_sum " << diff_sum << std::endl;
818 if (std::abs(3.01389 - sum) >
eps)
821 if (std::abs(diff_sum) >
eps)
823 "wrong result %3.4e != $3.4e", 0, diff_sum);
826 if (choice_value == HDIVTRI_AINSWORTH) {
835 "Different pointers");
838 std::cout <<
"Face\n";
844 std::cout <<
"sum " << sum << std::endl;
845 if (fabs(1.93056 - sum) >
eps)
849 if (choice_value == HDIVTRI_DEMKOWICZ) {
859 "Different pointers");
862 std::cout <<
"Face\n";
867 std::cout <<
"sum " << sum << std::endl;
868 const double expected_result = 28.25;
869 if (fabs((expected_result - sum) / expected_result) >
eps) {
874 if (choice_value == HCURLTRI_AINSWORTH) {
884 "Different pointers");
887 std::cout <<
"Edges\n";
888 for (
int ee = 0; ee < 3; ee++) {
895 std::cout <<
"Face\n";
901 std::cout <<
"sum " << sum << std::endl;
902 if (fabs(0.333333 - sum) >
eps) {
907 if (choice_value == HCURLTRI_DEMKOWICZ) {
916 "Different pointers");
919 std::cout <<
"Edges\n";
920 for (
int ee = 0; ee < 3; ee++) {
927 std::cout <<
"Face\n";
932 std::cout <<
"sum " << sum << std::endl;
933 if (fabs(1.04591 - sum) >
eps) {
938 if (choice_value == L2TRI) {
948 "Different pointers");
951 std::cout <<
"Face\n";
957 std::cout <<
"sum " << sum << std::endl;
958 if (fabs(0.671875 - sum) >
eps) {
975 edge_data.
dataOnEntities[MBVERTEX][0].getBBNodeOrder().resize(2,
false);
976 std::fill(edge_data.
dataOnEntities[MBVERTEX][0].getBBNodeOrder().begin(),
982 pts_edge.resize(2, nb_gauss_pts,
false);
983 cblas_dcopy(nb_gauss_pts, &
QUAD_1D_TABLE[edge_rule]->points[1], 2,
985 cblas_dcopy(nb_gauss_pts,
QUAD_1D_TABLE[edge_rule]->weights, 1,
993 cblas_dcopy(2 * nb_gauss_pts,
QUAD_1D_TABLE[edge_rule]->points, 1,
997 if (choice_value == H1EDGE_AINSWORTH) {
1006 "Different pointers");
1008 double sum = 0, diff_sum = 0;
1009 std::cout <<
"Edge\n";
1020 std::cout <<
"sum " << sum << std::endl;
1021 std::cout <<
"diff sum " << diff_sum << std::endl;
1022 if (std::abs(0.506122 - sum) >
eps)
1025 if (std::abs(2.85714 - diff_sum) >
eps)
1029 if (choice_value == H1EDGE_BERNSTEIN_BEZIER) {
1039 "Should be diffrent pointers");
1041 double sum = 0, diff_sum = 0;
1042 std::cout <<
"Vertex\n";
1043 std::cout << edge_data.
dataOnEntities[MBVERTEX][0].getN(
"TET_FIELD")
1045 std::cout << edge_data.
dataOnEntities[MBVERTEX][0].getDiffN(
"TET_FIELD")
1047 std::cout <<
"Edge\n";
1048 std::cout << edge_data.
dataOnEntities[MBEDGE][0].getN(
"TET_FIELD")
1050 std::cout << edge_data.
dataOnEntities[MBEDGE][0].getDiffN(
"TET_FIELD")
1059 std::cout <<
"sum " << sum << std::endl;
1060 std::cout <<
"diff sum " << diff_sum << std::endl;
1061 if (std::abs(4 - sum) >
eps)
1064 if (std::abs(diff_sum) >
eps)
1068 if (choice_value == HCURLEDGE_AINSWORTH) {
1078 "Different pointers");
1086 std::cout.precision(std::numeric_limits<double>::max_digits10 - 1);
1087 std::cout <<
"sum " << sum << std::endl;
1088 if (fabs(-4.174149659863944 - sum) >
eps) {
1093 if (choice_value == HCURLEDGE_DEMKOWICZ) {
1102 "Different pointers");
1109 std::cout.precision(std::numeric_limits<double>::max_digits10 - 1);
1110 std::cout <<
"sum " << sum << std::endl;
1111 if (std::fabs(4.571428571428571 - sum) >
eps) {
1116 if (choice_value == L2EDGE) {
1134 std::cout <<
"sum " << sum << std::endl;
1135 if (std::fabs(sum) >
eps) {
1138 "Difference between ainsworth and demkowicz base should be zero");
1145 if (base.size1() != pts_edge.size2())
1147 "wrong number of integration points");
1150 "wrong number of base functions");
1153 for (
auto gg = 0; gg != pts_edge.size2(); ++gg) {
1154 double w = pts_edge(1, gg);
1158 ort_sum += base(gg,
i) * base(gg,
j) *
w;
1163 std::cout <<
"ort sum " << ort_sum << std::endl;
1164 if (std::fabs(ort_sum) >
eps) {
1167 "check orthogonality of base");
1172 double ort_diff_sum = 0;
1173 for (
auto gg = 0; gg != pts_edge.size2(); ++gg) {
1174 double w = pts_edge(1, gg);
1178 ort_diff_sum += diff_base(gg,
i) * diff_base(gg,
j) *
w;
1183 std::cout <<
"ort diff sum " << ort_diff_sum << std::endl;
1184 if (std::fabs(ort_diff_sum) >
eps) {
1186 "check orthogonality of diff lobatto base");
1198 for (
int ee = 0; ee < 4; ee++) {
1210 nb_gauss_pts = pts_quad.size2();
1215 for (
int i = 0;
i < nb_gauss_pts; ++
i) {
1243 if (choice_value == H1QUAD) {
1252 "Different pointers");
1254 double sum = 0, diff_sum = 0;
1255 for (
int ee = 0; ee < 4; ee++) {
1266 std::cout << sum <<
" " << diff_sum << endl;
1268 if (std::abs(3.58249 - sum) >
eps)
1272 if (std::abs(-0.134694 - diff_sum) >
eps)