libMesh
cell_polyhedron.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2025 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 #ifndef LIBMESH_CELL_POLYHEDRON_H
21 #define LIBMESH_CELL_POLYHEDRON_H
22 
23 
24 // Local includes
25 #include "libmesh/libmesh_common.h"
26 #include "libmesh/cell.h"
27 
28 namespace libMesh
29 {
30 
31 // Forward declarations
32 class Polygon;
33 
42 class Polyhedron : public Cell
43 {
44 public:
45 
51  Polyhedron (const std::vector<std::shared_ptr<Polygon>> & sides,
52  Elem * p);
53 
54  Polyhedron (Polyhedron &&) = delete;
55  Polyhedron (const Polyhedron &) = delete;
56  Polyhedron & operator= (const Polyhedron &) = delete;
57  Polyhedron & operator= (Polyhedron &&) = delete;
58  virtual ~Polyhedron() = default;
59 
64  virtual bool runtime_topology() const override { return true; }
65 
77  virtual Point master_point (const unsigned int i) const override;
78 
79  static const int num_children = 0; // Refinement not yet supported
80 
84  virtual unsigned int n_nodes() const override { return this->_nodelinks_data.size(); }
85 
90  virtual unsigned int n_sides() const override final { return _elemlinks_data.size()-2; }
91 
95  virtual unsigned int n_edges() const override final { return _edge_lookup.size(); }
96 
101  virtual unsigned int n_faces() const override final { return _elemlinks_data.size()-2; }
102 
106  virtual unsigned int n_children() const override final { return num_children; }
107 
115  virtual bool is_child_on_side(const unsigned int c,
116  const unsigned int s) const override;
117 
122  virtual unsigned int opposite_side(const unsigned int s) const override final;
123 
128  virtual unsigned int opposite_node(const unsigned int n,
129  const unsigned int s) const override final;
130 
134  using Elem::key;
135 
141  virtual dof_id_type key () const override;
142 
147  virtual dof_id_type key (const unsigned int s) const override;
148 
155  virtual dof_id_type low_order_key (const unsigned int s) const override;
156 
161  virtual unsigned int local_side_node(unsigned int side,
162  unsigned int side_node) const override;
163 
169  virtual unsigned int local_edge_node(unsigned int edge,
170  unsigned int edge_node) const override;
171 
175  virtual std::unique_ptr<Elem> side_ptr (const unsigned int i) override final;
176 
180  virtual void side_ptr (std::unique_ptr<Elem> & elem,
181  const unsigned int i) override final;
182 
186  virtual std::unique_ptr<Elem> build_side_ptr (const unsigned int i) override;
187 
191  virtual void build_side_ptr (std::unique_ptr<Elem> & elem,
192  const unsigned int i) override;
193 
194  // Avoid hiding deprecated version with different signature
195  using Elem::build_side_ptr;
196 
200  virtual std::unique_ptr<Elem> build_edge_ptr (const unsigned int i) override final;
201 
207  virtual void build_edge_ptr (std::unique_ptr<Elem> & edge, const unsigned int i) override final;
208 
213  virtual std::pair<Real, Real> qual_bounds (const ElemQuality q) const override;
214 
218  virtual std::vector<unsigned int> sides_on_edge(const unsigned int e) const override final;
219 
223  virtual bool is_edge_on_side(const unsigned int e,
224  const unsigned int s) const override final;
225 
231  virtual unsigned int n_permutations() const override { return 1; }
232 
233  virtual void permute(unsigned int libmesh_dbg_var(perm_num)) override final
234  { libmesh_assert_equal_to(perm_num, 0); }
235 
236  virtual bool is_flipped() const override final;
237 
246  virtual void flip(BoundaryInfo *) override final { libmesh_not_implemented(); };
247 
248  virtual std::vector<unsigned int> edges_adjacent_to_node(const unsigned int n) const override;
249 
264  virtual void retriangulate() = 0;
265 
271  bool convex();
272 
276  unsigned int n_subelements() const { return cast_int<unsigned int>(this->_triangulation.size()); }
277 
284  virtual std::array<int, 4> subelement (unsigned int i) const
285  {
286  libmesh_assert_less(i, this->_triangulation.size());
287  return this->_triangulation[i];
288  }
289 
294  virtual std::array<Point, 4> master_subelement (unsigned int i) const;
295 
302  std::tuple<unsigned int, Real, Real, Real>
303  subelement_coordinates (const Point & p,
304  Real tol = TOLERANCE*TOLERANCE) const;
305 
306  virtual bool on_reference_element(const Point & p,
307  const Real eps = TOLERANCE) const override final;
308 
309 protected:
310 
318  std::vector<std::shared_ptr<Polygon>> side_clones() const;
319 
324  bool side_has_edge_nodes(unsigned int side,
325  unsigned int min_node,
326  unsigned int max_node) const;
327 
337  std::vector<Elem *> _elemlinks_data;
338 
343  std::vector<Node *> _nodelinks_data;
344 
353  std::vector<std::tuple<std::shared_ptr<Polygon>,
354  bool,
355  std::vector<unsigned int>>> _sidelinks_data;
356 
366  std::vector<std::pair<unsigned int, unsigned int>> _edge_lookup;
367 
376  std::vector<std::array<int, 4>> _triangulation;
377 };
378 
379 
380 } // namespace libMesh
381 
382 #endif // LIBMESH_CELL_POLYHEDRON_H
Polyhedron & operator=(const Polyhedron &)=delete
virtual unsigned int n_nodes() const override
std::vector< Elem * > _elemlinks_data
Data for links to parent/neighbor/interior_parent elements.
The Polyhedron is an element in 3D with an arbitrary number of polygonal faces.
virtual bool is_child_on_side(const unsigned int c, const unsigned int s) const override
virtual unsigned int n_permutations() const override
Maybe we have non-identity permutations, but trying to figure out how many is an exercise in applied ...
std::vector< Node * > _nodelinks_data
Data for links to nodes.
virtual unsigned int opposite_side(const unsigned int s) const override final
Throws an error.
virtual std::unique_ptr< Elem > build_side_ptr(const unsigned int i)=0
virtual dof_id_type key() const
Definition: elem.C:753
virtual unsigned int local_edge_node(unsigned int edge, unsigned int edge_node) const override
Similar to Elem::local_side_node(), but instead of a side id, takes an edge id and a node id on that ...
static constexpr Real TOLERANCE
virtual std::array< Point, 4 > master_subelement(unsigned int i) const
std::vector< std::tuple< std::shared_ptr< Polygon >, bool, std::vector< unsigned int > > > _sidelinks_data
Data for links to sides.
virtual std::pair< Real, Real > qual_bounds(const ElemQuality q) const override
virtual bool on_reference_element(const Point &p, const Real eps=TOLERANCE) const override final
This is the base class from which all geometric element types are derived.
Definition: elem.h:94
static const int num_children
Polyhedron(const std::vector< std::shared_ptr< Polygon >> &sides, Elem *p)
Arbitrary polyhedral element, takes a vector of shared pointers to sides (which should already be con...
virtual ~Polyhedron()=default
The libMesh namespace provides an interface to certain functionality in the library.
virtual unsigned int n_sides() const override final
virtual std::unique_ptr< Elem > build_edge_ptr(const unsigned int i) override final
std::vector< std::pair< unsigned int, unsigned int > > _edge_lookup
One entry for each polyhedron edge, a pair indicating the side number and the edge-of-side number whi...
bool side_has_edge_nodes(unsigned int side, unsigned int min_node, unsigned int max_node) const
Helper method for finding the non-cached side that shares an edge, by examining the local node ids th...
std::tuple< unsigned int, Real, Real, Real > subelement_coordinates(const Point &p, Real tol=TOLERANCE *TOLERANCE) const
virtual bool is_flipped() const override final
virtual bool is_edge_on_side(const unsigned int e, const unsigned int s) const override final
virtual void retriangulate()=0
Create a triangulation (tetrahedralization) from the current node locations and face triangulations...
unsigned int n_subelements() const
virtual std::array< int, 4 > subelement(unsigned int i) const
virtual dof_id_type low_order_key(const unsigned int s) const override
The Cell is an abstract element type that lives in three dimensions.
Definition: cell.h:38
virtual void flip(BoundaryInfo *) override final
A flip is one of those general non-identity permutations we can&#39;t handle.
The BoundaryInfo class contains information relevant to boundary conditions including storing faces...
Definition: boundary_info.h:57
virtual unsigned int opposite_node(const unsigned int n, const unsigned int s) const override final
Throws an error - opposite_side(s) is too hard to define in general on polyhedra. ...
virtual std::unique_ptr< Elem > build_side_ptr(const unsigned int i) override
Copies the Polygon side coincident with side i.
ElemQuality
Defines an enum for element quality metrics.
virtual dof_id_type key() const override
virtual void permute(unsigned int libmesh_dbg_var(perm_num)) override final
std::vector< std::shared_ptr< Polygon > > side_clones() const
virtual Point master_point(const unsigned int i) const override
virtual unsigned int n_edges() const override final
virtual unsigned int local_side_node(unsigned int side, unsigned int side_node) const override
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual std::vector< unsigned int > edges_adjacent_to_node(const unsigned int n) const override
virtual std::unique_ptr< Elem > side_ptr(const unsigned int i) override final
std::vector< std::array< int, 4 > > _triangulation
Data for a triangulation (tetrahedralization) of the polyhedron.
virtual std::vector< unsigned int > sides_on_edge(const unsigned int e) const override final
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:39
virtual bool runtime_topology() const override
virtual unsigned int n_faces() const override final
virtual unsigned int n_children() const override final
uint8_t dof_id_type
Definition: id_types.h:67