LCOV - code coverage report
Current view: top level - include/fe - fe_monomial_n_dofs.h (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4573 (924896) with base 3f0912 Lines: 45 75 60.0 %
Date: 2026-11-18 21:52:26 Functions: 1 1 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             : // 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             : #ifndef LIBMESH_FE_MONOMIAL_N_DOFS_H
      19             : #define LIBMESH_FE_MONOMIAL_N_DOFS_H
      20             : 
      21             : #include "libmesh/enum_elem_type.h"
      22             : #include "libmesh/enum_order.h"
      23             : #include "libmesh/libmesh.h" // invalid_uint
      24             : #include "libmesh/libmesh_device.h"
      25             : 
      26             : namespace libMesh
      27             : {
      28             : 
      29             : namespace FECounts
      30             : {
      31             : 
      32             : /**
      33             :  * \returns The number of Monomial dofs on an element of type \p t at
      34             :  * order \p o, or \p invalid_uint for a combination its element type
      35             :  * does not fix.
      36             :  *
      37             :  * monomial_n_dofs() in fe_monomial.C answers the same question and
      38             :  * reports those cases as errors; it reads its counts from here, so that
      39             :  * device code, which cannot call into the library, gets the same
      40             :  * numbers from the same place.
      41             :  *
      42             :  * Every count this states is the number of monomials of degree o in the
      43             :  * element's dimension, C(o+dim, dim) -- checked for every element type at
      44             :  * every order up to sixth.  Writing it as that formula would be a change
      45             :  * in its own right, so what is here is the same switch, moved.
      46             :  */
      47             : LIBMESH_DEVICE_INLINE constexpr unsigned int
      48     5926350 : monomial_n_dofs (const ElemType t, const Order o)
      49             : {
      50     5926350 :   switch (o)
      51             :     {
      52             : 
      53             :       // constant shape functions
      54             :       // no matter what shape there is only one DOF.
      55     2812511 :     case CONSTANT:
      56     2812511 :       return (t != INVALID_ELEM) ? 1 : 0;
      57             : 
      58             : 
      59             :       // Discontinuous linear shape functions
      60             :       // expressed in the monomials.
      61     1907483 :     case FIRST:
      62             :       {
      63     1455203 :         switch (t)
      64             :           {
      65           0 :           case NODEELEM:
      66           0 :             return 1;
      67             : 
      68         490 :           case EDGE2:
      69             :           case EDGE3:
      70             :           case EDGE4:
      71         490 :             return 2;
      72             : 
      73       98967 :           case C0POLYGON:
      74             :           case TRI3:
      75             :           case TRISHELL3:
      76             :           case TRI6:
      77             :           case TRI7:
      78             :           case QUAD4:
      79             :           case QUADSHELL4:
      80             :           case QUAD8:
      81             :           case QUADSHELL8:
      82             :           case QUAD9:
      83             :           case QUADSHELL9:
      84       98967 :             return 3;
      85             : 
      86      502980 :           case TET4:
      87             :           case TET10:
      88             :           case TET14:
      89             :           case HEX8:
      90             :           case HEX20:
      91             :           case HEX27:
      92             :           case PRISM6:
      93             :           case PRISM15:
      94             :           case PRISM18:
      95             :           case PRISM20:
      96             :           case PRISM21:
      97             :           case PYRAMID5:
      98             :           case PYRAMID13:
      99             :           case PYRAMID14:
     100             :           case PYRAMID18:
     101             :           case C0POLYHEDRON:
     102      502980 :             return 4;
     103             : 
     104           0 :           case INVALID_ELEM:
     105           0 :             return 0;
     106             : 
     107           0 :           default:
     108           0 :             return invalid_uint;
     109             :           }
     110             :       }
     111             : 
     112             : 
     113             :       // Discontinuous quadratic shape functions
     114             :       // expressed in the monomials.
     115      533770 :     case SECOND:
     116             :       {
     117      406737 :         switch (t)
     118             :           {
     119           0 :           case NODEELEM:
     120           0 :             return 1;
     121             : 
     122         466 :           case EDGE2:
     123             :           case EDGE3:
     124             :           case EDGE4:
     125         466 :             return 3;
     126             : 
     127       31936 :           case C0POLYGON:
     128             :           case TRI3:
     129             :           case TRISHELL3:
     130             :           case TRI6:
     131             :           case TRI7:
     132             :           case QUAD4:
     133             :           case QUADSHELL4:
     134             :           case QUAD8:
     135             :           case QUADSHELL8:
     136             :           case QUAD9:
     137             :           case QUADSHELL9:
     138       31936 :             return 6;
     139             : 
     140      134908 :           case TET4:
     141             :           case TET10:
     142             :           case TET14:
     143             :           case HEX8:
     144             :           case HEX20:
     145             :           case HEX27:
     146             :           case PRISM6:
     147             :           case PRISM15:
     148             :           case PRISM18:
     149             :           case PRISM20:
     150             :           case PRISM21:
     151             :           case PYRAMID5:
     152             :           case PYRAMID13:
     153             :           case PYRAMID14:
     154             :           case PYRAMID18:
     155             :           case C0POLYHEDRON:
     156      134908 :             return 10;
     157             : 
     158           0 :           case INVALID_ELEM:
     159           0 :             return 0;
     160             : 
     161           0 :           default:
     162           0 :             return invalid_uint;
     163             :           }
     164             :       }
     165             : 
     166             : 
     167             :       // Discontinuous cubic shape functions
     168             :       // expressed in the monomials.
     169      382725 :     case THIRD:
     170             :       {
     171      288980 :         switch (t)
     172             :           {
     173           0 :           case NODEELEM:
     174           0 :             return 1;
     175             : 
     176         466 :           case EDGE2:
     177             :           case EDGE3:
     178             :           case EDGE4:
     179         466 :             return 4;
     180             : 
     181        6168 :           case C0POLYGON:
     182             :           case TRI3:
     183             :           case TRISHELL3:
     184             :           case TRI6:
     185             :           case TRI7:
     186             :           case QUAD4:
     187             :           case QUADSHELL4:
     188             :           case QUAD8:
     189             :           case QUADSHELL8:
     190             :           case QUAD9:
     191             :           case QUADSHELL9:
     192        6168 :             return 10;
     193             : 
     194      112396 :           case TET4:
     195             :           case TET10:
     196             :           case TET14:
     197             :           case HEX8:
     198             :           case HEX20:
     199             :           case HEX27:
     200             :           case PRISM6:
     201             :           case PRISM15:
     202             :           case PRISM18:
     203             :           case PRISM20:
     204             :           case PRISM21:
     205             :           case PYRAMID5:
     206             :           case PYRAMID13:
     207             :           case PYRAMID14:
     208             :           case PYRAMID18:
     209             :           case C0POLYHEDRON:
     210      112396 :             return 20;
     211             : 
     212           0 :           case INVALID_ELEM:
     213           0 :             return 0;
     214             : 
     215           0 :           default:
     216           0 :             return invalid_uint;
     217             :           }
     218             :       }
     219             : 
     220             : 
     221             :       // Discontinuous quartic shape functions
     222             :       // expressed in the monomials.
     223      193677 :     case FOURTH:
     224             :       {
     225      142983 :         switch (t)
     226             :           {
     227           0 :           case NODEELEM:
     228           0 :             return 1;
     229             : 
     230         466 :           case EDGE2:
     231             :           case EDGE3:
     232         466 :             return 5;
     233             : 
     234       15496 :           case C0POLYGON:
     235             :           case TRI3:
     236             :           case TRISHELL3:
     237             :           case TRI6:
     238             :           case TRI7:
     239             :           case QUAD4:
     240             :           case QUADSHELL4:
     241             :           case QUAD8:
     242             :           case QUADSHELL8:
     243             :           case QUAD9:
     244             :           case QUADSHELL9:
     245       15496 :             return 15;
     246             : 
     247      126369 :           case TET4:
     248             :           case TET10:
     249             :           case TET14:
     250             :           case HEX8:
     251             :           case HEX20:
     252             :           case HEX27:
     253             :           case PRISM6:
     254             :           case PRISM15:
     255             :           case PRISM18:
     256             :           case PRISM20:
     257             :           case PRISM21:
     258             :           case PYRAMID5:
     259             :           case PYRAMID13:
     260             :           case PYRAMID14:
     261             :           case C0POLYHEDRON:
     262      126369 :             return 35;
     263             : 
     264           0 :           case INVALID_ELEM:
     265           0 :             return 0;
     266             : 
     267           0 :           default:
     268           0 :             return invalid_uint;
     269             :           }
     270             :       }
     271             : 
     272             : 
     273       96184 :     default:
     274             :       {
     275       96184 :         const unsigned int order = static_cast<unsigned int>(o);
     276       96184 :         switch (t)
     277             :           {
     278           0 :           case NODEELEM:
     279           0 :             return 1;
     280             : 
     281         736 :           case EDGE2:
     282             :           case EDGE3:
     283         736 :             return (order+1);
     284             : 
     285       10426 :           case C0POLYGON:
     286             :           case TRI3:
     287             :           case TRISHELL3:
     288             :           case TRI6:
     289             :           case TRI7:
     290             :           case QUAD4:
     291             :           case QUADSHELL4:
     292             :           case QUAD8:
     293             :           case QUADSHELL8:
     294             :           case QUAD9:
     295             :           case QUADSHELL9:
     296       10426 :             return (order+1)*(order+2)/2;
     297             : 
     298       85022 :           case TET4:
     299             :           case TET10:
     300             :           case TET14:
     301             :           case HEX8:
     302             :           case HEX20:
     303             :           case HEX27:
     304             :           case PRISM6:
     305             :           case PRISM15:
     306             :           case PRISM18:
     307             :           case PRISM20:
     308             :           case PRISM21:
     309             :           case PYRAMID5:
     310             :           case PYRAMID13:
     311             :           case PYRAMID14:
     312             :           case C0POLYHEDRON:
     313       85022 :             return (order+1)*(order+2)*(order+3)/6;
     314             : 
     315           0 :           case INVALID_ELEM:
     316           0 :             return 0;
     317             : 
     318           0 :           default:
     319           0 :             return invalid_uint;
     320             :           }
     321             :       }
     322             :     }
     323             : }
     324             : 
     325             : } // namespace FECounts
     326             : 
     327             : } // namespace libMesh
     328             : 
     329             : #endif // LIBMESH_FE_MONOMIAL_N_DOFS_H

Generated by: LCOV version 1.14