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 : // Local Includes
20 : #include "libmesh/libmesh_config.h"
21 :
22 : #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
23 :
24 : #include "libmesh/inf_fe.h"
25 : #include "libmesh/jacobi_polynomials.h"
26 :
27 : using namespace libMesh;
28 :
29 : // Anonymous namespace for local helper functions
30 : namespace {
31 :
32 : // When alpha=beta=0, the Jacobi polynomials reduce to the Legendre polynomials.
33 410 : Real legendre_eval(unsigned int n, Real x)
34 : {
35 410 : if (n == 0)
36 44 : return 1.;
37 :
38 300 : Real val = JacobiPolynomials::value(n, /*alpha=*/0, /*beta=*/0, x);
39 :
40 : // For n>0, there is an even/odd shift of -1/+1 applied. I'm not
41 : // sure why this is done for the infinite elements, as it is not
42 : // part of the "standard" Legendre polynomial definition, I'm just
43 : // copying what was done in the original implementation...
44 405 : return val + (n % 2 == 0 ? -1 : +1);
45 : }
46 :
47 164 : Real legendre_eval_deriv(unsigned int n, Real x)
48 : {
49 410 : return JacobiPolynomials::deriv(n, /*alpha=*/0, /*beta=*/0, x);
50 : }
51 : } // anonymous namespace
52 :
53 :
54 : namespace libMesh
55 : {
56 :
57 : // Specialize the eval() function for 1, 2, and 3 dimensions and the CARTESIAN mapping type
58 : // to call the local helper function from the anonymous namespace.
59 0 : template <> Real InfFE<1,LEGENDRE,CARTESIAN>::eval(Real x, Order, unsigned n) { return legendre_eval(n, x); }
60 0 : template <> Real InfFE<2,LEGENDRE,CARTESIAN>::eval(Real x, Order, unsigned n) { return legendre_eval(n, x); }
61 410 : template <> Real InfFE<3,LEGENDRE,CARTESIAN>::eval(Real x, Order, unsigned n) { return legendre_eval(n, x); }
62 :
63 : // Specialize the eval_deriv() function for 1, 2, and 3 dimensions and the CARTESIAN mapping type
64 : // to call the local helper function from the anonymous namespace.
65 0 : template <> Real InfFE<1,LEGENDRE,CARTESIAN>::eval_deriv(Real x, Order, unsigned n) { return legendre_eval_deriv(n, x); }
66 0 : template <> Real InfFE<2,LEGENDRE,CARTESIAN>::eval_deriv(Real x, Order, unsigned n) { return legendre_eval_deriv(n, x); }
67 574 : template <> Real InfFE<3,LEGENDRE,CARTESIAN>::eval_deriv(Real x, Order, unsigned n) { return legendre_eval_deriv(n, x); }
68 :
69 : } // namespace libMesh
70 :
71 :
72 : #endif // LIBMESH_ENABLE_INFINITE_ELEMENTS
|