LCOV - code coverage report
Current view: top level - src/fe - fe_lagrange_shape_2D.C (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4573 (924896) with base 3f0912 Lines: 175 221 79.2 %
Date: 2026-11-18 21:52:26 Functions: 26 32 81.2 %
Legend: Lines: hit not hit

          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             : // Local includes
      20             : #include "libmesh/fe.h"
      21             : #include "libmesh/elem.h"
      22             : #include "libmesh/fe_lagrange_shape_1D.h"
      23             : #include "libmesh/fe_simplex_lagrange.h"
      24             : #include "libmesh/fe_tensor_product_lagrange.h"
      25             : #include "libmesh/enum_to_string.h"
      26             : #include "libmesh/face_c0polygon.h"
      27             : 
      28             : // Anonymous namespace for functions shared by LAGRANGE and
      29             : // L2_LAGRANGE implementations. Implementations appear at the bottom
      30             : // of this file.
      31             : namespace
      32             : {
      33             : using namespace libMesh;
      34             : 
      35             : template <FEFamily T>
      36             : Real fe_lagrange_2D_shape(const ElemType,
      37             :                           const Elem * elem,
      38             :                           const Order order,
      39             :                           const unsigned int i,
      40             :                           const Point & p);
      41             : 
      42             : template <FEFamily T>
      43             : Real fe_lagrange_2D_shape_deriv(const ElemType type,
      44             :                                 const Elem * elem,
      45             :                                 const Order order,
      46             :                                 const unsigned int i,
      47             :                                 const unsigned int j,
      48             :                                 const Point & p);
      49             : 
      50             : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
      51             : 
      52             : template <FEFamily T>
      53             : Real fe_lagrange_2D_shape_second_deriv(const ElemType type,
      54             :                                        const Elem * elem,
      55             :                                        const Order order,
      56             :                                        const unsigned int i,
      57             :                                        const unsigned int j,
      58             :                                        const Point & p);
      59             : 
      60             : #endif // LIBMESH_ENABLE_SECOND_DERIVATIVES
      61             : 
      62             : } // anonymous namespace
      63             : 
      64             : 
      65             : 
      66             : namespace libMesh
      67             : {
      68             : 
      69             : 
      70   243467258 : LIBMESH_DEFAULT_VECTORIZED_FE(2,LAGRANGE)
      71     1384039 : LIBMESH_DEFAULT_VECTORIZED_FE(2,L2_LAGRANGE)
      72             : 
      73             : 
      74             : template <>
      75   276816407 : Real FE<2,LAGRANGE>::shape(const ElemType type,
      76             :                            const Order order,
      77             :                            const unsigned int i,
      78             :                            const Point & p)
      79             : {
      80   276816407 :   return fe_lagrange_2D_shape<LAGRANGE>(type, nullptr, order, i, p);
      81             : }
      82             : 
      83             : 
      84             : 
      85             : template <>
      86           0 : Real FE<2,L2_LAGRANGE>::shape(const ElemType type,
      87             :                               const Order order,
      88             :                               const unsigned int i,
      89             :                               const Point & p)
      90             : {
      91           0 :   return fe_lagrange_2D_shape<L2_LAGRANGE>(type, nullptr, order, i, p);
      92             : }
      93             : 
      94             : 
      95             : template <>
      96   542641219 : Real FE<2,LAGRANGE>::shape(const Elem * elem,
      97             :                            const Order order,
      98             :                            const unsigned int i,
      99             :                            const Point & p,
     100             :                            const bool add_p_level)
     101             : {
     102   167723678 :   libmesh_assert(elem);
     103             : 
     104             :   // call the orientation-independent shape functions
     105   856782591 :   return fe_lagrange_2D_shape<LAGRANGE>(elem->type(), elem, order + add_p_level*elem->p_level(), i, p);
     106             : }
     107             : 
     108             : 
     109             : 
     110             : template <>
     111     2399775 : Real FE<2,L2_LAGRANGE>::shape(const Elem * elem,
     112             :                               const Order order,
     113             :                               const unsigned int i,
     114             :                               const Point & p,
     115             :                               const bool add_p_level)
     116             : {
     117      616333 :   libmesh_assert(elem);
     118             : 
     119             :   // call the orientation-independent shape functions
     120     3632441 :   return fe_lagrange_2D_shape<L2_LAGRANGE>(elem->type(), elem, order + add_p_level*elem->p_level(), i, p);
     121             : }
     122             : 
     123             : 
     124             : template <>
     125   427682973 : Real FE<2,LAGRANGE>::shape(const FEType fet,
     126             :                            const Elem * elem,
     127             :                            const unsigned int i,
     128             :                            const Point & p,
     129             :                            const bool add_p_level)
     130             : {
     131   134620997 :   libmesh_assert(elem);
     132   648666979 :   return fe_lagrange_2D_shape<LAGRANGE>(elem->type(), elem, fet.order + add_p_level*elem->p_level(), i, p);
     133             : }
     134             : 
     135             : 
     136             : 
     137             : template <>
     138           0 : Real FE<2,L2_LAGRANGE>::shape(const FEType fet,
     139             :                               const Elem * elem,
     140             :                               const unsigned int i,
     141             :                               const Point & p,
     142             :                               const bool add_p_level)
     143             : {
     144           0 :   libmesh_assert(elem);
     145           0 :   return fe_lagrange_2D_shape<L2_LAGRANGE>(elem->type(), elem, fet.order + add_p_level*elem->p_level(), i, p);
     146             : }
     147             : 
     148             : 
     149             : template <>
     150   292694414 : Real FE<2,LAGRANGE>::shape_deriv(const ElemType type,
     151             :                                  const Order order,
     152             :                                  const unsigned int i,
     153             :                                  const unsigned int j,
     154             :                                  const Point & p)
     155             : {
     156   292694414 :   return fe_lagrange_2D_shape_deriv<LAGRANGE>(type, nullptr, order, i, j, p);
     157             : }
     158             : 
     159             : 
     160             : 
     161             : template <>
     162           0 : Real FE<2,L2_LAGRANGE>::shape_deriv(const ElemType type,
     163             :                                     const Order order,
     164             :                                     const unsigned int i,
     165             :                                     const unsigned int j,
     166             :                                     const Point & p)
     167             : {
     168           0 :   return fe_lagrange_2D_shape_deriv<L2_LAGRANGE>(type, nullptr, order, i, j, p);
     169             : }
     170             : 
     171             : 
     172             : 
     173             : template <>
     174   230631308 : Real FE<2,LAGRANGE>::shape_deriv(const Elem * elem,
     175             :                                  const Order order,
     176             :                                  const unsigned int i,
     177             :                                  const unsigned int j,
     178             :                                  const Point & p,
     179             :                                  const bool add_p_level)
     180             : {
     181    64678886 :   libmesh_assert(elem);
     182             : 
     183             :   // call the orientation-independent shape functions
     184   359938136 :   return fe_lagrange_2D_shape_deriv<LAGRANGE>(elem->type(), elem, order + add_p_level*elem->p_level(), i, j, p);
     185             : }
     186             : 
     187             : 
     188             : 
     189             : template <>
     190      572056 : Real FE<2,L2_LAGRANGE>::shape_deriv(const Elem * elem,
     191             :                                     const Order order,
     192             :                                     const unsigned int i,
     193             :                                     const unsigned int j,
     194             :                                     const Point & p,
     195             :                                     const bool add_p_level)
     196             : {
     197      147752 :   libmesh_assert(elem);
     198             : 
     199             :   // call the orientation-independent shape functions
     200      867560 :   return fe_lagrange_2D_shape_deriv<L2_LAGRANGE>(elem->type(), elem, order + add_p_level*elem->p_level(), i, j, p);
     201             : }
     202             : 
     203             : 
     204             : template <>
     205  4593987764 : Real FE<2,LAGRANGE>::shape_deriv(const FEType fet,
     206             :                                  const Elem * elem,
     207             :                                  const unsigned int i,
     208             :                                  const unsigned int j,
     209             :                                  const Point & p,
     210             :                                  const bool add_p_level)
     211             : {
     212  1174191220 :   libmesh_assert(elem);
     213  6937045800 :   return fe_lagrange_2D_shape_deriv<LAGRANGE>(elem->type(), elem, fet.order + add_p_level*elem->p_level(), i, j, p);
     214             : }
     215             : 
     216             : 
     217             : 
     218             : template <>
     219           0 : Real FE<2,L2_LAGRANGE>::shape_deriv(const FEType fet,
     220             :                                     const Elem * elem,
     221             :                                     const unsigned int i,
     222             :                                     const unsigned int j,
     223             :                                     const Point & p,
     224             :                                     const bool add_p_level)
     225             : {
     226           0 :   libmesh_assert(elem);
     227           0 :   return fe_lagrange_2D_shape_deriv<L2_LAGRANGE>(elem->type(), elem, fet.order + add_p_level*elem->p_level(), i, j, p);
     228             : }
     229             : 
     230             : 
     231             : 
     232             : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
     233             : 
     234             : template <>
     235    55352283 : Real FE<2,LAGRANGE>::shape_second_deriv(const ElemType type,
     236             :                                         const Order order,
     237             :                                         const unsigned int i,
     238             :                                         const unsigned int j,
     239             :                                         const Point & p)
     240             : {
     241    55352283 :   return fe_lagrange_2D_shape_second_deriv<LAGRANGE>(type, nullptr, order, i, j, p);
     242             : }
     243             : 
     244             : 
     245             : 
     246             : template <>
     247           0 : Real FE<2,L2_LAGRANGE>::shape_second_deriv(const ElemType type,
     248             :                                            const Order order,
     249             :                                            const unsigned int i,
     250             :                                            const unsigned int j,
     251             :                                            const Point & p)
     252             : {
     253           0 :   return fe_lagrange_2D_shape_second_deriv<L2_LAGRANGE>(type, nullptr, order, i, j, p);
     254             : }
     255             : 
     256             : 
     257             : 
     258             : template <>
     259     1110087 : Real FE<2,LAGRANGE>::shape_second_deriv(const Elem * elem,
     260             :                                         const Order order,
     261             :                                         const unsigned int i,
     262             :                                         const unsigned int j,
     263             :                                         const Point & p,
     264             :                                         const bool add_p_level)
     265             : {
     266      348216 :   libmesh_assert(elem);
     267             : 
     268             :   // call the orientation-independent shape functions
     269     1806519 :   return fe_lagrange_2D_shape_second_deriv<LAGRANGE>(elem->type(), elem, order + add_p_level*elem->p_level(), i, j, p);
     270             : }
     271             : 
     272             : 
     273             : 
     274             : template <>
     275      334644 : Real FE<2,L2_LAGRANGE>::shape_second_deriv(const Elem * elem,
     276             :                                            const Order order,
     277             :                                            const unsigned int i,
     278             :                                            const unsigned int j,
     279             :                                            const Point & p,
     280             :                                            const bool add_p_level)
     281             : {
     282       90444 :   libmesh_assert(elem);
     283             : 
     284             :   // call the orientation-independent shape functions
     285      515532 :   return fe_lagrange_2D_shape_second_deriv<L2_LAGRANGE>(elem->type(), elem, order + add_p_level*elem->p_level(), i, j, p);
     286             : }
     287             : 
     288             : 
     289             : template <>
     290    61636980 : Real FE<2,LAGRANGE>::shape_second_deriv(const FEType fet,
     291             :                                         const Elem * elem,
     292             :                                         const unsigned int i,
     293             :                                         const unsigned int j,
     294             :                                         const Point & p,
     295             :                                         const bool add_p_level)
     296             : {
     297    15476469 :   libmesh_assert(elem);
     298    92589918 :   return fe_lagrange_2D_shape_second_deriv<LAGRANGE>(elem->type(), elem, fet.order + add_p_level*elem->p_level(), i, j, p);
     299             : }
     300             : 
     301             : 
     302             : 
     303             : template <>
     304           0 : Real FE<2,L2_LAGRANGE>::shape_second_deriv(const FEType fet,
     305             :                                            const Elem * elem,
     306             :                                            const unsigned int i,
     307             :                                            const unsigned int j,
     308             :                                            const Point & p,
     309             :                                            const bool add_p_level)
     310             : {
     311           0 :   libmesh_assert(elem);
     312           0 :   return fe_lagrange_2D_shape_second_deriv<L2_LAGRANGE>(elem->type(), elem, fet.order + add_p_level*elem->p_level(), i, j, p);
     313             : }
     314             : 
     315             : #endif // LIBMESH_ENABLE_SECOND_DERIVATIVES
     316             : 
     317             : } // namespace libMesh
     318             : 
     319             : 
     320             : 
     321             : 
     322             : // Anonymous namespace function definitions
     323             : namespace
     324             : {
     325             : using namespace libMesh;
     326             : 
     327             : template <FEFamily T>
     328  1249540374 : Real fe_lagrange_2D_shape(const ElemType type,
     329             :                           const Elem * elem,
     330             :                           const Order order,
     331             :                           const unsigned int i,
     332             :                           const Point & p)
     333             : {
     334             : #if LIBMESH_DIM > 1
     335             : 
     336  1249540374 :   switch (order)
     337             :     {
     338             :       // linear Lagrange shape functions
     339   372987602 :     case FIRST:
     340             :       {
     341   259388483 :         switch (type)
     342             :           {
     343   316536336 :           case QUAD4:
     344             :           case QUADSHELL4:
     345             :           case QUAD8:
     346             :           case QUADSHELL8:
     347             :           case QUAD9:
     348             :           case QUADSHELL9:
     349             :             {
     350             :               // Compute quad shape functions as a tensor-product
     351   103054372 :               libmesh_assert_less (i, 4);
     352   415897148 :               return libMesh::detail::fe_lagrange_quad4_shape(i, p(0), p(1));
     353             :             }
     354             : 
     355    56205966 :           case TRI3:
     356             :           case TRISHELL3:
     357             :           case TRI6:
     358             :           case TRI7:
     359             :             {
     360    15186264 :               libmesh_assert_less (i, 3);
     361    56205966 :               return libMesh::detail::fe_lagrange_tri3_shape(i, p(0), p(1));
     362             :             }
     363             : 
     364      245300 :           case C0POLYGON:
     365             :             {
     366             :               // C0Polygon requires using newer FE APIs
     367      245300 :               if (!elem)
     368           0 :                 libmesh_error_msg("Code (see stack trace) used an outdated FE function overload.\n"
     369             :                                   "Shape functions on a C0Polygon are not defined by its ElemType alone.");
     370             : 
     371       68150 :               libmesh_assert(elem->type() == C0POLYGON);
     372             : 
     373       68150 :               const C0Polygon & poly = *cast_ptr<const C0Polygon *>(elem);
     374             : 
     375             :               // We can't use a small tolerance here, because in
     376             :               // inverse_map() Newton might hand us intermediate
     377             :               // iterates outside the polygon.
     378      245300 :               const auto [s, a, b] = poly.subtriangle_coordinates(p, 100);
     379      245300 :               if (s == invalid_uint)
     380           0 :                 return 0;
     381       68150 :               libmesh_assert_less(s, poly.n_subtriangles());
     382             : 
     383      245300 :               const auto subtri = poly.subtriangle(s);
     384             : 
     385             :               // Avoid signed/unsigned comparison warnings
     386      245300 :               const int nodei = i;
     387      245300 :               if (nodei == subtri[0])
     388       49060 :                 return 1-a-b;
     389      196240 :               if (nodei == subtri[1])
     390       49060 :                 return a;
     391      147180 :               if (nodei == subtri[2])
     392       49060 :                 return b;
     393             : 
     394             :               // Basis function i is not supported on p's subtriangle
     395       27260 :               return 0;
     396             :             }
     397             : 
     398           0 :           default:
     399           0 :             libmesh_error_msg("ERROR: Unsupported 2D element type: " << Utility::enum_to_string(type));
     400             :           }
     401             :       }
     402             : 
     403             : 
     404             :       // quadratic Lagrange shape functions
     405   546194120 :     case SECOND:
     406             :       {
     407   402113763 :         switch (type)
     408             :           {
     409     9605288 :           case QUAD8:
     410             :           case QUADSHELL8:
     411             :             {
     412     2770472 :               libmesh_assert_less (i, 8);
     413     9605288 :               return libMesh::detail::fe_lagrange_quad8_shape(i, p(0), p(1));
     414             :             }
     415             : 
     416   209734470 :           case QUAD4:
     417        5760 :             libmesh_assert_msg(T == L2_LAGRANGE,
     418             :                                "High order on first order elements only supported for L2 families");
     419             :             libmesh_fallthrough();
     420    99943047 :           case QUAD9:
     421             :           case QUADSHELL9:
     422             :             {
     423    99955260 :               libmesh_assert_less (i, 9);
     424   309683970 :               return libMesh::detail::fe_lagrange_quad9_shape(i, p(0), p(1));
     425             :             }
     426             : 
     427   156062694 :           case TRI3:
     428        4470 :             libmesh_assert_msg(T == L2_LAGRANGE,
     429             :                                "High order on first order elements only supported for L2 families");
     430             :             libmesh_fallthrough();
     431    70594632 :           case TRI6:
     432             :           case TRI7:
     433             :             {
     434    70846638 :               libmesh_assert_less (i, 6);
     435   226904862 :               return libMesh::detail::fe_lagrange_tri6_shape(i, p(0), p(1));
     436             :             }
     437             : 
     438           0 :           default:
     439           0 :             libmesh_error_msg("ERROR: Unsupported 2D element type: " << Utility::enum_to_string(type));
     440             :           }
     441             :       }
     442             : 
     443             : 
     444             : 
     445             :       // "cubic" (one cubic bubble) Lagrange shape functions on TRI7
     446   330358652 :     case THIRD:
     447             :       {
     448   330358652 :         switch (type)
     449             :           {
     450   330358652 :           case TRI7:
     451             :             {
     452    91318674 :               libmesh_assert_less (i, 7);
     453   330358652 :               return libMesh::detail::fe_lagrange_tri7_shape(i, p(0), p(1));
     454             :             }
     455             : 
     456           0 :           default:
     457           0 :             libmesh_error_msg("ERROR: Unsupported 2D element type: " << Utility::enum_to_string(type));
     458             :           }
     459             :       } // end case THIRD
     460             : 
     461             : 
     462             : 
     463             :       // unsupported order
     464           0 :     default:
     465           0 :       libmesh_error_msg("ERROR: Unsupported 2D FE order: " << order);
     466             :     }
     467             : #else // LIBMESH_DIM > 1
     468             :   libmesh_ignore(type, order, i, p);
     469             :   libmesh_not_implemented();
     470             : #endif
     471             : }
     472             : 
     473             : 
     474             : 
     475             : template <FEFamily T>
     476  5117885542 : Real fe_lagrange_2D_shape_deriv(const ElemType type,
     477             :                                 const Elem * elem,
     478             :                                 const Order order,
     479             :                                 const unsigned int i,
     480             :                                 const unsigned int j,
     481             :                                 const Point & p)
     482             : {
     483             : #if LIBMESH_DIM > 1
     484             : 
     485  1321178438 :   libmesh_assert_less (j, 2);
     486             : 
     487  5117885542 :   switch (order)
     488             :     {
     489             :       // linear Lagrange shape functions
     490   149802318 :     case FIRST:
     491             :       {
     492   106423922 :         switch (type)
     493             :           {
     494   103996144 :           case QUAD4:
     495             :           case QUADSHELL4:
     496             :           case QUAD8:
     497             :           case QUADSHELL8:
     498             :           case QUAD9:
     499             :           case QUADSHELL9:
     500             :             {
     501    31781712 :               libmesh_assert_less (i, 4);
     502   103996144 :               return libMesh::detail::fe_lagrange_quad4_shape_deriv(i, j, p(0), p(1));
     503             :             }
     504             : 
     505    11788980 :           case TRI3:
     506             :           case TRISHELL3:
     507             :           case TRI6:
     508             :           case TRI7:
     509             :             {
     510    11788980 :               libmesh_assert_less (i, 3);
     511    11788980 :               return libMesh::detail::fe_lagrange_tri3_shape_deriv(i, j);
     512             :             }
     513             : 
     514      434600 :           case C0POLYGON:
     515             :             {
     516             :               // C0Polygon requires using newer FE APIs
     517      434600 :               if (!elem)
     518           0 :                 libmesh_error_msg("Code (see stack trace) used an outdated FE function overload.\n"
     519             :                                   "Shape functions on a C0Polygon are not defined by its ElemType alone.");
     520             : 
     521      108760 :               libmesh_assert(elem->type() == C0POLYGON);
     522             : 
     523      108760 :               const C0Polygon & poly = *cast_ptr<const C0Polygon *>(elem);
     524             : 
     525             :               // We can't use a small tolerance here, because in
     526             :               // inverse_map() Newton might hand us intermediate
     527             :               // iterates outside the polygon.
     528      434600 :               const auto [s, a, b] = poly.subtriangle_coordinates(p, 100);
     529      434600 :               if (s == invalid_uint)
     530           0 :                 return 0;
     531      108760 :               libmesh_assert_less(s, poly.n_subtriangles());
     532             : 
     533      434600 :               const auto subtri = poly.subtriangle(s);
     534             : 
     535             :               // Find derivatives w.r.t. subtriangle barycentric
     536             :               // coordinates
     537      108760 :               Real du_da = 0, du_db = 0;
     538             : 
     539             :               // Avoid signed/unsigned comparison warnings
     540      434600 :               const int nodei = i;
     541      434600 :               if (nodei == subtri[0])
     542       21752 :                 du_da = du_db = -1;
     543      347680 :               else if (nodei == subtri[1])
     544       21752 :                 du_da = 1;
     545      260760 :               else if (nodei == subtri[2])
     546       21752 :                 du_db = 1;
     547             :               else
     548             :                 // Basis function i is not supported on p's subtriangle
     549       43504 :                 return 0;
     550             : 
     551             :               // We want to return derivatives with respect to xi and
     552             :               // eta in master space for the polygon, but what we
     553             :               // calculated above are with respect to xi and eta
     554             :               // coordinates for a master *triangle*.  We need to
     555             :               // convert from one to the other.
     556             : 
     557      260760 :               const auto master_points = poly.master_subtriangle(s);
     558             : 
     559      260760 :               const Real dxi_da = master_points[1](0) - master_points[0](0);
     560      260760 :               const Real dxi_db = master_points[2](0) - master_points[0](0);
     561      260760 :               const Real deta_da = master_points[1](1) - master_points[0](1);
     562      260760 :               const Real deta_db = master_points[2](1) - master_points[0](1);
     563      260760 :               const Real jac = dxi_da*deta_db - dxi_db*deta_da;
     564             : 
     565      260760 :               switch (j)
     566             :                 {
     567             :                   // d()/dxi
     568      130380 :                 case 0:
     569             :                   {
     570      130380 :                     const Real da_dxi = deta_db / jac;
     571      130380 :                     const Real db_dxi = -deta_da / jac;
     572      130380 :                     return du_da*da_dxi + du_db*db_dxi;
     573             :                   }
     574             :                   // d()/deta
     575      130380 :                 case 1:
     576             :                   {
     577      130380 :                     const Real da_deta = -dxi_db / jac;
     578      130380 :                     const Real db_deta = dxi_da / jac;
     579      130380 :                     return du_da*da_deta + du_db*db_deta;
     580             :                   }
     581           0 :                 default:
     582           0 :                   libmesh_error_msg("ERROR: Invalid derivative index j = " << j);
     583             :                 }
     584             :             }
     585             : 
     586           0 :           default:
     587           0 :             libmesh_error_msg("ERROR: Unsupported 2D element type: " << Utility::enum_to_string(type));
     588             :           }
     589             :       }
     590             : 
     591             : 
     592             :       // quadratic Lagrange shape functions
     593  4467918390 :     case SECOND:
     594             :       {
     595  3324771064 :         switch (type)
     596             :           {
     597    18418320 :           case QUAD8:
     598             :           case QUADSHELL8:
     599             :             {
     600     4903584 :               libmesh_assert_less (i, 8);
     601    18418320 :               return libMesh::detail::fe_lagrange_quad8_shape_deriv(i, j, p(0), p(1));
     602             :             }
     603             : 
     604   433670688 :           case QUAD4:
     605        9018 :             libmesh_assert_msg(T == L2_LAGRANGE,
     606             :                                "High order on first order elements only supported for L2 families");
     607             :             libmesh_fallthrough();
     608   161834688 :           case QUAD9:
     609             :           case QUADSHELL9:
     610             :             {
     611   161852724 :               libmesh_assert_less (i, 9);
     612   595514394 :               return libMesh::detail::fe_lagrange_quad9_shape_deriv(i, j, p(0), p(1));
     613             :             }
     614             : 
     615  2875234332 :           case TRI3:
     616        6348 :             libmesh_assert_msg(T == L2_LAGRANGE,
     617             :                                "High order on first order elements only supported for L2 families");
     618             :             libmesh_fallthrough();
     619   978651096 :           case TRI6:
     620             :           case TRI7:
     621             :             {
     622   978757692 :               libmesh_assert_less (i, 6);
     623  3853985676 :               return libMesh::detail::fe_lagrange_tri6_shape_deriv(i, j, p(0), p(1));
     624             :             }
     625             : 
     626           0 :           default:
     627           0 :             libmesh_error_msg("ERROR: Unsupported 2D element type: " << Utility::enum_to_string(type));
     628             :           }
     629             :       }
     630             : 
     631             : 
     632             : 
     633             :       // "cubic" (one cubic bubble) Lagrange shape functions on TRI7
     634   500164834 :     case THIRD:
     635             :       {
     636   500164834 :         switch (type)
     637             :           {
     638   500164834 :           case TRI7:
     639             :             {
     640   131984986 :               libmesh_assert_less (i, 7);
     641   500164834 :               return libMesh::detail::fe_lagrange_tri7_shape_deriv(i, j, p(0), p(1));
     642             :             }
     643             : 
     644           0 :           default:
     645           0 :             libmesh_error_msg("ERROR: Unsupported 2D element type: " << Utility::enum_to_string(type));
     646             :           }
     647             :       } // end case THIRD
     648             : 
     649             : 
     650             : 
     651             :       // unsupported order
     652           0 :     default:
     653           0 :       libmesh_error_msg("ERROR: Unsupported 2D FE order: " << order);
     654             :     }
     655             : #else // LIBMESH_DIM > 1
     656             :   libmesh_ignore(type, order, i, j, p);
     657             :   libmesh_not_implemented();
     658             : #endif
     659             : }
     660             : 
     661             : 
     662             : 
     663             : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
     664             : 
     665             : template <FEFamily T>
     666    87434967 : Real fe_lagrange_2D_shape_second_deriv(const ElemType type,
     667             :                                        const Elem *,
     668             :                                        const Order order,
     669             :                                        const unsigned int i,
     670             :                                        const unsigned int j,
     671             :                                        const Point & p)
     672             : {
     673             : #if LIBMESH_DIM > 1
     674             : 
     675             :   // j = 0 ==> d^2 phi / dxi^2
     676             :   // j = 1 ==> d^2 phi / dxi deta
     677             :   // j = 2 ==> d^2 phi / deta^2
     678    30999027 :   libmesh_assert_less (j, 3);
     679             : 
     680    87434967 :   switch (order)
     681             :     {
     682             :       // linear Lagrange shape functions
     683      877455 :     case FIRST:
     684             :       {
     685      877455 :         switch (type)
     686             :           {
     687      575820 :           case QUAD4:
     688             :           case QUADSHELL4:
     689             :           case QUAD8:
     690             :           case QUADSHELL8:
     691             :           case QUAD9:
     692             :           case QUADSHELL9:
     693             :             {
     694      196944 :               libmesh_assert_less (i, 4);
     695      575820 :               return libMesh::detail::fe_lagrange_quad4_shape_second_deriv(i, j, p(0), p(1));
     696             :             }
     697             : 
     698             :           // All second derivatives for linear triangles are zero.
     699      112281 :           case TRI3:
     700             :           case TRISHELL3:
     701             :           case TRI6:
     702             :           case TRI7:
     703             : 
     704             :           // All second derivatives for piecewise-linear polygons are
     705             :           // zero or dirac-type distributions, but we can't put the
     706             :           // latter in a Real, so beware when integrating...
     707             :           case C0POLYGON:
     708             :             {
     709      112281 :               return 0.;
     710             :             }
     711             : 
     712           0 :           default:
     713           0 :             libmesh_error_msg("ERROR: Unsupported 2D element type: " << Utility::enum_to_string(type));
     714             : 
     715             :           } // end switch (type)
     716             :       } // end case FIRST
     717             : 
     718             : 
     719             :       // quadratic Lagrange shape functions
     720    40068123 :     case SECOND:
     721             :       {
     722    40068123 :         switch (type)
     723             :           {
     724     3291072 :           case QUAD8:
     725             :           case QUADSHELL8:
     726             :             {
     727     1079016 :               libmesh_assert_less (j, 3);
     728     3291072 :               return libMesh::detail::fe_lagrange_quad8_shape_second_deriv(i, j, p(0), p(1));
     729             :             } // end case QUAD8
     730             : 
     731     5953662 :           case QUAD4:
     732       13527 :             libmesh_assert_msg(T == L2_LAGRANGE,
     733             :                                "High order on first order elements only supported for L2 families");
     734             :             libmesh_fallthrough();
     735     3201444 :           case QUAD9:
     736             :           case QUADSHELL9:
     737             :             {
     738     3228498 :               libmesh_assert_less (i, 9);
     739     9168633 :               return libMesh::detail::fe_lagrange_quad9_shape_second_deriv(i, j, p(0), p(1));
     740             :             } // end case QUAD9
     741             : 
     742    17848314 :           case TRI3:
     743        9522 :             libmesh_assert_msg(T == L2_LAGRANGE,
     744             :                                "High order on first order elements only supported for L2 families");
     745             :             libmesh_fallthrough();
     746     9739332 :           case TRI6:
     747             :           case TRI7:
     748             :             {
     749     9769626 :               libmesh_assert_less (j, 3);
     750    27608418 :               return libMesh::detail::fe_lagrange_tri6_shape_second_deriv(i, j);
     751             :             }  // end case TRI6+TRI7
     752             : 
     753           0 :           default:
     754           0 :             libmesh_error_msg("ERROR: Unsupported 2D element type: " << Utility::enum_to_string(type));
     755             :           }
     756             :       } // end case SECOND
     757             : 
     758             : 
     759             : 
     760             :       // "cubic" (one cubic bubble) Lagrange shape functions on TRI7
     761    46489389 :     case THIRD:
     762             :       {
     763    46489389 :         switch (type)
     764             :           {
     765    29876727 :           case TRI3:
     766           0 :             libmesh_assert_msg(T == L2_LAGRANGE,
     767             :                                "High order on first order elements only supported for L2 families");
     768             :             libmesh_fallthrough();
     769    16600923 :           case TRI6:
     770             :           case TRI7:
     771             :             {
     772    16612662 :               libmesh_assert_less (j, 3);
     773    46489389 :               return libMesh::detail::fe_lagrange_tri7_shape_second_deriv(i, j, p(0), p(1));
     774             :             }  // end case TRI6+TRI7
     775             : 
     776           0 :           default:
     777           0 :             libmesh_error_msg("ERROR: Unsupported 2D element type: " << Utility::enum_to_string(type));
     778             :           }
     779             :       } // end case THIRD
     780             : 
     781             :       // unsupported order
     782           0 :     default:
     783           0 :       libmesh_error_msg("ERROR: Unsupported 2D FE order: " << order);
     784             : 
     785             :     } // end switch (order)
     786             : 
     787             : #else // LIBMESH_DIM > 1
     788             :   libmesh_ignore(type, order, i, j, p);
     789             :   libmesh_not_implemented();
     790             : #endif
     791             : }
     792             : 
     793             : #endif // LIBMESH_ENABLE_SECOND_DERIVATIVES
     794             : 
     795             : } // anonymous namespace

Generated by: LCOV version 1.14