49 #ifndef INTREPID_UTILS_CPP
50 #define INTREPID_UTILS_CPP
62 int getFieldRank(
const EFunctionSpace spaceType) {
67 case FUNCTION_SPACE_HGRAD:
68 case FUNCTION_SPACE_HVOL:
72 case FUNCTION_SPACE_HCURL:
73 case FUNCTION_SPACE_HDIV:
74 case FUNCTION_SPACE_VECTOR_HGRAD:
78 case FUNCTION_SPACE_TENSOR_HGRAD:
83 TEUCHOS_TEST_FOR_EXCEPTION( !( isValidFunctionSpace(spaceType) ), std::invalid_argument,
84 ">>> ERROR (Intrepid::getFieldRank): Invalid function space type");
91 int getOperatorRank(
const EFunctionSpace spaceType,
92 const EOperator operatorType,
95 int fieldRank = Intrepid::getFieldRank(spaceType);
98 #ifdef HAVE_INTREPID_DEBUG
99 TEUCHOS_TEST_FOR_EXCEPTION( !( (0 <= fieldRank) && (fieldRank <= 2) ),
100 std::invalid_argument,
101 ">>> ERROR (Intrepid::getOperatorRank): Invalid field rank");
102 TEUCHOS_TEST_FOR_EXCEPTION( !( (1 <= spaceDim ) && (spaceDim <= 3) ),
103 std::invalid_argument,
104 ">>> ERROR (Intrepid::getOperatorRank): Invalid space dimension");
106 int operatorRank = -999;
113 if(operatorType == OPERATOR_VALUE) {
123 TEUCHOS_TEST_FOR_EXCEPTION( ( fieldRank > 0 ),
124 std::invalid_argument,
125 ">>> ERROR (getOperatorRank): Only scalar fields are allowed in 1D");
131 switch(operatorType) {
154 operatorRank = spaceDim - 3;
160 operatorRank = 3 - spaceDim;
165 TEUCHOS_TEST_FOR_EXCEPTION( ( (spaceDim == 3) && (fieldRank == 0) ), std::invalid_argument,
166 ">>> ERROR (Intrepid::getOperatorRank): CURL cannot be applied to scalar fields in 3D");
180 TEUCHOS_TEST_FOR_EXCEPTION( ( (spaceDim > 1) && (fieldRank == 0) ), std::invalid_argument,
181 ">>> ERROR (Intrepid::getOperatorRank): DIV cannot be applied to scalar fields in 2D and 3D");
186 TEUCHOS_TEST_FOR_EXCEPTION( !( isValidOperator(operatorType) ), std::invalid_argument,
187 ">>> ERROR (Intrepid::getOperatorRank): Invalid operator type");
196 int getOperatorOrder(
const EOperator operatorType) {
199 switch(operatorType){
221 opOrder = (int)operatorType - (
int)OPERATOR_D1 + 1;
225 TEUCHOS_TEST_FOR_EXCEPTION( !( Intrepid::isValidOperator(operatorType) ),
226 std::invalid_argument,
227 ">>> ERROR (Intrepid::getOperatorOrder): Invalid operator type");
234 int getDkEnumeration(
const int xMult,
238 if( (yMult < 0) && (zMult < 0)) {
240 #ifdef HAVE_INTREPID_DEBUG
243 ">>> ERROR (Intrepid::getDkEnumeration): Derivative order out of range");
252 #ifdef HAVE_INTREPID_DEBUG
254 TEUCHOS_TEST_FOR_EXCEPTION( !( (0 <= xMult) && (0 <= yMult) &&
256 ">>> ERROR (Intrepid::getDkEnumeration): Derivative order out of range");
265 int order = xMult + yMult + zMult;
267 #ifdef HAVE_INTREPID_DEBUG
269 TEUCHOS_TEST_FOR_EXCEPTION( !( (0 <= xMult) && (0 <= yMult) && (0 <= zMult) &&
271 ">>> ERROR (Intrepid::getDkEnumeration): Derivative order out of range");
273 int enumeration = zMult;
274 for(
int i = 0; i < order - xMult + 1; i++){
284 void getDkMultiplicities(Teuchos::Array<int>& partialMult,
285 const int derivativeEnum,
286 const EOperator operatorType,
287 const int spaceDim) {
302 static const int binNumber[66] = {
310 7, 7, 7, 7, 7, 7, 7, 7,
311 8, 8, 8, 8, 8, 8, 8, 8, 8,
312 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
313 10,10,10,10,10,10,10,10,10,10,10
317 static const int binBegin[66] ={
324 21,21,21,21,21,21,21,
325 28,28,28,28,28,28,28,28,
326 36,36,36,36,36,36,36,36,36,
327 45,45,45,45,45,45,45,45,45,45,
328 55,55,55,55,55,55,55,55,55,55,55
331 #ifdef HAVE_INTREPID_DEBUG
333 TEUCHOS_TEST_FOR_EXCEPTION( !( (0 <= derivativeEnum) && (derivativeEnum < getDkCardinality(operatorType,spaceDim) ) ),
334 std::invalid_argument,
335 ">>> ERROR (Intrepid::getDkMultiplicities): Invalid derivative enumeration value for this order and space dimension");
340 switch(operatorType){
352 derivativeOrder = Intrepid::getOperatorOrder(operatorType);
356 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
357 ">>> ERROR (Intrepid::getDkMultiplicities): operator type Dk required for this method");
365 partialMult.resize(1);
368 partialMult[0] = derivativeOrder;
374 partialMult.resize(2);
377 partialMult[1] = derivativeEnum;
378 partialMult[0] = derivativeOrder - derivativeEnum;
384 partialMult.resize(3);
387 partialMult[0] = derivativeOrder - binNumber[derivativeEnum];
388 partialMult[1] = binNumber[derivativeEnum] + binBegin[derivativeEnum] - derivativeEnum;
389 partialMult[2] = derivativeEnum - binBegin[derivativeEnum];
393 TEUCHOS_TEST_FOR_EXCEPTION( !( (0 < spaceDim ) && (spaceDim < 4) ), std::invalid_argument,
394 ">>> ERROR (Intrepid::getDkMultiplicities): Invalid space dimension");
400 int getDkCardinality(
const EOperator operatorType,
401 const int spaceDim) {
405 switch(operatorType){
417 derivativeOrder = Intrepid::getOperatorOrder(operatorType);
421 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
422 ">>> ERROR (Intrepid::getDkCardinality): operator type Dk required for this method");
425 int cardinality = -999;
433 cardinality = derivativeOrder + 1;
437 cardinality = (derivativeOrder + 1)*(derivativeOrder + 2)/2;
441 TEUCHOS_TEST_FOR_EXCEPTION( !( (0 < spaceDim ) && (spaceDim < 4) ), std::invalid_argument,
442 ">>> ERROR (Intrepid::getDkcardinality): Invalid space dimension");
455 void setOrdinalTagData(std::vector<std::vector<std::vector<int> > > &tagToOrdinal,
456 std::vector<std::vector<int> > &ordinalToTag,
462 const int posDfOrd) {
466 ordinalToTag.resize(basisCard);
467 for (
int i = 0; i < basisCard; i++) {
468 ordinalToTag[i].resize(4);
469 for (
int j = 0; j < tagSize; j++) {
470 ordinalToTag[i][j] = tags[i*tagSize + j];
477 for (
int i = 0; i < basisCard; i++) {
478 if (maxScDim < tags[i*tagSize + posScDim]) {
479 maxScDim = tags[i*tagSize + posScDim];
486 for (
int i = 0; i < basisCard; i++) {
487 if (maxScOrd < tags[i*tagSize + posScOrd]) {
488 maxScOrd = tags[i*tagSize + posScOrd];
495 for (
int i = 0; i < basisCard; i++) {
496 if (maxDfOrd < tags[i*tagSize + posDfOrd]) {
497 maxDfOrd = tags[i*tagSize + posDfOrd];
503 std::vector<int> rank1Array(maxDfOrd, -1);
506 std::vector<std::vector<int> > rank2Array(maxScOrd, rank1Array);
509 tagToOrdinal.assign(maxScDim, rank2Array);
512 for (
int i = 0; i < basisCard; i++) {
513 tagToOrdinal[tags[i*tagSize]][tags[i*tagSize+1]][tags[i*tagSize+2]] = i;
#define INTREPID_MAX_DERIVATIVE
Maximum order of derivatives allowed in intrepid.