15 {
17
18 auto core_log = logging::core::get();
19 core_log->add_sink(
23
24 try {
25
26
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;
34 int nb_sidesets = 10;
35 int sidesets[nb_sidesets];
36
37 CHKERR PetscOptionsBegin(PETSC_COMM_WORLD,
"",
"Split sides options",
38 "none");
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,
51 PETSC_NULL);
52 CHKERR PetscOptionsBool(
"-output_vtk",
"if true outout vtk file",
"",
54 ierr = PetscOptionsEnd();
56
57 moab::Core mb_instance;
58 moab::Interface &moab = mb_instance;
59
60 const char *option;
61 option = "";
63
64
67
68 if (flg_file != PETSC_TRUE) {
70 "*** ERROR -my_file (mesh file needed)");
71 }
72 if (flg_list_of_sidesets != PETSC_TRUE) {
74 "List of sidesets not given -my_side_sets ...");
75 }
76
77
79
81
83
85
86 auto &meshsets_index = m_mng->getMeshsetsMultindex();
88 auto &m_by_id_and_type =
90
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();
95 }
96
98 std::vector<BitRefLevel> bit_levels;
100
101 auto update_meshsets = [&]() {
105 CHKERR bit_mng->updateMeshsetByEntitiesChildren(
106 cubit_meshset, bit_levels.back(), cubit_meshset, MBMAXTYPE, true);
107 }
109 };
110
111
112 if (split_corner_edges) {
115
116 for (int mm = 0; mm != nb_sidesets; mm++) {
117
118
119 auto mit =
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]);
124
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);
130
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);
149 }
150
151 int nb_tris;
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;
155
157 CHKERR moab.write_file(
"out_edges_to_refine.vtk",
"VTK",
"",
158 meshset_of_edges_to_refine_ptr->get_ptr(), 1);
159
161 CHKERR refine_mng->addVerticesInTheMiddleOfEdges(
162 *meshset_of_edges_to_refine_ptr, bit_levels.back());
163 CHKERR refine_mng->refineTets(0, bit_levels.back());
165 }
166
167
168 for (int mm = 0; mm != nb_sidesets; mm++) {
169
170
171 auto mit =
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]);
176
178 << "Split sideset " << mit->getMeshsetId();
179
180 const auto cubit_meshset = mit->getMeshset();
181 {
182
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);
193
194
195 CHKERR interface_ptr->getSides(cubit_meshset, bit_levels.back(),
true,
196 0);
197
199 << "Add bit level " << bit_levels.size();
200 bit_levels.push_back(
BitRefLevel().set(bit_levels.size()));
201
202 CHKERR interface_ptr->splitSides(*ref_level_meshset_ptr,
203 bit_levels.back(), cubit_meshset,
204 add_prisms, true, 0);
205 }
206
208 }
209
210 if (squash_bit_levels == PETSC_TRUE) {
211 for (unsigned int ll = 0; ll != bit_levels.size() - 1; ll++) {
213 true);
214 }
215 CHKERR bit_mng->shiftRightBitRef(bit_levels.size() - 1);
216 }
217
221 if (squash_bit_levels)
223 else
224 bit = bit_levels.back();
226 MBTET, *meshset_ptr);
227 CHKERR moab.write_file(
"out.vtk",
"VTK",
"", meshset_ptr->get_ptr(), 1);
228 }
229
230 ParallelComm *pcomm = ParallelComm::get_pcomm(&moab,
MYPCOMM_INDEX);
231 if (pcomm == NULL)
233 "Communicator should be allocated");
234
235 CHKERR pcomm->assign_global_ids(0, 3, 1,
false);
236 CHKERR moab.write_file(
"out.h5m");
237 }
239
241
242 return 0;
243}
#define CATCH_ERRORS
Catch errors.
#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 ...
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
@ MOFEM_DATA_INCONSISTENCY
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
static LoggerType & setLog(const std::string channel)
Set ans resset chanel logger.
#define MOFEM_LOG(channel, severity)
Log.
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
#define _IT_CUBITMESHSETS_FOR_LOOP_(MESHSET_MANAGER, IT)
Iterator that loops over all the Cubit MeshSets in a moFEM field.
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
auto get_temp_meshset_ptr(moab::Interface &moab)
Create smart pointer to temporary meshset.
virtual moab::Interface & get_moab()=0
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.
Deprecated interface functions.
static boost::shared_ptr< SinkType > createSink(boost::shared_ptr< std::ostream > stream_ptr, std::string comm_filter)
Create a sink object.
static boost::shared_ptr< std::ostream > getStrmWorld()
Get the strm world object.
Mesh refinement interface.
Interface for managing meshsets containing materials and boundary conditions.
Create interface from given surface and insert flat prisms in-between.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.