bitrl & cuberl Documentation
Simulation engine for reinforcement learning agents
Loading...
Searching...
No Matches
mesh.h
Go to the documentation of this file.
1#ifndef MESH_H
2#define MESH_H
3
5#include "bitrl/bitrl_types.h"
9
10#include "boost/noncopyable.hpp"
11
12namespace bitrl
13{
14namespace utils
15{
16namespace geom
17{
18
19// forward declarations
20template <int dim, typename T> class GeomPoint;
21
25template <int spacedim> class Mesh : private boost::noncopyable
26{
27
28 public:
33
35 typedef typename std::vector<Node<spacedim> *>::iterator node_iterator_impl;
36 typedef typename std::vector<Node<spacedim> *>::const_iterator cnode_iterator_impl;
37
39 typedef typename std::vector<Element<spacedim> *>::iterator element_iterator_impl;
40 typedef typename std::vector<Element<spacedim> *>::const_iterator celement_iterator_impl;
41
43 typedef typename std::vector<edge_ptr_t>::iterator edge_iterator_impl;
44 typedef typename std::vector<edge_ptr_t>::const_iterator cedge_iterator_impl;
45
47 typedef typename std::vector<face_ptr_t>::iterator face_iterator_impl;
48 typedef typename std::vector<face_ptr_t>::const_iterator cface_iterator_impl;
49
50 const static int dimension = spacedim;
51
53 Mesh();
54
56 virtual ~Mesh();
57
58 void reserve_n_nodes(uint_t n) { topology_.reserve_n_nodes(n); }
59 void reserve_n_elements(uint_t n) { topology_.reserve_n_elements(n); }
60 void reserve_n_edges(uint_t n) { topology_.reserve_n_edges(n); }
61 void reserve_n_faces(uint_t n) { topology_.reserve_n_faces(n); }
62
70
76
82
87 uint_t pid = 0);
88
93 uint_t pid = 0);
94
98 void set_n_boundaries(uint_t nb) { n_boundaries_ = nb; }
99
103 Node<spacedim> *node(uint_t n) { return topology_.node(n); }
104
108 const Node<spacedim> *node(uint_t n) const { return topology_.node(n); }
109
113 Element<spacedim> *element(uint_t e) { return topology_.element(e); }
114
118 const Element<spacedim> *element(uint_t e) const { return topology_.element(e); }
119
123 uint_t n_vertices() const;
124
128 uint_t n_nodes() const { return topology_.n_nodes(); }
129
133 uint_t n_elements() const { return topology_.n_elements(); }
134
136 uint_t n_edges() const;
137
139 uint_t n_faces() const;
140
144 uint_t n_active_faces() const;
145
147 MeshTopology<spacedim> *topology() { return &topology_; }
148
150 const MeshTopology<spacedim> *topology() const { return &topology_; }
151
153 void faces(const MeshConnectivity &faces_idx, std::vector<cface_ptr_t> &faces_ptr) const
154 {
155 topology_.faces(faces_idx, faces_ptr);
156 }
157
159 uint_t n_boundaries() const { return n_boundaries_; }
160
162 node_iterator_impl nodes_begin() { return topology_.nodes_begin(); }
163 node_iterator_impl nodes_end() { return topology_.nodes_end(); }
164
166 cnode_iterator_impl nodes_begin() const { return topology_.nodes_begin(); }
167 cnode_iterator_impl nodes_end() const { return topology_.nodes_end(); }
168
170 element_iterator_impl elements_begin() { return topology_.elements_begin(); }
171 element_iterator_impl elements_end() { return topology_.elements_end(); }
172
174 celement_iterator_impl elements_begin() const { return topology_.elements_begin(); }
175 celement_iterator_impl elements_end() const { return topology_.elements_end(); }
176
178 edge_iterator_impl edges_begin() { return topology_.edges_begin(); }
179 edge_iterator_impl edges_end() { return topology_.edges_end(); }
180
182 cedge_iterator_impl edges_begin() const { return topology_.edges_begin(); }
183 cedge_iterator_impl edges_end() const { return topology_.edges_end(); }
184
186 face_iterator_impl faces_begin() { return topology_.faces_begin(); }
187 face_iterator_impl faces_end() { return topology_.faces_end(); }
188
190 cface_iterator_impl faces_begin() const { return topology_.faces_begin(); }
191 cface_iterator_impl faces_end() const { return topology_.faces_end(); }
192
193 private:
195 uint_t n_boundaries_;
196
198 MeshTopology<spacedim> topology_;
199};
200
201template <int spacedim> inline uint_t Mesh<spacedim>::n_edges() const
202{
203 return topology_.n_edges();
204}
205
206template <int spacedim> inline uint_t Mesh<spacedim>::n_faces() const
207{
208 return topology_.n_faces();
209}
210
211template <> inline uint_t Mesh<1>::n_edges() const { return n_vertices(); }
212
213template <> inline uint_t Mesh<1>::n_faces() const { return n_edges(); }
214
215} // namespace geom
216} // namespace utils
217} // namespace bitrl
218
219#endif // MESH_H
Wraps the notion of an element.
Definition element.h:30
A class that describes a point with spacedim spatial dimension space.
Definition geom_point.h:22
MeshConnectivity class stores the various connectivities for a mesh object.
Definition mesh_connectivity.h:21
Definition mesh_topology.h:36
element_traits< Element< spacedim > >::cface_ptr_t cface_ptr_t
Definition mesh_topology.h:51
uint_t n_edges() const
get the number of edges in the mesh
Definition mesh_topology.h:143
element_traits< Element< spacedim > >::cedge_ptr_t cedge_ptr_t
Definition mesh_topology.h:50
element_traits< Element< spacedim > >::face_ptr_t face_ptr_t
Definition mesh_topology.h:48
element_traits< Element< spacedim > >::edge_ptr_t edge_ptr_t
Definition mesh_topology.h:47
A class that represents a mesh.
Definition mesh.h:26
void reserve_n_nodes(uint_t n)
Definition mesh.h:58
cface_iterator_impl faces_begin() const
Raw faces iteration.
Definition mesh.h:190
node_iterator_impl nodes_begin()
Raw node iteration.
Definition mesh.h:162
cface_iterator_impl faces_end() const
Definition mesh.h:191
void set_n_boundaries(uint_t nb)
Definition mesh.h:98
MeshTopology< spacedim >::edge_ptr_t edge_ptr_t
Definition mesh.h:29
std::vector< Node< spacedim > * >::const_iterator cnode_iterator_impl
Definition mesh.h:36
edge_iterator_impl edges_begin()
Raw faces iteration.
Definition mesh.h:178
element_iterator_impl elements_begin()
Raw elements iteration.
Definition mesh.h:170
uint_t n_edges() const
How many edges the mesh has.
Definition mesh.h:201
uint_t n_vertices() const
Definition mesh.cpp:79
std::vector< face_ptr_t >::iterator face_iterator_impl
Face iteration.
Definition mesh.h:47
MeshTopology< spacedim >::face_ptr_t face_ptr_t
Definition mesh.h:30
element_iterator_impl elements_end()
Definition mesh.h:171
cedge_iterator_impl edges_end() const
Definition mesh.h:183
static const int dimension
Definition mesh.h:50
const Element< spacedim > * element(uint_t e) const
Definition mesh.h:118
uint_t n_active_faces() const
Definition mesh.cpp:88
face_iterator_impl faces_end()
Definition mesh.h:187
MeshTopology< spacedim >::cface_ptr_t cface_ptr_t
Definition mesh.h:32
Node< spacedim > * create_node(const GeomPoint< spacedim, real_t > &point, uint_t global_id=bitrl::consts::INVALID_ID, uint_t pid=0)
Definition mesh.cpp:32
uint_t n_nodes() const
Definition mesh.h:128
Node< spacedim > * node(uint_t n)
Definition mesh.h:103
uint_t n_boundaries() const
Get the number of boundaries of the mesh.
Definition mesh.h:159
uint_t n_faces() const
how many faces the mesh has
Definition mesh.h:206
std::vector< edge_ptr_t >::iterator edge_iterator_impl
Edge iteration.
Definition mesh.h:43
edge_ptr_t create_edge(ElementType::sub_type t, uint_t global_id=bitrl::consts::INVALID_ID, uint_t pid=0)
Definition mesh.cpp:57
Node< spacedim > * create_vertex(const GeomPoint< spacedim, real_t > &point, uint_t global_id=bitrl::consts::INVALID_ID, uint_t pid=0)
Definition mesh.cpp:19
edge_iterator_impl edges_end()
Definition mesh.h:179
celement_iterator_impl elements_end() const
Definition mesh.h:175
celement_iterator_impl elements_begin() const
Raw elements iteration.
Definition mesh.h:174
cnode_iterator_impl nodes_begin() const
Raw node iteration.
Definition mesh.h:166
std::vector< Element< spacedim > * >::iterator element_iterator_impl
Element iteration.
Definition mesh.h:39
node_iterator_impl nodes_end()
Definition mesh.h:163
cedge_iterator_impl edges_begin() const
Raw faces iteration.
Definition mesh.h:182
cnode_iterator_impl nodes_end() const
Definition mesh.h:167
void faces(const MeshConnectivity &faces_idx, std::vector< cface_ptr_t > &faces_ptr) const
Get the pointers to the faces described by the given MeshConnectivity.
Definition mesh.h:153
const MeshTopology< spacedim > * topology() const
Read access to the topology of the mesh.
Definition mesh.h:150
void reserve_n_faces(uint_t n)
Definition mesh.h:61
MeshTopology< spacedim > * topology()
Return read/write access to the topology of the mesh.
Definition mesh.h:147
std::vector< face_ptr_t >::const_iterator cface_iterator_impl
Definition mesh.h:48
const Node< spacedim > * node(uint_t n) const
Definition mesh.h:108
std::vector< Node< spacedim > * >::iterator node_iterator_impl
Node iteration.
Definition mesh.h:35
void reserve_n_elements(uint_t n)
Definition mesh.h:59
face_ptr_t create_face(ElementType::sub_type t, uint_t global_id=bitrl::consts::INVALID_ID, uint_t pid=0)
Definition mesh.cpp:69
std::vector< Element< spacedim > * >::const_iterator celement_iterator_impl
Definition mesh.h:40
Element< spacedim > * create_element(ElementType::sub_type t, uint_t global_id=bitrl::consts::INVALID_ID, uint_t pid=0)
Definition mesh.cpp:42
face_iterator_impl faces_begin()
Raw faces iteration.
Definition mesh.h:186
virtual ~Mesh()
dtor
Definition mesh.cpp:16
void reserve_n_edges(uint_t n)
Definition mesh.h:60
uint_t n_elements() const
Definition mesh.h:133
MeshTopology< spacedim >::cedge_ptr_t cedge_ptr_t
Definition mesh.h:31
std::vector< edge_ptr_t >::const_iterator cedge_iterator_impl
Definition mesh.h:44
Element< spacedim > * element(uint_t e)
Definition mesh.h:113
Mesh()
Constructor. Creates an empty Mesh.
Definition mesh.cpp:14
Wraps the notion of a node. A node is simply a point in dim-space that can hold dofs.
Definition node.h:24
const uint_t INVALID_ID
Invalid id.
Definition bitrl_consts.h:21
OutT resolve(const std::string &name, const std::map< std::string, std::any > &input)
Definition std_map_utils.h:25
Definition bitrl_consts.h:14
std::size_t uint_t
uint_t
Definition bitrl_types.h:43
sub_type
Definition element_type.h:34