v0.14.0
meshset_to_vtk.cpp
Go to the documentation of this file.
1 /** \file meshset_to_vtk.cpp
2  * \example meshset_to_vtk.cpp
3  * \brief Print all meshset to VTK file
4  *
5 */
6 
7 
8 
9 #include <MoFEM.hpp>
10 using namespace MoFEM;
11 
12 static char help[] = "...\n\n";
13 
14 int main(int argc, char *argv[]) {
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 }
MoFEM::UnknownInterface::getInterface
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.
Definition: UnknownInterface.hpp:93
SIDESET
@ SIDESET
Definition: definitions.h:147
MYPCOMM_INDEX
#define MYPCOMM_INDEX
default communicator number PCOMM
Definition: definitions.h:215
MoFEM::CoreTmp< 0 >
Core (interface) class.
Definition: Core.hpp:82
help
static char help[]
Definition: meshset_to_vtk.cpp:12
MoFEM.hpp
MoFEM::CoreTmp< 0 >::Finalize
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition: Core.cpp:112
MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:16
MoFEM::Interface
DeprecatedCoreInterface Interface
Definition: Interface.hpp:1975
NODESET
@ NODESET
Definition: definitions.h:146
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:535
MoFEM::MeshsetsManager::saveMeshsetToFile
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
Definition: MeshsetsManager.cpp:1396
MoFEM
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
MoFEM::MeshsetsManager::setMeshsetFromFile
MoFEMErrorCode setMeshsetFromFile(const string file_name, const bool clean_file_options=true)
add blocksets reading config file
Definition: MeshsetsManager.cpp:788
convert.type
type
Definition: convert.py:64
main
int main(int argc, char *argv[])
Definition: meshset_to_vtk.cpp:14
mesh_file_name
char mesh_file_name[255]
Definition: mesh_smoothing.cpp:23
MoFEM::MeshsetsManager::getMeshsetsMultindex
CubitMeshSet_multiIndex & getMeshsetsMultindex()
Definition: MeshsetsManager.hpp:229
MoFEM::CoreTmp< 0 >::Initialize
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
MoFEM::Types::CubitBCType
std::bitset< 32 > CubitBCType
Definition: Types.hpp:52
CATCH_ERRORS
#define CATCH_ERRORS
Catch errors.
Definition: definitions.h:372
MoFEM::Core
CoreTmp< 0 > Core
Definition: Core.hpp:1094
BLOCKSET
@ BLOCKSET
Definition: definitions.h:148
MoFEM::Exceptions::ierr
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:76
MoFEM::MeshsetsManager
Interface for managing meshsets containing materials and boundary conditions.
Definition: MeshsetsManager.hpp:104