14 {
15
17
18 try {
19
20 moab::Core mb_instance;
21 moab::Interface &moab = mb_instance;
22 ParallelComm *pcomm = ParallelComm::get_pcomm(&moab,
MYPCOMM_INDEX);
23 if (pcomm == NULL)
24 pcomm = new ParallelComm(&moab, PETSC_COMM_WORLD);
25
26
28 char mesh_out_file[255] = "out.h5m";
29 PetscBool flg_file = PETSC_FALSE;
30 PetscBool flg_n_part = PETSC_FALSE;
31 PetscBool flg_part = PETSC_FALSE;
32 PetscBool only_tags = PETSC_FALSE;
33 PetscInt n_partas = 1;
34 PetscBool create_lower_dim_ents = PETSC_TRUE;
36 PetscInt adj_dim = 0;
37
38 ierr = PetscOptionsBegin(PETSC_COMM_WORLD,
"",
"none",
"none");
40
41 CHKERR PetscOptionsString(
"-my_file",
"mesh file name",
"",
"mesh.h5m",
43 if (flg_file != PETSC_TRUE)
44 CHKERR PetscOptionsString(
"-file_name",
"mesh file name",
"",
"mesh.h5m",
46 if (flg_file != PETSC_TRUE)
47 SETERRQ(PETSC_COMM_SELF, 1,
48 "*** ERROR -my_file (-file_name) (mesh file needed)");
49
50 const char *option;
51 option = "";
53
54 CHKERR PetscOptionsString(
"-output_file",
"output mesh file name",
"",
55 "out.h5m", mesh_out_file, 255, PETSC_NULL);
56 CHKERR PetscOptionsInt(
"-my_nparts",
"number of parts",
"", n_partas,
57 &n_partas, &flg_n_part);
58 CHKERR PetscOptionsInt(
"-nparts",
"number of parts",
"", n_partas,
59 &n_partas, &flg_part);
60
61 if (!flg_n_part && !flg_part)
62 SETERRQ(PETSC_COMM_SELF, 1,
63 "*** ERROR partitioning number not given (-nparts)");
64
65 auto get_nb_ents_by_dim = [&](
const int dim) {
66 int nb;
67 CHKERR moab.get_number_entities_by_dimension(0,
dim, nb);
68 return nb;
69 };
71 if (get_nb_ents_by_dim(
dim))
72 break;
73 }
74
77 "Dimension of entities to partition not found");
78
79 CHKERR PetscOptionsInt(
"-dim",
"entities dim",
"",
dim, &
dim, PETSC_NULL);
80
81 CHKERR PetscOptionsInt(
"-adj_dim",
"adjacency dim",
"", adj_dim, &adj_dim,
82 PETSC_NULL);
84 "-my_create_lower_dim_ents", "if true create lower dimension entireties",
85 "", create_lower_dim_ents, &create_lower_dim_ents, PETSC_NULL);
86 CHKERR PetscOptionsBool(
"-block_tags",
"only block and meshsests tags",
"",
87 only_tags, &only_tags, PETSC_NULL);
88
89 ierr = PetscOptionsEnd();
91
93 for (int d : {3, 2, 1})
94 if (ents.num_of_dimension(d))
95 return d;
96 return 0;
97 };
98
99
102
104 CHKERR meshsets_interface_ptr->setMeshsetFromFile();
105
108 int min_dim = 3;
109 for (auto cit = meshsets_interface_ptr->getBegin();
110 cit != meshsets_interface_ptr->getEnd(); cit++) {
112 CHKERR m_field.
get_moab().get_entities_by_handle(cit->getMeshset(), ents,
113 true);
114 min_dim = std::min(min_dim,
get_dim(ents));
116 }
117
118 int g_dim;
119 MPI_Allreduce(&min_dim, &g_dim, 1, MPI_INT, MPI_MIN, m_field.
get_comm());
120 if (g_dim < adj_dim) {
122 << "The minimum meshsets dimension is = " << min_dim;
123 }
124 if (adj_dim >=
dim) {
126 <<
"The -adj_dim >= dim, adj_dim = " << adj_dim <<
" dim = " <<
dim;
127 }
129
130 {
132 CHKERR moab.get_entities_by_dimension(0,
dim, ents_dim,
false);
133 if (create_lower_dim_ents) {
136 CHKERR moab.get_adjacencies(ents_dim, 2,
true, faces,
137 moab::Interface::UNION);
138 }
141 CHKERR moab.get_adjacencies(ents_dim, 1,
true, edges,
142 moab::Interface::UNION);
143 }
144 }
147 ents_dim,
dim, adj_dim, n_partas,
nullptr,
nullptr,
nullptr,
VERBOSE);
148 }
149
150 auto get_tag_list = [&]() {
151 std::vector<Tag> tags_list;
154 for (
auto &
m : list) {
155 auto meshset =
m.getMeshset();
156 std::vector<Tag> tmp_tags_list;
158 tmp_tags_list);
159 for (
auto t : tmp_tags_list) {
160 tags_list.push_back(
t);
161 }
162 }
163
164 return tags_list;
165 };
166
169 if (only_tags) {
170 auto tags_list = get_tag_list();
171 std::sort(tags_list.begin(), tags_list.end());
172 auto new_end = std::unique(tags_list.begin(), tags_list.end());
173 tags_list.resize(std::distance(tags_list.begin(), new_end));
174 tags_list.push_back(pcomm->part_tag());
175
176 CHKERR moab.write_file(mesh_out_file,
"MOAB",
"", &root_mesh, 1,
177 &*tags_list.begin(), tags_list.size());
178 } else {
179 CHKERR moab.write_file(mesh_out_file,
"MOAB",
"");
180 }
181 }
182 }
184
187
188 return 0;
189}
#define CATCH_ERRORS
Catch errors.
#define MYPCOMM_INDEX
default communicator number PCOMM
@ MOFEM_DATA_INCONSISTENCY
#define CHKERR
Inline error check.
FTensor::Index< 'm', SPACE_DIM > m
#define MOFEM_LOG(channel, severity)
Log.
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
MoFEMErrorCode partitionMesh(const Range &ents, const int dim, const int adj_dim, const int n_parts, Tag *th_vertex_weights=nullptr, Tag *th_edge_weights=nullptr, Tag *th_part_weights=nullptr, int verb=VERBOSE, const bool debug=false)
Set partition tag to each finite element in the problem.
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
constexpr double t
plate stiffness
virtual moab::Interface & get_moab()=0
virtual MPI_Comm & get_comm() const =0
virtual int get_comm_rank() const =0
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.
Interface for managing meshsets containing materials and boundary conditions.
CubitMeshSet_multiIndex & getMeshsetsMultindex()
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.