29 ParallelComm *pcomm = ParallelComm::get_pcomm(&moab,
MYPCOMM_INDEX);
31 pcomm =
new ParallelComm(&moab, PETSC_COMM_WORLD);
35 char mesh_out_file[255] =
"out.h5m";
36 PetscBool flg_file = PETSC_FALSE;
37 PetscBool flg_n_part = PETSC_FALSE;
38 PetscBool flg_part = PETSC_FALSE;
39 PetscBool only_tags = PETSC_FALSE;
40 PetscInt n_partas = 1;
41 PetscBool create_lower_dim_ents = PETSC_TRUE;
45 ierr = PetscOptionsBegin(PETSC_COMM_WORLD,
"",
"none",
"none");
48 CHKERR PetscOptionsString(
"-my_file",
"mesh file name",
"",
"mesh.h5m",
50 if (flg_file != PETSC_TRUE)
51 CHKERR PetscOptionsString(
"-file_name",
"mesh file name",
"",
"mesh.h5m",
53 if (flg_file != PETSC_TRUE)
54 SETERRQ(PETSC_COMM_SELF, 1,
55 "*** ERROR -my_file (-file_name) (mesh file needed)");
61 CHKERR PetscOptionsString(
"-output_file",
"output mesh file name",
"",
62 "out.h5m", mesh_out_file, 255, PETSC_NULL);
63 CHKERR PetscOptionsInt(
"-my_nparts",
"number of parts",
"", n_partas,
64 &n_partas, &flg_n_part);
65 CHKERR PetscOptionsInt(
"-nparts",
"number of parts",
"", n_partas,
66 &n_partas, &flg_part);
68 if (!flg_n_part && !flg_part)
69 SETERRQ(PETSC_COMM_SELF, 1,
70 "*** ERROR partitioning number not given (-nparts)");
72 auto get_nb_ents_by_dim = [&](
const int dim) {
74 CHKERR moab.get_number_entities_by_dimension(0, dim, nb);
77 for (; dim >= 0; dim--) {
78 if (get_nb_ents_by_dim(dim))
84 "Dimension of entities to partition not found");
86 CHKERR PetscOptionsInt(
"-dim",
"entities dim",
"", dim, &dim, PETSC_NULL);
88 CHKERR PetscOptionsInt(
"-adj_dim",
"adjacency dim",
"", adj_dim, &adj_dim,
91 "-my_create_lower_dim_ents",
"if true create lower dimension entireties",
92 "", create_lower_dim_ents, &create_lower_dim_ents, PETSC_NULL);
93 CHKERR PetscOptionsBool(
"-block_tags",
"only block and meshsests tags",
"",
94 only_tags, &only_tags, PETSC_NULL);
96 ierr = PetscOptionsEnd();
100 for (
int d : {3, 2, 1})
101 if (ents.num_of_dimension(
d))
111 CHKERR meshsets_interface_ptr->setMeshsetFromFile();
116 for (
auto cit = meshsets_interface_ptr->getBegin();
117 cit != meshsets_interface_ptr->getEnd(); cit++) {
119 CHKERR m_field.
get_moab().get_entities_by_handle(cit->getMeshset(), ents,
121 min_dim = std::min(min_dim,
get_dim(ents));
126 MPI_Allreduce(&min_dim, &g_dim, 1, MPI_INT, MPI_MIN, m_field.
get_comm());
127 if (g_dim < adj_dim) {
129 <<
"The minimum meshsets dimension is = " << min_dim;
131 if (adj_dim >= dim) {
133 <<
"The -adj_dim >= dim, adj_dim = " << adj_dim <<
" dim = " << dim;
139 CHKERR moab.get_entities_by_dimension(0, dim, ents_dim,
false);
140 if (create_lower_dim_ents) {
143 CHKERR moab.get_adjacencies(ents_dim, 2,
true, faces,
144 moab::Interface::UNION);
148 CHKERR moab.get_adjacencies(ents_dim, 1,
true, edges,
149 moab::Interface::UNION);
154 ents_dim, dim, adj_dim, n_partas,
nullptr,
nullptr,
nullptr,
VERBOSE);
157 auto get_tag_list = [&]() {
158 std::vector<Tag> tags_list;
161 for (
auto &
m : list) {
162 auto meshset =
m.getMeshset();
163 std::vector<Tag> tmp_tags_list;
166 for (
auto t : tmp_tags_list) {
167 tags_list.push_back(
t);
177 auto tags_list = get_tag_list();
178 std::sort(tags_list.begin(), tags_list.end());
179 auto new_end = std::unique(tags_list.begin(), tags_list.end());
180 tags_list.resize(std::distance(tags_list.begin(), new_end));
181 tags_list.push_back(pcomm->part_tag());
183 CHKERR moab.write_file(mesh_out_file,
"MOAB",
"", &root_mesh, 1,
184 &*tags_list.begin(), tags_list.size());
186 CHKERR moab.write_file(mesh_out_file,
"MOAB",
"");