21 {
22
24 try {
25 moab::Core mb_instance;
26 moab::Interface &moab = mb_instance;
28
29 auto test_quad = [&]() {
32 int rule_ksi = 6;
33 int rule_eta = 8;
35 rule_eta);
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);
41 }
43 if (fabs(20.0 - sum_coords) >
eps) {
45 "wrong result %3.4e", sum_coords);
46 }
47 if (fabs(1.0 - sum_gauss_pts) >
eps) {
49 "wrong result %3.4e", sum_gauss_pts);
50 }
52 };
53
54 auto test_hex = [&]() {
57 int rule_ksi = 4;
58 int rule_eta = 5;
59 int rule_zet = 6;
61 rule_eta, rule_zet);
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);
67 }
69 if (fabs(54.0 - sum_coords) >
eps) {
71 "wrong result %3.4e", sum_coords);
72 }
73 if (fabs(1.0 - sum_gauss_pts) >
eps) {
75 "wrong result %3.4e", sum_gauss_pts);
76 }
78 };
79
80 auto test_refined_triangle = [&]() {
82
85
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);
91 }
92 constexpr double eps = 1e-8;
93
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);
100 }
101 if (fabs(1.0 - sum_gauss_pts) >
eps) {
103 "wrong result %3.4e", sum_gauss_pts);
104 }
105
106 constexpr bool debug =
false;
107
109
110 auto [nodes, triangles, level_index] = refine;
111
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];
118 }
119 ele_coords[3 *
n + 2] = 0;
120 }
121 return ele_coords;
122 };
123
124 moab::Core mb_instance;
125 moab::Interface &moab = mb_instance;
126
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);
131
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];
137 }
138
140 << triangles[6 *
t + 0] <<
" " << triangles[6 *
t + 1] <<
" "
141 << triangles[6 *
t + 2] << std::endl;
142
144 CHKERR moab.create_element(MBTRI, conn.data(), 3, tri);
145 }
146
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),
149 0};
151 CHKERR moab.create_vertex(coords.data(), node);
152 }
153
154 CHKERR moab.write_file(
"gauss_refine.vtk",
"VTK",
"");
155 }
156
158 };
159
162 CHKERR test_refined_triangle();
163 }
165
167}
#define CATCH_ERRORS
Catch errors.
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_DATA_INCONSISTENCY
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
#define MOFEM_LOG(channel, severity)
Log.
FTensor::Index< 'i', SPACE_DIM > i
const double n
refractive index of diffusive medium
constexpr double t
plate stiffness
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.