bitrl & cuberl Documentation
Simulation engine for reinforcement learning agents
Loading...
Searching...
No Matches
face_element.h
Go to the documentation of this file.
1#ifndef FACE_ELEMENT_H
2#define FACE_ELEMENT_H
3
5#include "bitrl/bitrl_types.h"
9
10#include <any>
11#include <array>
12
13namespace bitrl
14{
15namespace utils
16{
17namespace geom
18{
19
21// template<int spacedim> class Mesh;
22
23template <int dim> class Element;
24template <int dim> class Node;
25template <int dim, int topodim> class FaceElement;
26
35template <int spacedim>
36class FaceElement<spacedim, 0> : public GeomPoint<spacedim>, public MeshEntity
37{
38
39 public:
44
48 explicit FaceElement(uint_t global_id, real_t val = 0.0, uint_t pid = 0,
49 const std::any &data = std::any());
50
54 FaceElement(const std::array<real_t, spacedim> &coords, uint_t global_id, uint_t pid = 0,
55 const std::any &data = std::any());
56
61 const std::any &data);
62
67
71 FaceElement &operator=(const FaceElement &t);
72
76 virtual ~FaceElement() {}
77
79 void make_vertex() { is_vertex_ = true; }
80
82 bool is_vertex() const { return is_vertex_; }
83
87 real_t volume() const { return 0.0; }
88
90 GeomPoint<spacedim> centroid() const { return *this; }
91
92 bool on_boundary() const { return boundary_indicator_ != bitrl::consts::INVALID_ID; }
93 uint_t boundary_indicator() const { return boundary_indicator_; }
94
95 private:
96 bool is_vertex_;
97 uint_t boundary_indicator_;
98};
99
111template <> class FaceElement<2, 1>
112{
113
114 public:
115 static const int dim_ = 2;
116 static const int topodim_ = 1;
117
119 typedef const Node<2> *cnode_ptr_t;
121 typedef const Node<2> &cnode_ref_t;
126
128 virtual ~FaceElement() {}
129
131 virtual void resize_nodes();
132
134 virtual uint_t n_nodes() const { return n_nodes_; }
135
137 virtual void set_node(uint_t i, node_ptr_t node);
138
140 virtual node_ptr_t node_ptr(uint_t n);
141
143 virtual uint_t n_vertices() const { return 2; }
144
146 virtual uint_t n_edges() const { return 2; }
147
149 virtual uint_t n_faces() const { return 2; }
150
153 void set_owner_element(Element<2> *o) { owner_ = o; }
154
158 void set_shared_element(Element<2> *n) { neighbor_ = n; }
159
162 {
163 owner_ = o;
164 neighbor_ = n;
165 }
166
168 void set_boundary_indicator(uint_t bind) { boundary_indicator_ = bind; }
169
172 Element<2> *owner() { return owner_; }
173
177 Element<2> *neighbor() { return neighbor_; }
178
180 virtual std::vector<uint_t> get_vertices_ids() const;
181
183 bool on_boundary() const { return boundary_indicator_ != bitrl::consts::INVALID_ID; }
184
186 uint_t boundary_indicator() const { return boundary_indicator_; }
187
189 real_t volume() const;
190
195 real_t owner_neighbor_distance() const;
196
198 virtual std::ostream &print_mesh_entity_info(std::ostream &out) const;
199
201 const GeomPoint<2> centroid() const;
202
205 bool is_owner(uint_t id) const;
206
208 Element<2> &get_neighbor();
209
211 const Element<2> &get_neighbor() const;
212
214 Element<2> &get_owner();
215
217 const Element<2> &get_owner() const;
218
220 cnode_ref_t get_vertex(uint_t v) const;
221
223 node_ref_t get_vertex(uint_t v);
224
226 const DynVec<real_t> normal_vector() const;
227
228 bool is_active() const { return true; }
229 uint_t get_id() const { return id_; }
230 void set_id(uint_t id) { id_ = id; }
231 bool has_valid_id() const { return true; }
232
233 protected:
234 FaceElement();
235 FaceElement(uint_t id, uint_t pid = 0);
237
239 std::vector<node_ptr_t> nodes_;
240
241 private:
243 Element<2> *owner_;
244
246 Element<2> *neighbor_;
247
250 uint_t boundary_indicator_;
251
253 std::ostream &print_(std::ostream &o) const;
254
256 uint_t id_;
257
259 uint_t n_nodes_;
260};
261
262inline std::ostream &FaceElement<2, 1>::print_mesh_entity_info(std::ostream &out) const
263{
264 return print_(out);
265}
266
267/*
268
269//forward declaration
270class Face;
271
272template<>
273class FaceElement<3,1>
274{
275
276 protected:
277
278
279 FaceElement();
280 FaceElement(uint_t id,uint_t pid=0);
281 FaceElement(uint_t id, uint_t nnodes, uint_t pid);
282
283 public:
284
285 static const int dim_ = 3;
286 static const int topodim_ = 1;
287
288 typedef EdgeSelector<3>::ptr_t edge_ptr_t;
289 typedef EdgeSelector<3>::ptr_t face_ptr_t;
290
291 virtual ~FaceElement(){}
292
293
294 void set_owner_element(Face* o){owner_ = o;}
295 void set_shared_element(Face* n){neighbor_ = n;}
296 void set_owner_shared_elements(Face* o, Face* n)
297 {owner_ = o; neighbor_ = n;}
298 void set_boundary_indicator(uint_t bind){boundary_indicator_=bind;}
299 Face* owner(){return owner_;}
300 Face* neighbor(){return neighbor_;}
301 bool on_boundary () const {return true;}
302 uint_t boundary_indicator()const{return boundary_indicator_;}
303
304
305
306 virtual std::ostream& print_mesh_entity_info(std::ostream &out)const;
307
309 real_t volume()const{return 0.0;}
310
312 GeomPoint<3> centroid()const{return GeomPoint<3>(0.0);}
313
316 bool is_owner(uint_t id)const{return true;}
317
319 Element<3>& get_neighbor(){}
320
322 const Element<3>& get_neighbor()const{}
323
325 Element<3>& get_owner(){}
326
328 const Element<3>& get_owner()const{}
329
330 bool is_active()const{return true;}
331
332 uint_t get_id()const{return id_;}
333 void set_id(uint_t id){id_ = id;}
334 bool has_valid_id()const{return true;}
335
336private:
337
338 Face* owner_;
339 Face* neighbor_;
340 uint_t boundary_indicator_;
341
342 std::ostream& print_(std::ostream& o)const;
343
344 uint_t id_;
345
346
347};
348
349inline
350std::ostream&
351FaceElement<3,1>::print_mesh_entity_info(std::ostream &out)const
352{
353 return print_(out);
354}
355
356*/
357
358//
360// * A Face<3> IsA FaceElement<3,2>
361// *
362// * This is the base class for representing faces in MeshGeometry::dim_ = 3
363// * spatial dimension. Concrete classes of this class implement the pure virtual
364// * functions inherited by Element<3,2> class. Concrete classes of this class are
365// * Quad<3>, Tri<3>.
366// */
367//
368// template<>
369// class FaceElement<3,2>
370//{
371//
372// protected:
373//
374//
375// FaceElement();
376//
377// FaceElement(uint_t id,uint_t pid=0);
378//
379// public:
380//
381//
382// static const int dim_ = 3;
383// static const int topodim_ = 2;
384//
385// typedef EdgeSelector<3>::ptr_t edge_ptr_t;
386// typedef EdgeSelector<3>::ptr_t face_ptr_t;
387//
388//
389// /**
390// *\detailed dtor
391// */
392// virtual ~FaceElement(){}
393//
394//
395// /**
396// * set the pointer to the
397// * element that holds the side.
398// */
399// void set_owner_element(Element<3>* o){owner_ = o;}
400//
401//
402// /**
403// * set the pointer to the element that
404// * shares this side. It also sets the old sharing element
405// * to the element we use before calling this function
406// */
407// void set_shared_element(Element<3>* n){neighbor_ = n;}
408//
409//
410// /**
411// * set the pointers for the shared and owner of this side
412// */
413// void set_owner_shared_element(Element<3>* o, Element<3>* n)
414// {owner_ = o; neighbor_ = n;}
415//
416//
417// /**
418// *\detailed set the boundary indicator for the FaceElement
419// */
420// void set_boundary_indicator(uint_t bind){boundary_indicator_=bind;}
421//
422//
423//
424//
425// /**
426// *\detailed read/write access to the owner of this
427// * face. May return NULL
428// */
429// Element<3>* owner(){return owner_;}
430//
431//
432// /**
433// *\detailed read/write access to the neighbor of this
434// * face. May return NULL
435// */
436// Element<3>* neighbor(){return neighbor_;}
437//
438//
439// /**
440// * @returns \p true iff a boundary indicator has been set
441// */
442// bool on_boundary () const { return false;/*return
443// boundary_indicator_!=LibSimPP::internal_mesh_entity_id();*/}
444//
445//
446// /**
447// *\detailed get the boundary indicator of the face
448// */
449// uint_t boundary_indicator()const{return boundary_indicator_;}
450//
451//
452// /**
453// *\detailed print the information for the MeshEntity
454// */
455// virtual std::ostream& print_mesh_entity_info(std::ostream &out)const;
456//
457// /// \brief
458// real_t volume()const{return 0.0;}
459//
460// /// \brief Returns the centroid of the face element
461// /// \brief The centroid is the point itself
462// GeomPoint<3> centroid()const{return GeomPoint<3>(0.0);}
463//
464// /// \brief computes a reference distance between the
465// /// centroids of the two elements sharing the FaceElement
466// /// If this lies on the the boundary then the centroid of
467// /// the FaceElementis used
468// real_t owner_neighbor_distance()const{return 0.0;}
469//
470// bool is_active()const{return true;}
471//
472// /// \brief Returns true if the owner of the cell has
473// /// the given id
474// bool is_owner(uint_t id)const{throw std::logic_error("Not implemented");}
475//
476// /// \brief Read/write access to the neighbor element
477// Element<3>& get_neighbor(){throw std::logic_error("Not implemented");}
478//
479// /// \brief Read reference to the neighbor of the side
480// const Element<3>& get_neighbor()const{throw std::logic_error("Not implemented");}
481//
482//
483// /// \brief Read/write access to the neighbor element
484// Element<3>& get_owner(){throw std::logic_error("Not implemented");}
485//
486// /// \brief Read reference to the neighbor of the side
487// const Element<3>& get_owner()const{throw std::logic_error("Not implemented");}
488//
489// /// \brief Returns the normal vector to the face
490// const DynVec<real_t> normal_vector()const{throw std::logic_error("Not implemented");}
491//
492// uint_t get_id()const{return id_;}
493// void set_id(uint_t id){id_ = id;}
494// bool has_valid_id()const{return true;}
495//
496// protected:
497//
498//
499// /**
500// *\detailed the owner of the FaceElement
501// */
502// Element<3>* owner_;
503//
504//
505// /**
506// *\detailed the neighbor of the FaceElement
507// */
508// Element<3>* neighbor_;
509//
510//
511// /**
512// *\detailed the boundary indicator of the edge
513// */
514// uint_t boundary_indicator_;
515//
516// uint_t id_;
517//
518// /**
519// *\detailed we fail to link with the print_mesh_entity_info
520// */
521// std::ostream& print_(std::ostream& o)const;
522//
523//};
524//
525// inline
526// std::ostream&
527// FaceElement<3,2>::print_mesh_entity_info(std::ostream &out)const
528//{
529// return print_(out);
530//}
531
532} // namespace geom
533} // namespace utils
534} // namespace bitrl
535#endif
Wraps the notion of an element.
Definition element.h:30
void set_owner_element(Element< 2 > *o)
Definition face_element.h:153
Node< 2 > & node_ref_t
Definition face_element.h:120
void set_shared_element(Element< 2 > *n)
Definition face_element.h:158
bool on_boundary() const
Returns true iff a boundary indicator has been set.
Definition face_element.h:183
void set_id(uint_t id)
Definition face_element.h:230
uint_t boundary_indicator() const
Get the boundary indicator of the face.
Definition face_element.h:186
EdgeSelector< 2 >::ptr_t edge_ptr_t
Definition face_element.h:122
const Node< 2 > * cnode_ptr_t
Definition face_element.h:119
Node< 2 > * node_ptr_t
Definition face_element.h:118
uint_t get_id() const
Definition face_element.h:229
Element< 2 > * owner()
Definition face_element.h:172
EdgeSelector< 2 >::cptr_t cface_ptr_t
Definition face_element.h:125
void set_owner_shared_elements(Element< 2 > *o, Element< 2 > *n)
set the pointers for the shared and owner of this side
Definition face_element.h:161
bool has_valid_id() const
Definition face_element.h:231
Element< 2 > * neighbor()
Definition face_element.h:177
bool is_active() const
Definition face_element.h:228
std::vector< node_ptr_t > nodes_
The nodes of the element.
Definition face_element.h:239
virtual uint_t n_faces() const
How many faces the element has.
Definition face_element.h:149
virtual uint_t n_nodes() const
How many nodes the element has.
Definition face_element.h:134
virtual uint_t n_edges() const
How many edges the element has.
Definition face_element.h:146
const Node< 2 > & cnode_ref_t
Definition face_element.h:121
virtual uint_t n_vertices() const
How many vertices the element has.
Definition face_element.h:143
EdgeSelector< 2 >::ptr_t face_ptr_t
Definition face_element.h:124
void set_boundary_indicator(uint_t bind)
set the boundary indicator for the FaceElement
Definition face_element.h:168
virtual ~FaceElement()
dtor
Definition face_element.h:128
EdgeSelector< 2 >::cptr_t cedge_ptr_t
Definition face_element.h:123
GeomPoint< spacedim > centroid() const
The centroid is the point itself.
Definition face_element.h:90
real_t volume() const
Definition face_element.h:87
uint_t boundary_indicator() const
Definition face_element.h:93
bool on_boundary() const
Definition face_element.h:92
void make_vertex()
detailed make this node a vertex
Definition face_element.h:79
bool is_vertex() const
returns true iff make_vertex has been called on this object
Definition face_element.h:82
virtual ~FaceElement()
Definition face_element.h:76
Definition edge_face_selector.h:12
A class that describes a point with spacedim spatial dimension space.
Definition geom_point.h:22
Helper class that wraps non template dependent parameters and common to every mesh entity.
Definition mesh_entity.h:23
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
double real_t
real_t
Definition bitrl_types.h:23
Eigen::RowVectorX< T > DynVec
Dynamically sized row vector.
Definition bitrl_types.h:74
std::size_t uint_t
uint_t
Definition bitrl_types.h:43
EdgeType< dim, 1 >::cptr_t cptr_t
Definition edge_face_selector.h:39
EdgeType< dim, 1 >::ptr_t ptr_t
Definition edge_face_selector.h:37