LCOV - code coverage report
Current view: top level - include/enums - enum_order.h (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4229 (6a9aeb) with base 727f46 Lines: 6 6 100.0 %
Date: 2025-08-19 19:27:09 Functions: 5 5 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // The libMesh Finite Element Library.
       2             : // Copyright (C) 2002-2025 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
       3             : 
       4             : // This library is free software; you can redistribute it and/or
       5             : // modify it under the terms of the GNU Lesser General Public
       6             : // License as published by the Free Software Foundation; either
       7             : // version 2.1 of the License, or (at your option) any later version.
       8             : 
       9             : // This library is distributed in the hope that it will be useful,
      10             : // but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      12             : // Lesser General Public License for more details.
      13             : 
      14             : // You should have received a copy of the GNU Lesser General Public
      15             : // License along with this library; if not, write to the Free Software
      16             : // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
      17             : 
      18             : 
      19             : 
      20             : #ifndef LIBMESH_ENUM_ORDER_H
      21             : #define LIBMESH_ENUM_ORDER_H
      22             : 
      23             : namespace libMesh {
      24             : 
      25             : /**
      26             :  * \enum libMesh::Order defines an \p enum for polynomial orders.
      27             :  * Fixing each label to a specific int, since \p InfFE and p refinement
      28             :  * may cast between them.
      29             :  *
      30             :  * \note It is possible to safely cast integral values larger than 43
      31             :  * to Order, provided that the cast value fits in the range of int. A
      32             :  * potential use case for such a cast is when employing the QGrid
      33             :  * class at extremely high order.
      34             :  *
      35             :  * The fixed type, i.e. ": int", enumeration syntax used here allows
      36             :  * this enum to be forward declared as
      37             :  * enum Order : int;
      38             :  * reducing header file dependencies.
      39             :  */
      40             : enum Order : int {
      41             :             CONSTANT     =  0,
      42             :             FIRST        =  1,
      43             :             SECOND       =  2,
      44             :             THIRD        =  3,
      45             :             FOURTH       =  4,
      46             :             FIFTH        =  5,
      47             :             SIXTH        =  6,
      48             :             SEVENTH      =  7,
      49             :             EIGHTH       =  8,
      50             :             NINTH        =  9,
      51             :             TENTH        = 10,
      52             :             ELEVENTH     = 11,
      53             :             TWELFTH      = 12,
      54             :             THIRTEENTH   = 13,
      55             :             FOURTEENTH   = 14,
      56             :             FIFTEENTH    = 15,
      57             :             SIXTEENTH    = 16,
      58             :             SEVENTEENTH  = 17,
      59             :             EIGHTTEENTH  = 18, // misspelling, deprecated
      60             :             EIGHTEENTH  = 18,
      61             :             NINETEENTH   = 19,
      62             :             TWENTIETH    = 20,
      63             :             TWENTYFIRST   = 21,
      64             :             TWENTYSECOND  = 22,
      65             :             TWENTYTHIRD   = 23,
      66             :             TWENTYFOURTH  = 24,
      67             :             TWENTYFIFTH   = 25,
      68             :             TWENTYSIXTH   = 26,
      69             :             TWENTYSEVENTH = 27,
      70             :             TWENTYEIGHTH  = 28,
      71             :             TWENTYNINTH   = 29,
      72             :             THIRTIETH     = 30,
      73             :             THIRTYFIRST   = 31,
      74             :             THIRTYSECOND  = 32,
      75             :             THIRTYTHIRD   = 33,
      76             :             THIRTYFOURTH  = 34,
      77             :             THIRTYFIFTH   = 35,
      78             :             THIRTYSIXTH   = 36,
      79             :             THIRTYSEVENTH = 37,
      80             :             THIRTYEIGHTH  = 38,
      81             :             THIRTYNINTH   = 39,
      82             :             FORTIETH     = 40,
      83             :             FORTYFIRST   = 41,
      84             :             FORTYSECOND  = 42,
      85             :             FORTYTHIRD   = 43,
      86             :             MAXIMUM = 255,
      87             :             // Invalid
      88             :             INVALID_ORDER};
      89             : 
      90             :   // Standardize this so nvc++ and clang -fsanitize=integer don't
      91             :   // complain about all the ways in which we might do it wrong
      92             :   template <typename T>
      93  3004390270 :   inline Order operator+(Order o, T p)
      94             :   {
      95 60867943826 :     return static_cast<Order>(static_cast<int>(o) + int(p));
      96             :   }
      97             : 
      98             :   template <typename T>
      99   232859787 :   inline Order operator-(Order o, T p)
     100             :   {
     101  2000285928 :     return static_cast<Order>(static_cast<int>(o) - int(p));
     102             :   }
     103             : 
     104             :   template <typename T>
     105   114074737 :   inline Order operator+(T p, Order o)
     106             :   {
     107   114074737 :     return o + p;
     108             :   }
     109             : 
     110             :   template <typename T>
     111             :   inline Order & operator+=(Order &o, T p)
     112             :   {
     113             :     o = o + p;
     114             :     return o;
     115             :   }
     116             : 
     117             :   template <typename T>
     118             :   inline Order & operator-=(Order &o, T p)
     119             :   {
     120             :     o = o - p;
     121             :     return o;
     122             :   }
     123             : 
     124             : }
     125             : 
     126             : #endif

Generated by: LCOV version 1.14