v0.15.0
Loading...
Searching...
No Matches
delete_ho_nodes.cpp
Go to the documentation of this file.
1/** \file delete_ho_nodes.cpp
2 \brief Delete higher order nodes
3 \example delete_ho_nodes.cpp
4
5*/
6
7
8
9#include <MoFEM.hpp>
10
11using namespace MoFEM;
12
13// struct MyAddRemove: public moab::Interface::HONodeAddedRemoved {
14
15// void node_added (EntityHandle node, EntityHandle element ) {
16// cerr << "Node has beed added..." << endl;
17// }
18// void node_removed (EntityHandle node) {
19// cerr << "Node has beed deleted..." << endl;
20// }
21
22// };
23
24static char help[] = "...\n\n";
25
26int main(int argc, char *argv[]) {
27 MoFEM::Core::Initialize(&argc, &argv, (char *)0, help);
28
29 try {
30
31 // global variables
32 char mesh_file_name[255];
33 PetscBool flg_file = PETSC_FALSE;
34 PetscOptionsBegin(PETSC_COMM_WORLD, "", "Field to vertices options",
35 "none");
36 CHKERR PetscOptionsString("-my_file", "mesh file name", "", "mesh.h5m",
37 mesh_file_name, 255, &flg_file);
38 PetscOptionsEnd();
39
40 moab::Core mb_instance;
41 moab::Interface &moab = mb_instance;
42 ParallelComm *pcomm = ParallelComm::get_pcomm(&moab, MYPCOMM_INDEX);
43 if (pcomm == NULL)
44 pcomm = new ParallelComm(&moab, PETSC_COMM_WORLD);
45 const char *option;
46 option = "";
47 CHKERR moab.load_file(mesh_file_name, 0, option);
48
49 // Create MoFEM database
50 MoFEM::Core core(moab);
51
52 if (flg_file != PETSC_TRUE) {
53 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA,
54 "*** ERROR -my_file (MESH FILE NEEDED)");
55 }
56
57 Range all_tets, topo_nodes, mid_nodes;
58 CHKERR moab.get_entities_by_type(0, MBTET, all_tets);
59 CHKERR moab.get_connectivity(all_tets, topo_nodes, true);
60 CHKERR moab.get_connectivity(all_tets, mid_nodes, false);
61 std::cout << "\n Mesh contains of " << mid_nodes.size()
62 << " nodes in total. ";
63 mid_nodes = subtract(mid_nodes, topo_nodes);
64 std::cout << mid_nodes.size() << " higher order nodes. \n";
65
66 for (int dim : {1, 2, 3}) {
67 EntityHandle sub_meshset;
68 CHKERR moab.create_meshset(MESHSET_SET, sub_meshset);
69 Range edges;
70 CHKERR moab.get_entities_by_dimension(0, dim, edges, false);
71 CHKERR moab.add_entities(sub_meshset, edges);
72 CHKERR moab.convert_entities(sub_meshset, false, false,
73 false /*,&my_add_remove*/);
74 }
75
76 Range new_nodes;
77 CHKERR moab.get_entities_by_type(0, MBVERTEX, new_nodes);
78 PetscPrintf(PETSC_COMM_WORLD, "New number of nodes: %d. \n",
79 new_nodes.size());
80 PetscPrintf(PETSC_COMM_WORLD, "Saving file out.h5m... \n");
81
82 CHKERR moab.write_file("out.h5m");
83 }
85
87
88 return 0;
89}
int main()
#define CATCH_ERRORS
Catch errors.
#define MYPCOMM_INDEX
default communicator number PCOMM
@ MOFEM_INVALID_DATA
Definition definitions.h:36
#define CHKERR
Inline error check.
static char help[]
char mesh_file_name[255]
implementation of Data Operators for Forces and Sources
Definition Common.hpp:10
Core (interface) class.
Definition Core.hpp:82
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
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition Core.cpp:118