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_LAGRANGE_N_DOFS_H 19 : #define LIBMESH_FE_LAGRANGE_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 Lagrange dofs on an element of type \p t at 34 : * order \p o, or \p invalid_uint for a combination whose count its 35 : * element type does not fix -- an order the family does not have, a 36 : * type that order cannot be built on, or a polytope, whose dofs follow 37 : * its node count instead. 38 : * 39 : * lagrange_n_dofs() in fe_lagrange.C answers the same question and 40 : * reports those cases as errors; it reads its counts from here, so that 41 : * device code, which cannot call into the library, gets the same 42 : * numbers from the same place. 43 : */ 44 : LIBMESH_DEVICE_INLINE constexpr unsigned int 45 421707281 : lagrange_n_dofs (const ElemType t, const Order o) 46 : { 47 421707281 : switch (o) 48 : { 49 : // lagrange can only be constant on a single node 50 48683 : case CONSTANT: 51 : { 52 48683 : switch (t) 53 : { 54 12196 : case NODEELEM: 55 12196 : return 1; 56 : 57 8 : default: 58 8 : return invalid_uint; 59 : } 60 : } 61 : 62 : // linear Lagrange shape functions 63 115405354 : case FIRST: 64 : { 65 87811429 : switch (t) 66 : { 67 1367 : case NODEELEM: 68 1367 : return 1; 69 : 70 7765944 : case EDGE2: 71 : case EDGE3: 72 : case EDGE4: 73 7765944 : return 2; 74 : 75 4033216 : case TRI3: 76 : case TRISHELL3: 77 : case TRI3SUBDIVISION: 78 : case TRI6: 79 : case TRI7: 80 4033216 : return 3; 81 : 82 17136181 : case QUAD4: 83 : case QUADSHELL4: 84 : case QUAD8: 85 : case QUADSHELL8: 86 : case QUAD9: 87 : case QUADSHELL9: 88 17136181 : return 4; 89 : 90 1356166 : case TET4: 91 : case TET10: 92 : case TET14: 93 1356166 : return 4; 94 : 95 11845812 : case HEX8: 96 : case HEX20: 97 : case HEX27: 98 11845812 : return 8; 99 : 100 966270 : case PRISM6: 101 : case PRISM15: 102 : case PRISM18: 103 : case PRISM20: 104 : case PRISM21: 105 966270 : return 6; 106 : 107 232384 : case PYRAMID5: 108 : case PYRAMID13: 109 : case PYRAMID14: 110 : case PYRAMID18: 111 232384 : return 5; 112 : 113 0 : case INVALID_ELEM: 114 0 : return 0; 115 : 116 541668 : case C0POLYGON: 117 : case C0POLYHEDRON: 118 : // A polytope's dof count follows from its node count, which 119 : // its element type does not fix 120 541668 : return invalid_uint; 121 : 122 0 : default: 123 0 : return invalid_uint; 124 : } 125 : } 126 : 127 : 128 : // quadratic Lagrange shape functions 129 238994718 : case SECOND: 130 : { 131 238994718 : switch (t) 132 : { 133 195 : case NODEELEM: 134 195 : return 1; 135 : 136 3346064 : case EDGE3: 137 3346064 : return 3; 138 : 139 28723669 : case TRI6: 140 : case TRI7: 141 28723669 : return 6; 142 : 143 729303 : case QUAD8: 144 : case QUADSHELL8: 145 729303 : return 8; 146 : 147 17587596 : case QUAD9: 148 : case QUADSHELL9: 149 17587596 : return 9; 150 : 151 10067232 : case TET10: 152 : case TET14: 153 10067232 : return 10; 154 : 155 1011521 : case HEX20: 156 1011521 : return 20; 157 : 158 27436822 : case HEX27: 159 27436822 : return 27; 160 : 161 3223082 : case PRISM15: 162 3223082 : return 15; 163 : 164 1737371 : case PRISM18: 165 : case PRISM20: 166 : case PRISM21: 167 1737371 : return 18; 168 : 169 822314 : case PYRAMID13: 170 822314 : return 13; 171 : 172 347180 : case PYRAMID14: 173 : case PYRAMID18: 174 347180 : return 14; 175 : 176 0 : case INVALID_ELEM: 177 0 : return 0; 178 : 179 2 : default: 180 2 : return invalid_uint; 181 : } 182 : } 183 : 184 67258519 : case THIRD: 185 : { 186 67258519 : switch (t) 187 : { 188 0 : case NODEELEM: 189 0 : return 1; 190 : 191 4392 : case EDGE4: 192 4392 : return 4; 193 : 194 1306592 : case PRISM20: 195 1306592 : return 20; 196 : 197 1819299 : case PRISM21: 198 1819299 : return 21; 199 : 200 636868 : case PYRAMID18: 201 636868 : return 18; 202 : 203 20418359 : case TRI7: 204 20418359 : return 7; 205 : 206 7354627 : case TET14: 207 7354627 : return 14; 208 : 209 0 : case INVALID_ELEM: 210 0 : return 0; 211 : 212 0 : default: 213 0 : return invalid_uint; 214 : } 215 : } 216 : 217 2 : default: 218 2 : return invalid_uint; 219 : } 220 : } 221 : 222 : } // namespace FECounts 223 : 224 : } // namespace libMesh 225 : 226 : #endif // LIBMESH_FE_LAGRANGE_N_DOFS_H