Intrepid
/usr/src/RPM/BUILD/trilinos10-10.6.4/packages/intrepid/src/Discretization/Basis/Intrepid_HGRAD_TRI_C1_FEMDef.hpp
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   
00038 template<class Scalar, class ArrayScalar>
00039 Basis_HGRAD_TRI_C1_FEM<Scalar,ArrayScalar>::Basis_HGRAD_TRI_C1_FEM()
00040   {
00041     this -> basisCardinality_  = 3;
00042     this -> basisDegree_       = 1;    
00043     this -> basisCellTopology_ = shards::CellTopology(shards::getCellTopologyData<shards::Triangle<3> >() );
00044     this -> basisType_         = BASIS_FEM_DEFAULT;
00045     this -> basisCoordinates_  = COORDINATES_CARTESIAN;
00046     this -> basisTagsAreSet_   = false;
00047   }
00048   
00049   
00050   
00051 template<class Scalar, class ArrayScalar>
00052 void Basis_HGRAD_TRI_C1_FEM<Scalar, ArrayScalar>::initializeTags() {
00053   
00054   // Basis-dependent initializations
00055   int tagSize  = 4;        // size of DoF tag, i.e., number of fields in the tag
00056   int posScDim = 0;        // position in the tag, counting from 0, of the subcell dim 
00057   int posScOrd = 1;        // position in the tag, counting from 0, of the subcell ordinal
00058   int posDfOrd = 2;        // position in the tag, counting from 0, of DoF ordinal relative to the subcell
00059   
00060   // An array with local DoF tags assigned to the basis functions, in the order of their local enumeration 
00061   int tags[]  = { 0, 0, 0, 1,
00062                   0, 1, 0, 1,
00063                   0, 2, 0, 1 };
00064   
00065   // Basis-independent function sets tag and enum data in tagToOrdinal_ and ordinalToTag_ arrays:
00066   Intrepid::setOrdinalTagData(this -> tagToOrdinal_,
00067                               this -> ordinalToTag_,
00068                               tags,
00069                               this -> basisCardinality_,
00070                               tagSize,
00071                               posScDim,
00072                               posScOrd,
00073                               posDfOrd);
00074 }  
00075 
00076 
00077 
00078 template<class Scalar, class ArrayScalar> 
00079 void Basis_HGRAD_TRI_C1_FEM<Scalar, ArrayScalar>::getValues(ArrayScalar &        outputValues,
00080                                                             const ArrayScalar &  inputPoints,
00081                                                             const EOperator      operatorType) const {
00082   
00083   // Verify arguments
00084 #ifdef HAVE_INTREPID_DEBUG
00085   Intrepid::getValues_HGRAD_Args<Scalar, ArrayScalar>(outputValues,
00086                                                       inputPoints,
00087                                                       operatorType,
00088                                                       this -> getBaseCellTopology(),
00089                                                       this -> getCardinality() );
00090 #endif
00091   
00092   // Number of evaluation points = dim 0 of inputPoints
00093   int dim0 = inputPoints.dimension(0);  
00094   
00095   // Temporaries: (x,y) coordinates of the evaluation point
00096   Scalar x = 0.0;                                    
00097   Scalar y = 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           
00106         // outputValues is a rank-2 array with dimensions (basisCardinality_, dim0)
00107         outputValues(0, i0) = 1.0 - x - y;
00108         outputValues(1, i0) = x;
00109         outputValues(2, i0) = y;
00110       }
00111       break;
00112 
00113     case OPERATOR_GRAD:
00114     case OPERATOR_D1:
00115       for (int i0 = 0; i0 < dim0; i0++) {
00116 
00117         // outputValues is a rank-3 array with dimensions (basisCardinality_, dim0, spaceDim)
00118         outputValues(0, i0, 0) = -1.0;
00119         outputValues(0, i0, 1) = -1.0;
00120 
00121         outputValues(1, i0, 0) =  1.0;
00122         outputValues(1, i0, 1) =  0.0;
00123 
00124         outputValues(2, i0, 0) =  0.0;
00125         outputValues(2, i0, 1) =  1.0;
00126       }
00127       break;
00128 
00129     case OPERATOR_CURL:
00130       for (int i0 = 0; i0 < dim0; i0++) {
00131         outputValues(0, i0, 0) = -1.0;
00132         outputValues(0, i0, 1) =  1.0;
00133           
00134         outputValues(1, i0, 0) =  0.0;
00135         outputValues(1, i0, 1) = -1.0;
00136           
00137         outputValues(2, i0, 0) =  1.0;
00138         outputValues(2, i0, 1) =  0.0;
00139       }
00140       break;
00141 
00142     case OPERATOR_DIV:
00143       TEST_FOR_EXCEPTION( (operatorType == OPERATOR_DIV), std::invalid_argument,
00144                           ">>> ERROR (Basis_HGRAD_TRI_C1_FEM): DIV is invalid operator for rank-0 (scalar) fields in 2D.");
00145       break;
00146 
00147     case OPERATOR_D2:
00148     case OPERATOR_D3:
00149     case OPERATOR_D4:
00150     case OPERATOR_D5:
00151     case OPERATOR_D6:
00152     case OPERATOR_D7:
00153     case OPERATOR_D8:
00154     case OPERATOR_D9:
00155     case OPERATOR_D10:
00156       {
00157         // outputValues is a rank-3 array with dimensions (basisCardinality_, dim0, DkCardinality)
00158         int DkCardinality = Intrepid::getDkCardinality(operatorType, 
00159                                                        this -> basisCellTopology_.getDimension() );
00160         for(int dofOrd = 0; dofOrd < this -> basisCardinality_; dofOrd++) {
00161           for (int i0 = 0; i0 < dim0; i0++) {
00162             for(int dkOrd = 0; dkOrd < DkCardinality; dkOrd++){
00163               outputValues(dofOrd, i0, dkOrd) = 0.0;
00164             }
00165           }
00166         }
00167       }
00168       break;
00169 
00170     default:
00171       TEST_FOR_EXCEPTION( !( Intrepid::isValidOperator(operatorType) ), std::invalid_argument,
00172                           ">>> ERROR (Basis_HGRAD_TRI_C1_FEM): Invalid operator type");
00173   }
00174 }
00175   
00176 
00177   
00178 template<class Scalar, class ArrayScalar>
00179 void Basis_HGRAD_TRI_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_TRI_C1_FEM): FEM Basis calling an FVD member function");
00185 }
00186 
00187 
00188 }// namespace Intrepid