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