32 {
33
35
36 try {
37
39
40 PetscBool flg = PETSC_TRUE;
43 255, &flg);
44
45 if (flg != PETSC_TRUE)
47 "*** ERROR -my_file (MESH FILE NEEDED)");
48
49 int side_set = 200;
51 PETSC_NULL);
52
53 int restricted_side_set = 205;
55 &restricted_side_set, PETSC_NULL);
56
57 double shift[] = {0, 0, 0};
58 int nmax = 3;
60 if (flg && nmax != 3)
62 "three values expected");
63
64 int fixed_edges_blockset = 100;
66 &fixed_edges_blockset, PETSC_NULL);
67
68 int corner_nodes_blockset = 1;
70 &corner_nodes_blockset, PETSC_NULL);
71
72 double tol[] = {0, 0, 0};
73 int nmax_tol = 3;
75 if (flg && nmax_tol != 3)
77
78 PetscBool test = PETSC_FALSE;
81
82 moab::Core mb_instance;
83 moab::Interface &moab = mb_instance;
84 ParallelComm *pcomm = ParallelComm::get_pcomm(&moab,
MYPCOMM_INDEX);
85 auto moab_comm_wrap =
86 boost::make_shared<WrapMPIComm>(PETSC_COMM_WORLD, false);
87 if (pcomm == NULL)
88 pcomm =
89 new ParallelComm(&moab, moab_comm_wrap->get_comm());
90
91 const char *option;
92 option = "";
94
98
103 }
104
106 bit_level0.set(0);
109
113 bit_last);
114
116 bit_level0,
BitRefLevel().set(), MBTET,
"out_tets_init_level0.vtk",
117 "VTK", "");
119 bit_last,
BitRefLevel().set(), MBTET,
"out_tets_bit_last.vtk",
"VTK",
120 "");
121
122 int no_of_ents_not_in_database = -1;
123 Range ents_not_in_database;
124 if (test) {
125 core.getInterface<
BitRefManager>()->getAllEntitiesNotInDatabase(
126 ents_not_in_database);
127 no_of_ents_not_in_database = ents_not_in_database.size();
128 }
129
130
133
136
139
140
141 Range fixed_edges, corner_nodes;
144 fixed_edges_blockset,
SIDESET, 1, fixed_edges,
true);
145 }
148 fixed_edges_blockset,
BLOCKSET, 1, fixed_edges,
true);
149 }
152 corner_nodes_blockset,
BLOCKSET, 0, corner_nodes,
true);
153 }
154
155
156 Range restriced_surface;
159 restricted_side_set,
SIDESET, 2, restriced_surface,
true);
160
164 surface, true);
165 if (surface.empty())
167
168
169
172 "surface.vtk");
173 else
175
177
179 CHKERR moab.get_entities_by_dimension(0, 3, tets,
false);
180
184 const int nb_ref_cut = 1;
185 const int nb_ref_trim = 1;
188 auto shift_after_ref = [&]() {
191 mask.set(0);
192 for (int ll = 1; ll != nb_ref_cut + nb_ref_trim + 1; ++ll)
193 mask.set(ll);
195 nb_ref_cut + nb_ref_trim, mask,
VERBOSE);
197 };
199
201 ->writeEntitiesAllBitLevelsByType(
BitRefLevel().set(), MBTET,
202 "all_bits.vtk", "VTK", "");
203
204
205 double def_position[] = {0, 0, 0};
207 CHKERR moab.tag_get_handle(
"POSITION", 3, MB_TYPE_DOUBLE,
th,
208 MB_TAG_CREAT | MB_TAG_SPARSE, def_position);
209
211
212
213 int first_bit = 1;
215 fixed_edges, corner_nodes, true, false);
216
217
222 ->updateAllMeshsetsByEntitiesChildren(
BitRefLevel().set(first_bit + 1));
223
226 "out_split_tets.vtk", "VTK", "");
227
230 "out_split_prism.vtk", "VTK", "");
231
232 if (test) {
233 for (int ll = 0; ll != first_bit + 2; ++ll)
236 }
237
238
240 for (int ll = 0; ll != first_bit; ++ll)
241 shift_mask.set(ll);
243 first_bit, shift_mask,
VERBOSE);
244
245
249 "out_tets_shift_level0.vtk", "VTK", "");
252 "out_tets_shift_level1.vtk", "VTK", "");
255 "out_tets_shift_level1_prism.vtk", "VTK", "");
256
259 Range adj_surface_edges;
261 adj_surface_edges, moab::Interface::UNION);
263 CHKERR moab.delete_entities(adj_surface_edges);
264 CHKERR moab.delete_entities(surface_verts);
268
269 {
271 CHKERR moab.create_meshset(MESHSET_SET, meshset);
273 CHKERR moab.get_entities_by_dimension(0, 3, tets,
true);
274 CHKERR moab.add_entities(meshset, tets);
275 CHKERR moab.write_file(
"out.vtk",
"VTK",
"", &meshset, 1);
276 CHKERR moab.delete_entities(&meshset, 1);
277 }
279 bit_last,
BitRefLevel().set(), MBTET,
"out_tets_bit_last.vtk",
"VTK",
280 "");
282 "left_entities.vtk", "VTK", "");
283
285 if (test) {
287 core.getInterface<
BitRefManager>()->getAllEntitiesNotInDatabase(ents);
288 if (no_of_ents_not_in_database != static_cast<int>(ents.size())) {
289 MOFEM_LOG(
"WORLD", Sev::inform) << subtract(ents, ents_not_in_database);
291 CHKERR moab.create_meshset(MESHSET_SET, meshset);
293 CHKERR moab.get_entities_by_dimension(0, 3, tets,
true);
294 CHKERR moab.add_entities(meshset, subtract(ents, ents_not_in_database));
295 CHKERR moab.write_file(
"not_cleanded.vtk",
"VTK",
"", &meshset, 1);
296 CHKERR moab.delete_entities(&meshset, 1);
298 "Inconsistent number of ents %d!=%d",
299 no_of_ents_not_in_database, ents.size());
300 }
301 }
302 }
304
306
307 return 0;
308}
#define CATCH_ERRORS
Catch errors.
#define BITREFLEVEL_SIZE
max number of refinements
#define MYPCOMM_INDEX
default communicator number PCOMM
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ 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.
#define MOFEM_LOG(channel, severity)
Log.
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
bool checkMeshset(const int ms_id, const CubitBCType cubit_bc_type) const
check for CUBIT Id and CUBIT type
MoFEMErrorCode getEntitiesByDimension(const int ms_id, const unsigned int cubit_bc_type, const int dimension, Range &entities, const bool recursive=true) const
get entities from CUBIT/meshset of a particular entity dimension
#define _IT_CUBITMESHSETS_BY_SET_TYPE_FOR_LOOP_(MESHSET_MANAGER, CUBITBCTYPE, IT)
Iterator that loops over a specific Cubit MeshSet having a particular BC meshset in a moFEM field.
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
PetscErrorCode PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
PetscErrorCode PetscOptionsGetBool(PetscOptions *, const char pre[], const char name[], PetscBool *bval, PetscBool *set)
PetscErrorCode PetscOptionsGetRealArray(PetscOptions *, const char pre[], const char name[], PetscReal dval[], PetscInt *nmax, PetscBool *set)
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
virtual MoFEMErrorCode delete_ents_by_bit_ref(const BitRefLevel bit, const BitRefLevel mask, const bool remove_parent=false, int verb=DEFAULT_VERBOSITY, MoFEMTypes mf=MF_ZERO)=0
delete entities form mofem and moab database
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.
MoFEMErrorCode copySurface(const Range surface, Tag th=NULL, double *shift=NULL, double *origin=NULL, double *transform=NULL, const std::string save_mesh="")
copy surface entities
MoFEMErrorCode setCoords(Tag th, const BitRefLevel bit=BitRefLevel(), const BitRefLevel mask=BitRefLevel().set())
set coords from tag
const Range & getMergedSurfaces() const
MoFEMErrorCode setSurface(const Range surface)
set surface entities
MoFEMErrorCode buildTree()
build tree
MoFEMErrorCode splitSides(const BitRefLevel split_bit, const BitRefLevel bit, const Range &ents, Tag th=NULL)
split sides
const Range & getSurface() const
MoFEMErrorCode setConstrainSurface(const Range surf)
Set the constrain surface object.
MoFEMErrorCode setVolume(const Range volume)
set volume entities
MoFEMErrorCode setTagData(Tag th, const BitRefLevel bit=BitRefLevel())
set coords to tag
MoFEMErrorCode cutTrimAndMerge(int &first_bit, const int fraction_level, Tag th, const double tol_geometry, const double tol_cut_close, const double tol_trim_close, Range &fixed_edges, Range &corner_nodes, const bool update_meshsets=false, const bool debug=false)
Cut, trim and merge.
MoFEMErrorCode makeFront(const bool debug=false)
Create front from the surface.
MoFEMErrorCode refineMesh(const int init_bit_level, const int surf_levels, const int front_levels, Range *fixed_edges=nullptr, int verb=QUIET, const bool debug=false)
Refine and set level sets.
Interface for managing meshsets containing materials and boundary conditions.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.