Intrepid
http://trilinos.sandia.gov/packages/docs/r10.8/packages/intrepid/src/Shared/Intrepid_Types.hpp
Go to the documentation of this file.
00001 // @HEADER
00002 // ************************************************************************
00003 //
00004 //                           Intrepid Package
00005 //                 Copyright (2007) Sandia Corporation
00006 //
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Pavel Bochev  (pbboche@sandia.gov)
00038 //                    Denis Ridzal  (dridzal@sandia.gov), or
00039 //                    Kara Peterson (kjpeter@sandia.gov)
00040 //
00041 // ************************************************************************
00042 // @HEADER
00043 
00049 #ifndef INTREPID_INTREPID_TYPES_HPP
00050 #define INTREPID_INTREPID_TYPES_HPP
00051 
00052 #ifdef  HAVE_INTREPID_DEBUG
00053 #define INTREPID_VALIDATE( A )  A
00054 #else
00055 #define INTREPID_VALIDATE( A ) /* empty */
00056 #endif
00057 
00058 #include <Teuchos_ScalarTraits.hpp>
00059 
00063 #define INTREPID_MAX_ORDER 10
00064 
00068 #define INTREPID_MAX_INTEGRATION_POINTS 1001
00069 
00074 #define INTREPID_MAX_CUBATURE_DEGREE_EDGE 61
00075 
00080 #define INTREPID_MAX_CUBATURE_DEGREE_TRI 20
00081 
00086 #define INTREPID_MAX_CUBATURE_DEGREE_TET 20
00087 
00092 #define INTREPID_MAX_CUBATURE_DEGREE_PYRAMID 4
00093 
00097 #define INTREPID_MAX_DIMENSION 3
00098 
00103 #define INTREPID_MAX_NEWTON 15
00104 
00108 #define INTREPID_MAX_DERIVATIVE 10
00109 
00110 namespace Intrepid {
00111   
00114   static const double INTREPID_EPSILON   = std::abs(Teuchos::ScalarTraits<double>::eps());
00115     
00118   static const double INTREPID_THRESHOLD = 10.0 * INTREPID_EPSILON;
00119   
00122   static const double INTREPID_TOL       = 10.0* INTREPID_THRESHOLD;
00123   
00127   enum ECoordinates{
00128     COORDINATES_CARTESIAN=0,
00129     COORDINATES_POLAR,
00130     COORDINATES_CYLINDRICAL,
00131     COORDINATES_SPHERICAL,
00132     COORDINATES_MAX
00133   };
00134 
00135   inline std::string ECoordinatesToString(ECoordinates coords) {
00136     std::string retString;
00137     switch(coords) {
00138       case COORDINATES_CARTESIAN:   retString = "Cartesian";            break;
00139       case COORDINATES_POLAR:       retString = "Polar";                break;
00140       case COORDINATES_CYLINDRICAL: retString = "Cylindrical";          break;
00141       case COORDINATES_SPHERICAL:   retString = "Spherical";            break;
00142       case COORDINATES_MAX:         retString = "Max. Coordinates";     break;
00143       default:                      retString = "INVALID ECoordinates";
00144     }
00145     return retString;
00146   }
00147 
00153   inline int isValidCoordinate(ECoordinates coordinateType){
00154     return( ( coordinateType == COORDINATES_CARTESIAN)   ||
00155             ( coordinateType == COORDINATES_POLAR)       ||
00156             ( coordinateType == COORDINATES_CYLINDRICAL) ||
00157             ( coordinateType == COORDINATES_SPHERICAL) );
00158   }
00159   
00160   
00161   
00165   enum ENorm{
00166     NORM_ONE = 0,
00167     NORM_TWO,
00168     NORM_INF,
00169     NORM_FRO,    // Frobenius matrix norm
00170     NORM_MAX
00171   };
00172 
00173   inline std::string ENormToString(ENorm norm) {
00174     std::string retString;
00175     switch(norm) {
00176       case NORM_ONE:   retString = "1-Norm";         break;
00177       case NORM_TWO:   retString = "2-Norm";         break;
00178       case NORM_INF:   retString = "Infinity Norm";  break;
00179       case NORM_FRO:   retString = "Frobenius Norm"; break;
00180       case NORM_MAX:   retString = "Max. Norm";      break;
00181       default:         retString = "INVALID ENorm";
00182     }
00183     return retString;
00184   }
00185   
00191   inline int isValidNorm(ENorm normType){
00192     return( (normType == NORM_ONE) ||
00193             (normType == NORM_TWO) ||
00194             (normType == NORM_INF) ||
00195             (normType == NORM_FRO) ||
00196             (normType == NORM_MAX) );
00197   }
00198 
00199 
00200   
00206   enum EOperator{
00207     OPERATOR_VALUE = 0,
00208     OPERATOR_GRAD,      // 1
00209     OPERATOR_CURL,      // 2
00210     OPERATOR_DIV,       // 3
00211     OPERATOR_D1,        // 4
00212     OPERATOR_D2,        // 5
00213     OPERATOR_D3,        // 6
00214     OPERATOR_D4,        // 7
00215     OPERATOR_D5,        // 8
00216     OPERATOR_D6,        // 9
00217     OPERATOR_D7,        // 10
00218     OPERATOR_D8,        // 11
00219     OPERATOR_D9,        // 12
00220     OPERATOR_D10,       // 13
00221     OPERATOR_MAX        // 14
00222   };
00223   
00224   inline std::string EOperatorToString(EOperator op) {
00225     std::string retString;
00226     switch(op) {
00227       case OPERATOR_VALUE: retString = "Value";         break;
00228       case OPERATOR_GRAD:  retString = "Grad";          break;
00229       case OPERATOR_CURL:  retString = "Curl";          break;
00230       case OPERATOR_DIV:   retString = "Div";           break;
00231       case OPERATOR_D1:    retString = "D1";            break;
00232       case OPERATOR_D2:    retString = "D2";            break;
00233       case OPERATOR_D3:    retString = "D3";            break;
00234       case OPERATOR_D4:    retString = "D4";            break;
00235       case OPERATOR_D5:    retString = "D5";            break;
00236       case OPERATOR_D6:    retString = "D6";            break;
00237       case OPERATOR_D7:    retString = "D7";            break;
00238       case OPERATOR_D8:    retString = "D8";            break;
00239       case OPERATOR_D9:    retString = "D9";            break;
00240       case OPERATOR_D10:   retString = "D10";           break;
00241       case OPERATOR_MAX:   retString = "Max. Operator"; break;
00242       default:             retString = "INVALID EOperator";
00243     }
00244     return retString;
00245   }
00246   
00247   inline EOperator & operator++(EOperator &type) {
00248     return type = static_cast<EOperator>(type+1);
00249   }
00250     
00251   inline EOperator operator++(EOperator &type, int) {
00252     EOperator oldval = type;
00253     ++type;
00254     return oldval;
00255   }
00256    
00257   inline EOperator & operator--(EOperator &type) {
00258     return type = static_cast<EOperator>(type-1);
00259   }
00260     
00261   inline EOperator operator--(EOperator &type, int) {
00262     EOperator oldval = type;
00263     --type;
00264     return oldval;
00265   }
00266 
00272   inline int isValidOperator(const EOperator operatorType){
00273     return ( (operatorType == OPERATOR_VALUE) ||
00274              (operatorType == OPERATOR_GRAD)  || 
00275              (operatorType == OPERATOR_CURL)  || 
00276              (operatorType == OPERATOR_DIV)   ||
00277              (operatorType == OPERATOR_D1)    || 
00278              (operatorType == OPERATOR_D2)    || 
00279              (operatorType == OPERATOR_D3)    || 
00280              (operatorType == OPERATOR_D4)    || 
00281              (operatorType == OPERATOR_D5)    || 
00282              (operatorType == OPERATOR_D6)    || 
00283              (operatorType == OPERATOR_D7)    || 
00284              (operatorType == OPERATOR_D8)    || 
00285              (operatorType == OPERATOR_D9)    || 
00286              (operatorType == OPERATOR_D10) );
00287   }
00288   
00289   
00293   enum EFunctionSpace
00294     {
00295       FUNCTION_SPACE_HGRAD = 0,
00296       FUNCTION_SPACE_HCURL,
00297       FUNCTION_SPACE_HDIV,
00298       FUNCTION_SPACE_HVOL,
00299       FUNCTION_SPACE_VECTOR_HGRAD,
00300       FUNCTION_SPACE_TENSOR_HGRAD,
00301       FUNCTION_SPACE_MAX
00302     };
00303   
00304   inline std::string EFunctionSpaceToString(EFunctionSpace space) {
00305     std::string retString;
00306     switch(space) {
00307       case FUNCTION_SPACE_HGRAD:        retString = "H(grad)";     break;
00308       case FUNCTION_SPACE_HCURL:        retString = "H(curl)";     break;
00309       case FUNCTION_SPACE_HDIV:         retString = "H(div)";     break;
00310       case FUNCTION_SPACE_HVOL:         retString = "H(vol)";     break;
00311       case FUNCTION_SPACE_VECTOR_HGRAD: retString = "Vector H(grad)";     break;
00312       case FUNCTION_SPACE_TENSOR_HGRAD: retString = "Tensor H(grad)";     break;
00313       case FUNCTION_SPACE_MAX:          retString = "Max. Function space"; break;
00314       default:                          retString = "INVALID EFunctionSpace";
00315     }
00316     return retString;
00317   }
00318   
00324   inline int isValidFunctionSpace(const EFunctionSpace spaceType){
00325     return ( (spaceType == FUNCTION_SPACE_HGRAD) ||
00326              (spaceType == FUNCTION_SPACE_HCURL) || 
00327              (spaceType == FUNCTION_SPACE_HDIV)  ||
00328              (spaceType == FUNCTION_SPACE_HVOL)  ||
00329              (spaceType == FUNCTION_SPACE_VECTOR_HGRAD) || 
00330              (spaceType == FUNCTION_SPACE_TENSOR_HGRAD) );
00331   }
00332   
00333   
00334   
00343   enum EDiscreteSpace
00344     {
00345       DISCRETE_SPACE_COMPLETE = 0,        // value = 0
00346       DISCRETE_SPACE_INCOMPLETE,          // value = 1
00347       DISCRETE_SPACE_BROKEN,              // value = 2
00348       DISCRETE_SPACE_MAX                  // value = 3
00349     };
00350   
00351   inline std::string EDiscreteSpaceToString(EDiscreteSpace space) {
00352     std::string retString;
00353     switch(space) {
00354       case DISCRETE_SPACE_COMPLETE:   retString = "Complete";        break;
00355       case DISCRETE_SPACE_INCOMPLETE: retString = "Incomplete";      break;
00356       case DISCRETE_SPACE_BROKEN:     retString = "Broken";          break;
00357       case DISCRETE_SPACE_MAX:        retString = "Max. Rec. Space"; break;
00358       default:                              retString = "INVALID EDiscreteSpace";
00359     }
00360     return retString;
00361   }
00362   
00368   inline int isValidDiscreteSpace(const EDiscreteSpace spaceType){
00369     return ( (spaceType == DISCRETE_SPACE_COMPLETE) ||
00370              (spaceType == DISCRETE_SPACE_INCOMPLETE) || 
00371              (spaceType ==DISCRETE_SPACE_BROKEN) );
00372   }
00373 
00377   enum EPointType
00378     {
00379       POINTTYPE_EQUISPACED = 0,             // value = 0
00380       POINTTYPE_SPECTRAL,
00381       POINTTYPE_SPECTRAL_OPEN,
00382       POINTTYPE_WARPBLEND 
00383     };
00384   
00385   inline std::string EPointTypeToString(EPointType pointType) {
00386     std::string retString;
00387     switch (pointType) {
00388     case POINTTYPE_EQUISPACED:
00389       retString = "Equispaced Points";
00390       break;
00391     case POINTTYPE_WARPBLEND:
00392       retString = "WarpBlend Points";
00393       break;
00394     case POINTTYPE_SPECTRAL:
00395       retString = "Spectral Points";
00396       break;
00397     case POINTTYPE_SPECTRAL_OPEN:
00398       retString = "Open Spectral Points";
00399       break;
00400     }
00401     return retString;
00402   }
00403   
00409   inline int isValidPointType( const EPointType pointType ) {
00410     return ( (pointType == POINTTYPE_EQUISPACED ) ||
00411            (pointType == POINTTYPE_WARPBLEND ) );
00412   }
00413 
00417   enum EBasis
00418     {
00419       BASIS_FEM_DEFAULT = 0,                // value = 0
00420       BASIS_FEM_HIERARCHICAL,               // value = 1  
00421       BASIS_FEM_FIAT,                       // value = 2
00422       BASIS_FVD_DEFAULT,                    // value = 3
00423       BASIS_FVD_COVOLUME,                   // value = 4
00424       BASIS_FVD_MIMETIC,                    // value = 5
00425       BASIS_MAX                             // value = 6
00426     };
00427   
00428   inline std::string EBasisToString(EBasis basis) {
00429     std::string retString;
00430     switch(basis) {
00431       case BASIS_FEM_DEFAULT:      retString = "FEM Default";        break;
00432       case BASIS_FEM_HIERARCHICAL: retString = "FEM Hierarchical";   break;
00433       case BASIS_FEM_FIAT:         retString = "FEM FIAT";           break;
00434       case BASIS_FVD_DEFAULT:      retString = "FVD Default";        break;
00435       case BASIS_FVD_COVOLUME:     retString = "FVD Covolume";       break;
00436       case BASIS_FVD_MIMETIC:      retString = "FVD Mimetic";        break;
00437       case BASIS_MAX:              retString = "Max. Basis";         break;
00438       default:                     retString = "INVALID EBasis";
00439     }
00440     return retString;
00441   }
00442   
00448   inline int isValidBasis(const EBasis basisType){
00449     return ( (basisType == BASIS_FEM_DEFAULT) ||
00450              (basisType == BASIS_FEM_HIERARCHICAL) ||
00451              (basisType == BASIS_FEM_FIAT) ||
00452              (basisType == BASIS_FVD_DEFAULT) ||
00453              (basisType == BASIS_FVD_COVOLUME) ||
00454              (basisType == BASIS_FVD_MIMETIC) );
00455   }
00456 
00457   
00506   struct CubatureTemplate {
00507 
00510     int               numPoints_;
00511     
00514     double            points_[INTREPID_MAX_INTEGRATION_POINTS][INTREPID_MAX_DIMENSION];
00515     
00518     double            weights_[INTREPID_MAX_INTEGRATION_POINTS];
00519     
00520   };
00521 
00522 
00523 
00528   enum ECompEngine
00529   {
00530     COMP_CPP = 0,             
00531     COMP_BLAS,
00532     COMP_ENGINE_MAX
00533   };
00534 
00535   inline std::string ECompEngineToString(ECompEngine cEngine) {
00536     std::string retString;
00537     switch(cEngine) {
00538       case COMP_CPP:             retString = "Native C++";           break;
00539       case COMP_BLAS:            retString = "BLAS";                 break;
00540       case COMP_ENGINE_MAX:      retString = "Max. Comp. Engine";    break;
00541       default:                   retString = "INVALID ECompEngine";
00542     }
00543     return retString;
00544   }
00545   
00546   inline ECompEngine & operator++(ECompEngine &type) {
00547     return type = static_cast<ECompEngine>(type+1);
00548   }
00549 
00550   inline ECompEngine operator++(ECompEngine &type, int) {
00551     ECompEngine oldval = type;
00552     ++type;
00553     return oldval;
00554   }
00555 
00556   inline ECompEngine & operator--(ECompEngine &type) {
00557     return type = static_cast<ECompEngine>(type-1);
00558   }
00559 
00560   inline ECompEngine operator--(ECompEngine &type, int) {
00561     ECompEngine oldval = type;
00562     --type;
00563     return oldval;
00564   }
00565   
00566   
00572   inline int isValidCompEngine(const ECompEngine compEngType){
00573     return ( (compEngType == COMP_CPP) ||
00574              (compEngType == COMP_BLAS) );
00575   }
00576 
00577 } //namespace Intrepid
00578 
00734 #endif