|
Intrepid
|
00001 #ifndef INTREPID_HGRAD_QUAD_C2_FEMDEF_HPP 00002 #define INTREPID_HGRAD_QUAD_C2_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_C2_FEM<Scalar, ArrayScalar>::Basis_HGRAD_QUAD_C2_FEM() 00055 { 00056 this -> basisCardinality_ = 9; 00057 this -> basisDegree_ = 2; 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_C2_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 // edge midpoints 00080 1, 0, 0, 1, 00081 1, 1, 0, 1, 00082 1, 2, 0, 1, 00083 1, 3, 0, 1, 00084 // quad center 00085 2, 0, 0, 1}; 00086 00087 // Basis-independent function sets tag and enum data in tagToOrdinal_ and ordinalToTag_ arrays: 00088 Intrepid::setOrdinalTagData(this -> tagToOrdinal_, 00089 this -> ordinalToTag_, 00090 tags, 00091 this -> basisCardinality_, 00092 tagSize, 00093 posScDim, 00094 posScOrd, 00095 posDfOrd); 00096 } 00097 00098 00099 00100 template<class Scalar, class ArrayScalar> 00101 void Basis_HGRAD_QUAD_C2_FEM<Scalar, ArrayScalar>::getValues(ArrayScalar & outputValues, 00102 const ArrayScalar & inputPoints, 00103 const EOperator operatorType) const { 00104 00105 // Verify arguments 00106 #ifdef HAVE_INTREPID_DEBUG 00107 Intrepid::getValues_HGRAD_Args<Scalar, ArrayScalar>(outputValues, 00108 inputPoints, 00109 operatorType, 00110 this -> getBaseCellTopology(), 00111 this -> getCardinality() ); 00112 #endif 00113 00114 // Number of evaluation points = dim 0 of inputPoints 00115 int dim0 = inputPoints.dimension(0); 00116 00117 // Temporaries: (x,y) coordinates of the evaluation point 00118 Scalar x = 0.0; 00119 Scalar y = 0.0; 00120 00121 switch (operatorType) { 00122 00123 case OPERATOR_VALUE: 00124 for (int i0 = 0; i0 < dim0; i0++) { 00125 x = inputPoints(i0, 0); 00126 y = inputPoints(i0, 1); 00127 00128 // outputValues is a rank-2 array with dimensions (basisCardinality_, dim0) 00129 outputValues(0, i0) = x*(x - 1.0)*y*(y - 1.0)/4.0; 00130 outputValues(1, i0) = x*(x + 1.0)*y*(y - 1.0)/4.0; 00131 outputValues(2, i0) = x*(x + 1.0)*y*(y + 1.0)/4.0; 00132 outputValues(3, i0) = x*(x - 1.0)*y*(y + 1.0)/4.0; 00133 // edge midpoints basis functions 00134 outputValues(4, i0) = (1.0 - x)*(1.0 + x)*y*(y - 1.0)/2.0; 00135 outputValues(5, i0) = x*(x + 1.0)*(1.0 - y)*(1.0 + y)/2.0; 00136 outputValues(6, i0) = (1.0 - x)*(1.0 + x)*y*(y + 1.0)/2.0; 00137 outputValues(7, i0) = x*(x - 1.0)*(1.0 - y)*(1.0 + y)/2.0; 00138 // quad bubble basis function 00139 outputValues(8, i0) = (1.0 - x)*(1.0 + x)*(1.0 - y)*(1.0 + y); 00140 } 00141 break; 00142 00143 case OPERATOR_GRAD: 00144 case OPERATOR_D1: 00145 for (int i0 = 0; i0 < dim0; i0++) { 00146 x = inputPoints(i0,0); 00147 y = inputPoints(i0,1); 00148 00149 // outputValues is a rank-3 array with dimensions (basisCardinality_, dim0, spaceDim) 00150 outputValues(0, i0, 0) = (-0.25 + 0.5*x)*(-1. + y)*y; 00151 outputValues(0, i0, 1) = (-1.0 + x)*x*(-0.25 + 0.5*y); 00152 00153 outputValues(1, i0, 0) = (0.25 + 0.5*x)*(-1. + y)*y; 00154 outputValues(1, i0, 1) = x*(1. + x)*(-0.25 + 0.5*y); 00155 00156 outputValues(2, i0, 0) = (0.25 + 0.5*x)*y*(1. + y); 00157 outputValues(2, i0, 1) = x*(1. + x)*(0.25 + 0.5*y); 00158 00159 outputValues(3, i0, 0) = (-0.25 + 0.5*x)*y*(1. + y); 00160 outputValues(3, i0, 1) = (-1. + x)*x*(0.25 + 0.5*y); 00161 00162 outputValues(4, i0, 0) = x*(1.0 - y)*y; 00163 outputValues(4, i0, 1) = 0.5*(1.0 - x)*(1.0 + x)*(-1.0 + 2.0*y); 00164 00165 outputValues(5, i0, 0) = 0.5*(1.0 - y)*(1.0 + y)*(1.0 + 2.0*x); 00166 outputValues(5, i0, 1) =-x*(1.0 + x)*y; 00167 00168 outputValues(6, i0, 0) =-y*(1.0 + y)*x; 00169 outputValues(6, i0, 1) = 0.5*(1.0 - x)*(1.0 + x)*(1.0 + 2.0*y); 00170 00171 outputValues(7, i0, 0) = 0.5*(1.0 - y)*(1.0+ y)*(-1.0 + 2.0*x); 00172 outputValues(7, i0, 1) = (1.0 - x)*x*y; 00173 00174 outputValues(8, i0, 0) =-2.0*(1.0 - y)*(1.0 + y)*x; 00175 outputValues(8, i0, 1) =-2.0*(1.0 - x)*(1.0 + x)*y; 00176 } 00177 break; 00178 00179 case OPERATOR_CURL: 00180 for (int i0 = 0; i0 < dim0; i0++) { 00181 x = inputPoints(i0,0); 00182 y = inputPoints(i0,1); 00183 00184 // outputValues is a rank-3 array with dimensions (basisCardinality_, dim0, spaceDim) 00185 // CURL(u) = (u_y, -u_x), is rotated GRAD 00186 outputValues(0, i0, 1) =-(-0.25 + 0.5*x)*(-1. + y)*y; 00187 outputValues(0, i0, 0) = (-1.0 + x)*x*(-0.25 + 0.5*y); 00188 00189 outputValues(1, i0, 1) =-(0.25 + 0.5*x)*(-1. + y)*y; 00190 outputValues(1, i0, 0) = x*(1. + x)*(-0.25 + 0.5*y); 00191 00192 outputValues(2, i0, 1) =-(0.25 + 0.5*x)*y*(1. + y); 00193 outputValues(2, i0, 0) = x*(1. + x)*(0.25 + 0.5*y); 00194 00195 outputValues(3, i0, 1) =-(-0.25 + 0.5*x)*y*(1. + y); 00196 outputValues(3, i0, 0) = (-1. + x)*x*(0.25 + 0.5*y); 00197 00198 outputValues(4, i0, 1) =-x*(1.0 - y)*y; 00199 outputValues(4, i0, 0) = 0.5*(1.0 - x)*(1.0 + x)*(-1.0 + 2.0*y); 00200 00201 outputValues(5, i0, 1) =-0.5*(1.0 - y)*(1.0 + y)*(1.0 + 2.0*x); 00202 outputValues(5, i0, 0) =-x*(1.0 + x)*y; 00203 00204 outputValues(6, i0, 1) = y*(1.0 + y)*x; 00205 outputValues(6, i0, 0) = 0.5*(1.0 - x)*(1.0 + x)*(1.0 + 2.0*y); 00206 00207 outputValues(7, i0, 1) =-0.5*(1.0 - y)*(1.0 + y)*(-1.0 + 2.0*x); 00208 outputValues(7, i0, 0) = (1.0 - x)*x*y; 00209 00210 outputValues(8, i0, 1) = 2.0*(1.0 - y)*(1.0 + y)*x; 00211 outputValues(8, i0, 0) =-2.0*(1.0 - x)*(1.0 + x)*y; 00212 } 00213 break; 00214 00215 case OPERATOR_DIV: 00216 TEUCHOS_TEST_FOR_EXCEPTION( (operatorType == OPERATOR_DIV), std::invalid_argument, 00217 ">>> ERROR (Basis_HGRAD_QUAD_C2_FEM): DIV is invalid operator for rank-0 (scalar) functions in 2D"); 00218 break; 00219 00220 case OPERATOR_D2: 00221 for (int i0 = 0; i0 < dim0; i0++) { 00222 x = inputPoints(i0,0); 00223 y = inputPoints(i0,1); 00224 00225 // outputValues is a rank-3 array with dimensions (basisCardinality_, dim0, D2Cardinality=3) 00226 outputValues(0, i0, 0) = 0.5*(-1.0 + y)*y; 00227 outputValues(0, i0, 1) = 0.25 - 0.5*y + x*(-0.5 + 1.*y); 00228 outputValues(0, i0, 2) = 0.5*(-1.0 + x)*x; 00229 00230 outputValues(1, i0, 0) = 0.5*(-1.0 + y)*y; 00231 outputValues(1, i0, 1) =-0.25 + 0.5*y + x*(-0.5 + 1.*y); 00232 outputValues(1, i0, 2) = 0.5*x*(1.0 + x); 00233 00234 outputValues(2, i0, 0) = 0.5*y*(1.0 + y); 00235 outputValues(2, i0, 1) = 0.25 + 0.5*y + x*(0.5 + 1.*y); 00236 outputValues(2, i0, 2) = 0.5*x*(1.0 + x); 00237 00238 outputValues(3, i0, 0) = 0.5*y*(1.0 + y); 00239 outputValues(3, i0, 1) =-0.25 - 0.5*y + x*(0.5 + 1.*y); 00240 outputValues(3, i0, 2) = 0.5*(-1.0 + x)*x; 00241 00242 outputValues(4, i0, 0) = (1.0 - y)*y; 00243 outputValues(4, i0, 1) = x*(1. - 2.*y); 00244 outputValues(4, i0, 2) = (1.0 - x)*(1.0 + x); 00245 00246 outputValues(5, i0, 0) = (1.0 - y)*(1.0 + y); 00247 outputValues(5, i0, 1) = x*(0. - 2.*y) - 1.*y; 00248 outputValues(5, i0, 2) =-x*(1.0 + x); 00249 00250 outputValues(6, i0, 0) =-y*(1.0 + y); 00251 outputValues(6, i0, 1) = x*(-1. - 2.*y); 00252 outputValues(6, i0, 2) = (1.0 - x)*(1.0 + x); 00253 00254 outputValues(7, i0, 0) = (1.0 - y)*(1.0 + y); 00255 outputValues(7, i0, 1) = x*(0. - 2.*y) + 1.*y; 00256 outputValues(7, i0, 2) = (1.0 - x)*x; 00257 00258 outputValues(8, i0, 0) =-2.0 + 2.0*y*y; 00259 outputValues(8, i0, 1) = 4*x*y; 00260 outputValues(8, i0, 2) =-2.0 + 2.0*x*x; 00261 00262 } 00263 break; 00264 00265 case OPERATOR_D3: 00266 // outputValues is a rank-3 array with dimensions (basisCardinality_, dim0, D3Cardinality=4) 00267 for (int i0 = 0; i0 < dim0; i0++) { 00268 x = inputPoints(i0,0); 00269 y = inputPoints(i0,1); 00270 00271 outputValues(0, i0, 0) = 0.0; 00272 outputValues(0, i0, 1) =-0.5 + y; 00273 outputValues(0, i0, 2) =-0.5 + x; 00274 outputValues(0, i0, 3) = 0.0; 00275 00276 outputValues(1, i0, 0) = 0.0; 00277 outputValues(1, i0, 1) =-0.5 + y; 00278 outputValues(1, i0, 2) = 0.5 + x; 00279 outputValues(1, i0, 3) = 0.0; 00280 00281 outputValues(2, i0, 0) = 0.0; 00282 outputValues(2, i0, 1) = 0.5 + y; 00283 outputValues(2, i0, 2) = 0.5 + x; 00284 outputValues(2, i0, 3) = 0.0; 00285 00286 outputValues(3, i0, 0) = 0.0; 00287 outputValues(3, i0, 1) = 0.5 + y; 00288 outputValues(3, i0, 2) =-0.5 + x; 00289 outputValues(3, i0, 3) = 0.0; 00290 00291 outputValues(4, i0, 0) = 0.0; 00292 outputValues(4, i0, 1) = 1.0 - 2.0*y; 00293 outputValues(4, i0, 2) =-2.0*x; 00294 outputValues(4, i0, 3) = 0.0; 00295 00296 outputValues(5, i0, 0) = 0.0; 00297 outputValues(5, i0, 1) =-2.0*y; 00298 outputValues(5, i0, 2) =-1.0 - 2.0*x; 00299 outputValues(5, i0, 3) = 0.0; 00300 00301 outputValues(6, i0, 0) = 0.0; 00302 outputValues(6, i0, 1) =-1.0 - 2.0*y; 00303 outputValues(6, i0, 2) =-2.0*x; 00304 outputValues(6, i0, 3) = 0.0; 00305 00306 outputValues(7, i0, 0) = 0.0; 00307 outputValues(7, i0, 1) =-2.0*y; 00308 outputValues(7, i0, 2) = 1.0 - 2.0*x; 00309 outputValues(7, i0, 3) = 0.0; 00310 00311 outputValues(8, i0, 0) = 0.0; 00312 outputValues(8, i0, 1) = 4.0*y; 00313 outputValues(8, i0, 2) = 4.0*x; 00314 outputValues(8, i0, 3) = 0.0; 00315 } 00316 break; 00317 00318 case OPERATOR_D4: 00319 // outputValues is a rank-3 array with dimensions (basisCardinality_, dim0, D4Cardinality=5) 00320 for (int i0 = 0; i0 < dim0; i0++) { 00321 00322 outputValues(0, i0, 0) = 0.0; 00323 outputValues(0, i0, 1) = 0.0; 00324 outputValues(0, i0, 2) = 1.0; 00325 outputValues(0, i0, 3) = 0.0; 00326 outputValues(0, i0, 4) = 0.0; 00327 00328 outputValues(1, i0, 0) = 0.0; 00329 outputValues(1, i0, 1) = 0.0; 00330 outputValues(1, i0, 2) = 1.0; 00331 outputValues(1, i0, 3) = 0.0; 00332 outputValues(1, i0, 4) = 0.0; 00333 00334 outputValues(2, i0, 0) = 0.0; 00335 outputValues(2, i0, 1) = 0.0; 00336 outputValues(2, i0, 2) = 1.0; 00337 outputValues(2, i0, 3) = 0.0; 00338 outputValues(2, i0, 4) = 0.0; 00339 00340 outputValues(3, i0, 0) = 0.0; 00341 outputValues(3, i0, 1) = 0.0; 00342 outputValues(3, i0, 2) = 1.0; 00343 outputValues(3, i0, 3) = 0.0; 00344 outputValues(3, i0, 4) = 0.0; 00345 00346 outputValues(4, i0, 0) = 0.0; 00347 outputValues(4, i0, 1) = 0.0; 00348 outputValues(4, i0, 2) =-2.0; 00349 outputValues(4, i0, 3) = 0.0; 00350 outputValues(4, i0, 4) = 0.0; 00351 00352 outputValues(5, i0, 0) = 0.0; 00353 outputValues(5, i0, 1) = 0.0; 00354 outputValues(5, i0, 2) =-2.0; 00355 outputValues(5, i0, 3) = 0.0; 00356 outputValues(5, i0, 4) = 0.0; 00357 00358 outputValues(6, i0, 0) = 0.0; 00359 outputValues(6, i0, 1) = 0.0; 00360 outputValues(6, i0, 2) =-2.0; 00361 outputValues(6, i0, 3) = 0.0; 00362 outputValues(6, i0, 4) = 0.0; 00363 00364 outputValues(7, i0, 0) = 0.0; 00365 outputValues(7, i0, 1) = 0.0; 00366 outputValues(7, i0, 2) =-2.0; 00367 outputValues(7, i0, 3) = 0.0; 00368 outputValues(7, i0, 4) = 0.0; 00369 00370 outputValues(8, i0, 0) = 0.0; 00371 outputValues(8, i0, 1) = 0.0; 00372 outputValues(8, i0, 2) = 4.0; 00373 outputValues(8, i0, 3) = 0.0; 00374 outputValues(8, i0, 4) = 0.0; 00375 } 00376 break; 00377 00378 case OPERATOR_D5: 00379 case OPERATOR_D6: 00380 case OPERATOR_D7: 00381 case OPERATOR_D8: 00382 case OPERATOR_D9: 00383 case OPERATOR_D10: 00384 { 00385 // outputValues is a rank-3 array with dimensions (basisCardinality_, dim0, DkCardinality) 00386 int DkCardinality = Intrepid::getDkCardinality(operatorType, 00387 this -> basisCellTopology_.getDimension() ); 00388 for(int dofOrd = 0; dofOrd < this -> basisCardinality_; dofOrd++) { 00389 for (int i0 = 0; i0 < dim0; i0++) { 00390 for(int dkOrd = 0; dkOrd < DkCardinality; dkOrd++){ 00391 outputValues(dofOrd, i0, dkOrd) = 0.0; 00392 } 00393 } 00394 } 00395 } 00396 break; 00397 00398 default: 00399 TEUCHOS_TEST_FOR_EXCEPTION( !( Intrepid::isValidOperator(operatorType) ), std::invalid_argument, 00400 ">>> ERROR (Basis_HGRAD_QUAD_C2_FEM): Invalid operator type"); 00401 } 00402 } 00403 00404 00405 00406 template<class Scalar, class ArrayScalar> 00407 void Basis_HGRAD_QUAD_C2_FEM<Scalar, ArrayScalar>::getValues(ArrayScalar& outputValues, 00408 const ArrayScalar & inputPoints, 00409 const ArrayScalar & cellVertices, 00410 const EOperator operatorType) const { 00411 TEUCHOS_TEST_FOR_EXCEPTION( (true), std::logic_error, 00412 ">>> ERROR (Basis_HGRAD_QUAD_C2_FEM): FEM Basis calling an FVD member function"); 00413 } 00414 00415 00416 00417 template<class Scalar, class ArrayScalar> 00418 void Basis_HGRAD_QUAD_C2_FEM<Scalar, ArrayScalar>::getDofCoords(ArrayScalar & DofCoords) const { 00419 #ifdef HAVE_INTREPID_DEBUG 00420 // Verify rank of output array. 00421 TEUCHOS_TEST_FOR_EXCEPTION( !(DofCoords.rank() == 2), std::invalid_argument, 00422 ">>> ERROR: (Intrepid::Basis_HGRAD_QUAD_C2_FEM::getDofCoords) rank = 2 required for DofCoords array"); 00423 // Verify 0th dimension of output array. 00424 TEUCHOS_TEST_FOR_EXCEPTION( !( DofCoords.dimension(0) == this -> basisCardinality_ ), std::invalid_argument, 00425 ">>> ERROR: (Intrepid::Basis_HGRAD_QUAD_C2_FEM::getDofCoords) mismatch in number of DoF and 0th dimension of DofCoords array"); 00426 // Verify 1st dimension of output array. 00427 TEUCHOS_TEST_FOR_EXCEPTION( !( DofCoords.dimension(1) == (int)(this -> basisCellTopology_.getDimension()) ), std::invalid_argument, 00428 ">>> ERROR: (Intrepid::Basis_HGRAD_QUAD_C2_FEM::getDofCoords) incorrect reference cell (1st) dimension in DofCoords array"); 00429 #endif 00430 00431 DofCoords(0,0) = -1.0; DofCoords(0,1) = -1.0; 00432 DofCoords(1,0) = 1.0; DofCoords(1,1) = -1.0; 00433 DofCoords(2,0) = 1.0; DofCoords(2,1) = 1.0; 00434 DofCoords(3,0) = -1.0; DofCoords(3,1) = 1.0; 00435 00436 DofCoords(4,0) = 0.0; DofCoords(4,1) = -1.0; 00437 DofCoords(5,0) = 1.0; DofCoords(5,1) = 0.0; 00438 DofCoords(6,0) = 0.0; DofCoords(6,1) = 1.0; 00439 DofCoords(7,0) = -1.0; DofCoords(7,1) = 0.0; 00440 00441 DofCoords(8,0) = 0.0; DofCoords(8,1) = 0.0; 00442 00443 } 00444 00445 }// namespace Intrepid 00446 #endif
1.7.6.1