12 using namespace MoFEM;
14 static char help[] =
"mesh cutting\n\n";
16 int main(
int argc,
char *argv[]) {
24 int surface_side_set = 200;
25 PetscBool flg_vol_block_set;
26 int vol_block_set = 1;
30 double shift[] = {0, 0, 0};
32 int fraction_level = 2;
33 PetscBool squash_bits = PETSC_TRUE;
34 PetscBool set_coords = PETSC_TRUE;
36 int create_surface_side_set = 201;
37 PetscBool flg_create_surface_side_set;
41 double tol[] = {1e-2, 2e-1, 2e-1};
43 PetscBool
debug = PETSC_FALSE;
45 CHKERR PetscOptionsBegin(PETSC_COMM_WORLD,
"",
"Mesh cut options",
"none");
46 CHKERR PetscOptionsString(
"-my_file",
"mesh file name",
"",
"mesh.h5m",
48 CHKERR PetscOptionsInt(
"-surface_side_set",
"surface side set",
"",
49 surface_side_set, &surface_side_set, PETSC_NULL);
50 CHKERR PetscOptionsInt(
"-vol_block_set",
"volume side set",
"",
51 vol_block_set, &vol_block_set, &flg_vol_block_set);
52 CHKERR PetscOptionsInt(
"-edges_block_set",
"edges block set",
"",
54 CHKERR PetscOptionsInt(
"-vertex_block_set",
"vertex block set",
"",
56 CHKERR PetscOptionsRealArray(
"-shift",
"shift surface by vector",
"", shift,
58 CHKERR PetscOptionsInt(
"-fraction_level",
"fraction of merges merged",
"",
59 fraction_level, &fraction_level, PETSC_NULL);
60 CHKERR PetscOptionsBool(
"-squash_bits",
"true to squash bits at the end",
61 "", squash_bits, &squash_bits, PETSC_NULL);
62 CHKERR PetscOptionsBool(
"-set_coords",
"true to set coords at the end",
"",
63 set_coords, &set_coords, PETSC_NULL);
64 CHKERR PetscOptionsBool(
"-output_vtk",
"if true outout vtk file",
"",
66 CHKERR PetscOptionsInt(
"-create_side_set",
"crete side set",
"",
67 create_surface_side_set, &create_surface_side_set,
68 &flg_create_surface_side_set);
69 CHKERR PetscOptionsInt(
"-nb_ref_cut",
"nb refinements befor cut",
"",
70 nb_ref_cut, &nb_ref_cut, PETSC_NULL);
71 CHKERR PetscOptionsInt(
"-nb_ref_trim",
"nb refinements befor trim",
"",
72 nb_ref_trim, &nb_ref_trim, PETSC_NULL);
73 CHKERR PetscOptionsRealArray(
74 "-tol",
"tolerances tolCut, tolCutClose, tolTrim, tolTrimClose",
"",
75 tol, &nmax_tol, &flg_tol);
76 CHKERR PetscOptionsBool(
"-debug",
"debug (produces many VTK files)",
"",
78 ierr = PetscOptionsEnd();
83 "*** ERROR -my_file (MESH FILE NEEDED)");
85 if (flg_shift && nmax != 3) {
89 if (flg_tol && nmax_tol != 3)
94 ParallelComm *pcomm = ParallelComm::get_pcomm(&moab,
MYPCOMM_INDEX);
96 pcomm =
new ParallelComm(&moab, PETSC_COMM_WORLD);
140 "Side set not found %d", surface_side_set);
143 Range fixed_edges, corner_nodes;
146 1, fixed_edges,
true);
149 1, fixed_edges,
true);
156 if (flg_vol_block_set) {
162 "Block set %d not found", vol_block_set);
164 CHKERR moab.get_entities_by_dimension(0, 3, tets,
false);
176 auto shift_after_ref = [&]() {
180 for (
int ll = 1; ll != nb_ref_cut + nb_ref_trim + 1; ++ll)
183 nb_ref_cut + nb_ref_trim, mask,
VERBOSE);
189 double def_position[] = {0, 0, 0};
191 CHKERR moab.tag_get_handle(
"POSITION", 3, MB_TYPE_DOUBLE,
th,
192 MB_TAG_CREAT | MB_TAG_SPARSE, def_position);
199 tol[1],
tol[2], fixed_edges, corner_nodes,
207 if (flg_vol_block_set) {
217 for (
int ll = 0; ll != first_bit; ++ll)
220 first_bit - 1, shift_mask,
VERBOSE);
226 CHKERR moab.get_adjacencies(cut_mesh->
getSurface(), 1,
false, surface_edges,
227 moab::Interface::UNION);
229 CHKERR moab.delete_entities(surface_edges);
230 CHKERR moab.delete_entities(surface_verts);
232 if (flg_create_surface_side_set) {
235 create_surface_side_set,
SIDESET))
239 "Warring >>> sideset %d is on the mesh",
240 create_surface_side_set);
246 CHKERR moab.write_file(
"out.h5m");
250 CHKERR moab.create_meshset(MESHSET_SET, meshset);
251 if (flg_vol_block_set) {
255 CHKERR moab.add_entities(meshset, ents);
262 CHKERR moab.write_file(
"out.vtk",
"VTK",
"", &meshset, 1);
263 CHKERR moab.delete_entities(&meshset, 1);