9 {
10
12
13 try {
14
15 PetscBool flg = PETSC_TRUE;
18 255, &flg);
20 if (flg != PETSC_TRUE) {
22 "*** ERROR -my_file (MESH FILE NEEDED)");
23 }
24
25 moab::Core mb_instance;
26 moab::Interface &moab = mb_instance;
27
28 const char *option;
29 option = "";
31
34
35 auto get_dim = [&]() {
37 int nb_ents_3d;
39 0, 3, nb_ents_3d, true);
40 if (nb_ents_3d > 0) {
42 } else {
43 int nb_ents_2d;
45 0, 2, nb_ents_2d, true);
46 if (nb_ents_2d > 0) {
48 } else {
50 }
51 }
53 };
54
56
58
60 bit_level0.set(0);
61 if (
dim == 3 ||
dim == 2) {
64 } else {
66 "Dimension not handled by test");
67 }
68
70 bit_level1.set(1);
71
72 auto refine_edges = [&](
auto bit0,
auto bit) {
77
78
80 Range edges_to_refine;
81 CHKERR moab.get_entities_by_type(*meshset_ptr, MBEDGE, edges_to_refine);
82 int ii = 0;
83 for (Range::iterator eit = edges_to_refine.begin();
84 eit != edges_to_refine.end(); eit++, ii++) {
85 int numb = ii % 2;
86 if (numb == 0) {
87 CHKERR moab.add_entities(*meshset_ref_edges_ptr, &*eit, 1);
88 }
89 }
90 CHKERR refine->addVerticesInTheMiddleOfEdges(*meshset_ref_edges_ptr,
bit,
94 }
else if (
dim == 2) {
96 } else {
98 "Dimension not handled by test");
99 }
101 };
102
103 auto refine_ents_hanging_nodes = [&](
auto bit0,
auto bit) {
108
109
112 CHKERR moab.get_entities_by_dimension(*meshset_ptr,
dim, ents_dim);
113 int ii = 0;
114 for (Range::iterator eit = ents_dim.begin(); eit != ents_dim.end();
115 eit++, ii++) {
116 int numb = ii % 2;
117 if (numb == 0) {
118 std::vector<EntityHandle> adj_ents;
119 CHKERR moab.get_adjacencies(&*eit, 1, 1,
false, adj_ents);
120 CHKERR moab.add_entities(*meshset_ref_edges_ptr, &*adj_ents.begin(),
121 adj_ents.size());
122 }
123 }
124
125 CHKERR refine->addVerticesInTheMiddleOfEdges(*meshset_ref_edges_ptr,
bit,
126 false,
QUIET, 10000);
128 CHKERR refine->refineTetsHangingNodes(*meshset_ptr,
bit,
QUIET,
true);
129 }
else if (
dim == 2) {
130 CHKERR refine->refineTrisHangingNodes(*meshset_ptr,
bit,
QUIET,
true);
131 } else {
133 "Dimension not handled by test");
134 }
136 };
137
138 auto save_blessed_field = [&](
auto bit) {
140
141 std::ofstream myfile;
142 myfile.open("mesh_refine.txt");
143
148 CHKERR moab.get_entities_by_handle(*out_meshset_tet_ptr, tets);
149 {
150 int ii = 0;
151 for (Range::iterator tit = tets.begin(); tit != tets.end(); tit++) {
152 int num_nodes;
154 CHKERR moab.get_connectivity(*tit, conn, num_nodes,
true);
155
156 for (int nn = 0; nn < num_nodes; nn++) {
157
158 myfile << conn[nn] << " ";
159 }
160
161 myfile << std::endl;
162 if (ii > 25)
163 break;
164 }
165 }
166
167 myfile.close();
168
170 };
171
172 auto save_vtk = [&](
auto bit) {
177 CHKERR moab.write_file(
"out_mesh_refine.vtk",
"VTK",
"",
178 out_meshset_tet_ptr->get_ptr(), 1);
180 };
181
187 }
189
191
192 return 0;
193}
#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 refernce to pointer of interface.