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