Intrepid
http://trilinos.sandia.gov/packages/docs/r10.12/packages/intrepid/src/Discretization/Basis/Intrepid_HGRAD_LINE_C1_FEMDef.hpp
Go to the documentation of this file.
00001 #ifndef INTREPID_HGRAD_LINE_C1_FEMDEF_HPP
00002 #define INTREPID_HGRAD_LINE_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 
00054 template<class Scalar, class ArrayScalar>
00055 Basis_HGRAD_LINE_C1_FEM<Scalar,ArrayScalar>::Basis_HGRAD_LINE_C1_FEM() {
00056     this -> basisCardinality_  = 2;
00057     this -> basisDegree_       = 1;    
00058     this -> basisCellTopology_ = shards::CellTopology(shards::getCellTopologyData<shards::Line<2> >() );
00059     this -> basisType_         = BASIS_FEM_DEFAULT;
00060     this -> basisCoordinates_  = COORDINATES_CARTESIAN;
00061     this -> basisTagsAreSet_   = false;
00062 }
00063 
00064 
00065 
00066 template<class Scalar, class ArrayScalar> 
00067 void Basis_HGRAD_LINE_C1_FEM<Scalar, ArrayScalar>::getValues(ArrayScalar &        outputValues,
00068                                                                     const ArrayScalar &  inputPoints,
00069                                                                     const EOperator      operatorType) const {
00070   
00071   // Verify arguments
00072 #ifdef HAVE_INTREPID_DEBUG
00073   Intrepid::getValues_HGRAD_Args<Scalar, ArrayScalar>(outputValues,
00074                                                       inputPoints,
00075                                                       operatorType,
00076                                                       this -> getBaseCellTopology(),
00077                                                       this -> getCardinality() );
00078 #endif
00079   // Number of evaluation points = dim 0 of inputPoints
00080   int dim0 = inputPoints.dimension(0);  
00081   
00082   // Temporaries: (x,y) coordinates of the evaluation point
00083   Scalar x = 0.0;                                    
00084   
00085   switch (operatorType) {
00086     
00087     case OPERATOR_VALUE:
00088       for (int i0 = 0; i0 < dim0; i0++) {
00089         x = inputPoints(i0, 0);
00090         
00091         // outputValues is a rank-2 array with dimensions (basisCardinality_, dim0)
00092         outputValues(0, i0) = (1.0 - x)/2.0;
00093         outputValues(1, i0) = (1.0 + x)/2.0;
00094       }
00095       break;
00096       
00097     case OPERATOR_GRAD:
00098     case OPERATOR_DIV:
00099     case OPERATOR_CURL:
00100     case OPERATOR_D1:
00101       for (int i0 = 0; i0 < dim0; i0++) {
00102         x = inputPoints(i0,0);
00103         
00104         // outputValues is a rank-3 array with dimensions (basisCardinality_, dim0, spaceDim)
00105         outputValues(0, i0, 0) = -0.5;
00106         outputValues(1, i0, 0) = 0.5;
00107       }
00108       break;
00109       
00110     case OPERATOR_D2:
00111       for (int i0 = 0; i0 < dim0; i0++) {
00112         
00113         // outputValues is a rank-3 array with dimensions (basisCardinality_, dim0, D2Cardinality=3) 
00114         outputValues(0, i0, 0) =  0.0;
00115         outputValues(1, i0, 0) =  0.0;
00116       }
00117       break;
00118       
00119     case OPERATOR_D3:
00120     case OPERATOR_D4:
00121     case OPERATOR_D5:
00122     case OPERATOR_D6:
00123     case OPERATOR_D7:
00124     case OPERATOR_D8:
00125     case OPERATOR_D9:
00126     case OPERATOR_D10:
00127       {
00128         // outputValues is a rank-3 array with dimensions (basisCardinality_, dim0, DkCardinality)
00129         int DkCardinality = Intrepid::getDkCardinality(operatorType, 
00130                                                        this -> basisCellTopology_.getDimension() );
00131         for(int dofOrd = 0; dofOrd < this -> basisCardinality_; dofOrd++) {
00132           for (int i0 = 0; i0 < dim0; i0++) {
00133             for(int dkOrd = 0; dkOrd < DkCardinality; dkOrd++){
00134               outputValues(dofOrd, i0, dkOrd) = 0.0;
00135             }
00136           }
00137         }
00138       }
00139       break;
00140       
00141     default:
00142       TEUCHOS_TEST_FOR_EXCEPTION( !( Intrepid::isValidOperator(operatorType) ), std::invalid_argument,
00143                           ">>> ERROR (Basis_HGRAD_LINE_C1_FEM): Invalid operator type");
00144   }
00145 }
00146 
00147 template<class Scalar, class ArrayScalar>
00148 void Basis_HGRAD_LINE_C1_FEM<Scalar, ArrayScalar>::initializeTags() {
00149   
00150   // Basis-dependent intializations
00151   int tagSize  = 4;        // size of DoF tag, i.e., number of fields in the tag
00152   int posScDim = 0;        // position in the tag, counting from 0, of the subcell dim 
00153   int posScOrd = 1;        // position in the tag, counting from 0, of the subcell ordinal
00154   int posDfOrd = 2;        // position in the tag, counting from 0, of DoF ordinal relative to the subcell
00155 
00156   // An array with local DoF tags assigned to basis functions, in the order of their local enumeration 
00157   int tags[]  = { 0, 0, 0, 1,
00158                   0, 1, 0, 1};
00159   
00160   // Basis-independent function sets tag and enum data in tagToOrdinal_ and ordinalToTag_ arrays:
00161   Intrepid::setOrdinalTagData(this -> tagToOrdinal_,
00162                               this -> ordinalToTag_,
00163                               tags,
00164                               this -> basisCardinality_,
00165                               tagSize,
00166                               posScDim,
00167                               posScOrd,
00168                               posDfOrd);
00169 }
00170 
00171 template<class Scalar, class ArrayScalar>
00172 void Basis_HGRAD_LINE_C1_FEM<Scalar, ArrayScalar>::getValues(ArrayScalar&           outputValues,
00173                                                                     const ArrayScalar &    inputPoints,
00174                                                                     const ArrayScalar &    cellVertices,
00175                                                                     const EOperator        operatorType) const {
00176   TEUCHOS_TEST_FOR_EXCEPTION( (true), std::logic_error,
00177                       ">>> ERROR (Basis_HGRAD_LINE_C1_FEM): FEM Basis calling an FVD member function");
00178 }
00179 
00180 }// namespace Intrepid
00181 #endif