v0.14.0
loops_test.cpp
Go to the documentation of this file.
1 
2 
3 #include <MoFEM.hpp>
4 
5 using namespace MoFEM;
6 
7 static char help[] = "...\n\n";
8 
9 int main(int argc, char *argv[]) {
10 
11  MoFEM::Core::Initialize(&argc, &argv, (char *)0, help);
12 
13  try {
14 
15  moab::Core mb_instance;
16  moab::Interface &moab = mb_instance;
17 
18  // Read parameters from line command
19  PetscBool flg = PETSC_TRUE;
20  char mesh_file_name[255];
21 #if PETSC_VERSION_GE(3, 6, 4)
22  ierr = PetscOptionsGetString(PETSC_NULL, "", "-my_file", mesh_file_name,
23  255, &flg);
24  CHKERRG(ierr);
25 #else
26  ierr = PetscOptionsGetString(PETSC_NULL, PETSC_NULL, "-my_file",
27  mesh_file_name, 255, &flg);
28  CHKERRG(ierr);
29 #endif
30  if (flg != PETSC_TRUE) {
31  SETERRQ(PETSC_COMM_SELF, 1, "*** ERROR -my_file (MESH FILE NEEDED)");
32  }
33 
34  // Read mesh to MOAB
35  const char *option;
36  option = "";
37  CHKERR moab.load_file(mesh_file_name, 0, option);
38 
39  // Create MoFEM (Joseph) database
40  MoFEM::Core core(moab);
41  MoFEM::Interface &m_field = core;
42 
43  // Open mesh_file_name.txt for writing
44  std::ofstream myfile;
45  myfile.open((std::string(mesh_file_name) + ".txt").c_str());
46 
47  std::cout << "<<<< All BLOCKSETs, SIDESETs and NODESETs >>>>>" << std::endl;
48  for (_IT_CUBITMESHSETS_FOR_LOOP_(m_field, it)) {
49  std::cout << it->getName() << std::endl;
50  myfile << it->getName() << std::endl;
51  }
52  std::cout << "<<<< BLOCKSETs >>>>>" << std::endl;
54  std::cout << it->getName() << std::endl;
55  myfile << it->getName() << std::endl;
56  }
57  std::cout << "<<<< NODESETs >>>>>" << std::endl;
59  std::cout << it->getName() << std::endl;
60  myfile << it->getName() << std::endl;
61  }
62  std::cout << "<<<< SIDESETs >>>>>" << std::endl;
64  std::cout << it->getName() << std::endl;
65  myfile << it->getName() << std::endl;
66  }
67  std::cout << "<<<< MeshSet of Name Moon >>>>" << std::endl;
68  for (_IT_CUBITMESHSETS_BY_NAME_FOR_LOOP_(m_field, "Moon", it)) {
69  std::cout << it->getName() << std::endl;
70  myfile << it->getName() << std::endl;
71  if (it->getBcTypeULong() & BLOCKSET) {
72  std::cout << "BLOCKSET" << std::endl;
73  myfile << "BLOCKSET" << std::endl;
74  }
75  if (it->getBcTypeULong() & SIDESET) {
76  std::cout << "SIDESET" << std::endl;
77  myfile << "SIDESET" << std::endl;
78  }
79  if (it->getBcTypeULong() & NODESET) {
80  std::cout << "NODESET" << std::endl;
81  myfile << "NODESET" << std::endl;
82  }
83  }
84 
85  // Close mesh_file_name.txt
86  myfile.close();
87  }
89 
91 }
main
int main(int argc, char *argv[])
Definition: loops_test.cpp:9
SIDESET
@ SIDESET
Definition: definitions.h:160
MoFEM::CoreTmp< 0 >
Core (interface) class.
Definition: Core.hpp:82
help
static char help[]
Definition: loops_test.cpp:7
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:2010
NODESET
@ NODESET
Definition: definitions.h:159
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
MoFEM
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
mesh_file_name
char mesh_file_name[255]
Definition: mesh_smoothing.cpp:22
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
CATCH_ERRORS
#define CATCH_ERRORS
Catch errors.
Definition: definitions.h:385
_IT_CUBITMESHSETS_BY_SET_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.
Definition: MeshsetsManager.hpp:71
MoFEM::Core
CoreTmp< 0 > Core
Definition: Core.hpp:1148
BLOCKSET
@ BLOCKSET
Definition: definitions.h:161
MoFEM::Exceptions::ierr
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:76
MoFEM::PetscOptionsGetString
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
Definition: DeprecatedPetsc.hpp:172
_IT_CUBITMESHSETS_BY_NAME_FOR_LOOP_
#define _IT_CUBITMESHSETS_BY_NAME_FOR_LOOP_(MESHSET_MANAGER, NAME, IT)
Iterator that loops over Cubit BlockSet having a particular name.
Definition: MeshsetsManager.hpp:94
_IT_CUBITMESHSETS_FOR_LOOP_
#define _IT_CUBITMESHSETS_FOR_LOOP_(MESHSET_MANAGER, IT)
Iterator that loops over all the Cubit MeshSets in a moFEM field.
Definition: MeshsetsManager.hpp:34
CHKERRG
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:496