libMesh
Loading...
Searching...
No Matches
cell_polyhedron.h
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 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
28namespace libMesh
29{
30
31// Forward declarations
32class Polygon;
33
42class Polyhedron : public Cell
43{
44public:
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;
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 std::unique_ptr<Elem> side_ptr (const unsigned int i) const;
181
185 virtual void side_ptr (std::unique_ptr<Elem> & elem,
186 const unsigned int i) override final;
187
191 virtual std::unique_ptr<Elem> build_side_ptr (const unsigned int i) override;
192
196 virtual void build_side_ptr (std::unique_ptr<Elem> & elem,
197 const unsigned int i) override;
198
199 // Avoid hiding deprecated version with different signature
201
205 virtual std::unique_ptr<Elem> build_edge_ptr (const unsigned int i) override final;
206
212 virtual void build_edge_ptr (std::unique_ptr<Elem> & edge, const unsigned int i) override final;
213
218 virtual std::pair<Real, Real> qual_bounds (const ElemQuality q) const override;
219
223 virtual std::vector<unsigned int> sides_on_edge(const unsigned int e) const override final;
224
228 virtual bool is_edge_on_side(const unsigned int e,
229 const unsigned int s) const override final;
230
236 virtual unsigned int n_permutations() const override { return 1; }
237
238 virtual void permute(unsigned int libmesh_dbg_var(perm_num)) override final
239 { libmesh_assert_equal_to(perm_num, 0); }
240
241 virtual bool is_flipped() const override final;
242
251 virtual void flip(BoundaryInfo *) override final { libmesh_not_implemented(); };
252
253 virtual std::vector<unsigned int> edges_adjacent_to_node(const unsigned int n) const override;
254
269 virtual void retriangulate() = 0;
270
276 bool convex();
277
281 unsigned int n_subelements() const { return cast_int<unsigned int>(this->_triangulation.size()); }
282
289 virtual std::array<int, 4> subelement (unsigned int i) const
290 {
291 libmesh_assert_less(i, this->_triangulation.size());
292 return this->_triangulation[i];
293 }
294
299 virtual std::array<Point, 4> master_subelement (unsigned int i) const;
300
307 std::tuple<unsigned int, Real, Real, Real>
308 subelement_coordinates (const Point & p,
309 Real tol = TOLERANCE*TOLERANCE) const;
310
311 virtual bool on_reference_element(const Point & p,
312 const Real eps = TOLERANCE) const override final;
313
314protected:
315
323 std::vector<std::shared_ptr<Polygon>> side_clones() const;
324
329 bool side_has_edge_nodes(unsigned int side,
330 unsigned int min_node,
331 unsigned int max_node) const;
332
342 std::vector<Elem *> _elemlinks_data;
343
348 std::vector<Node *> _nodelinks_data;
349
358 std::vector<std::tuple<std::shared_ptr<Polygon>,
359 bool,
360 std::vector<unsigned int>>> _sidelinks_data;
361
371 std::vector<std::pair<unsigned int, unsigned int>> _edge_lookup;
372
381 std::vector<std::array<int, 4>> _triangulation;
382};
383
384
385} // namespace libMesh
386
387#endif // LIBMESH_CELL_POLYHEDRON_H
The BoundaryInfo class contains information relevant to boundary conditions including storing faces,...
The Cell is an abstract element type that lives in three dimensions.
Definition cell.h:39
This is the base class from which all geometric element types are derived.
Definition elem.h:96
virtual dof_id_type key(const unsigned int s) const =0
virtual std::unique_ptr< Elem > build_side_ptr(const unsigned int i)=0
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:40
The Polyhedron is an element in 3D with an arbitrary number of polygonal faces.
virtual std::array< Point, 4 > master_subelement(unsigned int i) const
virtual unsigned int n_edges() const override final
virtual Point master_point(const unsigned int i) const override
virtual std::unique_ptr< Elem > build_side_ptr(const unsigned int i) override
Copies the Polygon side coincident with side i.
virtual bool is_child_on_side(const unsigned int c, const unsigned int s) const override
virtual std::vector< unsigned int > edges_adjacent_to_node(const unsigned int n) const override
virtual std::vector< unsigned int > sides_on_edge(const unsigned int e) const override final
virtual std::array< int, 4 > subelement(unsigned int i) const
virtual bool runtime_topology() const override
Polyhedron & operator=(const Polyhedron &)=delete
virtual std::unique_ptr< Elem > side_ptr(const unsigned int i) override final
virtual bool is_edge_on_side(const unsigned int e, const unsigned int s) const override final
virtual unsigned int n_faces() const override final
virtual void retriangulate()=0
Create a triangulation (tetrahedralization) from the current node locations and face triangulations.
virtual unsigned int opposite_side(const unsigned int s) const override final
Throws an error.
virtual dof_id_type low_order_key(const unsigned int s) const override
virtual unsigned int n_children() const override final
virtual unsigned int local_side_node(unsigned int side, unsigned int side_node) const override
virtual bool is_flipped() const override final
virtual unsigned int n_nodes() const override
unsigned int n_subelements() const
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.
static const int num_children
std::vector< Elem * > _elemlinks_data
Data for links to parent/neighbor/interior_parent elements.
virtual unsigned int n_sides() const override final
virtual void permute(unsigned int libmesh_dbg_var(perm_num)) override final
virtual dof_id_type key() const override
Polyhedron(const Polyhedron &)=delete
Polyhedron(Polyhedron &&)=delete
virtual bool on_reference_element(const Point &p, const Real eps=TOLERANCE) const override final
std::tuple< unsigned int, Real, Real, Real > subelement_coordinates(const Point &p, Real tol=TOLERANCE *TOLERANCE) const
std::vector< std::shared_ptr< Polygon > > side_clones() const
virtual void flip(BoundaryInfo *) override final
A flip is one of those general non-identity permutations we can't handle.
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...
std::vector< Node * > _nodelinks_data
Data for links to nodes.
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 ...
virtual ~Polyhedron()=default
virtual std::pair< Real, Real > qual_bounds(const ElemQuality q) const override
std::vector< std::tuple< std::shared_ptr< Polygon >, bool, std::vector< unsigned int > > > _sidelinks_data
Data for links to sides.
std::vector< std::array< int, 4 > > _triangulation
Data for a triangulation (tetrahedralization) of the polyhedron.
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...
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 ...
The libMesh namespace provides an interface to certain functionality in the library.
ElemQuality
Defines an enum for element quality metrics.
static constexpr Real TOLERANCE
uint8_t dof_id_type
Definition id_types.h:67
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real