simple_mesh_wrapper.h
Go to the documentation of this file.
1 /*
2 This file is part of the Ristra Wonton project.
3 Please see the license file at the root of this repository, or at:
4  https://github.com/laristra/wonton/blob/master/LICENSE
5 */
6 
7 #ifndef WONTON_SIMPLE_MESH_WRAPPER_H_
8 #define WONTON_SIMPLE_MESH_WRAPPER_H_
9 
11 
12 #include <vector>
13 #include <algorithm>
14 
16 #include "wonton/support/wonton.h"
17 #include "wonton/support/Point.h"
18 
24 namespace Wonton {
38 class Simple_Mesh_Wrapper : public AuxMeshTopology<Simple_Mesh_Wrapper> {
39  public:
50  explicit Simple_Mesh_Wrapper(Simple_Mesh const & mesh,
51  bool request_sides = true,
52  bool request_wedges = true,
53  bool request_corners = true) :
55  request_sides, request_wedges, request_corners),
56  mesh_(mesh) {
58  } // explicit constructor
59 
61  Simple_Mesh_Wrapper(Simple_Mesh_Wrapper const & inmesh) = delete;
62 
64  Simple_Mesh_Wrapper & operator=(Simple_Mesh_Wrapper const & inmesh) = delete;
65 
67  ~Simple_Mesh_Wrapper() = default;
68 
70  // The following methods are needed somewhere within AuxMeshTopology
71 
73  int space_dimension() const {
74  return mesh_.space_dimension();
75  }
76 
77  // The number of OWNED entities
78 
80  int num_owned_cells() const {
81  return mesh_.num_entities(Entity_kind::CELL,
83  }
84 
86  int num_owned_faces() const {
87  return mesh_.num_entities(Entity_kind::FACE,
89  }
90 
92  int num_owned_nodes() const {
93  return mesh_.num_entities(Entity_kind::NODE,
95  }
96 
97  // number of ghost data entities
98 
100  int num_ghost_cells() const {
101  return mesh_.num_entities(Entity_kind::CELL,
103  }
104 
106  int num_ghost_faces() const {
107  return mesh_.num_entities(Entity_kind::FACE,
109  }
110 
112  int num_ghost_nodes() const {
113  return mesh_.num_entities(Entity_kind::NODE,
115  }
116 
117  // cell type: Simple_Mesh only has OWNED
124  Entity_type cell_get_type(int const cellid) const {
126  }
127 
128  // node type: Simple_Mesh only has OWNED
135  Entity_type node_get_type(int const nodeid) const {
137  }
138 
139  // cell element type: Simple_Mesh only deals with HEX
146  Element_type cell_get_element_type(int const cellid) const {
147  return Element_type::HEX;
148  }
149 
150  // Connectivity information
151 
161  void cell_get_faces_and_dirs(int const cellid, std::vector<int> *cfaces,
162  std::vector<int> *cfdirs) const {
163  mesh_.cell_get_faces_and_dirs(cellid, cfaces, cfdirs);
164  }
165 
172  void cell_get_nodes(int const cellid, std::vector<int> *nodes) const {
173  mesh_.cell_get_nodes(cellid, nodes);
174  }
175 
181  void face_get_nodes(int const faceid, std::vector<int> *nodes) const {
182  mesh_.face_get_nodes(faceid, nodes);
183  }
184 
192  void node_get_cells(int const nodeid,
193  Entity_type const ptype,
194  std::vector<int> *nodecells) const {
195  mesh_.node_get_cells(nodeid, nodecells);
196  }
197 
199  GID_t get_global_id(int const id, Entity_kind const kind) const {
200  return id;
201  }
202 
203 
212  template<int D>
213  void node_get_coordinates(int const nodeid, Point<D>* pp) const
214  {
215  mesh_.node_get_coordinates(nodeid, pp);
216  }
217 
218  private:
220  Simple_Mesh const & mesh_;
221 }; // class Simple_Mesh_Wrapper
222 
223 } // namespace Wonton
224 
225 #endif // WONTON_SIMPLE_MESH_WRAPPER_H_
Element_type cell_get_element_type(int const cellid) const
Get the Element_type (e.g. HEX) of a specific cell.
Definition: simple_mesh_wrapper.h:146
Definition: wonton.h:128
void cell_get_nodes(int const cellid, std::vector< int > *nodes) const
Get the list of node IDs for a specific cell.
Definition: simple_mesh_wrapper.h:172
Entity_type node_get_type(int const nodeid) const
Get the Entity_type (e.g. PARALLEL_OWNED) of a specific node.
Definition: simple_mesh_wrapper.h:135
int num_entities(const Entity_kind kind, const Entity_type type) const
Determine the number of a specific mesh entity.
Definition: simple_mesh.h:163
Simple_Mesh_Wrapper & operator=(Simple_Mesh_Wrapper const &inmesh)=delete
Assignment operator (disabled).
void node_get_coordinates(int const nodeid, Point< D > *pp) const
Get the coordinates of a specific node as a Wonton::Point.
Definition: simple_mesh_wrapper.h:213
A thin wrapper that implements mesh methods for Simple_Mesh.
Definition: simple_mesh_wrapper.h:38
Factorize a number N into D equal (or nearly equal) factors.
Definition: adaptive_refinement_mesh.h:31
void node_get_cells(const ID nodeid, std::vector< ID > *cells) const
For a given node, get all the cells attached to this node.
Definition: simple_mesh.h:260
Definition: wonton.h:87
void cell_get_faces_and_dirs(int const cellid, std::vector< int > *cfaces, std::vector< int > *cfdirs) const
Get the list of face IDs and face normal directions for a specific cell.
Definition: simple_mesh_wrapper.h:161
int space_dimension() const
Spatial dimension of the mesh.
Definition: simple_mesh.h:153
Entity_type
The parallel type of a given entity.
Definition: wonton.h:124
int num_ghost_nodes() const
The number of GHOST nodes in the mesh.
Definition: simple_mesh_wrapper.h:112
Definition: wonton.h:85
Definition: wonton.h:161
int space_dimension() const
The spatial dimension of the mesh.
Definition: simple_mesh_wrapper.h:73
int num_ghost_cells() const
The number of GHOST cells in the mesh.
Definition: simple_mesh_wrapper.h:100
Definition: wonton.h:88
Represents a point in an N-dimensional space.
Definition: Point.h:50
void cell_get_faces_and_dirs(const ID cellid, std::vector< ID > *faces, std::vector< int > *fdirs) const
For a given cell, get the list of faces and the direction of their normals.
Definition: simple_mesh.h:218
void node_get_cells(int const nodeid, Entity_type const ptype, std::vector< int > *nodecells) const
Get the list of IDs of all cells of a particular parallel type attached to a node.
Definition: simple_mesh_wrapper.h:192
A very light-weight, serial, 2D/3D Cartesian mesh.
Definition: simple_mesh.h:47
Entity_kind
The type of mesh entity.
Definition: wonton.h:81
GID_t get_global_id(int const id, Entity_kind const kind) const
Get the global ID. NOTE: Simple_Mesh only has local IDs.
Definition: simple_mesh_wrapper.h:199
void build_aux_entities()
Definition: AuxMeshTopology.h:1331
int64_t GID_t
Definition: wonton.h:76
int num_owned_faces() const
The number of OWNED faces in the mesh.
Definition: simple_mesh_wrapper.h:86
A very light-weight, simple mesh infrastructure.
void face_get_nodes(int const faceid, std::vector< int > *nodes) const
Get the list of node IDs for a specific face.
Definition: simple_mesh_wrapper.h:181
int num_owned_nodes() const
The number of ONWED nodes in the mesh.
Definition: simple_mesh_wrapper.h:92
Element_type
Element (cell topology) type.
Definition: wonton.h:153
Simple_Mesh_Wrapper(Simple_Mesh const &mesh, bool request_sides=true, bool request_wedges=true, bool request_corners=true)
Constructor for the mesh wrapper.
Definition: simple_mesh_wrapper.h:50
void face_get_nodes(const ID faceid, std::vector< ID > *nodes) const
For a given face, get the list of nodes.
Definition: simple_mesh.h:247
void node_get_coordinates(const ID nodeid, Point< D > *pp) const
Get the coordinates of a node.
Definition: simple_mesh.h:280
~Simple_Mesh_Wrapper()=default
Destructor.
Definition: wonton.h:127
int num_owned_cells() const
The number of OWNED cells in the mesh.
Definition: simple_mesh_wrapper.h:80
int num_ghost_faces() const
The number of GHOST faces in the mesh.
Definition: simple_mesh_wrapper.h:106
Entity_type cell_get_type(int const cellid) const
Get the Entity_type (e.g. PARALLEL_OWNED) of a specific cell.
Definition: simple_mesh_wrapper.h:124
void cell_get_nodes(const ID cellid, std::vector< ID > *nodes) const
For a given cell, get the list of nodes.
Definition: simple_mesh.h:235