v0.9.0
Functions | Variables
delete_ho_nodes.cpp File Reference

Delete higher order nodes. More...

#include <MoFEM.hpp>

Go to the source code of this file.

Functions

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

Variables

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

Detailed Description

Delete higher order nodes.

Definition in file delete_ho_nodes.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)
Examples
delete_ho_nodes.cpp.

Definition at line 38 of file delete_ho_nodes.cpp.

38  {
39  MoFEM::Core::Initialize(&argc, &argv, (char *)0, help);
40 
41  try {
42 
43  // global variables
44  char mesh_file_name[255];
45  PetscBool flg_file = PETSC_FALSE;
46  CHKERR PetscOptionsBegin(PETSC_COMM_WORLD, "", "Field to vertices options",
47  "none");
48  CHKERR PetscOptionsString("-my_file", "mesh file name", "", "mesh.h5m",
49  mesh_file_name, 255, &flg_file);
50  ierr = PetscOptionsEnd();
51  CHKERRG(ierr);
52 
53  moab::Core mb_instance;
54  moab::Interface &moab = mb_instance;
55  ParallelComm *pcomm = ParallelComm::get_pcomm(&moab, MYPCOMM_INDEX);
56  if (pcomm == NULL)
57  pcomm = new ParallelComm(&moab, PETSC_COMM_WORLD);
58  const char *option;
59  option = "";
60  CHKERR moab.load_file(mesh_file_name, 0, option);
61 
62  // Create MoFEM database
63  MoFEM::Core core(moab);
64 
65  if (flg_file != PETSC_TRUE) {
66  SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA,
67  "*** ERROR -my_file (MESH FILE NEEDED)");
68  }
69 
70  Range all_tets, topo_nodes, mid_nodes;
71  CHKERR moab.get_entities_by_type(0, MBTET, all_tets);
72  CHKERR moab.get_connectivity(all_tets, topo_nodes, true);
73  CHKERR moab.get_connectivity(all_tets, mid_nodes, false);
74  std::cout << "\n Mesh contains of " << mid_nodes.size()
75  << " nodes in total. ";
76  mid_nodes = subtract(mid_nodes, topo_nodes);
77  std::cout << mid_nodes.size() << " higher order nodes. \n";
78 
79  for (int dim : {1, 2, 3}) {
80  EntityHandle sub_meshset;
81  CHKERR moab.create_meshset(MESHSET_SET, sub_meshset);
82  Range edges;
83  CHKERR moab.get_entities_by_dimension(0, dim, edges, false);
84  CHKERR moab.add_entities(sub_meshset, edges);
85  CHKERR moab.convert_entities(sub_meshset, false, false,
86  false /*,&my_add_remove*/);
87  }
88 
89  Range new_nodes;
90  CHKERR moab.get_entities_by_type(0, MBVERTEX, new_nodes);
91  PetscPrintf(PETSC_COMM_WORLD, "New number of nodes: %d. \n",
92  new_nodes.size());
93  PetscPrintf(PETSC_COMM_WORLD, "Saving file out.h5m... \n");
94 
95  CHKERR moab.write_file("out.h5m");
96  }
98 
100 
101  return 0;
102 }
static char help[]
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:544
Core (interface) class.
Definition: Core.hpp:50
char mesh_file_name[255]
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
Definition: Core.cpp:51
#define CHKERR
Inline error check.
Definition: definitions.h:596
#define MYPCOMM_INDEX
default communicator number PCOMM
Definition: definitions.h:285
#define CATCH_ERRORS
Catch errors.
Definition: definitions.h:433
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition: Core.cpp:61

Variable Documentation

◆ help

char help[] = "...\n\n"
static
Examples
delete_ho_nodes.cpp.

Definition at line 36 of file delete_ho_nodes.cpp.