Intrepid
/usr/src/RPM/BUILD/trilinos10-10.6.4/packages/intrepid/src/Discretization/Basis/Intrepid_HGRAD_TET_C1_FEMDef.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 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Pavel Bochev (pbboche@sandia.gov) or
00025 //                    Denis Ridzal (dridzal@sandia.gov).
00026 //
00027 // ************************************************************************
00028 // @HEADER
00029 
00035 namespace Intrepid {
00036 
00037   template<class Scalar, class ArrayScalar>
00038   Basis_HGRAD_TET_C1_FEM<Scalar, ArrayScalar>::Basis_HGRAD_TET_C1_FEM()
00039   {
00040     this -> basisCardinality_  = 4;
00041     this -> basisDegree_       = 1;    
00042     this -> basisCellTopology_ = shards::CellTopology(shards::getCellTopologyData<shards::Tetrahedron<4> >() );
00043     this -> basisType_         = BASIS_FEM_DEFAULT;
00044     this -> basisCoordinates_  = COORDINATES_CARTESIAN;
00045     this -> basisTagsAreSet_   = false;
00046   }
00047   
00048   
00049 template<class Scalar, class ArrayScalar>
00050 void Basis_HGRAD_TET_C1_FEM<Scalar, ArrayScalar>::initializeTags() {
00051   
00052   // Basis-dependent intializations
00053   int tagSize  = 4;        // size of DoF tag
00054   int posScDim = 0;        // position in the tag, counting from 0, of the subcell dim 
00055   int posScOrd = 1;        // position in the tag, counting from 0, of the subcell ordinal
00056   int posDfOrd = 2;        // position in the tag, counting from 0, of DoF ordinal relative to the subcell
00057 
00058   // An array with local DoF tags assigned to basis functions, in the order of their local enumeration 
00059   int tags[]  = { 0, 0, 0, 1,
00060                   0, 1, 0, 1,
00061                   0, 2, 0, 1,
00062                   0, 3, 0, 1 };
00063   
00064   // Basis-independent function sets tag and enum data in tagToOrdinal_ and ordinalToTag_ arrays:
00065   Intrepid::setOrdinalTagData(this -> tagToOrdinal_,
00066                               this -> ordinalToTag_,
00067                               tags,
00068                               this -> basisCardinality_,
00069                               tagSize,
00070                               posScDim,
00071                               posScOrd,
00072                               posDfOrd);
00073 }
00074 
00075 
00076 
00077 template<class Scalar, class ArrayScalar>
00078 void Basis_HGRAD_TET_C1_FEM<Scalar, ArrayScalar>::getValues(ArrayScalar &        outputValues,
00079                                                              const ArrayScalar &  inputPoints,
00080                                                              const EOperator      operatorType) const {
00081   
00082   // Verify arguments
00083 #ifdef HAVE_INTREPID_DEBUG
00084   Intrepid::getValues_HGRAD_Args<Scalar, ArrayScalar>(outputValues,
00085                                                       inputPoints,
00086                                                       operatorType,
00087                                                       this -> getBaseCellTopology(),
00088                                                       this -> getCardinality() );
00089 #endif
00090   
00091   // Number of evaluation points = dim 0 of inputPoints
00092   int dim0 = inputPoints.dimension(0);  
00093   
00094   // Temporaries: (x,y,z) coordinates of the evaluation point
00095   Scalar x = 0.0;                                    
00096   Scalar y = 0.0;   
00097   Scalar z = 0.0;
00098   
00099   switch (operatorType) {
00100     
00101     case OPERATOR_VALUE:
00102       for (int i0 = 0; i0 < dim0; i0++) {
00103         x = inputPoints(i0, 0);
00104         y = inputPoints(i0, 1);
00105         z = inputPoints(i0, 2);
00106         
00107         // outputValues is a rank-2 array with dimensions (basisCardinality_, dim0)
00108         outputValues(0, i0) = 1.0 - x - y -z;
00109         outputValues(1, i0) = x;
00110         outputValues(2, i0) = y;
00111         outputValues(3, i0) = z;
00112       }
00113       break;
00114       
00115     case OPERATOR_GRAD:
00116     case OPERATOR_D1:
00117       for (int i0 = 0; i0 < dim0; i0++) {
00118         
00119         // outputValues is a rank-3 array with dimensions (basisCardinality_, dim0, spaceDim)
00120         outputValues(0, i0, 0) = -1.0;
00121         outputValues(0, i0, 1) = -1.0;
00122         outputValues(0, i0, 2) = -1.0;
00123         
00124         outputValues(1, i0, 0) =  1.0;
00125         outputValues(1, i0, 1) =  0.0;
00126         outputValues(1, i0, 2) =  0.0;
00127         
00128         outputValues(2, i0, 0) =  0.0;
00129         outputValues(2, i0, 1) =  1.0;
00130         outputValues(2, i0, 2) =  0.0;
00131   
00132         outputValues(3, i0, 0) =  0.0;
00133         outputValues(3, i0, 1) =  0.0;
00134         outputValues(3, i0, 2) =  1.0;
00135       }
00136       break;
00137       
00138     case OPERATOR_CURL:
00139       TEST_FOR_EXCEPTION( (operatorType == OPERATOR_CURL), std::invalid_argument,
00140                           ">>> ERROR (Basis_HGRAD_TET_C1_FEM): CURL is invalid operator for rank-0 (scalar) functions in 3D");
00141       break;
00142       
00143     case OPERATOR_DIV:
00144       TEST_FOR_EXCEPTION( (operatorType == OPERATOR_DIV), std::invalid_argument,
00145                           ">>> ERROR (Basis_HGRAD_TET_C1_FEM): DIV is invalid operator for rank-0 (scalar) functions in 3D");
00146       break;
00147       
00148     case OPERATOR_D2:
00149     case OPERATOR_D3:
00150     case OPERATOR_D4:
00151     case OPERATOR_D5:
00152     case OPERATOR_D6:
00153     case OPERATOR_D7:
00154     case OPERATOR_D8:
00155     case OPERATOR_D9:
00156     case OPERATOR_D10:
00157       {
00158         // outputValues is a rank-3 array with dimensions (basisCardinality_, dim0, DkCardinality)
00159         int DkCardinality = Intrepid::getDkCardinality(operatorType, 
00160                                                        this -> basisCellTopology_.getDimension() );
00161         for(int dofOrd = 0; dofOrd < this -> basisCardinality_; dofOrd++) {
00162           for (int i0 = 0; i0 < dim0; i0++) {
00163             for(int dkOrd = 0; dkOrd < DkCardinality; dkOrd++){
00164               outputValues(dofOrd, i0, dkOrd) = 0.0;
00165             }
00166           }
00167         }
00168       }
00169       break;
00170     default:
00171       TEST_FOR_EXCEPTION( !( Intrepid::isValidOperator(operatorType) ), std::invalid_argument,
00172                           ">>> ERROR (Basis_HGRAD_TET_C1_FEM): Invalid operator type");
00173   }
00174 }
00175 
00176 
00177   
00178 template<class Scalar, class ArrayScalar>
00179 void Basis_HGRAD_TET_C1_FEM<Scalar, ArrayScalar>::getValues(ArrayScalar&           outputValues,
00180                                                              const ArrayScalar &    inputPoints,
00181                                                              const ArrayScalar &    cellVertices,
00182                                                              const EOperator        operatorType) const {
00183   TEST_FOR_EXCEPTION( (true), std::logic_error,
00184                       ">>> ERROR (Basis_HGRAD_TET_C1_FEM): FEM Basis calling an FVD member function");
00185 }
00186 }// namespace Intrepid