19 #ifndef __INTREPID2_UTILS_DEF_HPP__
20 #define __INTREPID2_UTILS_DEF_HPP__
32 KOKKOS_INLINE_FUNCTION
33 ordinal_type getFieldRank(
const EFunctionSpace spaceType) {
34 ordinal_type fieldRank = -1;
38 case FUNCTION_SPACE_HGRAD:
39 case FUNCTION_SPACE_HVOL:
43 case FUNCTION_SPACE_HCURL:
44 case FUNCTION_SPACE_HDIV:
45 case FUNCTION_SPACE_VECTOR_HGRAD:
49 case FUNCTION_SPACE_TENSOR_HGRAD:
54 INTREPID2_TEST_FOR_ABORT( !isValidFunctionSpace(spaceType),
55 ">>> ERROR (Intrepid2::getFieldRank): Invalid function space type");
61 KOKKOS_INLINE_FUNCTION
62 ordinal_type getOperatorRank(
const EFunctionSpace spaceType,
63 const EOperator operatorType,
64 const ordinal_type spaceDim) {
66 const auto fieldRank = Intrepid2::getFieldRank(spaceType);
67 #ifdef HAVE_INTREPID2_DEBUG
69 INTREPID2_TEST_FOR_ABORT( !(0 <= fieldRank && fieldRank <= 2),
70 ">>> ERROR (Intrepid2::getOperatorRank): Invalid field rank");
71 INTREPID2_TEST_FOR_ABORT( !(1 <= spaceDim && spaceDim <= 3),
72 ">>> ERROR (Intrepid2::getOperatorRank): Invalid space dimension");
74 ordinal_type operatorRank = -999;
80 if (operatorType == OPERATOR_VALUE) {
89 INTREPID2_TEST_FOR_ABORT( fieldRank > 0,
90 ">>> ERROR (getOperatorRank): Only scalar fields are allowed in 1D");
96 switch (operatorType) {
119 operatorRank = spaceDim - 3;
124 operatorRank = 3 - spaceDim;
129 INTREPID2_TEST_FOR_ABORT( ( (spaceDim == 3) && (fieldRank == 0) ),
130 ">>> ERROR (Intrepid2::getOperatorRank): CURL cannot be applied to scalar fields in 3D");
144 INTREPID2_TEST_FOR_ABORT( ( (spaceDim > 1) && (fieldRank == 0) ),
145 ">>> ERROR (Intrepid2::getOperatorRank): DIV cannot be applied to scalar fields in 2D and 3D");
150 INTREPID2_TEST_FOR_ABORT( !( isValidOperator(operatorType) ),
151 ">>> ERROR (Intrepid2::getOperatorRank): Invalid operator type");
159 KOKKOS_INLINE_FUNCTION
160 ordinal_type getOperatorOrder(
const EOperator operatorType) {
161 ordinal_type opOrder = -1;
163 switch (operatorType) {
185 opOrder = (ordinal_type)operatorType - (ordinal_type)OPERATOR_D1 + 1;
189 INTREPID2_TEST_FOR_ABORT( !( Intrepid2::isValidOperator(operatorType) ),
190 ">>> ERROR (Intrepid2::getOperatorOrder): Invalid operator type");
196 KOKKOS_INLINE_FUNCTION
197 ordinal_type getDkEnumeration(
const ordinal_type xMult,
198 const ordinal_type yMult,
199 const ordinal_type zMult) {
201 if (yMult < 0 && zMult < 0) {
203 #ifdef HAVE_INTREPID2_DEBUG
206 ">>> ERROR (Intrepid2::getDkEnumeration): Derivative order out of range");
214 #ifdef HAVE_INTREPID2_DEBUG
217 ">>> ERROR (Intrepid2::getDkEnumeration): Derivative order out of range");
226 const auto order = xMult + yMult + zMult;
227 #ifdef HAVE_INTREPID2_DEBUG
229 INTREPID2_TEST_FOR_ABORT( !( (0 <= xMult) && (0 <= yMult) && (0 <= zMult) &&
231 ">>> ERROR (Intrepid2::getDkEnumeration): Derivative order out of range");
233 ordinal_type enumeration = zMult;
234 const ordinal_type iend = order-xMult+1;
235 for(ordinal_type i=0;i<iend;++i) {
352 KOKKOS_INLINE_FUNCTION
353 ordinal_type getDkCardinality(
const EOperator operatorType,
354 const ordinal_type spaceDim) {
357 ordinal_type derivativeOrder;
358 switch(operatorType) {
370 derivativeOrder = Intrepid2::getOperatorOrder(operatorType);
374 INTREPID2_TEST_FOR_ABORT(
true,
375 ">>> ERROR (Intrepid2::getDkCardinality): operator type Dk required for this method");
378 ordinal_type cardinality = -999;
386 cardinality = derivativeOrder + 1;
390 cardinality = (derivativeOrder + 1)*(derivativeOrder + 2)/2;
394 INTREPID2_TEST_FOR_ABORT( !( (0 < spaceDim ) && (spaceDim < 4) ),
395 ">>> ERROR (Intrepid2::getDkcardinality): Invalid space dimension");
Header function for Intrepid2::Util class and other utility functions.
static constexpr ordinal_type MaxDerivative
Maximum order of derivatives allowed in intrepid.