libMesh
Loading...
Searching...
No Matches
fe_lagrange_gll.C
Go to the documentation of this file.
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// Local includes
21#include "libmesh/elem.h"
22#include "libmesh/enum_to_string.h"
23#include "libmesh/fe.h"
24#include "libmesh/fe_interface.h"
25#include "libmesh/fe_lagrange_gll_shape_1D.h"
26#include "libmesh/fe_macro.h"
27
28
29namespace libMesh
30{
31
46unsigned int lagrange_gll_n_dofs(const ElemType t, const Order o)
47{
48 libmesh_assert_greater (o, 0);
49
50 const unsigned int n = static_cast<unsigned int>(o) + 1;
51
52 libmesh_error_msg_if(n > fe_lagrange_gll_max_points_1D,
53 "The LAGRANGE_GLL basis of order " << o << " needs " << n
54 << " Gauss-Lobatto points. The table has at most "
56
57 switch (t)
58 {
59 case NODEELEM:
60 return 1;
61
62 // An edge element has only vertices and an interior, so it needs no other nodes at any
63 // order
64 case EDGE2:
65 case EDGE3:
66 case EDGE4:
67 return n;
68
69 // Above order one, the edge degrees of freedom need mid-edge nodes
70 case QUAD4:
71 case QUADSHELL4:
72 libmesh_error_msg_if(o > FIRST,
73 "The LAGRANGE_GLL basis of order " << o << " puts " << o - 1
74 << " degrees of freedom on each edge. "
75 << Utility::enum_to_string(t) << " has no mid-edge nodes. "
76 "Use QUAD8 or QUAD9.");
77 libmesh_fallthrough();
78 case QUAD8:
79 case QUADSHELL8:
80 case QUAD9:
81 case QUADSHELL9:
82 return n*n;
83
84 // In three dimensions, the face degrees of freedom also need face nodes
85 case HEX8:
86 libmesh_error_msg_if(o > FIRST,
87 "The LAGRANGE_GLL basis of order " << o
88 << " puts degrees of freedom on the edges and faces of a hexahedron. "
89 "HEX8 has no edge or face nodes. Use HEX27.");
90 libmesh_fallthrough();
91 case HEX20:
92 libmesh_error_msg_if(o > FIRST,
93 "The LAGRANGE_GLL basis of order " << o << " puts " << (o - 1)*(o - 1)
94 << " degrees of freedom on each face. HEX20 has no face nodes. "
95 "Use HEX27.");
96 libmesh_fallthrough();
97 case HEX27:
98 return n*n*n;
99
100 case INVALID_ELEM:
101 return 0;
102
103 default:
104 libmesh_error_msg("The LAGRANGE_GLL basis is a tensor product. It does not support "
105 << Utility::enum_to_string(t) << ".");
106 }
107}
108
109
110unsigned int lagrange_gll_n_dofs(const Elem * e, const Order o)
111{
113 return lagrange_gll_n_dofs(e->type(), o);
114}
115
125 const Order o,
126 const unsigned int n)
127{
128 libmesh_assert_greater (o, 0);
129
130 const unsigned int per_edge = static_cast<unsigned int>(o) - 1;
131
132 switch (t)
133 {
134 case NODEELEM:
135 return 1;
136
137 case EDGE2:
138 case EDGE3:
139 case EDGE4:
140 return (n < 2) ? 1 : 0;
141
142 case QUAD4:
143 case QUADSHELL4:
144 libmesh_assert_less (n, 4);
145 libmesh_fallthrough();
146 case QUAD8:
147 case QUADSHELL8:
148 case QUAD9:
149 case QUADSHELL9:
150 if (n < 4)
151 return 1;
152 if (n < 8)
153 return per_edge;
154 return 0;
155
156 case HEX8:
157 libmesh_assert_less (n, 8);
158 libmesh_fallthrough();
159 case HEX20:
160 case HEX27:
161 if (n < 8)
162 return 1;
163 if (n < 20)
164 return per_edge;
165 if (n < 26)
166 return per_edge * per_edge;
167 return 0;
168
169 case INVALID_ELEM:
170 return 0;
171
172 default:
173 libmesh_error_msg("The LAGRANGE_GLL basis is a tensor product. It does not support "
174 << Utility::enum_to_string(t) << ".");
175 }
176}
177
182unsigned int lagrange_gll_n_dofs_per_elem(const ElemType t, const Order o)
183{
184 libmesh_assert_greater (o, 0);
185
186 const unsigned int per_edge = static_cast<unsigned int>(o) - 1;
187
188 switch (t)
189 {
190 case NODEELEM:
191 case INVALID_ELEM:
192 return 0;
193
194 case EDGE2:
195 case EDGE3:
196 case EDGE4:
197 return per_edge;
198
199 case QUAD4:
200 case QUADSHELL4:
201 case QUAD8:
202 case QUADSHELL8:
203 case QUAD9:
204 case QUADSHELL9:
205 return per_edge * per_edge;
206
207 case HEX8:
208 case HEX20:
209 case HEX27:
210 return per_edge * per_edge * per_edge;
211
212 default:
213 libmesh_error_msg("The LAGRANGE_GLL basis is a tensor product. It does not support "
214 << Utility::enum_to_string(t) << ".");
215 }
216}
217
218
226 const Order order,
227 const std::vector<Number> & elem_soln,
228 std::vector<Number> & nodal_soln,
229 const bool add_p_level)
230{
231 const unsigned int n_nodes = elem->n_nodes();
232
233 nodal_soln.resize(n_nodes);
234
235 const FEType fe_type(order, LAGRANGE_GLL);
236
237 const unsigned int n_sf =
238 FEInterface::n_shape_functions(fe_type, elem, add_p_level);
239
240 std::vector<Point> refspace_nodes;
241 FEBase::get_refspace_nodes(elem->type(), refspace_nodes);
242 libmesh_assert_equal_to (refspace_nodes.size(), n_nodes);
243 libmesh_assert_equal_to (elem_soln.size(), n_sf);
244
245 std::fill(nodal_soln.begin(), nodal_soln.end(), 0);
246
247 for (const auto n : make_range(n_nodes))
248 for (const auto i : make_range(n_sf))
249 nodal_soln[n] += elem_soln[i] *
250 FEInterface::shape(fe_type, elem, i, refspace_nodes[n], add_p_level);
251}
252
258template <> unsigned int FE<1,LAGRANGE_GLL>::n_dofs(const ElemType t, const Order o) { return lagrange_gll_n_dofs(t, o); }
259template <> unsigned int FE<2,LAGRANGE_GLL>::n_dofs(const ElemType t, const Order o) { return lagrange_gll_n_dofs(t, o); }
260template <> unsigned int FE<3,LAGRANGE_GLL>::n_dofs(const ElemType t, const Order o) { return lagrange_gll_n_dofs(t, o); }
261
262template <> unsigned int FE<0,LAGRANGE_GLL>::n_dofs(const Elem * e, const Order o) { return lagrange_gll_n_dofs(e, o); }
263template <> unsigned int FE<1,LAGRANGE_GLL>::n_dofs(const Elem * e, const Order o) { return lagrange_gll_n_dofs(e, o); }
264template <> unsigned int FE<2,LAGRANGE_GLL>::n_dofs(const Elem * e, const Order o) { return lagrange_gll_n_dofs(e, o); }
265template <> unsigned int FE<3,LAGRANGE_GLL>::n_dofs(const Elem * e, const Order o) { return lagrange_gll_n_dofs(e, o); }
266
267template <> unsigned int FE<0,LAGRANGE_GLL>::n_dofs_at_node(const ElemType t, const Order o, const unsigned int n) { return lagrange_gll_n_dofs_at_node(t, o, n); }
268template <> unsigned int FE<1,LAGRANGE_GLL>::n_dofs_at_node(const ElemType t, const Order o, const unsigned int n) { return lagrange_gll_n_dofs_at_node(t, o, n); }
269template <> unsigned int FE<2,LAGRANGE_GLL>::n_dofs_at_node(const ElemType t, const Order o, const unsigned int n) { return lagrange_gll_n_dofs_at_node(t, o, n); }
270template <> unsigned int FE<3,LAGRANGE_GLL>::n_dofs_at_node(const ElemType t, const Order o, const unsigned int n) { return lagrange_gll_n_dofs_at_node(t, o, n); }
271
272template <> unsigned int FE<0,LAGRANGE_GLL>::n_dofs_at_node(const Elem & e, const Order o, const unsigned int n) { return lagrange_gll_n_dofs_at_node(e.type(), o, n); }
273template <> unsigned int FE<1,LAGRANGE_GLL>::n_dofs_at_node(const Elem & e, const Order o, const unsigned int n) { return lagrange_gll_n_dofs_at_node(e.type(), o, n); }
274template <> unsigned int FE<2,LAGRANGE_GLL>::n_dofs_at_node(const Elem & e, const Order o, const unsigned int n) { return lagrange_gll_n_dofs_at_node(e.type(), o, n); }
275template <> unsigned int FE<3,LAGRANGE_GLL>::n_dofs_at_node(const Elem & e, const Order o, const unsigned int n) { return lagrange_gll_n_dofs_at_node(e.type(), o, n); }
276
277template <> unsigned int FE<0,LAGRANGE_GLL>::n_dofs_per_elem(const ElemType t, const Order o) { return lagrange_gll_n_dofs_per_elem(t, o); }
278template <> unsigned int FE<1,LAGRANGE_GLL>::n_dofs_per_elem(const ElemType t, const Order o) { return lagrange_gll_n_dofs_per_elem(t, o); }
279template <> unsigned int FE<2,LAGRANGE_GLL>::n_dofs_per_elem(const ElemType t, const Order o) { return lagrange_gll_n_dofs_per_elem(t, o); }
280template <> unsigned int FE<3,LAGRANGE_GLL>::n_dofs_per_elem(const ElemType t, const Order o) { return lagrange_gll_n_dofs_per_elem(t, o); }
281
282template <> unsigned int FE<0,LAGRANGE_GLL>::n_dofs_per_elem(const Elem & e, const Order o) { return lagrange_gll_n_dofs_per_elem(e.type(), o); }
283template <> unsigned int FE<1,LAGRANGE_GLL>::n_dofs_per_elem(const Elem & e, const Order o) { return lagrange_gll_n_dofs_per_elem(e.type(), o); }
284template <> unsigned int FE<2,LAGRANGE_GLL>::n_dofs_per_elem(const Elem & e, const Order o) { return lagrange_gll_n_dofs_per_elem(e.type(), o); }
285template <> unsigned int FE<3,LAGRANGE_GLL>::n_dofs_per_elem(const Elem & e, const Order o) { return lagrange_gll_n_dofs_per_elem(e.type(), o); }
286
287// The basis is continuous across a shared entity, because the two elements put each
288// shared degree of freedom at the same point
293
294// A nodal basis is not hierarchic
295template <> bool FE<0,LAGRANGE_GLL>::is_hierarchic() const { return false; }
296template <> bool FE<1,LAGRANGE_GLL>::is_hierarchic() const { return false; }
297template <> bool FE<2,LAGRANGE_GLL>::is_hierarchic() const { return false; }
298template <> bool FE<3,LAGRANGE_GLL>::is_hierarchic() const { return false; }
299
300// Each shape function depends on the orientation of the entity that owns it. Elements
301// with different orientations thus need new shape values.
302template <> bool FE<0,LAGRANGE_GLL>::shapes_need_reinit() const { return true; }
303template <> bool FE<1,LAGRANGE_GLL>::shapes_need_reinit() const { return true; }
304template <> bool FE<2,LAGRANGE_GLL>::shapes_need_reinit() const { return true; }
305template <> bool FE<3,LAGRANGE_GLL>::shapes_need_reinit() const { return true; }
306
307#ifdef LIBMESH_ENABLE_AMR
308template <>
310 DofMap & dof_map,
311 const unsigned int variable_number,
312 const Elem * elem)
313{ compute_proj_constraints(constraints, dof_map, variable_number, elem); }
314
315template <>
317 DofMap & dof_map,
318 const unsigned int variable_number,
319 const Elem * elem)
320{ compute_proj_constraints(constraints, dof_map, variable_number, elem); }
321#endif // LIBMESH_ENABLE_AMR
322
323
324} // namespace libMesh
The constraint matrix storage format.
Definition dof_map.h:112
This class handles the numbering of degrees of freedom on a mesh.
Definition dof_map.h:181
This is the base class from which all geometric element types are derived.
Definition elem.h:96
virtual unsigned int n_nodes() const =0
virtual ElemType type() const =0
static void get_refspace_nodes(const ElemType t, std::vector< Point > &nodes)
static Real shape(const unsigned int dim, const FEType &fe_t, const ElemType t, const unsigned int i, const Point &p)
static unsigned int n_shape_functions(const unsigned int dim, const FEType &fe_t, const ElemType t)
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
Definition fe_type.h:197
virtual bool is_hierarchic() const override
static unsigned int n_dofs_per_elem(const ElemType t, const Order o)
virtual FEContinuity get_continuity() const override
static void compute_constraints(DofConstraints &constraints, DofMap &dof_map, const unsigned int variable_number, const Elem *elem)
Computes the constraint matrix contributions (for non-conforming adapted meshes) corresponding to var...
static unsigned int n_dofs(const ElemType t, const Order o)
static unsigned int n_dofs_at_node(const ElemType t, const Order o, const unsigned int n)
virtual bool shapes_need_reinit() const override
std::string enum_to_string(const T e)
The libMesh namespace provides an interface to certain functionality in the library.
LIBMESH_FE_NODAL_SOLN(BERNSTEIN, bernstein_nodal_soln)
ElemType
Defines an enum for geometric element types.
libmesh_assert(ctx)
unsigned int lagrange_gll_n_dofs(const ElemType t, const Order o)
unsigned int lagrange_gll_n_dofs_per_elem(const ElemType t, const Order o)
unsigned int lagrange_gll_n_dofs_at_node(const ElemType t, const Order o, const unsigned int n)
constexpr unsigned int fe_lagrange_gll_max_points_1D
The number of points in the largest Gauss-Lobatto rule that QGaussLobatto tabulates,...
void lagrange_gll_nodal_soln(const Elem *elem, const Order order, const std::vector< Number > &elem_soln, std::vector< Number > &nodal_soln, const bool add_p_level)
Evaluates a solution at the nodes of elem.
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition int_range.h:176
LIBMESH_FE_SIDE_NODAL_SOLN(HIERARCHIC_VEC)
const dof_id_type n_nodes
Definition tecplot_io.C:67