Intrepid
http://trilinos.sandia.gov/packages/docs/r11.2/packages/intrepid/src/Discretization/Basis/Intrepid_HCURL_QUAD_I1_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 // 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 namespace Intrepid {
00050 
00051 template<class Scalar, class ArrayScalar>
00052 Basis_HCURL_QUAD_I1_FEM<Scalar,ArrayScalar>::Basis_HCURL_QUAD_I1_FEM()
00053   {
00054     this -> basisCardinality_  = 4;
00055     this -> basisDegree_       = 1;
00056     this -> basisCellTopology_ = shards::CellTopology(shards::getCellTopologyData<shards::Quadrilateral<4> >() );
00057     this -> basisType_         = BASIS_FEM_DEFAULT;
00058     this -> basisCoordinates_  = COORDINATES_CARTESIAN;
00059     this -> basisTagsAreSet_   = false;
00060   }
00061   
00062 template<class Scalar, class ArrayScalar>
00063 void Basis_HCURL_QUAD_I1_FEM<Scalar, ArrayScalar>::initializeTags() {
00064   
00065   // Basis-dependent intializations
00066   int tagSize  = 4;        // size of DoF tag
00067   int posScDim = 0;        // position in the tag, counting from 0, of the subcell dim 
00068   int posScOrd = 1;        // position in the tag, counting from 0, of the subcell ordinal
00069   int posDfOrd = 2;        // position in the tag, counting from 0, of DoF ordinal relative to the subcell
00070 
00071   // An array with local DoF tags assigned to basis functions, in the order of their local enumeration 
00072   int tags[]  = {
00073                   1, 0, 0, 1,
00074                   1, 1, 0, 1,
00075                   1, 2, 0, 1,
00076                   1, 3, 0, 1};
00077   
00078   // Basis-independent function sets tag and enum data in tagToOrdinal_ and ordinalToTag_ arrays:
00079   Intrepid::setOrdinalTagData(this -> tagToOrdinal_,
00080                               this -> ordinalToTag_,
00081                               tags,
00082                               this -> basisCardinality_,
00083                               tagSize,
00084                               posScDim,
00085                               posScOrd,
00086                               posDfOrd);
00087 }
00088 
00089 
00090 
00091 template<class Scalar, class ArrayScalar>
00092 void Basis_HCURL_QUAD_I1_FEM<Scalar, ArrayScalar>::getValues(ArrayScalar &        outputValues,
00093                                                             const ArrayScalar &  inputPoints,
00094                                                             const EOperator      operatorType) const {
00095   
00096 // Verify arguments
00097 #ifdef HAVE_INTREPID_DEBUG
00098   Intrepid::getValues_HCURL_Args<Scalar, ArrayScalar>(outputValues,
00099                                                       inputPoints,
00100                                                       operatorType,
00101                                                       this -> getBaseCellTopology(),
00102                                                       this -> getCardinality() );
00103 #endif
00104   
00105  // Number of evaluation points = dim 0 of inputPoints
00106   int dim0 = inputPoints.dimension(0);
00107 
00108   // Temporaries: (x,y) coordinates of the evaluation point
00109   Scalar x = 0.0;                                    
00110   Scalar y = 0.0;                                    
00111   
00112   switch (operatorType) {
00113     case OPERATOR_VALUE:
00114       for (int i0 = 0; i0 < dim0; i0++) {
00115         x = inputPoints(i0, 0);
00116         y = inputPoints(i0, 1);
00117         
00118         // outputValues is a rank-3 array with dimensions (basisCardinality_, dim0, spaceDim)
00119         outputValues(0, i0, 0) = (1.0 - y)/4.0;
00120         outputValues(0, i0, 1) =  0.0;
00121 
00122         outputValues(1, i0, 0) =  0.0;
00123         outputValues(1, i0, 1) = (1.0 + x)/4.0;
00124 
00125         outputValues(2, i0, 0) =-(1.0 + y)/4.0;
00126         outputValues(2, i0, 1) =  0.0;
00127 
00128         outputValues(3, i0, 0) =  0.0;
00129         outputValues(3, i0, 1) =-(1.0 - x)/4.0;
00130       }
00131       break;
00132       
00133     case OPERATOR_CURL:
00134       for (int i0 = 0; i0 < dim0; i0++) {
00135         
00136         // outputValues is a rank-2 array with dimensions (basisCardinality_, dim0)
00137         outputValues(0, i0) = 0.25;
00138         outputValues(1, i0) = 0.25;
00139         outputValues(2, i0) = 0.25;
00140         outputValues(3, i0) = 0.25;
00141       }
00142       break;
00143       
00144     case OPERATOR_DIV:
00145        TEUCHOS_TEST_FOR_EXCEPTION( (operatorType == OPERATOR_DIV), std::invalid_argument,
00146                           ">>> ERROR (Basis_HCURL_QUAD_I1_FEM): DIV is invalid operator for HCURL Basis Functions");
00147       break;
00148       
00149     case OPERATOR_GRAD:
00150        TEUCHOS_TEST_FOR_EXCEPTION( (operatorType == OPERATOR_GRAD), std::invalid_argument,
00151                           ">>> ERROR (Basis_HCURL_QUAD_I1_FEM): GRAD is invalid operator for HCURL Basis Functions");
00152       break;
00153 
00154     case OPERATOR_D1:
00155     case OPERATOR_D2:
00156     case OPERATOR_D3:
00157     case OPERATOR_D4:
00158     case OPERATOR_D5:
00159     case OPERATOR_D6:
00160     case OPERATOR_D7:
00161     case OPERATOR_D8:
00162     case OPERATOR_D9:
00163     case OPERATOR_D10:
00164       TEUCHOS_TEST_FOR_EXCEPTION( ( (operatorType == OPERATOR_D1)    ||
00165                             (operatorType == OPERATOR_D2)    ||
00166                             (operatorType == OPERATOR_D3)    ||
00167                             (operatorType == OPERATOR_D4)    ||
00168                             (operatorType == OPERATOR_D5)    ||
00169                             (operatorType == OPERATOR_D6)    ||
00170                             (operatorType == OPERATOR_D7)    ||
00171                             (operatorType == OPERATOR_D8)    ||
00172                             (operatorType == OPERATOR_D9)    ||
00173                             (operatorType == OPERATOR_D10) ),
00174                           std::invalid_argument,
00175                           ">>> ERROR (Basis_HCURL_QUAD_I1_FEM): Invalid operator type");
00176       break;
00177 
00178     default:
00179       TEUCHOS_TEST_FOR_EXCEPTION( ( (operatorType != OPERATOR_VALUE) &&
00180                             (operatorType != OPERATOR_GRAD)  &&
00181                             (operatorType != OPERATOR_CURL)  &&
00182                             (operatorType != OPERATOR_DIV)   &&
00183                             (operatorType != OPERATOR_D1)    &&
00184                             (operatorType != OPERATOR_D2)    &&
00185                             (operatorType != OPERATOR_D3)    &&
00186                             (operatorType != OPERATOR_D4)    &&
00187                             (operatorType != OPERATOR_D5)    &&
00188                             (operatorType != OPERATOR_D6)    &&
00189                             (operatorType != OPERATOR_D7)    &&
00190                             (operatorType != OPERATOR_D8)    &&
00191                             (operatorType != OPERATOR_D9)    &&
00192                             (operatorType != OPERATOR_D10) ),
00193                           std::invalid_argument,
00194                           ">>> ERROR (Basis_HCURL_QUAD_I1_FEM): Invalid operator type");
00195   }
00196 }
00197 
00198 
00199   
00200 template<class Scalar, class ArrayScalar>
00201 void Basis_HCURL_QUAD_I1_FEM<Scalar, ArrayScalar>::getValues(ArrayScalar&           outputValues,
00202                                                             const ArrayScalar &    inputPoints,
00203                                                             const ArrayScalar &    cellVertices,
00204                                                             const EOperator        operatorType) const {
00205   TEUCHOS_TEST_FOR_EXCEPTION( (true), std::logic_error,
00206                       ">>> ERROR (Basis_HCURL_QUAD_I1_FEM): FEM Basis calling an FVD member function");
00207                                                              }
00208 
00209 template<class Scalar, class ArrayScalar>
00210 void Basis_HCURL_QUAD_I1_FEM<Scalar, ArrayScalar>::getDofCoords(ArrayScalar & DofCoords) const {
00211 #ifdef HAVE_INTREPID_DEBUG
00212   // Verify rank of output array.
00213   TEUCHOS_TEST_FOR_EXCEPTION( !(DofCoords.rank() == 2), std::invalid_argument,
00214                       ">>> ERROR: (Intrepid::Basis_HCURL_QUAD_I1_FEM::getDofCoords) rank = 2 required for DofCoords array");
00215   // Verify 0th dimension of output array.
00216   TEUCHOS_TEST_FOR_EXCEPTION( !( DofCoords.dimension(0) == this -> basisCardinality_ ), std::invalid_argument,
00217                       ">>> ERROR: (Intrepid::Basis_HCURL_QUAD_I1_FEM::getDofCoords) mismatch in number of DoF and 0th dimension of DofCoords array");
00218   // Verify 1st dimension of output array.
00219   TEUCHOS_TEST_FOR_EXCEPTION( !( DofCoords.dimension(1) == (int)(this -> basisCellTopology_.getDimension()) ), std::invalid_argument,
00220                       ">>> ERROR: (Intrepid::Basis_HCURL_QUAD_I1_FEM::getDofCoords) incorrect reference cell (1st) dimension in DofCoords array");
00221 #endif
00222 
00223   DofCoords(0,0) =  0.0;   DofCoords(0,1) = -1.0;
00224   DofCoords(1,0) =  1.0;   DofCoords(1,1) =  0.0;
00225   DofCoords(2,0) =  0.0;   DofCoords(2,1) =  1.0;
00226   DofCoords(3,0) = -1.0;   DofCoords(3,1) =  0.0;
00227 }
00228 
00229 }// namespace Intrepid