Skip to content

Commit 70e9c97

Browse files
authored
Merge pull request #3458 from roystgnr/side_pyramids
Pyramid18 geometry + LAGRANGE support
2 parents e5b152e + 82b6cb2 commit 70e9c97

39 files changed

+1442
-73
lines changed

Makefile.in

Lines changed: 101 additions & 30 deletions
Large diffs are not rendered by default.

include/Makefile.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,7 @@ include_HEADERS = \
717717
geom/cell_pyramid.h \
718718
geom/cell_pyramid13.h \
719719
geom/cell_pyramid14.h \
720+
geom/cell_pyramid18.h \
720721
geom/cell_pyramid5.h \
721722
geom/cell_tet.h \
722723
geom/cell_tet10.h \
@@ -1074,6 +1075,7 @@ include_HEADERS = \
10741075
utils/tree_node.h \
10751076
utils/utility.h \
10761077
utils/vectormap.h \
1078+
utils/win_gettimeofday.h \
10771079
utils/xdr_cxx.h
10781080

10791081

include/fe/fe.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,6 +1324,16 @@ OutputShape fe_fdm_deriv(const Elem * elem,
13241324
const unsigned int, const Point &,
13251325
const bool));
13261326

1327+
template <typename OutputShape>
1328+
OutputShape fe_fdm_deriv(const ElemType type,
1329+
const Order order,
1330+
const unsigned int i,
1331+
const unsigned int j,
1332+
const Point & p,
1333+
OutputShape(*shape_func)
1334+
(const ElemType, const Order,
1335+
const unsigned int, const Point &));
1336+
13271337
template <typename OutputShape>
13281338
OutputShape
13291339
fe_fdm_second_deriv(const Elem * elem,
@@ -1337,6 +1347,18 @@ fe_fdm_second_deriv(const Elem * elem,
13371347
const unsigned int, const unsigned int,
13381348
const Point &, const bool));
13391349

1350+
template <typename OutputShape>
1351+
OutputShape fe_fdm_second_deriv(const ElemType type,
1352+
const Order order,
1353+
const unsigned int i,
1354+
const unsigned int j,
1355+
const Point & p,
1356+
OutputShape(*deriv_func)
1357+
(const ElemType, const Order,
1358+
const unsigned int,
1359+
const unsigned int,
1360+
const Point &));
1361+
13401362
/**
13411363
* Helper functions for Lagrange-based basis functions.
13421364
*/

include/geom/cell_prism20.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ class Prism20 final : public Prism
211211
std::vector<dof_id_type> & conn) const override;
212212

213213
/**
214-
* \returns 2 for all edge nodes and 4 for face nodes.
214+
* \returns 2 for all edge nodes, 4 for quad face nodes, 6 for tri
215+
* face nodes.
215216
*/
216217
virtual unsigned int n_second_order_adjacent_vertices (const unsigned int) const override;
217218

include/geom/cell_prism21.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ class Prism21 final : public Prism
214214
std::vector<dof_id_type> & conn) const override;
215215

216216
/**
217-
* \returns 2 for all edge nodes and 4 for face nodes.
217+
* \returns 2 for all edge nodes, 4 for quad face nodes, 3 for tri
218+
* face nodes, 6 for the interior node.
218219
*/
219220
virtual unsigned int n_second_order_adjacent_vertices (const unsigned int) const override;
220221

include/geom/cell_pyramid18.h

