17 {
18
20
21 try {
22
23 PetscBool flg = PETSC_TRUE;
26 255, &flg);
28 if (flg != PETSC_TRUE) {
30 "*** ERROR -my_file (MESH FILE NEEDED)");
31 }
32
33 moab::Core mb_instance;
34 moab::Interface &moab = mb_instance;
35
36 const char *option;
37 option = "";
39
42
44 int dim;
45 int nb_ents_3d;
47 0, 3, nb_ents_3d, true);
48 if (nb_ents_3d > 0) {
49 dim = 3;
50 } else {
51 int nb_ents_2d;
53 0, 2, nb_ents_2d, true);
54 if (nb_ents_2d > 0) {
55 dim = 2;
56 } else {
57 dim = 1;
58 }
59 }
60 return dim;
61 };
62
64
66
68 bit_level0.set(0);
69 if (dim == 3 || dim == 2) {
71 0, dim, bit_level0);
72 } else {
74 "Dimension not handled by test");
75 }
76
78 bit_level1.set(1);
79
80 auto refine_edges = [&](
auto bit0,
auto bit) {
85
86
88 Range edges_to_refine;
89 CHKERR moab.get_entities_by_type(*meshset_ptr, MBEDGE, edges_to_refine);
90 int ii = 0;
91 for (Range::iterator eit = edges_to_refine.begin();
92 eit != edges_to_refine.end(); eit++, ii++) {
93 int numb = ii % 2;
94 if (numb == 0) {
95 CHKERR moab.add_entities(*meshset_ref_edges_ptr, &*eit, 1);
96 }
97 }
98 CHKERR refine->addVerticesInTheMiddleOfEdges(*meshset_ref_edges_ptr,
bit,
100 if (dim == 3) {
102 } else if (dim == 2) {
104 } else {
106 "Dimension not handled by test");
107 }
109 };
110
111 auto refine_ents_hanging_nodes = [&](
auto bit0,
auto bit) {
116
117
120 CHKERR moab.get_entities_by_dimension(*meshset_ptr, dim, ents_dim);
121 int ii = 0;
122 for (Range::iterator eit = ents_dim.begin(); eit != ents_dim.end();
123 eit++, ii++) {
124 int numb = ii % 2;
125 if (numb == 0) {
126 std::vector<EntityHandle> adj_ents;
127 CHKERR moab.get_adjacencies(&*eit, 1, 1,
false, adj_ents);
128 CHKERR moab.add_entities(*meshset_ref_edges_ptr, &*adj_ents.begin(),
129 adj_ents.size());
130 }
131 }
132
133 CHKERR refine->addVerticesInTheMiddleOfEdges(*meshset_ref_edges_ptr,
bit,
134 false,
QUIET, 10000);
135 if (dim == 3) {
136 CHKERR refine->refineTetsHangingNodes(*meshset_ptr,
bit,
QUIET,
true);
137 } else if (dim == 2) {
138 CHKERR refine->refineTrisHangingNodes(*meshset_ptr,
bit,
QUIET,
true);
139 } else {
141 "Dimension not handled by test");
142 }
144 };
145
146 auto save_blessed_field = [&](
auto bit) {
148
149 std::ofstream myfile;
150 myfile.open("mesh_refine.txt");
151
156 CHKERR moab.get_entities_by_handle(*out_meshset_tet_ptr, tets);
157 {
158 int ii = 0;
159 for (Range::iterator tit = tets.begin(); tit != tets.end(); tit++) {
160 int num_nodes;
162 CHKERR moab.get_connectivity(*tit, conn, num_nodes,
true);
163
164 for (int nn = 0; nn < num_nodes; nn++) {
165
166 myfile << conn[nn] << " ";
167 }
168
169 myfile << std::endl;
170 if (ii > 25)
171 break;
172 }
173 }
174
175 myfile.close();
176
178 };
179
180 auto save_vtk = [&](
auto bit) {
185 CHKERR moab.write_file(
"out_mesh_refine.vtk",
"VTK",
"",
186 out_meshset_tet_ptr->get_ptr(), 1);
188 };
189
195 }
197
199
200 return 0;
201}
#define CATCH_ERRORS
Catch errors.
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
@ MOFEM_ATOM_TEST_INVALID
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
auto get_temp_meshset_ptr(moab::Interface &moab)
Create smart pointer to temporary meshset.
virtual moab::Interface & get_moab()=0
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.
Deprecated interface functions.
Mesh refinement interface.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.