v0.14.0
add_meshsets.cpp
Go to the documentation of this file.
1 /** \file add_meshsets.cpp
2 
3  \brief Add meshsets
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  MoFEM::Core::Initialize(&argc, &argv, (char *)0, help);
16 
17  try {
18 
19  moab::Core mb_instance;
20  moab::Interface &moab = mb_instance;
21 
22  char mesh_file_name[255];
23  char mesh_out_file[255] = "out.h5m";
24  PetscBool flg_file = PETSC_FALSE;
25  ierr = PetscOptionsBegin(PETSC_COMM_WORLD, "", "none", "none");
26  CHKERRQ(ierr);
27  CHKERR PetscOptionsString("-my_file", "mesh file name", "", "mesh.h5m",
28  mesh_file_name, 255, &flg_file);
29  CHKERR PetscOptionsString("-output_file", "output mesh file name", "",
30  "out.h5m", mesh_out_file, 255, PETSC_NULL);
31  ierr = PetscOptionsEnd();
32  CHKERRQ(ierr);
33 
34  const char *option;
35  option = "";
36  CHKERR moab.load_file(mesh_file_name, 0, option);
37 
38  ParallelComm *pcomm = ParallelComm::get_pcomm(&moab, MYPCOMM_INDEX);
39  if (pcomm == NULL)
40  pcomm = new ParallelComm(&moab, PETSC_COMM_WORLD);
41 
42  // Create MoFEM database
43  MoFEM::Core core(moab);
44  MoFEM::Interface &m_field = core;
45 
46  MeshsetsManager *meshsets_interface_ptr;
47  CHKERR m_field.getInterface(meshsets_interface_ptr);
48  CHKERR meshsets_interface_ptr->setMeshsetFromFile();
49 
50  MOFEM_LOG_CHANNEL("WORLD");
51  MOFEM_LOG_TAG("WORLD", "add_meshsets")
52  MOFEM_LOG("WORLD", Sev::inform)
53  << "Print all meshsets (old and added from meshsets "
54  "configurational file)";
55  for (auto cit = meshsets_interface_ptr->getBegin();
56  cit != meshsets_interface_ptr->getEnd(); cit++)
57  MOFEM_LOG("WORLD", Sev::inform) << *cit;
58 
59  CHKERR moab.write_file(mesh_out_file);
60  }
62 
64 
65  return 0;
66 }
MoFEM::UnknownInterface::getInterface
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.
Definition: UnknownInterface.hpp:93
MYPCOMM_INDEX
#define MYPCOMM_INDEX
default communicator number PCOMM
Definition: definitions.h:215
MoFEM::CoreTmp< 0 >
Core (interface) class.
Definition: Core.hpp:82
MOFEM_LOG_CHANNEL
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
Definition: LogManager.hpp:284
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
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:535
MoFEM::MeshsetsManager::getEnd
CubitMeshSet_multiIndex::iterator getEnd() const
get begin iterator of cubit mehset of given type (instead you can use IT_CUBITMESHSETS_TYPE_FOR_LOOP(...
Definition: MeshsetsManager.hpp:257
MoFEM
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
MoFEM::MeshsetsManager::getBegin
CubitMeshSet_multiIndex::iterator getBegin() const
get begin iterator of cubit mehset of given type (instead you can use IT_CUBITMESHSETS_TYPE_FOR_LOOP(...
Definition: MeshsetsManager.hpp:243
MoFEM::MeshsetsManager::setMeshsetFromFile
MoFEMErrorCode setMeshsetFromFile(const string file_name, const bool clean_file_options=true)
add blocksets reading config file
Definition: MeshsetsManager.cpp:788
MOFEM_LOG_TAG
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
Definition: LogManager.hpp:339
mesh_file_name
char mesh_file_name[255]
Definition: mesh_smoothing.cpp:23
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_LOG
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:308
CATCH_ERRORS
#define CATCH_ERRORS
Catch errors.
Definition: definitions.h:372
MoFEM::Core
CoreTmp< 0 > Core
Definition: Core.hpp:1094
MoFEM::Exceptions::ierr
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:76
help
static char help[]
Definition: add_meshsets.cpp:12
MoFEM::MeshsetsManager
Interface for managing meshsets containing materials and boundary conditions.
Definition: MeshsetsManager.hpp:104
main
int main(int argc, char *argv[])
Definition: add_meshsets.cpp:14