v0.14.0
Loading...
Searching...
No Matches
meshset_to_vtk.cpp File Reference
#include <MoFEM.hpp>

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Variables

static char help [] = "...\n\n"
 

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 14 of file meshset_to_vtk.cpp.

14 {
15
16 MoFEM::Core::Initialize(&argc, &argv, (char *)0, help);
17
18 try {
19
20 // global variables
21 char mesh_file_name[255];
22 PetscBool flg_file = PETSC_FALSE;
23
24 ierr = PetscOptionsBegin(PETSC_COMM_WORLD, "", "none", "none");
25 CHKERRQ(ierr);
26
27 CHKERR PetscOptionsString("-my_file", "mesh file name", "", "mesh.h5m",
28 mesh_file_name, 255, &flg_file);
29
30 ierr = PetscOptionsEnd();
31 CHKERRQ(ierr);
32
33 moab::Core mb_instance;
34 moab::Interface &moab = mb_instance;
35 ParallelComm *pcomm = ParallelComm::get_pcomm(&moab, MYPCOMM_INDEX);
36 if (pcomm == NULL)
37 pcomm = new ParallelComm(&moab, PETSC_COMM_WORLD);
38
39 const char *option;
40 option = "";
41 CHKERR moab.load_file(mesh_file_name, 0, option);
42
43 // Create MoFEM database
44 MoFEM::Core core(moab);
45 MoFEM::Interface &m_field = core;
46
47 if (flg_file != PETSC_TRUE) {
48 SETERRQ(PETSC_COMM_SELF, 1, "*** ERROR -my_file (MESH FILE NEEDED)");
49 }
50
51 MeshsetsManager *meshsets_manager;
52 CHKERR m_field.getInterface(meshsets_manager);
53 CHKERR meshsets_manager->setMeshsetFromFile();
54
56
57 for (auto &cit : meshsets_manager->getMeshsetsMultindex()) {
58
59 std::string type = "_";
60 if((cit.getBcType() & CubitBCType(BLOCKSET)).any())
61 type += "BLOCKSET_";
62 if((cit.getBcType() & CubitBCType(SIDESET)).any())
63 type += "SIDESET_";
64 if((cit.getBcType() & CubitBCType(NODESET)).any())
65 type += "NODESET_";
66
67 std::string name = "meshset" + type +
68 boost::lexical_cast<std::string>(cit.getMeshsetId()) +
69 ".vtk";
70 std::cout << "Writting file: " << name << endl;
71
72 CHKERR meshsets_manager->saveMeshsetToFile(
73 cit.getMeshsetId(), (cit.getBcType() & mask).to_ulong(), name);
74 }
75 }
77
79 CHKERRQ(ierr);
80
81 return 0;
82}
#define CATCH_ERRORS
Catch errors.
#define MYPCOMM_INDEX
default communicator number PCOMM
@ NODESET
@ SIDESET
@ BLOCKSET
#define CHKERR
Inline error check.
char mesh_file_name[255]
static char help[]
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
std::bitset< 32 > CubitBCType
Definition Types.hpp:52
Core (interface) class.
Definition Core.hpp:82
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
Definition Core.cpp:72
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition Core.cpp:112
Deprecated interface functions.
Interface for managing meshsets containing materials and boundary conditions.
MoFEMErrorCode saveMeshsetToFile(const int ms_id, const unsigned int cubit_bc_type, const std::string file_name="out_meshset.vtk", const std::string file_type="VTK", const std::string options="") const
save cubit meshset entities on the moab mesh
CubitMeshSet_multiIndex & getMeshsetsMultindex()
MoFEMErrorCode setMeshsetFromFile(const string file_name, const bool clean_file_options=true)
add blocksets reading config file
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.

Variable Documentation

◆ help

char help[] = "...\n\n"
static

Definition at line 12 of file meshset_to_vtk.cpp.