Line data Source code
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_PRISM21_H
21 : #define LIBMESH_CELL_PRISM21_H
22 :
23 : // Local includes
24 : #include "libmesh/cell_prism.h"
25 :
26 : namespace libMesh
27 : {
28 :
29 : /**
30 : * The \p Prism21 is an element in 3D composed of 21 nodes.
31 : * It is numbered like this:
32 : *
33 : * \verbatim
34 : * PRISM21:
35 : * 5
36 : * o
37 : * /:\
38 : * / : \
39 : * / : \
40 : * / : \
41 : * 14 o : o 13
42 : * / : \
43 : * / : \
44 : * / o 11 \
45 : * 3 / : \4
46 : * o---------o---------o
47 : * | :12 |
48 : * | : |
49 : * | o : o | zeta
50 : * | 17 o 16 | ^ eta (into page)
51 : * | .2. | | /
52 : * | . . | |/
53 : * 9 o . o . o 10 o---> xi
54 : * | . 15 . |
55 : * | 8 o o 7 |
56 : * | . . |
57 : * | . . |
58 : * | . . |
59 : * |. .|
60 : * o---------o---------o
61 : * 0 6 1
62 : * \endverbatim
63 : *
64 : * And it also includes two face nodes:
65 : * Node 18, centroid on side 0, arithmetic mean of 0/1/2 or 6/7/8
66 : * Node 19, centroid on side 4, arithmetic mean of 3/4/5 or 12/13/14
67 : *
68 : * And one midpoint node:
69 : * Node 20, on the interior, arithmetic mean of 9/10/11 or 15/16/17
70 : *
71 : * (xi, eta, zeta): { 0 <= xi <= 1
72 : * { 0 <= eta <= 1
73 : * { -1 <= zeta <= 1
74 : * { xi + eta <= 1
75 : * are the reference element coordinates associated with the given
76 : * numbering.
77 : *
78 : * \author Roy H. Stogner
79 : * \date 2022
80 : * \brief A 3D prismatic element with 21 nodes.
81 : */
82 : class Prism21 final : public Prism
83 : {
84 : public:
85 :
86 : /**
87 : * Constructor. By default this element has no parent.
88 : */
89 : explicit
90 232554 : Prism21 (Elem * p=nullptr) :
91 232554 : Prism(num_nodes, p, _nodelinks_data)
92 232554 : {}
93 :
94 : Prism21 (Prism21 &&) = delete;
95 : Prism21 (const Prism21 &) = delete;
96 : Prism21 & operator= (const Prism21 &) = delete;
97 : Prism21 & operator= (Prism21 &&) = delete;
98 241483 : virtual ~Prism21() = default;
99 :
100 : /**
101 : * \returns \p PRISM21.
102 : */
103 2073505196 : virtual ElemType type () const override { return PRISM21; }
104 :
105 : /**
106 : * \returns 21.
107 : */
108 532583472 : virtual unsigned int n_nodes() const override { return num_nodes; }
109 :
110 : /**
111 : * \returns 8.
112 : */
113 0 : virtual unsigned int n_sub_elem() const override { return 8; }
114 :
115 : /**
116 : * \returns \p true if the specified (local) node number is a vertex.
117 : */
118 : virtual bool is_vertex(const unsigned int i) const override;
119 :
120 : /**
121 : * \returns \p true if the specified (local) node number is an edge.
122 : */
123 : virtual bool is_edge(const unsigned int i) const override;
124 :
125 : /**
126 : * \returns \p true if the specified (local) node number is a face.
127 : */
128 : virtual bool is_face(const unsigned int i) const override;
129 :
130 : /**
131 : * \returns \p true if the specified (local) node number is on the
132 : * specified side.
133 : */
134 : virtual bool is_node_on_side(const unsigned int n,
135 : const unsigned int s) const override;
136 :
137 : virtual std::vector<unsigned int> nodes_on_side(const unsigned int s) const override;
138 :
139 : virtual std::vector<unsigned int> nodes_on_edge(const unsigned int e) const override;
140 :
141 : /**
142 : * \returns \p true if the specified (local) node number is on the
143 : * specified edge.
144 : */
145 : virtual bool is_node_on_edge(const unsigned int n,
146 : const unsigned int e) const override;
147 :
148 : /**
149 : * \returns \p true if the element map is definitely affine within
150 : * numerical tolerances.
151 : */
152 : virtual bool has_affine_map () const override;
153 :
154 : /**
155 : * \returns SECOND.
156 : */
157 : virtual Order default_order() const override;
158 :
159 : /**
160 : * Don't hide Elem::key() defined in the base class.
161 : */
162 : using Elem::key;
163 :
164 : /**
165 : * \returns An id associated with the \p s side of this element.
166 : * The id is not necessarily unique, but should be close.
167 : *
168 : * We reimplement this method here for the \p Prism21 since we can
169 : * use the center node of each quad face to provide a perfect (unique)
170 : * key.
171 : */
172 : virtual dof_id_type key (const unsigned int s) const override;
173 :
174 : /**
175 : * \returns \p Prism21::side_nodes_map[side][side_node] after doing some range checking.
176 : */
177 : virtual unsigned int local_side_node(unsigned int side,
178 : unsigned int side_node) const override;
179 :
180 : /**
181 : * \returns \p Prism21::edge_nodes_map[edge][edge_node] after doing some range checking.
182 : */
183 : virtual unsigned int local_edge_node(unsigned int edge,
184 : unsigned int edge_node) const override;
185 :
186 : /**
187 : * Builds a \p QUAD9 or \p TRI6 built coincident with face i.
188 : * The \p std::unique_ptr<Elem> handles the memory aspect.
189 : */
190 : virtual std::unique_ptr<Elem> build_side_ptr (const unsigned int i) override;
191 :
192 : /**
193 : * Rebuilds a \p QUAD9 or \p TRI6 built coincident with face i.
194 : */
195 : virtual void build_side_ptr (std::unique_ptr<Elem> & elem,
196 : const unsigned int i) override;
197 :
198 : // Avoid hiding deprecated version with different signature
199 : using Elem::build_side_ptr;
200 :
201 : /**
202 : * Builds a \p EDGE3 or \p INFEDGE2 built coincident with edge i.
203 : * The \p std::unique_ptr<Elem> handles the memory aspect.
204 : */
205 : virtual std::unique_ptr<Elem> build_edge_ptr (const unsigned int i) override;
206 :
207 : /**
208 : * Rebuilds a \p EDGE3 built coincident with edges 0 to 2, or \p
209 : * INFEDGE2 built coincident with edges 3 to 5.
210 : */
211 : virtual void build_edge_ptr (std::unique_ptr<Elem> & edge, const unsigned int i) override;
212 :
213 : virtual void connectivity(const unsigned int sc,
214 : const IOPackage iop,
215 : std::vector<dof_id_type> & conn) const override;
216 :
217 : /**
218 : * \returns 2 for all edge nodes, 4 for quad face nodes, 3 for tri
219 : * face nodes, 6 for the interior node.
220 : */
221 : virtual unsigned int n_second_order_adjacent_vertices (const unsigned int) const override;
222 :
223 : /**
224 : * \returns The element-local number of the \f$ v^{th} \f$ vertex
225 : * that defines the \f$ n^{th} \f$ second-order node.
226 : *
227 : * \note \p n is counted as depicted above, \f$ 6 \le n < 21 \f$.
228 : */
229 : virtual unsigned short int second_order_adjacent_vertex (const unsigned int n,
230 : const unsigned int v) const override;
231 :
232 : /**
233 : * \returns The child number \p c and element-local index \p v of the
234 : * \f$ n^{th} \f$ second-order node on the parent element. See
235 : * elem.h for further details.
236 : */
237 : virtual std::pair<unsigned short int, unsigned short int>
238 : second_order_child_vertex (const unsigned int n) const override;
239 :
240 : /**
241 : * Geometric constants for Prism21.
242 : */
243 : static const int num_nodes = 21;
244 : static const int nodes_per_side = 9;
245 : static const int nodes_per_edge = 3;
246 :
247 : /**
248 : * This maps the \f$ j^{th} \f$ node of the \f$ i^{th} \f$ side to
249 : * element node numbers.
250 : */
251 : static const unsigned int side_nodes_map[num_sides][nodes_per_side];
252 :
253 : /**
254 : * This maps the \f$ j^{th} \f$ node of the \f$ i^{th} \f$ edge to
255 : * element node numbers.
256 : */
257 : static const unsigned int edge_nodes_map[num_edges][nodes_per_edge];
258 :
259 : virtual void permute(unsigned int perm_num) override final;
260 :
261 : virtual void flip(BoundaryInfo *) override final;
262 :
263 : #ifdef LIBMESH_ENABLE_AMR
264 : virtual
265 : const std::vector<std::pair<unsigned char, unsigned char>> &
266 1875446 : parent_bracketing_nodes(unsigned int c,
267 : unsigned int n) const override
268 1875446 : { return _parent_bracketing_nodes[c][n]; }
269 : #endif
270 :
271 : unsigned int center_node_on_side(const unsigned short side) const override final;
272 :
273 : ElemType side_type (const unsigned int s) const override final;
274 :
275 : protected:
276 :
277 : /**
278 : * Data for links to nodes.
279 : */
280 : Node * _nodelinks_data[num_nodes];
281 :
282 :
283 :
284 : #ifdef LIBMESH_ENABLE_AMR
285 :
286 : /**
287 : * Matrix used to create the elements children.
288 : */
289 12167427 : virtual Real embedding_matrix (const unsigned int i,
290 : const unsigned int j,
291 : const unsigned int k) const override
292 12167427 : { return _embedding_matrix[i][j][k]; }
293 :
294 : /**
295 : * Matrix that computes new nodal locations/solution values
296 : * from current nodes/solution.
297 : */
298 : static const Real _embedding_matrix[num_children][num_nodes][num_nodes];
299 :
300 : /**
301 : * Pairs of nodes that bracket child nodes when doing mesh
302 : * refinement.
303 : */
304 : static const std::vector<std::pair<unsigned char, unsigned char>>
305 : _parent_bracketing_nodes[num_children][num_nodes];
306 :
307 2499588 : LIBMESH_ENABLE_TOPOLOGY_CACHES;
308 :
309 : #endif // LIBMESH_ENABLE_AMR
310 :
311 : /**
312 : * Matrix that tells which vertices define the location
313 : * of mid-side (or second-order) nodes. This matrix
314 : * handles only the second-order nodes that are unique
315 : * to \p Prism20. Earlier second-order nodes are identical
316 : * with \p Prism15, and are therefore handled through a
317 : * matrix contained in \p cell_prism.C; the final second-order node
318 : * is just a simple identity map.
319 : */
320 : static const unsigned short int _remaining_second_order_adjacent_vertices[5][4];
321 : };
322 :
323 : } // namespace libMesh
324 :
325 : #endif // LIBMESH_CELL_PRISM21_H
|