LCOV - code coverage report
Current view: top level - include/fe - fe_tensor_product_lagrange.h (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4573 (924896) with base 3f0912 Lines: 496 496 100.0 %
Date: 2026-11-18 21:52:26 Functions: 28 28 100.0 %
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             : #ifndef LIBMESH_FE_TENSOR_PRODUCT_LAGRANGE_H
      15             : #define LIBMESH_FE_TENSOR_PRODUCT_LAGRANGE_H
      16             : 
      17             : // Lagrange shape functions and their derivatives for the tensor-product
      18             : // topologies, in one place rather than spelled out per element order in
      19             : // fe_lagrange_shape_2D.C and fe_lagrange_shape_3D.C.
      20             : //
      21             : // They are inline and call nothing but each other and the 1D shapes,
      22             : // which is what the Kokkos work needs in order to evaluate the same
      23             : // expressions on a device.  The assertions are the exception: those are
      24             : // ours, host-only, and a device build will have to say what it wants
      25             : // done with them.
      26             : //
      27             : // The full-tensor members -- Quad4, Quad9, Hex8, Hex27 -- are products of
      28             : // the 1D shapes in fe_lagrange_shape_1D.h, one factor per reference
      29             : // coordinate, so they are written that way here.  Quad8 and Hex20 are
      30             : // not: they are the serendipity elements, whose interior and face nodes
      31             : // have been removed from the full tensor product, so their shapes are
      32             : // the usual closed forms instead of products.
      33             : 
      34             : #include "libmesh/libmesh_device.h"
      35             : #include "libmesh/fe_lagrange_shape_1D.h"
      36             : 
      37             : namespace libMesh
      38             : {
      39             : namespace detail
      40             : {
      41             : 
      42             : LIBMESH_DEVICE_INLINE
      43             : /**
      44             :  * Which 1D shape each reference direction takes for a given node: node i
      45             :  * of a tensor-product element evaluates shape i0(i) in xi times shape
      46             :  * i1(i) in eta (times i2(i) in zeta in 3D).  These maps are what let the
      47             :  * shapes below be written once per element rather than once per node.
      48             :  */
      49   134901732 : unsigned int quad4_i0(const unsigned int i)
      50             : {
      51   134901732 :   libmesh_assert_less(i, 4);
      52   306603268 :   return (i == 0 || i == 3) ? 0u : 1u;
      53             : }
      54             : 
      55             : LIBMESH_DEVICE_INLINE
      56   134901732 : unsigned int quad4_i1(const unsigned int i)
      57             : {
      58   134901732 :   libmesh_assert_less(i, 4);
      59   134901732 :   return i < 2 ? 0u : 1u;
      60             : }
      61             : 
      62             : LIBMESH_DEVICE_INLINE
      63   674462502 : unsigned int quad9_i0(const unsigned int i)
      64             : {
      65   265036482 :   libmesh_assert_less(i, 9);
      66             : 
      67   674462502 :   switch (i)
      68             :     {
      69    88345494 :     case 0:
      70             :     case 3:
      71             :     case 7:
      72    88345494 :       return 0;
      73   224820834 :     case 1:
      74             :     case 2:
      75             :     case 5:
      76   224820834 :       return 1;
      77   224820834 :     default:
      78   224820834 :       return 2;
      79             :     }
      80             : }
      81             : 
      82             : LIBMESH_DEVICE_INLINE
      83   674462502 : unsigned int quad9_i1(const unsigned int i)
      84             : {
      85   265036482 :   libmesh_assert_less(i, 9);
      86             : 
      87   674462502 :   switch (i)
      88             :     {
      89    88345494 :     case 0:
      90             :     case 1:
      91             :     case 4:
      92    88345494 :       return 0;
      93   224820834 :     case 2:
      94             :     case 3:
      95             :     case 6:
      96   224820834 :       return 1;
      97   224820834 :     default:
      98   224820834 :       return 2;
      99             :     }
     100             : }
     101             : 
     102             : LIBMESH_DEVICE_INLINE
     103   121028800 : unsigned int hex8_i0(const unsigned int i)
     104             : {
     105   121028800 :   libmesh_assert_less(i, 8);
     106   442899970 :   return (i == 0 || i == 3 || i == 4 || i == 7) ? 0u : 1u;
     107             : }
     108             : 
     109             : LIBMESH_DEVICE_INLINE
     110   121028800 : unsigned int hex8_i1(const unsigned int i)
     111             : {
     112   121028800 :   libmesh_assert_less(i, 8);
     113   466839296 :   return (i == 0 || i == 1 || i == 4 || i == 5) ? 0u : 1u;
     114             : }
     115             : 
     116             : LIBMESH_DEVICE_INLINE
     117   121028800 : unsigned int hex8_i2(const unsigned int i)
     118             : {
     119   121028800 :   libmesh_assert_less(i, 8);
     120   121028800 :   return i < 4 ? 0u : 1u;
     121             : }
     122             : 
     123             : LIBMESH_DEVICE_INLINE
     124  2629016460 : unsigned int hex27_i0(const unsigned int i)
     125             : {
     126   872265780 :   libmesh_assert_less(i, 27);
     127             : 
     128  2629016460 :   switch (i)
     129             :     {
     130   290755260 :     case 0:
     131             :     case 3:
     132             :     case 4:
     133             :     case 7:
     134             :     case 11:
     135             :     case 12:
     136             :     case 15:
     137             :     case 19:
     138             :     case 24:
     139   290755260 :       return 0;
     140   876338820 :     case 1:
     141             :     case 2:
     142             :     case 5:
     143             :     case 6:
     144             :     case 9:
     145             :     case 13:
     146             :     case 14:
     147             :     case 17:
     148             :     case 22:
     149   876338820 :       return 1;
     150   876338820 :     default:
     151   876338820 :       return 2;
     152             :     }
     153             : }
     154             : 
     155             : LIBMESH_DEVICE_INLINE
     156  2629016460 : unsigned int hex27_i1(const unsigned int i)
     157             : {
     158   872265780 :   libmesh_assert_less(i, 27);
     159             : 
     160  2629016460 :   switch (i)
     161             :     {
     162   290755260 :     case 0:
     163             :     case 1:
     164             :     case 4:
     165             :     case 5:
     166             :     case 8:
     167             :     case 12:
     168             :     case 13:
     169             :     case 16:
     170             :     case 21:
     171   290755260 :       return 0;
     172   876338820 :     case 2:
     173             :     case 3:
     174             :     case 6:
     175             :     case 7:
     176             :     case 10:
     177             :     case 14:
     178             :     case 15:
     179             :     case 18:
     180             :     case 23:
     181   876338820 :       return 1;
     182   876338820 :     default:
     183   876338820 :       return 2;
     184             :     }
     185             : }
     186             : 
     187             : LIBMESH_DEVICE_INLINE
     188  2629016460 : unsigned int hex27_i2(const unsigned int i)
     189             : {
     190   872265780 :   libmesh_assert_less(i, 27);
     191             : 
     192  2629016460 :   switch (i)
     193             :     {
     194   290755260 :     case 0:
     195             :     case 1:
     196             :     case 2:
     197             :     case 3:
     198             :     case 8:
     199             :     case 9:
     200             :     case 10:
     201             :     case 11:
     202             :     case 20:
     203   290755260 :       return 0;
     204   876338820 :     case 4:
     205             :     case 5:
     206             :     case 6:
     207             :     case 7:
     208             :     case 16:
     209             :     case 17:
     210             :     case 18:
     211             :     case 19:
     212             :     case 25:
     213   876338820 :       return 1;
     214   876338820 :     default:
     215   876338820 :       return 2;
     216             :     }
     217             : }
     218             : 
     219             : LIBMESH_DEVICE_INLINE
     220             : /**
     221             :  * Quad4 is the product of two linear 1D shapes, one per reference coordinate.
     222             :  */
     223   217175524 : Real fe_lagrange_quad4_shape(const unsigned int i,
     224             :                              const Real xi,
     225             :                              const Real eta)
     226             : {
     227   103054372 :   libmesh_assert_less(i, 4);
     228             : 
     229   103054372 :   return fe_lagrange_1D_linear_shape(quad4_i0(i), xi) *
     230   316536336 :          fe_lagrange_1D_linear_shape(quad4_i1(i), eta);
     231             : }
     232             : 
     233             : LIBMESH_DEVICE_INLINE
     234             : /**
     235             :  * Differentiating a product of two 1D shapes replaces the factor in the
     236             :  * requested direction with its 1D derivative and leaves the others.
     237             :  */
     238   103996144 : Real fe_lagrange_quad4_shape_deriv(const unsigned int i,
     239             :                                    const unsigned int j,
     240             :                                    const Real xi,
     241             :                                    const Real eta)
     242             : {
     243    31781712 :   libmesh_assert_less(i, 4);
     244    31781712 :   libmesh_assert_less(j, 2);
     245             : 
     246   103996144 :   switch (j)
     247             :     {
     248    15890856 :     case 0:
     249    15890856 :       return fe_lagrange_1D_linear_shape_deriv(quad4_i0(i), 0, xi) *
     250    51998072 :              fe_lagrange_1D_linear_shape(quad4_i1(i), eta);
     251             : 
     252    15890856 :     default:
     253    15890856 :       return fe_lagrange_1D_linear_shape(quad4_i0(i), xi) *
     254    51998072 :              fe_lagrange_1D_linear_shape_deriv(quad4_i1(i), 0, eta);
     255             :     }
     256             : }
     257             : 
     258             : LIBMESH_DEVICE_INLINE
     259             : /**
     260             :  * Quad9 is the product of two quadratic 1D shapes, one per reference coordinate.
     261             :  */
     262   309683970 : Real fe_lagrange_quad9_shape(const unsigned int i,
     263             :                              const Real xi,
     264             :                              const Real eta)
     265             : {
     266    99955260 :   libmesh_assert_less(i, 9);
     267             : 
     268   229567617 :   return fe_lagrange_1D_quadratic_shape(quad9_i0(i), xi) *
     269   309683970 :          fe_lagrange_1D_quadratic_shape(quad9_i1(i), eta);
     270             : }
     271             : 
     272             : LIBMESH_DEVICE_INLINE
     273             : /**
     274             :  * Differentiating a product of two 1D shapes replaces the factor in the
     275             :  * requested direction with its 1D derivative and leaves the others.
     276             :  */
     277   595514394 : Real fe_lagrange_quad9_shape_deriv(const unsigned int i,
     278             :                                    const unsigned int j,
     279             :                                    const Real xi,
     280             :                                    const Real eta)
     281             : {
     282   161852724 :   libmesh_assert_less(i, 9);
     283   161852724 :   libmesh_assert_less(j, 2);
     284             : 
     285   595514394 :   switch (j)
     286             :     {
     287   217863126 :     case 0:
     288   217863126 :       return fe_lagrange_1D_quadratic_shape_deriv(quad9_i0(i), 0, xi) *
     289   297757197 :              fe_lagrange_1D_quadratic_shape(quad9_i1(i), eta);
     290             : 
     291   217863126 :     default:
     292   217863126 :       return fe_lagrange_1D_quadratic_shape(quad9_i0(i), xi) *
     293   434693961 :              fe_lagrange_1D_quadratic_shape_deriv(quad9_i1(i), 0, eta);
     294             :     }
     295             : }
     296             : 
     297             : LIBMESH_DEVICE_INLINE
     298             : /**
     299             :  * Hex8 is the product of three linear 1D shapes, one per reference coordinate.
     300             :  */
     301   132483152 : Real fe_lagrange_hex8_shape(const unsigned int i,
     302             :                             const Real xi,
     303             :                             const Real eta,
     304             :                             const Real zeta)
     305             : {
     306    36725848 :   libmesh_assert_less(i, 8);
     307             : 
     308   132483152 :   return fe_lagrange_1D_linear_shape(hex8_i0(i), xi) *
     309    36725848 :          fe_lagrange_1D_linear_shape(hex8_i1(i), eta) *
     310   132483152 :          fe_lagrange_1D_linear_shape(hex8_i2(i), zeta);
     311             : }
     312             : 
     313             : LIBMESH_DEVICE_INLINE
     314             : /**
     315             :  * Differentiating a product of three 1D shapes replaces the factor in the
     316             :  * requested direction with its 1D derivative and leaves the others.
     317             :  */
     318   309968256 : Real fe_lagrange_hex8_shape_deriv(const unsigned int i,
     319             :                                   const unsigned int j,
     320             :                                   const Real xi,
     321             :                                   const Real eta,
     322             :                                   const Real zeta)
     323             : {
     324    78204384 :   libmesh_assert_less(i, 8);
     325    78204384 :   libmesh_assert_less(j, 3);
     326             : 
     327   309968256 :   switch (j)
     328             :     {
     329    26068128 :     case 0:
     330   103322752 :       return fe_lagrange_1D_linear_shape_deriv(hex8_i0(i), 0, xi) *
     331    26068128 :              fe_lagrange_1D_linear_shape(hex8_i1(i), eta) *
     332   103322752 :              fe_lagrange_1D_linear_shape(hex8_i2(i), zeta);
     333             : 
     334    26068128 :     case 1:
     335   103322752 :       return fe_lagrange_1D_linear_shape(hex8_i0(i), xi) *
     336    26068128 :              fe_lagrange_1D_linear_shape_deriv(hex8_i1(i), 0, eta) *
     337   103322752 :              fe_lagrange_1D_linear_shape(hex8_i2(i), zeta);
     338             : 
     339    26068128 :     default:
     340   103322752 :       return fe_lagrange_1D_linear_shape(hex8_i0(i), xi) *
     341    26068128 :              fe_lagrange_1D_linear_shape(hex8_i1(i), eta) *
     342   103322752 :              fe_lagrange_1D_linear_shape_deriv(hex8_i2(i), 0, zeta);
     343             :     }
     344             : }
     345             : 
     346             : LIBMESH_DEVICE_INLINE
     347             : /**
     348             :  * Hex27 is the product of three quadratic 1D shapes, one per reference coordinate.
     349             :  */
     350   214330725 : Real fe_lagrange_hex27_shape(const unsigned int i,
     351             :                              const Real xi,
     352             :                              const Real eta,
     353             :                              const Real zeta)
     354             : {
     355    58193019 :   libmesh_assert_less(i, 27);
     356             : 
     357   214330725 :   return fe_lagrange_1D_quadratic_shape(hex27_i0(i), xi) *
     358   162307260 :          fe_lagrange_1D_quadratic_shape(hex27_i1(i), eta) *
     359   214330725 :          fe_lagrange_1D_quadratic_shape(hex27_i2(i), zeta);
     360             : }
     361             : 
     362             : LIBMESH_DEVICE_INLINE
     363             : /**
     364             :  * Differentiating a product of three 1D shapes replaces the factor in the
     365             :  * requested direction with its 1D derivative and leaves the others.
     366             :  */
     367  3025669302 : Real fe_lagrange_hex27_shape_deriv(const unsigned int i,
     368             :                                    const unsigned int j,
     369             :                                    const Real xi,
     370             :                                    const Real eta,
     371             :                                    const Real zeta)
     372             : {
     373   755054865 :   libmesh_assert_less(i, 27);
     374   755054865 :   libmesh_assert_less(j, 3);
     375             : 
     376  3025669302 :   switch (j)
     377             :     {
     378   757088370 :     case 0:
     379  1008556434 :       return fe_lagrange_1D_quadratic_shape_deriv(hex27_i0(i), 0, xi) *
     380   757088370 :              fe_lagrange_1D_quadratic_shape(hex27_i1(i), eta) *
     381  1008556434 :              fe_lagrange_1D_quadratic_shape(hex27_i2(i), zeta);
     382             : 
     383   757088370 :     case 1:
     384  1513959849 :       return fe_lagrange_1D_quadratic_shape(hex27_i0(i), xi) *
     385   757088370 :              fe_lagrange_1D_quadratic_shape_deriv(hex27_i1(i), 0, eta) *
     386  1008556434 :              fe_lagrange_1D_quadratic_shape(hex27_i2(i), zeta);
     387             : 
     388   757088370 :     default:
     389  1008556434 :       return fe_lagrange_1D_quadratic_shape(hex27_i0(i), xi) *
     390   757088370 :              fe_lagrange_1D_quadratic_shape(hex27_i1(i), eta) *
     391  1513959849 :              fe_lagrange_1D_quadratic_shape_deriv(hex27_i2(i), 0, zeta);
     392             :     }
     393             : }
     394             : 
     395             : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
     396             : 
     397             : LIBMESH_DEVICE_INLINE
     398             : /**
     399             :  * Likewise for the second derivatives: a repeated direction takes the
     400             :  * 1D second derivative, and a mixed pair takes two 1D first
     401             :  * derivatives.
     402             :  */
     403      575820 : Real fe_lagrange_quad4_shape_second_deriv(const unsigned int i,
     404             :                                           const unsigned int j,
     405             :                                           const Real xi,
     406             :                                           const Real eta)
     407             : {
     408      196944 :   libmesh_assert_less(i, 4);
     409      196944 :   libmesh_assert_less(j, 3);
     410             : 
     411      575820 :   switch (j)
     412             :     {
     413      131296 :     case 0:
     414             :     case 2:
     415      131296 :       return 0.;
     416             : 
     417       65648 :     default:
     418       65648 :       return fe_lagrange_1D_linear_shape_deriv(quad4_i0(i), 0, xi) *
     419      191940 :              fe_lagrange_1D_linear_shape_deriv(quad4_i1(i), 0, eta);
     420             :     }
     421             : }
     422             : 
     423             : LIBMESH_DEVICE_INLINE
     424             : /**
     425             :  * Likewise for the second derivatives: a repeated direction takes the
     426             :  * 1D second derivative, and a mixed pair takes two 1D first
     427             :  * derivatives.
     428             :  */
     429    12397131 : Real fe_lagrange_quad9_shape_second_deriv(const unsigned int i,
     430             :                                           const unsigned int j,
     431             :                                           const Real xi,
     432             :                                           const Real eta)
     433             : {
     434     3228498 :   libmesh_assert_less(i, 9);
     435     3228498 :   libmesh_assert_less(j, 3);
     436             : 
     437    12397131 :   switch (j)
     438             :     {
     439     3056211 :     case 0:
     440     3056211 :       return fe_lagrange_1D_quadratic_shape_second_deriv(quad9_i0(i), 0, xi) *
     441     4132377 :              fe_lagrange_1D_quadratic_shape(quad9_i1(i), eta);
     442             : 
     443     3056211 :     case 1:
     444     3056211 :       return fe_lagrange_1D_quadratic_shape_deriv(quad9_i0(i), 0, xi) *
     445     6112422 :              fe_lagrange_1D_quadratic_shape_deriv(quad9_i1(i), 0, eta);
     446             : 
     447     3056211 :     default:
     448     3056211 :       return fe_lagrange_1D_quadratic_shape(quad9_i0(i), xi) *
     449     4792392 :              fe_lagrange_1D_quadratic_shape_second_deriv(quad9_i1(i), 0, eta);
     450             :     }
     451             : }
     452             : 
     453             : LIBMESH_DEVICE_INLINE
     454             : /**
     455             :  * Likewise for the second derivatives: a repeated direction takes the
     456             :  * 1D second derivative, and a mixed pair takes two 1D first
     457             :  * derivatives.
     458             :  */
     459    48775776 : Real fe_lagrange_hex8_shape_second_deriv(const unsigned int i,
     460             :                                          const unsigned int j,
     461             :                                          const Real xi,
     462             :                                          const Real eta,
     463             :                                          const Real zeta)
     464             : {
     465    12197136 :   libmesh_assert_less(i, 8);
     466    12197136 :   libmesh_assert_less(j, 6);
     467             : 
     468    48775776 :   switch (j)
     469             :     {
     470     6098568 :     case 0:
     471             :     case 2:
     472             :     case 5:
     473     6098568 :       return 0.;
     474             : 
     475     2032856 :     case 1:
     476     8129296 :       return fe_lagrange_1D_linear_shape_deriv(hex8_i0(i), 0, xi) *
     477     2032856 :              fe_lagrange_1D_linear_shape_deriv(hex8_i1(i), 0, eta) *
     478     8129296 :              fe_lagrange_1D_linear_shape(hex8_i2(i), zeta);
     479             : 
     480     2032856 :     case 3:
     481     8129296 :       return fe_lagrange_1D_linear_shape_deriv(hex8_i0(i), 0, xi) *
     482     2032856 :              fe_lagrange_1D_linear_shape(hex8_i1(i), eta) *
     483     8129296 :              fe_lagrange_1D_linear_shape_deriv(hex8_i2(i), 0, zeta);
     484             : 
     485     2032856 :     default:
     486     8129296 :       return fe_lagrange_1D_linear_shape(hex8_i0(i), xi) *
     487     2032856 :              fe_lagrange_1D_linear_shape_deriv(hex8_i1(i), 0, eta) *
     488     8129296 :              fe_lagrange_1D_linear_shape_deriv(hex8_i2(i), 0, zeta);
     489             :     }
     490             : }
     491             : 
     492             : LIBMESH_DEVICE_INLINE
     493             : /**
     494             :  * Likewise for the second derivatives: a repeated direction takes the
     495             :  * 1D second derivative, and a mixed pair takes two 1D first
     496             :  * derivatives.
     497             :  */
     498   254461986 : Real fe_lagrange_hex27_shape_second_deriv(const unsigned int i,
     499             :                                           const unsigned int j,
     500             :                                           const Real xi,
     501             :                                           const Real eta,
     502             :                                           const Real zeta)
     503             : {
     504    59017896 :   libmesh_assert_less(i, 27);
     505    59017896 :   libmesh_assert_less(j, 6);
     506             : 
     507   254461986 :   switch (j)
     508             :     {
     509    32574015 :     case 0:
     510    42410331 :       return fe_lagrange_1D_quadratic_shape_second_deriv(hex27_i0(i), 0, xi) *
     511    32574015 :              fe_lagrange_1D_quadratic_shape(hex27_i1(i), eta) *
     512    42410331 :              fe_lagrange_1D_quadratic_shape(hex27_i2(i), zeta);
     513             : 
     514    32574015 :     case 1:
     515    42410331 :       return fe_lagrange_1D_quadratic_shape_deriv(hex27_i0(i), 0, xi) *
     516    32574015 :              fe_lagrange_1D_quadratic_shape_deriv(hex27_i1(i), 0, eta) *
     517    42410331 :              fe_lagrange_1D_quadratic_shape(hex27_i2(i), zeta);
     518             : 
     519    32574015 :     case 2:
     520    65148030 :       return fe_lagrange_1D_quadratic_shape(hex27_i0(i), xi) *
     521    32574015 :              fe_lagrange_1D_quadratic_shape_second_deriv(hex27_i1(i), 0, eta) *
     522    42410331 :              fe_lagrange_1D_quadratic_shape(hex27_i2(i), zeta);
     523             : 
     524    32574015 :     case 3:
     525    42410331 :       return fe_lagrange_1D_quadratic_shape_deriv(hex27_i0(i), 0, xi) *
     526    32574015 :              fe_lagrange_1D_quadratic_shape(hex27_i1(i), eta) *
     527    65148030 :              fe_lagrange_1D_quadratic_shape_deriv(hex27_i2(i), 0, zeta);
     528             : 
     529    32574015 :     case 4:
     530    65148030 :       return fe_lagrange_1D_quadratic_shape(hex27_i0(i), xi) *
     531    32574015 :              fe_lagrange_1D_quadratic_shape_deriv(hex27_i1(i), 0, eta) *
     532    65148030 :              fe_lagrange_1D_quadratic_shape_deriv(hex27_i2(i), 0, zeta);
     533             : 
     534    32574015 :     default:
     535    42410331 :       return fe_lagrange_1D_quadratic_shape(hex27_i0(i), xi) *
     536    32574015 :              fe_lagrange_1D_quadratic_shape(hex27_i1(i), eta) *
     537    49989564 :              fe_lagrange_1D_quadratic_shape_second_deriv(hex27_i2(i), 0, zeta);
     538             :     }
     539             : }
     540             : 
     541             : #endif // LIBMESH_ENABLE_SECOND_DERIVATIVES
     542             : 
     543             : 
     544             : // The reduced-node ("serendipity") members of the tensor-product
     545             : // topologies: QUAD8 and HEX20 drop the interior/face nodes, so their
     546             : // bases are not products of 1D factors, but they live on the same
     547             : // reference domains and dispatch through the same element classes.
     548             : 
     549             : LIBMESH_DEVICE_INLINE
     550             : /**
     551             :  * Quad8 is serendipity rather than a tensor product: the Quad9 interior
     552             :  * node is gone, so a vertex shape is 0.25*(1 -+ xi)*(1 -+ eta)*(-1 +- xi
     553             :  * +- eta) and a mid-edge shape is 0.5*(1 - xi^2)*(1 -+ eta) or its
     554             :  * transpose.
     555             :  */
     556     9605288 : Real fe_lagrange_quad8_shape(const unsigned int i,
     557             :                              const Real xi,
     558             :                              const Real eta)
     559             : {
     560     2770472 :   libmesh_assert_less(i, 8);
     561             : 
     562     9605288 :   switch (i)
     563             :     {
     564     1200661 :     case 0: return 0.25 * (1.0 - xi) * (1.0 - eta) * (-1.0 - xi - eta);
     565     1200661 :     case 1: return 0.25 * (1.0 + xi) * (1.0 - eta) * (-1.0 + xi - eta);
     566     1200661 :     case 2: return 0.25 * (1.0 + xi) * (1.0 + eta) * (-1.0 + xi + eta);
     567     1200661 :     case 3: return 0.25 * (1.0 - xi) * (1.0 + eta) * (-1.0 - xi + eta);
     568     1200661 :     case 4: return 0.5  * (1.0 - xi * xi) * (1.0 - eta);
     569     1200661 :     case 5: return 0.5  * (1.0 + xi) * (1.0 - eta * eta);
     570     1200661 :     case 6: return 0.5  * (1.0 - xi * xi) * (1.0 + eta);
     571     1200661 :     default: return 0.5 * (1.0 - xi) * (1.0 - eta * eta);
     572             :     }
     573             : }
     574             : 
     575             : LIBMESH_DEVICE_INLINE
     576             : /**
     577             :  * Differentiated in place: the serendipity forms are not products, so each derivative is written out.
     578             :  */
     579    18418320 : Real fe_lagrange_quad8_shape_deriv(const unsigned int i,
     580             :                                    const unsigned int j,
     581             :                                    const Real xi,
     582             :                                    const Real eta)
     583             : {
     584     4903584 :   libmesh_assert_less(i, 8);
     585     4903584 :   libmesh_assert_less(j, 2);
     586             : 
     587    18418320 :   switch (j)
     588             :     {
     589             :       // d/dxi
     590     9209160 :     case 0:
     591     9209160 :       switch (i)
     592             :         {
     593     1764077 :         case 0: return .25*(1. - eta)*((1. - xi)*(-1.) +
     594     1151145 :                                        (-1.)*(-1. - xi - eta));
     595     1764077 :         case 1: return .25*(1. - eta)*((1. + xi)*(1.) +
     596     1151145 :                                        (1.)*(-1. + xi - eta));
     597     1764077 :         case 2: return .25*(1. + eta)*((1. + xi)*(1.) +
     598     1151145 :                                        (1.)*(-1. + xi + eta));
     599     1764077 :         case 3: return .25*(1. + eta)*((1. - xi)*(-1.) +
     600     1151145 :                                        (-1.)*(-1. - xi + eta));
     601     1151145 :         case 4: return .5*(-2.*xi)*(1. - eta);
     602     1151145 :         case 5: return .5*(1.)*(1. - eta*eta);
     603     1151145 :         case 6: return .5*(-2.*xi)*(1. + eta);
     604     1151145 :         default: return .5*(-1.)*(1. - eta*eta);
     605             :         }
     606             : 
     607             :       // d/deta
     608     9209160 :     default:
     609     9209160 :       switch (i)
     610             :         {
     611     1764077 :         case 0: return .25*(1. - xi)*((1. - eta)*(-1.) +
     612     1151145 :                                       (-1.)*(-1. - xi - eta));
     613     1764077 :         case 1: return .25*(1. + xi)*((1. - eta)*(-1.) +
     614     1151145 :                                       (-1.)*(-1. + xi - eta));
     615     1764077 :         case 2: return .25*(1. + xi)*((1. + eta)*(1.) +
     616     1151145 :                                       (1.)*(-1. + xi + eta));
     617     1764077 :         case 3: return .25*(1. - xi)*((1. + eta)*(1.) +
     618     1151145 :                                       (1.)*(-1. - xi + eta));
     619     1151145 :         case 4: return .5*(1. - xi*xi)*(-1.);
     620     1151145 :         case 5: return .5*(1. + xi)*(-2.*eta);
     621     1151145 :         case 6: return .5*(1. - xi*xi)*(1.);
     622     1151145 :         default: return .5*(1. - xi)*(-2.*eta);
     623             :         }
     624             :     }
     625             : }
     626             : 
     627             : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
     628             : LIBMESH_DEVICE_INLINE
     629             : /**
     630             :  * Second derivatives of the serendipity forms, likewise written out.
     631             :  */
     632     4370088 : Real fe_lagrange_quad8_shape_second_deriv(const unsigned int i,
     633             :                                           const unsigned int j,
     634             :                                           const Real xi,
     635             :                                           const Real eta)
     636             : {
     637     1079016 :   libmesh_assert_less(i, 8);
     638     1079016 :   libmesh_assert_less(j, 3);
     639             : 
     640     4370088 :   switch (j)
     641             :     {
     642     1456696 :     case 0:
     643     1456696 :       switch (i)
     644             :         {
     645      364174 :         case 0:
     646             :         case 1:
     647      364174 :           return 0.5 * (1.0 - eta);
     648      364174 :         case 2:
     649             :         case 3:
     650      364174 :           return 0.5 * (1.0 + eta);
     651      182087 :         case 4:
     652      182087 :           return eta - 1.0;
     653      182087 :         case 6:
     654      182087 :           return -1.0 - eta;
     655       89918 :         default:
     656       89918 :           return 0.0;
     657             :         }
     658             : 
     659     1456696 :     case 1:
     660     1456696 :       switch (i)
     661             :         {
     662      182087 :         case 0: return 0.25 * (1.0 - 2.0 * xi - 2.0 * eta);
     663      182087 :         case 1: return 0.25 * (-1.0 - 2.0 * xi + 2.0 * eta);
     664      182087 :         case 2: return 0.25 * (1.0 + 2.0 * xi + 2.0 * eta);
     665      182087 :         case 3: return 0.25 * (-1.0 + 2.0 * xi - 2.0 * eta);
     666       44959 :         case 4: return xi;
     667      182087 :         case 5: return -eta;
     668      182087 :         case 6: return -xi;
     669      182087 :         default: return eta;
     670             :         }
     671             : 
     672     1456696 :     default:
     673     1456696 :       switch (i)
     674             :         {
     675      364174 :         case 0:
     676             :         case 3:
     677      364174 :           return 0.5 * (1.0 - xi);
     678      364174 :         case 1:
     679             :         case 2:
     680      364174 :           return 0.5 * (1.0 + xi);
     681      182087 :         case 5:
     682      182087 :           return -1.0 - xi;
     683      182087 :         case 7:
     684      182087 :           return xi - 1.0;
     685       89918 :         default:
     686       89918 :           return 0.0;
     687             :         }
     688             :     }
     689             : }
     690             : #endif
     691             : 
     692             : LIBMESH_DEVICE_INLINE
     693             : /**
     694             :  * Hex20 is serendipity, the Hex27 tensor product without its face and
     695             :  * interior nodes.  The shapes are written in the unit-cube coordinates
     696             :  * x, y, z = (reference + 1)/2, which is the form in which the vertex and
     697             :  * mid-edge expressions are usually tabulated.
     698             :  */
     699    22257160 : Real fe_lagrange_hex20_shape(const unsigned int i,
     700             :                              const Real xi,
     701             :                              const Real eta,
     702             :                              const Real zeta)
     703             : {
     704     6207020 :   libmesh_assert_less(i, 20);
     705             : 
     706    22257160 :   const Real x = 0.5 * (xi + 1.0);
     707    22257160 :   const Real y = 0.5 * (eta + 1.0);
     708    22257160 :   const Real z = 0.5 * (zeta + 1.0);
     709             : 
     710    22257160 :   switch (i)
     711             :     {
     712     1112858 :     case 0: return (1.0 - x) * (1.0 - y) * (1.0 - z) * (1.0 - 2.0 * x - 2.0 * y - 2.0 * z);
     713     1112858 :     case 1: return x * (1.0 - y) * (1.0 - z) * (2.0 * x - 2.0 * y - 2.0 * z - 1.0);
     714     1112858 :     case 2: return x * y * (1.0 - z) * (2.0 * x + 2.0 * y - 2.0 * z - 3.0);
     715     1112858 :     case 3: return (1.0 - x) * y * (1.0 - z) * (2.0 * y - 2.0 * x - 2.0 * z - 1.0);
     716     1112858 :     case 4: return (1.0 - x) * (1.0 - y) * z * (2.0 * z - 2.0 * x - 2.0 * y - 1.0);
     717     1112858 :     case 5: return x * (1.0 - y) * z * (2.0 * x - 2.0 * y + 2.0 * z - 3.0);
     718     1112858 :     case 6: return x * y * z * (2.0 * x + 2.0 * y + 2.0 * z - 5.0);
     719     1112858 :     case 7: return (1.0 - x) * y * z * (2.0 * y - 2.0 * x + 2.0 * z - 3.0);
     720     1112858 :     case 8: return 4.0 * x * (1.0 - x) * (1.0 - y) * (1.0 - z);
     721     1112858 :     case 9: return 4.0 * x * y * (1.0 - y) * (1.0 - z);
     722     1112858 :     case 10: return 4.0 * x * (1.0 - x) * y * (1.0 - z);
     723     1112858 :     case 11: return 4.0 * (1.0 - x) * y * (1.0 - y) * (1.0 - z);
     724     1112858 :     case 12: return 4.0 * (1.0 - x) * (1.0 - y) * z * (1.0 - z);
     725     1112858 :     case 13: return 4.0 * x * (1.0 - y) * z * (1.0 - z);
     726     1112858 :     case 14: return 4.0 * x * y * z * (1.0 - z);
     727     1112858 :     case 15: return 4.0 * (1.0 - x) * y * z * (1.0 - z);
     728     1112858 :     case 16: return 4.0 * x * (1.0 - x) * (1.0 - y) * z;
     729     1112858 :     case 17: return 4.0 * x * y * (1.0 - y) * z;
     730     1112858 :     case 18: return 4.0 * x * (1.0 - x) * y * z;
     731     1112858 :     default: return 4.0 * (1.0 - x) * y * (1.0 - y) * z;
     732             :     }
     733             : }
     734             : 
     735             : LIBMESH_DEVICE_INLINE
     736             : /**
     737             :  * Differentiated in place: the serendipity forms are not products, so each derivative is written out.
     738             :  */
     739    72681660 : Real fe_lagrange_hex20_shape_deriv(const unsigned int i,
     740             :                                    const unsigned int j,
     741             :                                    const Real xi,
     742             :                                    const Real eta,
     743             :                                    const Real zeta)
     744             : {
     745    18295380 :   libmesh_assert_less(i, 20);
     746    18295380 :   libmesh_assert_less(j, 3);
     747             : 
     748    72681660 :   const Real x = 0.5 * (xi + 1.0);
     749    72681660 :   const Real y = 0.5 * (eta + 1.0);
     750    72681660 :   const Real z = 0.5 * (zeta + 1.0);
     751             : 
     752    72681660 :   switch (j)
     753             :     {
     754    24227220 :     case 0:
     755    24227220 :       switch (i)
     756             :         {
     757     1211361 :         case 0: return 0.5 * (1.0 - y) * (1.0 - z) * ((1.0 - x) * (-2.0) + (-1.0) * (1.0 - 2.0 * x - 2.0 * y - 2.0 * z));
     758     1211361 :         case 1: return 0.5 * (1.0 - y) * (1.0 - z) * (x * 2.0 + (2.0 * x - 2.0 * y - 2.0 * z - 1.0));
     759     1211361 :         case 2: return 0.5 * y * (1.0 - z) * (x * 2.0 + (2.0 * x + 2.0 * y - 2.0 * z - 3.0));
     760     1211361 :         case 3: return 0.5 * y * (1.0 - z) * ((1.0 - x) * (-2.0) + (-1.0) * (2.0 * y - 2.0 * x - 2.0 * z - 1.0));
     761     1211361 :         case 4: return 0.5 * (1.0 - y) * z * ((1.0 - x) * (-2.0) + (-1.0) * (2.0 * z - 2.0 * x - 2.0 * y - 1.0));
     762     1211361 :         case 5: return 0.5 * (1.0 - y) * z * (x * 2.0 + (2.0 * x - 2.0 * y + 2.0 * z - 3.0));
     763     1211361 :         case 6: return 0.5 * y * z * (x * 2.0 + (2.0 * x + 2.0 * y + 2.0 * z - 5.0));
     764     1211361 :         case 7: return 0.5 * y * z * ((1.0 - x) * (-2.0) + (-1.0) * (2.0 * y - 2.0 * x + 2.0 * z - 3.0));
     765     1211361 :         case 8: return 2.0 * (1.0 - y) * (1.0 - z) * (1.0 - 2.0 * x);
     766     1211361 :         case 9: return 2.0 * y * (1.0 - y) * (1.0 - z);
     767     1211361 :         case 10: return 2.0 * y * (1.0 - z) * (1.0 - 2.0 * x);
     768     1211361 :         case 11: return -2.0 * y * (1.0 - y) * (1.0 - z);
     769     1211361 :         case 12: return -2.0 * (1.0 - y) * z * (1.0 - z);
     770     1211361 :         case 13: return 2.0 * (1.0 - y) * z * (1.0 - z);
     771     1211361 :         case 14: return 2.0 * y * z * (1.0 - z);
     772     1211361 :         case 15: return -2.0 * y * z * (1.0 - z);
     773     1211361 :         case 16: return 2.0 * (1.0 - y) * z * (1.0 - 2.0 * x);
     774     1211361 :         case 17: return 2.0 * y * (1.0 - y) * z;
     775     1211361 :         case 18: return 2.0 * y * z * (1.0 - 2.0 * x);
     776     1211361 :         default: return -2.0 * y * (1.0 - y) * z;
     777             :         }
     778             : 
     779    24227220 :     case 1:
     780    24227220 :       switch (i)
     781             :         {
     782     1211361 :         case 0: return 0.5 * (1.0 - x) * (1.0 - z) * ((1.0 - y) * (-2.0) + (-1.0) * (1.0 - 2.0 * x - 2.0 * y - 2.0 * z));
     783     1211361 :         case 1: return 0.5 * x * (1.0 - z) * ((1.0 - y) * (-2.0) + (-1.0) * (2.0 * x - 2.0 * y - 2.0 * z - 1.0));
     784     1211361 :         case 2: return 0.5 * x * (1.0 - z) * (y * 2.0 + (2.0 * x + 2.0 * y - 2.0 * z - 3.0));
     785     1211361 :         case 3: return 0.5 * (1.0 - x) * (1.0 - z) * (y * 2.0 + (2.0 * y - 2.0 * x - 2.0 * z - 1.0));
     786     1211361 :         case 4: return 0.5 * (1.0 - x) * z * ((1.0 - y) * (-2.0) + (-1.0) * (2.0 * z - 2.0 * x - 2.0 * y - 1.0));
     787     1211361 :         case 5: return 0.5 * x * z * ((1.0 - y) * (-2.0) + (-1.0) * (2.0 * x - 2.0 * y + 2.0 * z - 3.0));
     788     1211361 :         case 6: return 0.5 * x * z * (y * 2.0 + (2.0 * x + 2.0 * y + 2.0 * z - 5.0));
     789     1211361 :         case 7: return 0.5 * (1.0 - x) * z * (y * 2.0 + (2.0 * y - 2.0 * x + 2.0 * z - 3.0));
     790     1211361 :         case 8: return -2.0 * x * (1.0 - x) * (1.0 - z);
     791     1211361 :         case 9: return 2.0 * x * (1.0 - z) * (1.0 - 2.0 * y);
     792     1211361 :         case 10: return 2.0 * x * (1.0 - x) * (1.0 - z);
     793     1211361 :         case 11: return 2.0 * (1.0 - x) * (1.0 - z) * (1.0 - 2.0 * y);
     794     1211361 :         case 12: return -2.0 * (1.0 - x) * z * (1.0 - z);
     795     1211361 :         case 13: return -2.0 * x * z * (1.0 - z);
     796     1211361 :         case 14: return 2.0 * x * z * (1.0 - z);
     797     1211361 :         case 15: return 2.0 * (1.0 - x) * z * (1.0 - z);
     798     1211361 :         case 16: return -2.0 * x * (1.0 - x) * z;
     799     1211361 :         case 17: return 2.0 * x * z * (1.0 - 2.0 * y);
     800     1211361 :         case 18: return 2.0 * x * (1.0 - x) * z;
     801     1211361 :         default: return 2.0 * (1.0 - x) * z * (1.0 - 2.0 * y);
     802             :         }
     803             : 
     804    24227220 :     default:
     805    24227220 :       switch (i)
     806             :         {
     807     1211361 :         case 0: return 0.5 * (1.0 - x) * (1.0 - y) * ((1.0 - z) * (-2.0) + (-1.0) * (1.0 - 2.0 * x - 2.0 * y - 2.0 * z));
     808     1211361 :         case 1: return 0.5 * x * (1.0 - y) * ((1.0 - z) * (-2.0) + (-1.0) * (2.0 * x - 2.0 * y - 2.0 * z - 1.0));
     809     1211361 :         case 2: return 0.5 * x * y * ((1.0 - z) * (-2.0) + (-1.0) * (2.0 * x + 2.0 * y - 2.0 * z - 3.0));
     810     1211361 :         case 3: return 0.5 * (1.0 - x) * y * ((1.0 - z) * (-2.0) + (-1.0) * (2.0 * y - 2.0 * x - 2.0 * z - 1.0));
     811     1211361 :         case 4: return 0.5 * (1.0 - x) * (1.0 - y) * (z * 2.0 + (2.0 * z - 2.0 * x - 2.0 * y - 1.0));
     812     1211361 :         case 5: return 0.5 * x * (1.0 - y) * (z * 2.0 + (2.0 * x - 2.0 * y + 2.0 * z - 3.0));
     813     1211361 :         case 6: return 0.5 * x * y * (z * 2.0 + (2.0 * x + 2.0 * y + 2.0 * z - 5.0));
     814     1211361 :         case 7: return 0.5 * (1.0 - x) * y * (z * 2.0 + (2.0 * y - 2.0 * x + 2.0 * z - 3.0));
     815     1211361 :         case 8: return -2.0 * x * (1.0 - x) * (1.0 - y);
     816     1211361 :         case 9: return -2.0 * x * y * (1.0 - y);
     817     1211361 :         case 10: return -2.0 * x * (1.0 - x) * y;
     818     1211361 :         case 11: return -2.0 * (1.0 - x) * y * (1.0 - y);
     819     1211361 :         case 12: return 2.0 * (1.0 - x) * (1.0 - y) * (1.0 - 2.0 * z);
     820     1211361 :         case 13: return 2.0 * x * (1.0 - y) * (1.0 - 2.0 * z);
     821     1211361 :         case 14: return 2.0 * x * y * (1.0 - 2.0 * z);
     822     1211361 :         case 15: return 2.0 * (1.0 - x) * y * (1.0 - 2.0 * z);
     823     1211361 :         case 16: return 2.0 * x * (1.0 - x) * (1.0 - y);
     824     1211361 :         case 17: return 2.0 * x * y * (1.0 - y);
     825     1211361 :         case 18: return 2.0 * x * (1.0 - x) * y;
     826     1211361 :         default: return 2.0 * (1.0 - x) * y * (1.0 - y);
     827             :         }
     828             :     }
     829             : }
     830             : 
     831             : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
     832             : LIBMESH_DEVICE_INLINE
     833             : /**
     834             :  * Second derivatives of the serendipity forms, likewise written out.
     835             :  */
     836    24134400 : Real fe_lagrange_hex20_shape_second_deriv(const unsigned int i,
     837             :                                           const unsigned int j,
     838             :                                           const Real xi,
     839             :                                           const Real eta,
     840             :                                           const Real zeta)
     841             : {
     842     6033600 :   libmesh_assert_less(i, 20);
     843     6033600 :   libmesh_assert_less(j, 6);
     844             : 
     845    24134400 :   const Real x = 0.5 * (xi + 1.0);
     846    24134400 :   const Real y = 0.5 * (eta + 1.0);
     847    24134400 :   const Real z = 0.5 * (zeta + 1.0);
     848             : 
     849    24134400 :   switch (j)
     850             :     {
     851     4022400 :     case 0:
     852     4022400 :       switch (i)
     853             :         {
     854      402240 :         case 0:
     855      402240 :         case 1: return (1.0 - y) * (1.0 - z);
     856      402240 :         case 2:
     857      402240 :         case 3: return y * (1.0 - z);
     858      402240 :         case 4:
     859      402240 :         case 5: return (1.0 - y) * z;
     860      402240 :         case 6:
     861      402240 :         case 7: return y * z;
     862      201120 :         case 8: return -2.0 * (1.0 - y) * (1.0 - z);
     863      201120 :         case 10: return -2.0 * y * (1.0 - z);
     864      201120 :         case 16: return -2.0 * (1.0 - y) * z;
     865      201120 :         case 18: return -2.0 * y * z;
     866      402240 :         default: return 0.0;
     867             :         }
     868             : 
     869     4022400 :     case 1:
     870     4022400 :       switch (i)
     871             :         {
     872      201120 :         case 0: return (1.25 - x - y - 0.5 * z) * (1.0 - z);
     873      201120 :         case 1: return (-x + y + 0.5 * z - 0.25) * (1.0 - z);
     874      201120 :         case 2: return (x + y - 0.5 * z - 0.75) * (1.0 - z);
     875      201120 :         case 3: return (-y + x + 0.5 * z - 0.25) * (1.0 - z);
     876      201120 :         case 4: return -0.25 * z * (4.0 * x + 4.0 * y - 2.0 * z - 3.0);
     877      201120 :         case 5: return -0.25 * z * (-4.0 * y + 4.0 * x + 2.0 * z - 1.0);
     878      201120 :         case 6: return 0.25 * z * (-5.0 + 4.0 * x + 4.0 * y + 2.0 * z);
     879      201120 :         case 7: return 0.25 * z * (4.0 * x - 4.0 * y - 2.0 * z + 1.0);
     880      201120 :         case 8: return (-1.0 + 2.0 * x) * (1.0 - z);
     881      201120 :         case 9: return (1.0 - 2.0 * y) * (1.0 - z);
     882      201120 :         case 10: return (1.0 - 2.0 * x) * (1.0 - z);
     883      201120 :         case 11: return (-1.0 + 2.0 * y) * (1.0 - z);
     884      201120 :         case 12: return z * (1.0 - z);
     885      201120 :         case 13: return -z * (1.0 - z);
     886      201120 :         case 14: return z * (1.0 - z);
     887      201120 :         case 15: return -z * (1.0 - z);
     888      201120 :         case 16: return (-1.0 + 2.0 * x) * z;
     889      201120 :         case 17: return (1.0 - 2.0 * y) * z;
     890      201120 :         case 18: return (1.0 - 2.0 * x) * z;
     891      201120 :         default: return (-1.0 + 2.0 * y) * z;
     892             :         }
     893             : 
     894     4022400 :     case 2:
     895     4022400 :       switch (i)
     896             :         {
     897      402240 :         case 0:
     898      402240 :         case 3: return (1.0 - x) * (1.0 - z);
     899      402240 :         case 1:
     900      402240 :         case 2: return x * (1.0 - z);
     901      402240 :         case 4:
     902      402240 :         case 7: return (1.0 - x) * z;
     903      402240 :         case 5:
     904      402240 :         case 6: return x * z;
     905      201120 :         case 9: return -2.0 * x * (1.0 - z);
     906      201120 :         case 11: return -2.0 * (1.0 - x) * (1.0 - z);
     907      201120 :         case 17: return -2.0 * x * z;
     908      201120 :         case 19: return -2.0 * (1.0 - x) * z;
     909      402240 :         default: return 0.0;
     910             :         }
     911             : 
     912     4022400 :     case 3:
     913     4022400 :       switch (i)
     914             :         {
     915      201120 :         case 0: return (1.25 - x - 0.5 * y - z) * (1.0 - y);
     916      201120 :         case 1: return (-x + 0.5 * y + z - 0.25) * (1.0 - y);
     917      201120 :         case 2: return -0.25 * y * (2.0 * y + 4.0 * x - 4.0 * z - 1.0);
     918      201120 :         case 3: return -0.25 * y * (-2.0 * y + 4.0 * x + 4.0 * z - 3.0);
     919      201120 :         case 4: return (-z + x + 0.5 * y - 0.25) * (1.0 - y);
     920      201120 :         case 5: return (x - 0.5 * y + z - 0.75) * (1.0 - y);
     921      201120 :         case 6: return 0.25 * y * (2.0 * y + 4.0 * x + 4.0 * z - 5.0);
     922      201120 :         case 7: return 0.25 * y * (-2.0 * y + 4.0 * x - 4.0 * z + 1.0);
     923      201120 :         case 8: return (-1.0 + 2.0 * x) * (1.0 - y);
     924      201120 :         case 9: return -y * (1.0 - y);
     925      201120 :         case 10: return (-1.0 + 2.0 * x) * y;
     926      201120 :         case 11: return y * (1.0 - y);
     927      201120 :         case 12: return (-1.0 + 2.0 * z) * (1.0 - y);
     928      201120 :         case 13: return (1.0 - 2.0 * z) * (1.0 - y);
     929      201120 :         case 14: return (1.0 - 2.0 * z) * y;
     930      201120 :         case 15: return (-1.0 + 2.0 * z) * y;
     931      201120 :         case 16: return (1.0 - 2.0 * x) * (1.0 - y);
     932      201120 :         case 17: return y * (1.0 - y);
     933      201120 :         case 18: return (1.0 - 2.0 * x) * y;
     934      201120 :         default: return -y * (1.0 - y);
     935             :         }
     936             : 
     937     4022400 :     case 4:
     938     4022400 :       switch (i)
     939             :         {
     940      201120 :         case 0: return (1.25 - 0.5 * x - y - z) * (1.0 - x);
     941      201120 :         case 1: return 0.25 * x * (2.0 * x - 4.0 * y - 4.0 * z + 3.0);
     942      201120 :         case 2: return -0.25 * x * (2.0 * x + 4.0 * y - 4.0 * z - 1.0);
     943      201120 :         case 3: return (-y + 0.5 * x + z - 0.25) * (1.0 - x);
     944      201120 :         case 4: return (-z + 0.5 * x + y - 0.25) * (1.0 - x);
     945      201120 :         case 5: return -0.25 * x * (2.0 * x - 4.0 * y + 4.0 * z - 1.0);
     946      201120 :         case 6: return 0.25 * x * (2.0 * x + 4.0 * y + 4.0 * z - 5.0);
     947      201120 :         case 7: return (y - 0.5 * x + z - 0.75) * (1.0 - x);
     948      201120 :         case 8: return x * (1.0 - x);
     949      201120 :         case 9: return (-1.0 + 2.0 * y) * x;
     950      201120 :         case 10: return -x * (1.0 - x);
     951      201120 :         case 11: return (-1.0 + 2.0 * y) * (1.0 - x);
     952      201120 :         case 12: return (-1.0 + 2.0 * z) * (1.0 - x);
     953      201120 :         case 13: return (-1.0 + 2.0 * z) * x;
     954      201120 :         case 14: return (1.0 - 2.0 * z) * x;
     955      201120 :         case 15: return (1.0 - 2.0 * z) * (1.0 - x);
     956      201120 :         case 16: return -x * (1.0 - x);
     957      201120 :         case 17: return (1.0 - 2.0 * y) * x;
     958      201120 :         case 18: return x * (1.0 - x);
     959      201120 :         default: return (1.0 - 2.0 * y) * (1.0 - x);
     960             :         }
     961             : 
     962     4022400 :     default:
     963     4022400 :       switch (i)
     964             :         {
     965      402240 :         case 0:
     966      402240 :         case 4: return (1.0 - x) * (1.0 - y);
     967      402240 :         case 1:
     968      402240 :         case 5: return x * (1.0 - y);
     969      402240 :         case 2:
     970      402240 :         case 6: return x * y;
     971      402240 :         case 3:
     972      402240 :         case 7: return (1.0 - x) * y;
     973      201120 :         case 12: return -2.0 * (1.0 - x) * (1.0 - y);
     974      201120 :         case 13: return -2.0 * x * (1.0 - y);
     975      201120 :         case 14: return -2.0 * x * y;
     976      201120 :         case 15: return -2.0 * (1.0 - x) * y;
     977      402240 :         default: return 0.0;
     978             :         }
     979             :     }
     980             : }
     981             : #endif
     982             : 
     983             : } // namespace detail
     984             : } // namespace libMesh
     985             : 
     986             : #endif // LIBMESH_FE_TENSOR_PRODUCT_LAGRANGE_H

Generated by: LCOV version 1.14