18 auto core_log = logging::core::get();
20 LogManager::createSink(LogManager::getStrmWorld(),
"SPLIT"));
21 LogManager::setLog(
"SPLIT");
28 PetscBool flg_file = PETSC_FALSE;
29 PetscBool squash_bit_levels = PETSC_TRUE;
30 PetscBool flg_list_of_sidesets = PETSC_FALSE;
32 PetscBool add_prisms = PETSC_FALSE;
33 PetscBool split_corner_edges = PETSC_FALSE;
35 int sidesets[nb_sidesets];
37 CHKERR PetscOptionsBegin(PETSC_COMM_WORLD,
"",
"Split sides options",
39 CHKERR PetscOptionsString(
"-my_file",
"mesh file name",
"",
"mesh.h5m",
41 CHKERR PetscOptionsBool(
"-squash_bit_levels",
"squash bit levels",
"",
42 squash_bit_levels, &squash_bit_levels, NULL);
43 CHKERR PetscOptionsIntArray(
"-side_sets",
"get list of sidesets",
"",
44 sidesets, &nb_sidesets, &flg_list_of_sidesets);
45 CHKERR PetscOptionsBool(
"-output_vtk",
"if true outout vtk file",
"",
47 CHKERR PetscOptionsBool(
"-add_prisms",
"if true outout vtk file",
"",
48 add_prisms, &add_prisms, PETSC_NULL);
49 CHKERR PetscOptionsBool(
"-split_corner_edges",
"if true outout vtk file",
50 "", split_corner_edges, &split_corner_edges,
52 CHKERR PetscOptionsBool(
"-output_vtk",
"if true outout vtk file",
"",
54 ierr = PetscOptionsEnd();
68 if (flg_file != PETSC_TRUE) {
70 "*** ERROR -my_file (mesh file needed)");
72 if (flg_list_of_sidesets != PETSC_TRUE) {
74 "List of sidesets not given -my_side_sets ...");
86 auto &meshsets_index = m_mng->getMeshsetsMultindex();
88 auto &m_by_id_and_type =
91 for (
auto mit = m_by_type.lower_bound(
SIDESET);
92 mit != m_by_type.upper_bound(
SIDESET); mit++) {
94 <<
"Sideset on the mesh id = " << mit->getMeshsetId();
98 std::vector<BitRefLevel> bit_levels;
101 auto update_meshsets = [&]() {
105 CHKERR bit_mng->updateMeshsetByEntitiesChildren(
106 cubit_meshset, bit_levels.back(), cubit_meshset, MBMAXTYPE,
true);
112 if (split_corner_edges) {
116 for (
int mm = 0; mm != nb_sidesets; mm++) {
120 m_by_id_and_type.find(boost::make_tuple(sidesets[mm],
SIDESET));
121 if (mit == m_by_id_and_type.end())
123 "No sideset in database id = %d", sidesets[mm]);
126 CHKERR moab.get_entities_by_type(mit->getMeshset(), MBTRI, faces,
true);
128 CHKERR moab.get_adjacencies(faces, 1,
true, faces_edges,
129 moab::Interface::UNION);
132 CHKERR skin.find_skin(0, faces,
false, skin_edges);
134 CHKERR moab.get_connectivity(skin_edges, skin_verts,
true);
136 CHKERR moab.get_adjacencies(skin_verts, 1,
true, vertex_edges,
137 moab::Interface::UNION);
138 Range vertex_edges_verts;
139 CHKERR moab.get_connectivity(vertex_edges, vertex_edges_verts,
true);
140 vertex_edges_verts = subtract(vertex_edges_verts, skin_verts);
141 Range vertex_edges_verts_edges;
142 CHKERR moab.get_adjacencies(vertex_edges_verts, 1,
true,
143 vertex_edges_verts_edges,
144 moab::Interface::UNION);
145 vertex_edges = subtract(vertex_edges, vertex_edges_verts_edges);
146 vertex_edges = subtract(vertex_edges, skin_edges);
147 vertex_edges = intersect(vertex_edges, faces_edges);
148 CHKERR moab.add_entities(*meshset_of_edges_to_refine_ptr, vertex_edges);
152 CHKERR moab.get_number_entities_by_type(*meshset_of_edges_to_refine_ptr,
153 MBEDGE, nb_tris,
true);
154 MOFEM_LOG(
"SPLIT", Sev::inform) <<
"Refine corner edges " << nb_tris;
157 CHKERR moab.write_file(
"out_edges_to_refine.vtk",
"VTK",
"",
158 meshset_of_edges_to_refine_ptr->get_ptr(), 1);
161 CHKERR refine_mng->addVerticesInTheMiddleOfEdges(
162 *meshset_of_edges_to_refine_ptr, bit_levels.back());
163 CHKERR refine_mng->refineTets(0, bit_levels.back());
168 for (
int mm = 0; mm != nb_sidesets; mm++) {
172 m_by_id_and_type.find(boost::make_tuple(sidesets[mm],
SIDESET));
173 if (mit == m_by_id_and_type.end())
175 "No sideset in database id = %d", sidesets[mm]);
178 <<
"Split sideset " << mit->getMeshsetId();
180 const auto cubit_meshset = mit->getMeshset();
184 CHKERR bit_mng->getEntitiesByTypeAndRefLevel(bit_levels.back(),
186 *ref_level_meshset_ptr);
187 CHKERR bit_mng->getEntitiesByTypeAndRefLevel(
189 *ref_level_meshset_ptr);
190 Range ref_level_tets;
191 CHKERR moab.get_entities_by_handle(*ref_level_meshset_ptr,
192 ref_level_tets,
true);
195 CHKERR interface_ptr->getSides(cubit_meshset, bit_levels.back(),
true,
199 <<
"Add bit level " << bit_levels.size();
200 bit_levels.push_back(
BitRefLevel().set(bit_levels.size()));
202 CHKERR interface_ptr->splitSides(*ref_level_meshset_ptr,
203 bit_levels.back(), cubit_meshset,
204 add_prisms,
true, 0);
210 if (squash_bit_levels == PETSC_TRUE) {
211 for (
unsigned int ll = 0; ll != bit_levels.size() - 1; ll++) {
215 CHKERR bit_mng->shiftRightBitRef(bit_levels.size() - 1);
221 if (squash_bit_levels)
224 bit = bit_levels.back();
226 MBTET, *meshset_ptr);
227 CHKERR moab.write_file(
"out.vtk",
"VTK",
"", meshset_ptr->get_ptr(), 1);
230 ParallelComm *pcomm = ParallelComm::get_pcomm(&moab,
MYPCOMM_INDEX);
233 "Communicator should be allocated");
235 CHKERR pcomm->assign_global_ids(0, 3, 1,
false);
236 CHKERR moab.write_file(
"out.h5m");