Lines changed: 287 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,287 @@
1+
// The libMesh Finite Element Library.
2+
// Copyright (C) 2002-2022 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_PYRAMID18_H
21+
#define LIBMESH_CELL_PYRAMID18_H
22+
23+
// Local includes
24+
#include "libmesh/cell_pyramid.h"
25+
26+
namespace libMesh
27+
{
28+
29+
/**
30+
* The \p Pyramid18 is an element in 3D composed of 18 nodes, designed
31+
* to interface with a QUAD9 element on the base and a TRI7 element on
32+
* each of the triangular faces. Cubit will generate hybrid meshes
33+
* with linear pyramids, but as of version 18 will not export
34+
* quadratic pyramids. Paraview may support 13-node pyramids, but
35+
* does not render 18-node pyramids correctly. So even if this
36+
* element works in libmesh, we are currently limited in what we can do
37+
* with it outside the library...
38+
*
39+
* The node numbering for the pyramid18 is given below:
40+
*
41+
* \verbatim
42+
* PYRAMID18:
43+
* o 4
44+
* //|\
45+
* // | \
46+
* // | \
47+
* // | \
48+
* 12 o/ | o 11
49+
* // | \
50+
* /o 9 o 10 \
51+
* // | \ zeta
52+
* // | \ ^ eta (into page)
53+
* 3 o/.......o.|........o 2 | /
54+
* ./ 7 | / |/
55+
* ./ | / o---> xi
56+
* ./ | /
57+
* ./ | /
58+
* 8 o/ o | o 6
59+
* ./ 13 | /
60+
* ./ | /
61+
* ./ |/
62+
* o--------o---------o
63+
* 0 5 1
64+
* \endverbatim
65+
*
66+
* And it also includes four triangle face nodes:
67+
* Node 14, on side 0, equidistant from 0/1/4 or 5/9/10
68+
* Node 15, on side 1, equidistant from 1/2/4 or 6/10/11
69+
* Node 16, on side 2, equidistant from 2/3/4 or 7/11/12
70+
* Node 17, on side 3, equidistant from 0/3/4 or 8/9/12
71+
*
72+
* (xi, eta, zeta): { zeta-1 <= xi <= 1-zeta
73+
* { zeta-1 <= eta <= 1-zeta
74+
* { 0 <= zeta <= 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 pyramid element with 18 nodes.
81+
*/
82+
class Pyramid18 final : public Pyramid
83+
{
84+
public:
85+
86+
/**
87+
* Constructor. By default this element has no parent.
88+
*/
89+
explicit
90+
Pyramid18 (Elem * p=nullptr) :
91+
Pyramid(Pyramid18::n_nodes(), p, _nodelinks_data)
92+
{}
93+
94+
Pyramid18 (Pyramid18 &&) = delete;
95+
Pyramid18 (const Pyramid18 &) = delete;
96+
Pyramid18 & operator= (const Pyramid18 &) = delete;
97+
Pyramid18 & operator= (Pyramid18 &&) = delete;
98+
virtual ~Pyramid18() = default;
99+
100+
/**
101+
* \returns 18.
102+
*/
103+
virtual unsigned int n_nodes() const override { return num_nodes; }
104+
105+
/**
106+
* \returns \p PYRAMID18.
107+
*/
108+
virtual ElemType type () const override { return PYRAMID18; }
109+
110+
/**
111+
* FIXME: we don't yet have a refinement pattern for pyramids...
112+
* \returns 1.
113+
*/
114+
virtual unsigned int n_sub_elem() const override { return 1; }
115+
116+
/**
117+
* \returns \p true if the specified (local) node number is a vertex.
118+
*/
119+
virtual bool is_vertex(const unsigned int i) const override;
120+
121+
/**
122+
* \returns \p true if the specified (local) node number is an edge.
123+
*/
124+
virtual bool is_edge(const unsigned int i) const override;
125+
126+
/**
127+
* \returns \p true if the specified (local) node number is a face.
128+
*/
129+
virtual bool is_face(const unsigned int i) const override;
130+
131+
/**
132+
* \returns \p true if the specified (local) node number is on the
133+
* specified side.
134+
*/
135+
virtual bool is_node_on_side(const unsigned int n,
136+
const unsigned int s) const override;
137+
138+
virtual std::vector<unsigned int> nodes_on_side(const unsigned int s) const override;
139+
140+
virtual std::vector<unsigned int> nodes_on_edge(const unsigned int e) const override;
141+
142+
/**
143+
* \returns \p true if the specified (local) node number is on the
144+
* specified edge.
145+
*/
146+
virtual bool is_node_on_edge(const unsigned int n,
147+
const unsigned int e) const override;
148+
149+
/**
150+
* \returns \p true if the element map is definitely affine within
151+
* numerical tolerances.
152+
*/
153+
virtual bool has_affine_map () const override;
154+
155+
/**
156+
* \returns SECOND.
157+
*/
158+
virtual Order default_order() const override;
159+
160+
/**
161+
* Don't hide Pyramid::key() defined in the base class.
162+
*/
163+
using Pyramid::key;
164+
165+
/**
166+
* \returns An id associated with the \p s side of this element.
167+
* The id is not necessarily unique, but should be close. This is
168+
* particularly useful in the \p MeshBase::find_neighbors() routine.
169+
*
170+
* We reimplement this method here for the \p Pyramid18 since we can
171+
* use the center node of the base face to provide a perfect (unique)
172+
* key.
173+
*/
174+
virtual dof_id_type key (const unsigned int s) const override;
175+
176+
/**
177+
* \returns \p Pyramid18::side_nodes_map[side][side_node] after doing some range checking.
178+
*/
179+
virtual unsigned int local_side_node(unsigned int side,
180+
unsigned int side_node) const override;
181+
182+
/**
183+
* \returns \p Pyramid18::edge_nodes_map[edge][edge_node] after doing some range checking.
184+
*/
185+
virtual unsigned int local_edge_node(unsigned int edge,
186+
unsigned int edge_node) const override;
187+
188+
/**
189+
* Builds a \p QUAD9 or \p TRI7 coincident with face i.
190+
* The \p std::unique_ptr<Elem> handles the memory aspect.
191+
*/
192+
virtual std::unique_ptr<Elem> build_side_ptr (const unsigned int i,
193+
bool proxy=false) override;
194+
195+
/**
196+
* Rebuilds a \p QUAD9 or \p TRI7 built coincident with face i.
197+
*/
198+
virtual void build_side_ptr (std::unique_ptr<Elem> & elem,
199+
const unsigned int i) override;
200+
201+
/**
202+
* Builds a \p EDGE3 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 coincident with edge i.
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, 3 for tri
218+
* face nodes.
219+
*/
220+
virtual unsigned int n_second_order_adjacent_vertices (const unsigned int n) 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+
virtual unsigned short int second_order_adjacent_vertex (const unsigned int n,
227+
const unsigned int v) const override;
228+
229+
/**
230+
* Geometric constants for Pyramid18.
231+
*/
232+
static const int num_nodes = 18;
233+
static const int num_sides = 5;
234+
static const int num_edges = 8;
235+
static const int num_children = 0; // not implemented
236+
static const int nodes_per_side = 9;
237+
static const int nodes_per_edge = 3;
238+
239+
/**
240+
* This maps the \f$ j^{th} \f$ node of the \f$ i^{th} \f$ side to
241+
* element node numbers.
242+
*/
243+
static const unsigned int side_nodes_map[num_sides][nodes_per_side];
244+
245+
/**
246+
* This maps the \f$ j^{th} \f$ node of the \f$ i^{th} \f$ edge to
247+
* element node numbers.
248+
*/
249+
static const unsigned int edge_nodes_map[num_edges][nodes_per_edge];
250+
251+
virtual void permute(unsigned int perm_num) override final;
252+
253+
virtual void flip(BoundaryInfo *) override final;
254+
255+
unsigned int center_node_on_side(const unsigned short side) const override final;
256+
257+
ElemType side_type (const unsigned int s) const override final;
258+
259+
protected:
260+
261+
/**
262+
* Data for links to nodes.
263+
*/
264+
Node * _nodelinks_data[num_nodes];
265+
266+
267+
268+
#ifdef LIBMESH_ENABLE_AMR
269+
270+
/**
271+
* Matrix used to create the elements children.
272+
*/
273+
virtual Real embedding_matrix (const unsigned int,
274+
const unsigned int,
275+
const unsigned int) const override
276+
{ libmesh_not_implemented(); return 0.; }
277+
278+
LIBMESH_ENABLE_TOPOLOGY_CACHES;
279+
280+
#endif // LIBMESH_ENABLE_AMR
281+
282+
};
283+
284+
} // namespace libMesh
285+
286+
287+
#endif // LIBMESH_CELL_PYRAMID18_H

