Intrepid
http://trilinos.sandia.gov/packages/docs/r10.12/packages/intrepid/src/Discretization/Basis/Intrepid_HGRAD_TET_C1_FEMDef.hpp
Go to the documentation of this file.
00001 #ifndef INTREPID_HGRAD_TET_C1_FEMDEF_HPP
00002 #define INTREPID_HGRAD_TET_C1_FEMDEF_HPP
00003 // @HEADER
00004 // ************************************************************************
00005 //
00006 //                           Intrepid Package
00007 //                 Copyright (2007) Sandia Corporation
00008 //
00009 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00010 // license for use of this work by or on behalf of the U.S. Government.
00011 //
00012 // Redistribution and use in source and binary forms, with or without
00013 // modification, are permitted provided that the following conditions are
00014 // met:
00015 //
00016 // 1. Redistributions of source code must retain the above copyright
00017 // notice, this list of conditions and the following disclaimer.
00018 //
00019 // 2. Redistributions in binary form must reproduce the above copyright
00020 // notice, this list of conditions and the following disclaimer in the
00021 // documentation and/or other materials provided with the distribution.
00022 //
00023 // 3. Neither the name of the Corporation nor the names of the
00024 // contributors may be used to endorse or promote products derived from
00025 // this software without specific prior written permission.
00026 //
00027 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00028 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00029 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00030 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00031 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00032 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00033 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00034 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00035 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00036 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00037 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00038 //
00039 // Questions? Contact Pavel Bochev  (pbboche@sandia.gov)
00040 //                    Denis Ridzal  (dridzal@sandia.gov), or
00041 //                    Kara Peterson (kjpeter@sandia.gov)
00042 //
00043 // ************************************************************************
00044 // @HEADER
00045 
00051 namespace Intrepid {
00052 
00053   template<class Scalar, class ArrayScalar>
00054   Basis_HGRAD_TET_C1_FEM<Scalar, ArrayScalar>::Basis_HGRAD_TET_C1_FEM()
00055   {
00056     this -> basisCardinality_  = 4;
00057     this -> basisDegree_       = 1;    
00058     this -> basisCellTopology_ = shards::CellTopology(shards::getCellTopologyData<shards::Tetrahedron<4> >() );
00059     this -> basisType_         = BASIS_FEM_DEFAULT;
00060     this -> basisCoordinates_  = COORDINATES_CARTESIAN;
00061     this -> basisTagsAreSet_   = false;
00062   }
00063   
00064   
00065 template<class Scalar, class ArrayScalar>
00066 void Basis_HGRAD_TET_C1_FEM<Scalar, ArrayScalar>::initializeTags() {
00067   
00068   // Basis-dependent intializations
00069   int tagSize  = 4;        // size of DoF tag
00070   int posScDim = 0;        // position in the tag, counting from 0, of the subcell dim 
00071   int posScOrd = 1;        // position in the tag, counting from 0, of the subcell ordinal
00072   int posDfOrd = 2;        // position in the tag, counting from 0, of DoF ordinal relative to the subcell
00073 
00074   // An array with local DoF tags assigned to basis functions, in the order of their local enumeration 
00075   int tags[]  = { 0, 0, 0, 1,
00076                   0, 1, 0, 1,
00077                   0, 2, 0, 1,
00078                   0, 3, 0, 1 };
00079   
00080   // Basis-independent function sets tag and enum data in tagToOrdinal_ and ordinalToTag_ arrays:
00081   Intrepid::setOrdinalTagData(this -> tagToOrdinal_,
00082                               this -> ordinalToTag_,
00083                               tags,
00084                               this -> basisCardinality_,
00085                               tagSize,
00086                               posScDim,
00087                               posScOrd,
00088                               posDfOrd);
00089 }
00090 
00091 
00092 
00093 template<class Scalar, class ArrayScalar>
00094 void Basis_HGRAD_TET_C1_FEM<Scalar, ArrayScalar>::getValues(ArrayScalar &        outputValues,
00095                                                              const ArrayScalar &  inputPoints,
00096                                                              const EOperator      operatorType) const {
00097   
00098   // Verify arguments
00099 #ifdef HAVE_INTREPID_DEBUG
00100   Intrepid::getValues_HGRAD_Args<Scalar, ArrayScalar>(outputValues,
00101                                                       inputPoints,
00102                                                       operatorType,
00103                                                       this -> getBaseCellTopology(),
00104                                                       this -> getCardinality() );
00105 #endif
00106   
00107   // Number of evaluation points = dim 0 of inputPoints
00108   int dim0 = inputPoints.dimension(0);  
00109   
00110   // Temporaries: (x,y,z) coordinates of the evaluation point
00111   Scalar x = 0.0;                                    
00112   Scalar y = 0.0;   
00113   Scalar z = 0.0;
00114   
00115   switch (operatorType) {
00116     
00117     case OPERATOR_VALUE:
00118       for (int i0 = 0; i0 < dim0; i0++) {
00119         x = inputPoints(i0, 0);
00120         y = inputPoints(i0, 1);
00121         z = inputPoints(i0, 2);
00122         
00123         // outputValues is a rank-2 array with dimensions (basisCardinality_, dim0)
00124         outputValues(0, i0) = 1.0 - x - y -z;
00125         outputValues(1, i0) = x;
00126         outputValues(2, i0) = y;
00127         outputValues(3, i0) = z;
00128       }
00129       break;
00130       
00131     case OPERATOR_GRAD:
00132     case OPERATOR_D1:
00133       for (int i0 = 0; i0 < dim0; i0++) {
00134         
00135         // outputValues is a rank-3 array with dimensions (basisCardinality_, dim0, spaceDim)
00136         outputValues(0, i0, 0) = -1.0;
00137         outputValues(0, i0, 1) = -1.0;
00138         outputValues(0, i0, 2) = -1.0;
00139         
00140         outputValues(1, i0, 0) =  1.0;
00141         outputValues(1, i0, 1) =  0.0;
00142         outputValues(1, i0, 2) =  0.0;
00143         
00144         outputValues(2, i0, 0) =  0.0;
00145         outputValues(2, i0, 1) =  1.0;
00146         outputValues(2, i0, 2) =  0.0;
00147   
00148         outputValues(3, i0, 0) =  0.0;
00149         outputValues(3, i0, 1) =  0.0;
00150         outputValues(3, i0, 2) =  1.0;
00151       }
00152       break;
00153       
00154     case OPERATOR_CURL:
00155       TEUCHOS_TEST_FOR_EXCEPTION( (operatorType == OPERATOR_CURL), std::invalid_argument,
00156                           ">>> ERROR (Basis_HGRAD_TET_C1_FEM): CURL is invalid operator for rank-0 (scalar) functions in 3D");
00157       break;
00158       
00159     case OPERATOR_DIV:
00160       TEUCHOS_TEST_FOR_EXCEPTION( (operatorType == OPERATOR_DIV), std::invalid_argument,
00161                           ">>> ERROR (Basis_HGRAD_TET_C1_FEM): DIV is invalid operator for rank-0 (scalar) functions in 3D");
00162       break;
00163       
00164     case OPERATOR_D2:
00165     case OPERATOR_D3:
00166     case OPERATOR_D4:
00167     case OPERATOR_D5:
00168     case OPERATOR_D6:
00169     case OPERATOR_D7:
00170     case OPERATOR_D8:
00171     case OPERATOR_D9:
00172     case OPERATOR_D10:
00173       {
00174         // outputValues is a rank-3 array with dimensions (basisCardinality_, dim0, DkCardinality)
00175         int DkCardinality = Intrepid::getDkCardinality(operatorType, 
00176                                                        this -> basisCellTopology_.getDimension() );
00177         for(int dofOrd = 0; dofOrd < this -> basisCardinality_; dofOrd++) {
00178           for (int i0 = 0; i0 < dim0; i0++) {
00179             for(int dkOrd = 0; dkOrd < DkCardinality; dkOrd++){
00180               outputValues(dofOrd, i0, dkOrd) = 0.0;
00181             }
00182           }
00183         }
00184       }
00185       break;
00186     default:
00187       TEUCHOS_TEST_FOR_EXCEPTION( !( Intrepid::isValidOperator(operatorType) ), std::invalid_argument,
00188                           ">>> ERROR (Basis_HGRAD_TET_C1_FEM): Invalid operator type");
00189   }
00190 }
00191 
00192 
00193   
00194 template<class Scalar, class ArrayScalar>
00195 void Basis_HGRAD_TET_C1_FEM<Scalar, ArrayScalar>::getValues(ArrayScalar&           outputValues,
00196                                                              const ArrayScalar &    inputPoints,
00197                                                              const ArrayScalar &    cellVertices,
00198                                                              const EOperator        operatorType) const {
00199   TEUCHOS_TEST_FOR_EXCEPTION( (true), std::logic_error,
00200                       ">>> ERROR (Basis_HGRAD_TET_C1_FEM): FEM Basis calling an FVD member function");
00201 }
00202 }// namespace Intrepid
00203 #endif