Line data Source code
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_HEX8_H
21 : #define LIBMESH_CELL_HEX8_H
22 :
23 : // Local includes
24 : #include "libmesh/cell_hex.h"
25 :
26 : namespace libMesh
27 : {
28 :
29 : /**
30 : * The \p Hex8 is an element in 3D composed of 8 nodes. It is
31 : * numbered like this:
32 : *
33 : * \verbatim
34 : * HEX8: 7 6
35 : * o--------z
36 : * /: /| zeta
37 : * / : / | ^ eta (into page)
38 : * 4 / : 5 / | | /
39 : * o--------o | |/
40 : * | o....|...o 2 o---> xi
41 : * | .3 | /
42 : * | . | /
43 : * |. |/
44 : * o--------o
45 : * 0 1
46 : * \endverbatim
47 : *
48 : * (xi, eta, zeta) in [-1,1]^3 are the reference element coordinates
49 : * associated with the given numbering.
50 : *
51 : * \author Benjamin S. Kirk
52 : * \date 2002
53 : * \brief A 3D hexahedral element with 8 nodes.
54 : */
55 : class Hex8 final : public Hex
56 : {
57 : public:
58 :
59 : /**
60 : * Constructor. By default this element has no parent.
61 : */
62 : explicit
63 3224870 : Hex8 (Elem * p=nullptr) :
64 3224870 : Hex(num_nodes, p, _nodelinks_data)
65 3224870 : {}
66 :
67 : Hex8 (Hex8 &&) = delete;
68 : Hex8 (const Hex8 &) = delete;
69 : Hex8 & operator= (const Hex8 &) = delete;
70 : Hex8 & operator= (Hex8 &&) = delete;
71 3393352 : virtual ~Hex8() = default;
72 :
73 : /**
74 : * \returns \p HEX8.
75 : */
76 1460932891 : virtual ElemType type () const override { return HEX8; }
77 :
78 : /**
79 : * \returns 8.
80 : */
81 396602437 : virtual unsigned int n_nodes() const override { return num_nodes; }
82 :
83 : /**
84 : * \returns 1.
85 : */
86 1920009 : virtual unsigned int n_sub_elem() const override { return 1; }
87 :
88 : /**
89 : * \returns \p true if the specified (local) node number is a vertex.
90 : */
91 : virtual bool is_vertex(const unsigned int i) const override;
92 :
93 : /**
94 : * \returns \p true if the specified (local) node number is an edge.
95 : */
96 : virtual bool is_edge(const unsigned int i) const override;
97 :
98 : /**
99 : * \returns \p true if the specified (local) node number is a face.
100 : */
101 : virtual bool is_face(const unsigned int i) const override;
102 :
103 : /**
104 : * \returns \p true if the specified (local) node number is on the
105 : * specified side.
106 : */
107 : virtual bool is_node_on_side(const unsigned int n,
108 : const unsigned int s) const override;
109 :
110 : virtual std::vector<unsigned int> nodes_on_side(const unsigned int s) const override;
111 :
112 : virtual std::vector<unsigned int> nodes_on_edge(const unsigned int e) const override;
113 :
114 : /**
115 : * \returns \p true if the specified (local) node number is on the
116 : * specified edge.
117 : */
118 : virtual bool is_node_on_edge(const unsigned int n,
119 : const unsigned int e) const override;
120 :
121 : /**
122 : * \returns \p true if the element map is definitely affine within
123 : * numerical tolerances.
124 : */
125 : virtual bool has_affine_map () const override;
126 :
127 : /**
128 : * \returns FIRST.
129 : */
130 : virtual Order default_order() const override;
131 :
132 : /**
133 : * Builds a QUAD4 built coincident with face i.
134 : * The \p std::unique_ptr<Elem> handles the memory aspect.
135 : */
136 : virtual std::unique_ptr<Elem> build_side_ptr (const unsigned int i) override;
137 :
138 : /**
139 : * Rebuilds a \p QUAD4 built coincident with face i.
140 : */
141 : virtual void build_side_ptr (std::unique_ptr<Elem> & elem,
142 : const unsigned int i) override;
143 :
144 : // Avoid hiding deprecated version with different signature
145 : using Elem::build_side_ptr;
146 :
147 : /**
148 : * Builds a EDGE2 built coincident with edge i.
149 : * The \p std::unique_ptr<Elem> handles the memory aspect.
150 : */
151 : virtual std::unique_ptr<Elem> build_edge_ptr (const unsigned int i) override;
152 :
153 : /**
154 : * Rebuilds a \p EDGE2 built coincident with edge i.
155 : */
156 : virtual void build_edge_ptr (std::unique_ptr<Elem> & edge, const unsigned int i) override;
157 :
158 : virtual void connectivity(const unsigned int sc,
159 : const IOPackage iop,
160 : std::vector<dof_id_type> & conn) const override;
161 :
162 : /**
163 : * Geometric constants for Hex8.
164 : */
165 : static const int num_nodes = 8;
166 : static const int nodes_per_side = 4;
167 : static const int nodes_per_edge = 2;
168 :
169 : /**
170 : * This maps the \f$ j^{th} \f$ node of the \f$ i^{th} \f$ side to
171 : * element node numbers.
172 : */
173 : static constexpr unsigned int side_nodes_map[num_sides][nodes_per_side] =
174 : {
175 : {0, 3, 2, 1}, // Side 0
176 : {0, 1, 5, 4}, // Side 1
177 : {1, 2, 6, 5}, // Side 2
178 : {2, 3, 7, 6}, // Side 3
179 : {3, 0, 4, 7}, // Side 4
180 : {4, 5, 6, 7} // Side 5
181 : };
182 :
183 : /**
184 : * This maps the \f$ j^{th} \f$ node of the \f$ i^{th} \f$ edge to
185 : * element node numbers.
186 : */
187 : static constexpr unsigned int edge_nodes_map[num_edges][nodes_per_edge] =
188 : {
189 : {0, 1}, // Edge 0
190 : {1, 2}, // Edge 1
191 : {2, 3}, // Edge 2
192 : {0, 3}, // Edge 3
193 : {0, 4}, // Edge 4
194 : {1, 5}, // Edge 5
195 : {2, 6}, // Edge 6
196 : {3, 7}, // Edge 7
197 : {4, 5}, // Edge 8
198 : {5, 6}, // Edge 9
199 : {6, 7}, // Edge 10
200 : {4, 7} // Edge 11
201 : };
202 :
203 : /**
204 : * Class static helper function that computes the centroid of a
205 : * hexahedral region from a set of input points which are assumed to
206 : * be in the standard "Hex8" ordering, possibly with some duplicates
207 : * indicating a "degenerate" side. Hex8::true_centroid() and
208 : * Pyramid5::true_centroid() are implemented in terms of this
209 : * function.
210 : */
211 : static Point centroid_from_points(
212 : const Point & x0, const Point & x1, const Point & x2, const Point & x3,
213 : const Point & x4, const Point & x5, const Point & x6, const Point & x7);
214 :
215 : /**
216 : * We compute the centroid of the Hex using a customized numerical
217 : * quadrature approach that avoids unnecessary object creation/heap
218 : * allocations.
219 : */
220 : virtual Point true_centroid () const override;
221 :
222 : /**
223 : * A specialization for computing the area of a hexahedron
224 : * with flat sides.
225 : */
226 : virtual Real volume () const override;
227 :
228 : /**
229 : * Builds a bounding box out of the nodal positions
230 : */
231 : virtual BoundingBox loose_bounding_box () const override;
232 :
233 : virtual void permute(unsigned int perm_num) override final;
234 :
235 : virtual void flip(BoundaryInfo *) override final;
236 :
237 : ElemType side_type (const unsigned int s) const override final;
238 :
239 : virtual Point side_vertex_average_normal(const unsigned int s) const override final;
240 :
241 : protected:
242 :
243 : /**
244 : * Data for links to nodes.
245 : */
246 : Node * _nodelinks_data[num_nodes];
247 :
248 :
249 :
250 : #ifdef LIBMESH_ENABLE_AMR
251 :
252 : /**
253 : * Matrix used to create the elements children.
254 : */
255 7055088 : virtual Real embedding_matrix (const unsigned int i,
256 : const unsigned int j,
257 : const unsigned int k) const override
258 7055088 : { return _embedding_matrix[i][j][k]; }
259 :
260 : /**
261 : * Matrix that computes new nodal locations/solution values
262 : * from current nodes/solution.
263 : */
264 : static const Real _embedding_matrix[num_children][num_nodes][num_nodes];
265 :
266 13738528 : LIBMESH_ENABLE_TOPOLOGY_CACHES;
267 :
268 : #endif // LIBMESH_ENABLE_AMR
269 : };
270 :
271 : } // namespace libMesh
272 :
273 : #endif // LIBMESH_CELL_HEX8_H
|