include/include_HEADERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ include_HEADERS = \
127127
geom/cell_pyramid.h \
128128
geom/cell_pyramid13.h \
129129
geom/cell_pyramid14.h \
130+
geom/cell_pyramid18.h \
130131
geom/cell_pyramid5.h \
131132
geom/cell_tet.h \
132133
geom/cell_tet10.h \
@@ -484,4 +485,5 @@ include_HEADERS = \
484485
utils/tree_node.h \
485486
utils/utility.h \
486487
utils/vectormap.h \
488+
utils/win_gettimeofday.h \
487489
utils/xdr_cxx.h

include/libmesh/Makefile.am

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ BUILT_SOURCES = \
117117
cell_pyramid.h \
118118
cell_pyramid13.h \
119119
cell_pyramid14.h \
120+
cell_pyramid18.h \
120121
cell_pyramid5.h \
121122
cell_tet.h \
122123
cell_tet10.h \
@@ -911,6 +912,9 @@ cell_pyramid13.h: $(top_srcdir)/include/geom/cell_pyramid13.h
911912
cell_pyramid14.h: $(top_srcdir)/include/geom/cell_pyramid14.h
912913
$(AM_V_GEN)rm -f $@ && $(LN_S) -f $< $@
913914

915+
cell_pyramid18.h: $(top_srcdir)/include/geom/cell_pyramid18.h
916+
$(AM_V_GEN)rm -f $@ && $(LN_S) -f $< $@
917+
914918
cell_pyramid5.h: $(top_srcdir)/include/geom/cell_pyramid5.h
915919
$(AM_V_GEN)rm -f $@ && $(LN_S) -f $< $@
916920

0 commit comments

Comments
 (0)