29 auto test_quad = [&]() {
34 CHKERR Tools::outerProductOfEdgeIntegrationPtsForQuad(pts_quad, rule_ksi,
36 int nb_gauss_pts = pts_quad.size2();
37 double sum_coords = 0, sum_gauss_pts = 0;
38 for (
int i = 0;
i < nb_gauss_pts; ++
i) {
39 sum_coords += pts_quad(0,
i) + pts_quad(1,
i);
40 sum_gauss_pts += pts_quad(2,
i);
43 if (fabs(20.0 - sum_coords) >
eps) {
45 "wrong result %3.4e", sum_coords);
47 if (fabs(1.0 - sum_gauss_pts) >
eps) {
49 "wrong result %3.4e", sum_gauss_pts);
54 auto test_hex = [&]() {
60 CHKERR Tools::outerProductOfEdgeIntegrationPtsForHex(pts_quad, rule_ksi,
62 int nb_gauss_pts = pts_quad.size2();
63 double sum_coords = 0, sum_gauss_pts = 0;
64 for (
int i = 0;
i < nb_gauss_pts; ++
i) {
65 sum_coords += pts_quad(0,
i) + pts_quad(1,
i) + pts_quad(2,
i);
66 sum_gauss_pts += pts_quad(3,
i);
69 if (fabs(54.0 - sum_coords) >
eps) {
71 "wrong result %3.4e", sum_coords);
73 if (fabs(1.0 - sum_gauss_pts) >
eps) {
75 "wrong result %3.4e", sum_gauss_pts);
80 auto test_refined_triangle = [&]() {
83 auto refine = Tools::refineTriangle(2);
84 auto new_gauss_pts = Tools::refineTriangleIntegrationPts(4, refine);
86 int new_nb_gauss_pts = new_gauss_pts.size2();
87 double sum_coords = 0, sum_gauss_pts = 0;
88 for (
int i = 0;
i < new_nb_gauss_pts; ++
i) {
89 sum_coords += new_gauss_pts(0,
i) + new_gauss_pts(1,
i);
90 sum_gauss_pts += new_gauss_pts(2,
i);
92 constexpr
double eps = 1e-8;
95 <<
"sum_gauss_pts " << sum_gauss_pts << endl;
96 MOFEM_LOG(
"WORLD", Sev::verbose) <<
"sum_coords " << sum_coords << endl;
97 if (fabs(64.0 - sum_coords) >
eps) {
99 "wrong result %3.4e", sum_coords);
101 if (fabs(1.0 - sum_gauss_pts) >
eps) {
103 "wrong result %3.4e", sum_gauss_pts);
106 constexpr
bool debug =
false;
110 auto [nodes, triangles, level_index] = refine;
112 auto get_coords = [&](
auto t) {
113 auto [nodes, triangles, level_index] = refine;
114 std::array<double, 9> ele_coords;
115 for (
auto n : {0, 1, 2}) {
116 for (
auto i : {0, 1}) {
117 ele_coords[3 *
n +
i] = nodes[2 * triangles[6 *
t +
n] +
i];
119 ele_coords[3 *
n + 2] = 0;
127 for (
auto t = level_index[level_index.size() - 2];
128 t != level_index.back(); ++
t) {
129 std::array<EntityHandle, 3> conn;
130 auto ele_coords = get_coords(
t);
132 for (
auto n : {0, 1, 2}) {
133 CHKERR moab.create_vertex(&ele_coords[3 *
n], conn[
n]);
135 << ele_coords[3 *
n] <<
" " << ele_coords[3 *
n + 1] <<
" "
136 << ele_coords[3 *
n + 2];
140 << triangles[6 *
t + 0] <<
" " << triangles[6 *
t + 1] <<
" "
141 << triangles[6 *
t + 2] << std::endl;
144 CHKERR moab.create_element(MBTRI, conn.data(), 3, tri);
147 for (
int i = 0;
i < new_nb_gauss_pts; ++
i) {
148 std::array<double, 3> coords{new_gauss_pts(0,
i), new_gauss_pts(1,
i),
151 CHKERR moab.create_vertex(coords.data(), node);
154 CHKERR moab.write_file(
"gauss_refine.vtk",
"VTK",
"");
162 CHKERR test_refined_triangle();