libMesh
Loading...
Searching...
No Matches
fe_lagrange_gll_shape.h
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#ifndef LIBMESH_FE_LAGRANGE_GLL_SHAPE_H
20#define LIBMESH_FE_LAGRANGE_GLL_SHAPE_H
21
22// Local includes
23#include "libmesh/enum_fe_family.h"
24#include "libmesh/enum_order.h"
25#include "libmesh/fe_lagrange_gll_shape_1D.h"
26#include "libmesh/int_range.h"
27
28// Tensor product evaluation shared by the Gauss-Lobatto nodal families. The families differ
29// only in how a shape function index maps to a tensor index, so each family specializes
30// fe_lagrange_gll_tensor_index and shares the rest.
31
32namespace libMesh
33{
34
42constexpr unsigned int fe_lagrange_gll_second_deriv_pairs[6][2] =
43 {{0, 0}, // d^2 phi / dxi^2
44 {0, 1}, // d^2 phi / dxi deta
45 {1, 1}, // d^2 phi / deta^2
46 {0, 2}, // d^2 phi / dxi dzeta
47 {1, 2}, // d^2 phi / deta dzeta
48 {2, 2}}; // d^2 phi / dzeta^2
49
50
54template <unsigned int Dim>
55constexpr unsigned int fe_lagrange_gll_n_second_derivs()
56{
57 return Dim * (Dim + 1) / 2;
58}
59
68template <FEFamily T>
70 const Order order,
71 const unsigned int dim,
72 const unsigned int i,
73 unsigned int * indices);
74
75
83template <>
85 const Order order,
86 const unsigned int dim,
87 const unsigned int i,
88 unsigned int * indices)
89{
90 const unsigned int n = static_cast<unsigned int>(order) + 1;
91
92 unsigned int stride = 1;
93
94 for (const auto d : make_range(dim))
95 {
96 indices[d] = (i / stride) % n;
97 stride *= n;
98 }
99
100 libmesh_assert_less (i, stride);
101}
102
112template <FEFamily T, unsigned int Dim>
114 const Order order,
115 const unsigned int i,
116 const Point & p,
117 const unsigned int * const deriv_coords,
118 const unsigned int n_deriv_coords)
119{
120 unsigned int indices[3];
121
122 fe_lagrange_gll_tensor_index<T>(elem, order, Dim, i, indices);
123
124 Real value = 1.;
125
126 for (const auto d : make_range(Dim))
127 {
128 unsigned int deriv_order = 0;
129 for (const auto k : make_range(n_deriv_coords))
130 if (deriv_coords[k] == d)
131 ++deriv_order;
132
133 switch (deriv_order)
134 {
135 case 0:
136 value *= fe_lagrange_gll_1D_shape(order, indices[d], p(d));
137 break;
138
139 case 1:
140 value *= fe_lagrange_gll_1D_shape_deriv(order, indices[d], 0, p(d));
141 break;
142
143#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
144 case 2:
145 value *= fe_lagrange_gll_1D_shape_second_deriv(order, indices[d], 0, p(d));
146 break;
147#endif
148
149 default:
150 libmesh_error_msg("Invalid derivative order " << deriv_order << ".");
151 }
152 }
153
154 return value;
155}
156
157} // namespace libMesh
158
159#endif // LIBMESH_FE_LAGRANGE_GLL_SHAPE_H
unsigned int dim
This is the base class from which all geometric element types are derived.
Definition elem.h:96
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:41
The libMesh namespace provides an interface to certain functionality in the library.
void fe_lagrange_gll_tensor_index< L2_LAGRANGE_GLL >(const Elem *, const Order order, const unsigned int dim, const unsigned int i, unsigned int *indices)
All L2_LAGRANGE_GLL degrees of freedom belong to the element.
constexpr unsigned int fe_lagrange_gll_n_second_derivs()
constexpr unsigned int fe_lagrange_gll_second_deriv_pairs[6][2]
The pair of coordinates differentiated by each second derivative index j of FE::shape_second_deriv().
Real fe_lagrange_gll_tensor_product(const Elem *elem, const Order order, const unsigned int i, const Point &p, const unsigned int *const deriv_coords, const unsigned int n_deriv_coords)
void fe_lagrange_gll_tensor_index(const Elem *elem, const Order order, const unsigned int dim, const unsigned int i, unsigned int *indices)
Writes the tensor index of shape function i of order order into the first dim entries of indices.
Real fe_lagrange_gll_1D_shape_deriv(const Order order, const unsigned int i, const unsigned int libmesh_dbg_var(j), const Real xi)
Real fe_lagrange_gll_1D_shape_second_deriv(const Order order, const unsigned int i, const unsigned int libmesh_dbg_var(j), const Real xi)
Real fe_lagrange_gll_1D_shape(const Order order, const unsigned int i, const Real xi)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
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
static const bool value
Definition xdr_io.C:55