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_TET4_H
21 : #define LIBMESH_CELL_TET4_H
22 :
23 : // Local includes
24 : #include "libmesh/cell_tet.h"
25 :
26 : namespace libMesh
27 : {
28 :
29 : /**
30 : * The \p Tet4 is an element in 3D composed of 4 nodes. It is
31 : * numbered like this:
32 : *
33 : * \verbatim
34 : * TET4:
35 : * 3
36 : * o zeta
37 : * /|\ ^
38 : * / | \ |
39 : * / | \ |
40 : * 0 o...|...o 2 o---> eta
41 : * \ | / \
42 : * \ | / \
43 : * \|/ xi (out of page)
44 : * o
45 : * 1
46 : * \endverbatim
47 : *
48 : * (xi, eta, zeta): { 0 <= xi <= 1
49 : * { 0 <= eta <= 1
50 : * { 0 <= zeta <= 1
51 : * { xi + eta + zeta <= 1
52 : * are the reference element coordinates associated with the given
53 : * numbering.
54 : *
55 : * \author Benjamin S. Kirk
56 : * \date 2002
57 : * \brief A 3D tetrahedral element with 4 nodes.
58 : */
59 : class Tet4 final : public Tet
60 : {
61 : public:
62 :
63 : /**
64 : * Constructor. By default this element has no parent.
65 : */
66 : explicit
67 15989345 : Tet4 (Elem * p=nullptr) :
68 15989345 : Tet(num_nodes, p, _nodelinks_data)
69 15989345 : {}
70 :
71 : Tet4 (Tet4 &&) = delete;
72 : Tet4 (const Tet4 &) = delete;
73 : Tet4 & operator= (const Tet4 &) = delete;
74 : Tet4 & operator= (Tet4 &&) = delete;
75 16855412 : virtual ~Tet4() = default;
76 :
77 : /**
78 : * \returns \p TET4.
79 : */
80 223729365 : virtual ElemType type () const override { return TET4; }
81 :
82 : /**
83 : * \returns 4.
84 : */
85 139011151 : virtual unsigned int n_nodes() const override { return num_nodes; }
86 :
87 : /**
88 : * \returns 1.
89 : */
90 8685 : virtual unsigned int n_sub_elem() const override { return 1; }
91 :
92 : /**
93 : * \returns \p true if the specified (local) node number is a vertex.
94 : */
95 : virtual bool is_vertex(const unsigned int i) const override;
96 :
97 : /**
98 : * \returns \p true if the specified (local) node number is an edge.
99 : */
100 : virtual bool is_edge(const unsigned int i) const override;
101 :
102 : /**
103 : * \returns \p true if the specified (local) node number is a face.
104 : */
105 : virtual bool is_face(const unsigned int i) const override;
106 :
107 : /**
108 : * \returns \p true if the specified (local) node number is on the
109 : * specified side.
110 : */
111 : virtual bool is_node_on_side(const unsigned int n,
112 : const unsigned int s) const override;
113 :
114 : virtual std::vector<unsigned int> nodes_on_side(const unsigned int s) const override;
115 :
116 : virtual std::vector<unsigned int> nodes_on_edge(const unsigned int e) const override;
117 :
118 : /**
119 : * \returns \p true if the specified (local) node number is on the
120 : * specified edge.
121 : */
122 : virtual bool is_node_on_edge(const unsigned int n,
123 : const unsigned int e) const override;
124 :
125 : /**
126 : * \returns \p true if the specified child is on the
127 : * specified side.
128 : */
129 : virtual bool is_child_on_side(const unsigned int c,
130 : const unsigned int s) const override;
131 :
132 : /**
133 : * \returns \p true if the element map is definitely affine within
134 : * numerical tolerances.
135 : */
136 2584374 : virtual bool has_affine_map () const override { return true; }
137 :
138 : /**
139 : * \returns \p true if the element has non-zero volume(), false otherwise.
140 : */
141 : virtual bool has_invertible_map(Real tol) const override;
142 :
143 : /**
144 : * \returns \p true if the Lagrange shape functions on this element
145 : * are linear.
146 : */
147 224931 : virtual bool is_linear () const override { return true; }
148 :
149 : /**
150 : * \returns FIRST.
151 : */
152 : virtual Order default_order() const override;
153 :
154 : /**
155 : * Builds a \p TRI3 built coincident with face i.
156 : * The \p std::unique_ptr<Elem> handles the memory aspect.
157 : */
158 : virtual std::unique_ptr<Elem> build_side_ptr (const unsigned int i) override;
159 :
160 : /**
161 : * Rebuilds a TRI3 built coincident with face i.
162 : */
163 : virtual void build_side_ptr (std::unique_ptr<Elem> & elem,
164 : const unsigned int i) override;
165 :
166 : // Avoid hiding deprecated version with different signature
167 : using Elem::build_side_ptr;
168 :
169 : /**
170 : * Builds a \p EDGE2 built coincident with face i.
171 : * The \p std::unique_ptr<Elem> handles the memory aspect.
172 : */
173 : virtual std::unique_ptr<Elem> build_edge_ptr (const unsigned int i) override;
174 :
175 : /**
176 : * Rebuilds a \p EDGE2 coincident with edge i.
177 : */
178 : virtual void build_edge_ptr (std::unique_ptr<Elem> & edge, const unsigned int i) override;
179 :
180 : virtual void connectivity(const unsigned int sc,
181 : const IOPackage iop,
182 : std::vector<dof_id_type> & conn) const override;
183 :
184 : /**
185 : * Geometric constants for Tet4.
186 : */
187 : static const int num_nodes = 4;
188 : static const int nodes_per_side = 3;
189 : static const int nodes_per_edge = 2;
190 :
191 : /**
192 : * This maps the \f$ j^{th} \f$ node of the \f$ i^{th} \f$ side to
193 : * element node numbers.
194 : */
195 : static constexpr unsigned int side_nodes_map[num_sides][nodes_per_side] =
196 : {
197 : {0, 2, 1}, // Side 0
198 : {0, 1, 3}, // Side 1
199 : {1, 2, 3}, // Side 2
200 : {2, 0, 3} // Side 3
201 : };
202 :
203 : /**
204 : * This maps the \f$ j^{th} \f$ node of the \f$ i^{th} \f$ edge to
205 : * element node numbers.
206 : */
207 : static constexpr unsigned int edge_nodes_map[num_edges][nodes_per_edge] =
208 : {
209 : {0, 1}, // Edge 0
210 : {1, 2}, // Edge 1
211 : {0, 2}, // Edge 2
212 : {0, 3}, // Edge 3
213 : {1, 3}, // Edge 4
214 : {2, 3} // Edge 5
215 : };
216 :
217 : /**
218 : * The centroid of a 4-node tetrahedron is simply given by the
219 : * average of its vertex positions.
220 : */
221 : virtual Point true_centroid () const override;
222 :
223 : /**
224 : * An optimized method for computing the area of a
225 : * 4-node tetrahedron.
226 : */
227 : virtual Real volume () const override;
228 :
229 : /**
230 : * \returns The min and max *dihedral* angles for the tetrahedron.
231 : *
232 : * \note There are 6 dihedral angles (angles between the planar
233 : * faces) for the Tet4. Dihedral angles near 180 deg. are generally
234 : * bad for interpolation. Small dihedral angles are not necessarily
235 : * bad for interpolation, but they can affect the stiffness matrix
236 : * condition number.
237 : */
238 : std::pair<Real, Real> min_and_max_angle() const;
239 :
240 : /**
241 : * Don't hide Tet::key(side) defined in the base class.
242 : */
243 : using Tet::key;
244 :
245 : /**
246 : * \returns An id associated with the global node ids of this
247 : * element. The id is not necessarily unique, but should be
248 : * close.
249 : */
250 : virtual dof_id_type key () const override;
251 :
252 : /**
253 : * Uses simple geometric tests to determine if the point p is inside
254 : * the tetrahedron.
255 : */
256 : virtual bool contains_point (const Point & p, Real tol) const override;
257 :
258 : virtual void permute(unsigned int perm_num) override final;
259 :
260 : virtual void flip(BoundaryInfo *) override final;
261 :
262 : ElemType side_type (const unsigned int s) const override final;
263 :
264 : virtual Point side_vertex_average_normal(const unsigned int s) const override final;
265 :
266 : protected:
267 :
268 : /**
269 : * Data for links to nodes.
270 : */
271 : Node * _nodelinks_data[num_nodes];
272 :
273 :
274 :
275 : #ifdef LIBMESH_ENABLE_AMR
276 :
277 : /**
278 : * Matrix used to create the elements children.
279 : */
280 : virtual Real embedding_matrix (const unsigned int i,
281 : const unsigned int j,
282 : const unsigned int k) const override;
283 :
284 : /**
285 : * Matrix that computes new nodal locations/solution values
286 : * from current nodes/solution.
287 : */
288 : static const Real _embedding_matrix[num_children][num_nodes][num_nodes];
289 :
290 7014604 : LIBMESH_ENABLE_TOPOLOGY_CACHES;
291 :
292 : #endif
293 :
294 : };
295 :
296 : } // namespace libMesh
297 :
298 :
299 : #endif // LIBMESH_CELL_TET4_H
|