v0.14.0
get_skin.cpp
Go to the documentation of this file.
1 #include <MoFEM.hpp>
3 
4 using namespace MoFEM;
5 
6 static char help[] = "...\n\n";
7 
8 int main(int argc, char *argv[]) {
9  MoFEM::Core::Initialize(&argc, &argv, (char *)0, help);
10 
11  try {
12 
13  moab::Core mb_instance;
14  moab::Interface &moab = mb_instance;
15  ParallelComm *pcomm = ParallelComm::get_pcomm(&moab, MYPCOMM_INDEX);
16  if (pcomm == NULL)
17  pcomm = new ParallelComm(&moab, PETSC_COMM_WORLD);
18 
19  // Create MoFEM database
20  MoFEM::Core core(moab);
21  MoFEM::Interface &m_field = core;
22 
23  // global variables
24  char mesh_file_name[255] = "mesh.h5m";
25  char mesh_out_file[255] = "out.h5m";
26  int dim = 3;
27  PetscBool flg_file;
28 
29  ierr = PetscOptionsBegin(PETSC_COMM_WORLD, "", "none", "none");
30  CHKERRQ(ierr);
31 
32  CHKERR PetscOptionsString("-file_name", "mesh file name", "", "mesh.h5m",
33  mesh_file_name, 255, &flg_file);
34  CHKERR PetscOptionsString("-output_file", "output mesh file name", "",
35  mesh_out_file, mesh_out_file, 255, PETSC_NULL);
36  CHKERR PetscOptionsInt("-dim", "mesh dimension", "", dim, &dim, PETSC_NULL);
37 
38 
39  ierr = PetscOptionsEnd();
40  CHKERRQ(ierr);
41 
42  if (flg_file != PETSC_TRUE)
43  SETERRQ(PETSC_COMM_SELF, 1,
44  "*** ERROR -my_file (-file_name) (MESH FILE NEEDED)");
45 
46  MOFEM_LOG("WORLD", Sev::inform) << "In file " << mesh_file_name;
47  MOFEM_LOG("WORLD", Sev::inform) << "Out file " << mesh_out_file;
48  MOFEM_LOG("WORLD", Sev::inform) << "Mesh dimension " << dim;
49 
50  const char *option;
51  option = "";
52  CHKERR moab.load_file(mesh_file_name, 0, option);
53 
54  Range ents, skin;
55  CHKERR moab.get_entities_by_dimension(0, dim, ents);
56  MOFEM_LOG("WORLD", Sev::verbose) << "Ents:\n" << ents;
57 
58  Skinner skinner(&moab);
59  CHKERR skinner.find_skin(0, ents, false, skin);
60  MOFEM_LOG("WORLD", Sev::verbose) << "Skin:\n" << skin;
61 
62  EntityHandle set;
63  CHKERR moab.create_meshset(MESHSET_SET, set);
64  CHKERR moab.add_entities(set, skin);
65 
66  CHKERR moab.write_file(mesh_out_file, "MOAB", "", &set, 1);
67  }
69 
71 
72  return 0;
73 }
MYPCOMM_INDEX
#define MYPCOMM_INDEX
default communicator number PCOMM
Definition: definitions.h:215
MoFEM::CoreTmp< 0 >
Core (interface) class.
Definition: Core.hpp:82
EntityHandle
MoFEM.hpp
BasicFiniteElements.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
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
help
static char help[]
Definition: get_skin.cpp:6
main
int main(int argc, char *argv[])
Definition: get_skin.cpp:8
mesh_file_name
char mesh_file_name[255]
Definition: mesh_smoothing.cpp:23
Range
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