libMesh
cell_hex.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_HEX_H
21 #define LIBMESH_CELL_HEX_H
22 
23 // Local includes
24 #include "libmesh/cell.h"
25 
26 namespace libMesh
27 {
28 
36 class Hex : public Cell
37 {
38 public:
39 
44  Hex(const unsigned int nn, Elem * p, Node ** nodelinkdata) :
45  Cell(nn, num_sides, p, _elemlinks_data, nodelinkdata)
46  {
47  // Make sure the interior parent isn't undefined
48  if (LIBMESH_DIM > 3)
49  this->set_interior_parent(nullptr);
50  }
51 
52  Hex (Hex &&) = delete;
53  Hex (const Hex &) = delete;
54  Hex & operator= (const Hex &) = delete;
55  Hex & operator= (Hex &&) = delete;
56  virtual ~Hex() = default;
57 
62  virtual Point master_point (const unsigned int i) const override final
63  {
64  libmesh_assert_less(i, this->n_nodes());
65  return Point(_master_points[i][0],
66  _master_points[i][1],
67  _master_points[i][2]);
68  }
69 
73  static const int num_sides = 6;
74  static const int num_edges = 12;
75  static const int num_children = 8;
76 
80  virtual unsigned int n_sides() const override final { return 6; }
81 
85  virtual unsigned int n_vertices() const override final { return 8; }
86 
90  virtual unsigned int n_edges() const override final { return 12; }
91 
95  virtual unsigned int n_faces() const override final { return 6; }
96 
100  virtual unsigned int n_children() const override final { return 8; }
101 
105  virtual bool is_child_on_side(const unsigned int c,
106  const unsigned int s) const override final;
107 
111  virtual bool is_edge_on_side(const unsigned int e,
112  const unsigned int s) const override final;
113 
117  virtual unsigned int opposite_side(const unsigned int s) const override final;
118 
124  virtual unsigned int opposite_node(const unsigned int n,
125  const unsigned int s) const override final;
126 
130  using Elem::key;
131 
136  virtual dof_id_type key (const unsigned int s) const override;
137 
144  virtual dof_id_type low_order_key (const unsigned int s) const override;
145 
149  virtual unsigned int local_side_node(unsigned int side,
150  unsigned int side_node) const override;
151 
155  virtual unsigned int local_edge_node(unsigned int edge,
156  unsigned int edge_node) const override;
157 
161  virtual std::unique_ptr<Elem> side_ptr (const unsigned int i) override final;
162 
166  virtual void side_ptr (std::unique_ptr<Elem> & side, const unsigned int i) override final;
167 
172  virtual Real quality (const ElemQuality q) const override;
173 
179  virtual std::pair<Real, Real> qual_bounds (const ElemQuality q) const override;
180 
181  virtual std::vector<unsigned int> sides_on_edge(const unsigned int e) const override final;
182 
186  virtual unsigned int n_permutations() const override final { return 24; }
187 
188  virtual bool is_flipped() const override final;
189 
190  virtual std::vector<unsigned int> edges_adjacent_to_node(const unsigned int n) const override;
191 
195  static const unsigned int edge_sides_map[12][2];
196 
197  virtual bool on_reference_element(const Point & p,
198  const Real eps = TOLERANCE) const override final;
199 
200 protected:
201 
205  Elem * _elemlinks_data[7+(LIBMESH_DIM>3)];
206 
214  static const unsigned short int _second_order_adjacent_vertices[12][2];
215 
219  static const unsigned short int _second_order_vertex_child_number[27];
220 
224  static const unsigned short int _second_order_vertex_child_index[27];
225 
229  static const Real _master_points[27][3];
230 
235  static const int _child_node_lookup[8][27];
236 
244  static const unsigned int adjacent_edges_map[/*num_vertices*/8][/*n_adjacent_edges*/3];
245 };
246 
247 } // namespace libMesh
248 
249 #endif // LIBMESH_CELL_HEX_H
virtual unsigned int opposite_side(const unsigned int s) const override final
Definition: cell_hex.C:211
virtual std::vector< unsigned int > sides_on_edge(const unsigned int e) const override final
Definition: cell_hex.C:202
virtual Point master_point(const unsigned int i) const override final
Definition: cell_hex.h:62
A Node is like a Point, but with more information.
Definition: node.h:52
static const Real _master_points[27][3]
Master element node locations.
Definition: cell_hex.h:229
virtual std::vector< unsigned int > edges_adjacent_to_node(const unsigned int n) const override
Definition: cell_hex.C:263
virtual dof_id_type key() const
Definition: elem.C:753
static constexpr Real TOLERANCE
virtual std::pair< Real, Real > qual_bounds(const ElemQuality q) const override
Definition: cell_hex.C:507
virtual bool is_flipped() const override final
Definition: cell_hex.C:254
The Hex is an element in 3D with 6 sides.
Definition: cell_hex.h:36
static const unsigned short int _second_order_adjacent_vertices[12][2]
Matrix that tells which vertices define the location of mid-side (or second-order) nodes...
Definition: cell_hex.h:214
virtual unsigned int n_permutations() const override final
Six sides, four orientations per side.
Definition: cell_hex.h:186
This is the base class from which all geometric element types are derived.
Definition: elem.h:94
Elem * _elemlinks_data[7+(LIBMESH_DIM >3)]
Data for links to parent/neighbor/interior_parent elements.
Definition: cell_hex.h:205
virtual unsigned int n_children() const override final
Definition: cell_hex.h:100
The libMesh namespace provides an interface to certain functionality in the library.
void set_interior_parent(Elem *p)
Sets the pointer to the element&#39;s interior_parent.
Definition: elem.C:1248
virtual unsigned int local_edge_node(unsigned int edge, unsigned int edge_node) const override
Definition: cell_hex.C:137
virtual bool is_child_on_side(const unsigned int c, const unsigned int s) const override final
Definition: cell_hex.C:170
virtual unsigned int n_nodes() const =0
static const int num_edges
Definition: cell_hex.h:74
static const int _child_node_lookup[8][27]
Lookup table from child id, child node id to "possible node location" (a simple dictionary-index in a...
Definition: cell_hex.h:235
static const int num_children
Definition: cell_hex.h:75
The Cell is an abstract element type that lives in three dimensions.
Definition: cell.h:38
virtual std::unique_ptr< Elem > side_ptr(const unsigned int i) override final
Definition: cell_hex.C:148
ElemQuality
Defines an enum for element quality metrics.
virtual unsigned int n_edges() const override final
Definition: cell_hex.h:90
virtual unsigned int n_faces() const override final
Definition: cell_hex.h:95
virtual unsigned int n_vertices() const override final
Definition: cell_hex.h:85
virtual dof_id_type low_order_key(const unsigned int s) const override
Definition: cell_hex.C:114
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual unsigned int n_sides() const override final
Definition: cell_hex.h:80
virtual Real quality(const ElemQuality q) const override
Definition: cell_hex.C:280
static const int num_sides
Geometric constants for all Hexes.
Definition: cell_hex.h:73
static const unsigned short int _second_order_vertex_child_number[27]
Vector that names a child sharing each second order node.
Definition: cell_hex.h:219
virtual bool on_reference_element(const Point &p, const Real eps=TOLERANCE) const override final
Definition: cell_hex.C:577
Hex(const unsigned int nn, Elem *p, Node **nodelinkdata)
Default brick element, takes number of nodes and parent.
Definition: cell_hex.h:44
static const unsigned short int _second_order_vertex_child_index[27]
Vector that names the child vertex index for each second order node.
Definition: cell_hex.h:224
virtual unsigned int opposite_node(const unsigned int n, const unsigned int s) const override final
Definition: cell_hex.C:220
virtual unsigned int local_side_node(unsigned int side, unsigned int side_node) const override
Definition: cell_hex.C:126
static const unsigned int adjacent_edges_map[8][3]
This maps the node to the (in this case) 3 edge ids adjacent to the node.
Definition: cell_hex.h:244
virtual ~Hex()=default
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:39
Hex & operator=(const Hex &)=delete
uint8_t dof_id_type
Definition: id_types.h:67
virtual bool is_edge_on_side(const unsigned int e, const unsigned int s) const override final
Definition: cell_hex.C:191
static const unsigned int edge_sides_map[12][2]
This maps each edge to the sides that contain said edge.
Definition: cell_hex.h:195