60 rval =
mOab.tag_get_handle(block_name.c_str(), 1, MB_TYPE_INTEGER, mat_tag,
61 MB_TAG_EXCL | MB_TAG_SPARSE);
62 if (
rval != MB_ALREADY_ALLOCATED) {
67 for (
auto mbtype : {MBTET, MBTRI, MBHEX, MBQUAD, MBEDGE, MBVERTEX}) {
68 CHKERR mOab.get_entities_by_type_and_tag(0, mbtype, &mat_tag, NULL, 1,
69 block_ents, moab::Interface::UNION);
72 if (!block_ents.empty()) {
73 std::map<int, Range> mat_map;
74 for (
auto &ent : block_ents) {
76 CHKERR mOab.tag_get_data(mat_tag, &ent, 1, &mat_id);
77 mat_map[mat_id].insert(ent);
80 for (
auto &[mat_id, mat_ents] : mat_map) {
81 std::string meshset_name = block_name +
"_" + std::to_string(mat_id);
85 <<
"Blockset " << meshset_name <<
" set added.";
98 CHKERR mOab.tag_get_handle(
"BOUNDARY_CONDITIONS", 1, MB_TYPE_INTEGER, bc_tag,
99 MB_TAG_CREAT | MB_TAG_SPARSE);
101 std::vector<std::tuple<int, std::string, std::string>> conditions = {
102 {1,
"FIX_ALL",
"FIX_ALL"},
103 {2,
"FIX_X",
"FIX_X"},
104 {3,
"FIX_Y",
"FIX_Y"},
105 {4,
"FIX_Z",
"FIX_Z"},
106 {5,
"FIX_X_2",
"DISP_X"},
107 {6,
"FIX_Y_2",
"DISP_Y"},
108 {7,
"FIX_Z_2",
"DISP_Z"},
109 {8,
"FORCE_X",
"FORCE_X"},
110 {9,
"FORCE_Y",
"FORCE_Y"},
111 {10,
"FORCE_Z",
"FORCE_Z"},
112 {11,
"VEL_X",
"VEL_X"},
113 {12,
"VEL_Y",
"VEL_Y"},
114 {13,
"VEL_Z",
"VEL_Z"},
115 {14,
"ACCL_X",
"ACCL_X"},
116 {15,
"ACCL_Y",
"ACCL_Y"},
117 {16,
"ACCL_Z",
"ACCL_Z"},
118 {17,
"TEMP",
"TEMP"},
119 {18,
"PRESSURE",
"PRESSURE"},
120 {19,
"HEAT_FLUX",
"HEAT_FLUX"},
121 {20,
"CONTACT",
"CONTACT"},
122 {21,
"DISPLACEMENT",
"DISPLACEMENT"},
123 {22,
"ROTATE_ALL",
"ROTATE_ALL"},
124 {23,
"ROTATE_X",
"ROTATE_X"},
125 {24,
"ROTATE_Y",
"ROTATE_Y"},
126 {25,
"ROTATE_Z",
"ROTATE_Z"},
127 {26,
"TEMPERATURE",
"TEMPERATURE"},
128 {50,
"TIE_MATRIX",
"TIE_MATRIX"}};
130 for (
auto &condition : conditions) {
131 int desired_val = std::get<0>(condition);
132 const void *desired_val_ptr = &desired_val;
134 CHKERR mOab.get_entities_by_type_and_tag(0, MBVERTEX, &bc_tag,
135 &desired_val_ptr, 1, bc);
139 CHKERR mOab.get_adjacencies(bc, 2,
true, faces, moab::Interface::UNION);
141 CHKERR mOab.get_adjacencies(bc, 1,
true, edges, moab::Interface::UNION);
144 CHKERR mOab.get_adjacencies(faces, 0,
false, adj_nodes,
145 moab::Interface::UNION);
148 non_BC_nodes = subtract(adj_nodes, bc);
150 CHKERR mOab.get_adjacencies(non_BC_nodes, 2,
false, non_BC_faces,
151 moab::Interface::UNION);
153 CHKERR mOab.get_adjacencies(non_BC_nodes, 1,
false, non_BC_edges,
154 moab::Interface::UNION);
156 faces = subtract(faces, non_BC_faces);
157 edges = subtract(edges, non_BC_edges);
159 MOFEM_LOG_C(
"WORLD", Sev::inform,
"Number of nodes assigned to %s = %d",
160 std::get<2>(condition).c_str(), bc.size());
161 MOFEM_LOG_C(
"WORLD", Sev::inform,
"Number of edges assigned to %s = %d",
162 std::get<2>(condition).c_str(), edges.size());
163 MOFEM_LOG_C(
"WORLD", Sev::inform,
"Number of faces assigned to %s = %d",
164 std::get<2>(condition).c_str(), faces.size());
167 std::get<1>(condition));
192 <<
"Print all meshsets (old and added from meshsets "
193 "configurational file)";
194 for (
auto cit = meshsets_interface_ptr->
getBegin();
195 cit != meshsets_interface_ptr->
getEnd(); cit++)
207 rval =
mOab.get_entities_by_dimension(0, 3, ents,
true);
208 if (
rval != MB_SUCCESS) {
210 <<
"No hexes/tets in the mesh, no material block set. Not Implemented";
216 MOFEM_LOG(
"WORLD", Sev::inform) <<
"Material block ADOLCMAT set added.";
224 char mesh_out_file[255] =
"out_vtk.h5m";
227 CHKERR PetscOptionsString(
"-output_file",
"output mesh file name",
"",
228 "out.h5m", mesh_out_file, 255, PETSC_NULL);
229 ierr = PetscOptionsEnd();
244 CHKERR mOab.get_entities_by_dimension(0, 3, ents);
245 if (ents.size() != 125) {
248 "atom test %d failed: Wrong number of elements %d, should be 125",
259 if (it->getMeshsetId() == 1) {
260 if (it->getName() !=
"FIX_ALL") {
262 "atom test %d failed: Wrong name of meshset %d, should be "
264 atom_test, it->getMeshsetId(), it->getName());
266 if (ents.size() != 25) {
268 "atom test %d failed: Wrong number of entities in meshset "
269 "%d with %d, should be 25",
270 atom_test, it->getMeshsetId(), ents.size());
272 }
else if (it->getMeshsetId() == 2) {
273 if (it->getName() !=
"FIX_X") {
275 "atom test %d failed: Wrong name of meshset %d, should be "
277 atom_test, it->getMeshsetId(), it->getName());
279 if (ents.size() != 25) {
281 "atom test %d failed: Wrong number of entities in meshset "
282 "%d with %d, should be 25",
283 atom_test, it->getMeshsetId(), ents.size());
285 }
else if (it->getMeshsetId() == 100) {
286 if (it->getName() !=
"ADOLCMAT") {
288 "atom test %d failed: Wrong name of meshset %d, should be "
290 atom_test, it->getMeshsetId(), it->getName());
300int main(
int argc,
char *argv[]) {
305 moab::Core mb_instance;
306 moab::Interface &moab = mb_instance;
307 ParallelComm *pcomm = ParallelComm::get_pcomm(&moab,
MYPCOMM_INDEX);
309 pcomm =
new ParallelComm(&moab, PETSC_COMM_WORLD);
#define MOFEM_LOG_C(channel, severity, format,...)
#define CATCH_ERRORS
Catch errors.
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#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 ...
@ MOFEM_ATOM_TEST_INVALID
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
#define MOFEM_LOG(channel, severity)
Log.
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
CubitMeshSet_multiIndex::iterator getBegin() const
get begin iterator of cubit mehset of given type (instead you can use IT_CUBITMESHSETS_TYPE_FOR_LOOP(...
MoFEMErrorCode addMeshset(const CubitBCType cubit_bc_type, const int ms_id, const std::string name="")
add cubit meshset
CubitMeshSet_multiIndex::iterator getEnd() const
get begin iterator of cubit mehset of given type (instead you can use IT_CUBITMESHSETS_TYPE_FOR_LOOP(...
#define _IT_CUBITMESHSETS_BY_SET_TYPE_FOR_LOOP_(MESHSET_MANAGER, CUBITBCTYPE, IT)
Iterator that loops over a specific Cubit MeshSet having a particular BC meshset in a moFEM field.
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
implementation of Data Operators for Forces and Sources
PetscErrorCode PetscOptionsGetBool(PetscOptions *, const char pre[], const char name[], PetscBool *bval, PetscBool *set)
virtual moab::Interface & get_moab()=0
virtual MPI_Comm & get_comm() 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.
MoFEMErrorCode addEntitiesToMeshset(const CubitBCType cubit_bc_type, const int ms_id, const Range &ents)
add entities to cubit meshset
MoFEMErrorCode setMeshsetFromFile(const string file_name, const bool clean_file_options=true)
add blocksets reading config file
Simple interface for fast problem set-up.
MoFEMErrorCode loadFile(const std::string options, const std::string mesh_file_name, LoadFileFunc loadFunc=defaultLoadFileFunc)
Load mesh file.
MoFEMErrorCode getOptions()
get options
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
MoFEMErrorCode setBoundaryConditions()
MoFEMErrorCode getBlockSetBCFromMesh(std::string)
VtkInterface(MoFEM::Interface &m_field, moab::Interface &moab)
MoFEMErrorCode getMaterialProperties()
MoFEMErrorCode readMesh()
MoFEMErrorCode checkResults()
MoFEMErrorCode writeOutput()
MoFEMErrorCode getBoundaryConditions()
MoFEM::Interface & mField