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