|
Intrepid
|
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 00050 #ifndef INTREPID_PRODUCTTOPOLOGY_HPP 00051 #define INTREPID_PRODUCTTOPOLOGY_HPP 00052 00053 #include "Shards_CellTopology.hpp" 00054 #include "Teuchos_Assert.hpp" 00055 #include <stdexcept> 00056 #include <map> 00057 00058 namespace Intrepid { 00059 00065 class ProductTopology { 00066 public: 00075 static void lineProduct2d( const int dim0 , 00076 const int entity0 , 00077 const int dim1 , 00078 const int entity1 , 00079 int &resultdim , 00080 int &resultentity ) 00081 { 00082 // two vertices 00083 if (dim0 == 0 && dim1 == 0) 00084 { 00085 resultdim = 0; 00086 if (entity0 == 0 && entity1 == 0) 00087 { 00088 resultentity = 0; 00089 } 00090 else if (entity0 == 0 && entity1 == 1) 00091 { 00092 resultentity = 3; 00093 } 00094 else if (entity0 == 1 && entity1 == 0) 00095 { 00096 resultentity = 1; 00097 } 00098 else if (entity0 == 1 && entity1 == 1) 00099 { 00100 resultentity = 2; 00101 } 00102 else 00103 { 00104 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument , 00105 "Intrepid::ProductTopology::lineProduct2D: illegal inputs" ); 00106 } 00107 } 00108 else if (dim0 == 0 && dim1 == 1) 00109 { 00110 resultdim = 1; 00111 if (entity0 == 0 && entity1 == 0) 00112 { 00113 resultentity = 3; 00114 } 00115 else if (entity0 == 1 && entity1 == 0) 00116 { 00117 resultentity = 1; 00118 } 00119 else 00120 { 00121 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument , 00122 "Intrepid::ProductTopology::lineProduct2D: illegal inputs" ); 00123 } 00124 } 00125 else if (dim0 == 1 && dim1 == 0) 00126 { 00127 resultdim = 1; 00128 if (entity0 == 0 && entity1 == 0) 00129 { 00130 resultentity = 0; 00131 } 00132 else if (entity0 == 0 && entity1 == 1) 00133 { 00134 resultentity = 2; 00135 } 00136 else 00137 { 00138 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument , 00139 "Intrepid::ProductTopology::lineProduct2D: illegal inputs" ); 00140 } 00141 } 00142 else if (dim0 == 1 && dim1 == 1) 00143 { 00144 resultdim = 2; 00145 if (entity0 == 0 && entity1 == 0) 00146 { 00147 resultentity = 0; 00148 } 00149 else 00150 { 00151 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument , 00152 "Intrepid::ProductTopology::lineProduct2D: illegal inputs" ); 00153 } 00154 } 00155 else 00156 { 00157 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument , 00158 "Intrepid::ProductTopology::lineProduct2D: illegal inputs" ); 00159 } 00160 00161 } 00162 00173 static void lineProduct3d( const int dim0 , 00174 const int entity0 , 00175 const int dim1 , 00176 const int entity1 , 00177 const int dim2 , 00178 const int entity2 , 00179 int &resultdim , 00180 int &resultentity ) 00181 { 00182 // on vertex 00183 if (dim0 == 0 && dim1 == 0 && dim2 == 0) 00184 { 00185 resultdim = 0; 00186 if (entity0 == 0 && entity1 == 0 && entity2 == 0 ) 00187 { 00188 resultentity = 0; 00189 } 00190 else if (entity0 == 0 && entity1 == 0 && entity2 == 1 ) 00191 { 00192 resultentity = 4; 00193 } 00194 else if (entity0 == 0 && entity1 == 1 && entity2 == 0 ) 00195 { 00196 resultentity = 3; 00197 } 00198 else if (entity0 == 0 && entity1 == 1 && entity2 == 1 ) 00199 { 00200 resultentity = 7; 00201 } 00202 else if (entity0 == 1 && entity1 == 0 && entity2 == 0) 00203 { 00204 resultentity = 1; 00205 } 00206 else if (entity0 == 1 && entity1 == 0 && entity2 == 1) 00207 { 00208 resultentity = 5; 00209 } 00210 else if (entity0 == 1 && entity1 == 1 && entity2 == 0) 00211 { 00212 resultentity = 2; 00213 } 00214 else if (entity0 == 1 && entity1 == 1 && entity2 == 1) 00215 { 00216 resultentity = 6; 00217 } 00218 else 00219 { 00220 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument , 00221 "Intrepid::ProductTopology::lineProduct3D: illegal inputs" ); 00222 } 00223 } 00224 // LINES 00225 // z coord is on line, other two on vertex, this makes an ascending vertical edge 00226 else if (dim0 == 0 && dim1 == 0 && dim2 == 1) 00227 { 00228 resultdim = 1; 00229 if (entity0 == 0 && entity1 == 0 && entity2 == 0) 00230 { 00231 resultentity = 8; 00232 } 00233 else if (entity0 == 0 && entity1 == 1 && entity2 == 0) 00234 { 00235 resultentity = 11; 00236 } 00237 else if (entity0 == 1 && entity1 == 0 && entity2 == 0) 00238 { 00239 resultentity = 9; 00240 } 00241 else if (entity0 == 1 && entity1 == 1 && entity2 == 0) 00242 { 00243 resultentity = 10; 00244 } 00245 else 00246 { 00247 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument , 00248 "Intrepid::ProductTopology::lineProduct3D: illegal inputs" ); 00249 } 00250 } 00251 // only y coord is on line, other two on vertex, this makes line along y axis 00252 else if (dim0 == 0 && dim1 == 1 && dim2 == 0) 00253 { 00254 resultdim = 1; 00255 if (entity0 == 0 && entity1 == 0 && entity2 == 0) 00256 { 00257 resultentity = 3; 00258 } 00259 else if (entity0 == 0 && entity1 == 0 && entity2 == 1) 00260 { 00261 resultentity = 7; 00262 } 00263 else if (entity0 == 1 && entity1 == 0 && entity2 == 0) 00264 { 00265 resultentity = 1; 00266 } 00267 else if (entity0 == 1 && entity1 == 0 && entity2 == 1) 00268 { 00269 resultentity = 5; 00270 } 00271 else 00272 { 00273 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument , 00274 "Intrepid::ProductTopology::lineProduct3D: illegal inputs" ); 00275 } 00276 } 00277 // x dof is on line, others on vertex. 00278 else if (dim0 == 1 && dim1 == 0 && dim2 == 0) 00279 { 00280 resultdim = 1; 00281 if (entity0 == 0 && entity1 == 0 && entity2 == 0) 00282 { 00283 resultentity = 0; 00284 } 00285 else if (entity0 == 0 && entity1 == 0 && entity2 == 1) 00286 { 00287 resultentity = 4; 00288 } 00289 else if (entity0 == 0 && entity1 == 1 && entity2 == 0) 00290 { 00291 resultentity = 2; 00292 } 00293 else if (entity0 == 0 && entity1 == 1 && entity2 == 1) 00294 { 00295 resultentity = 6; 00296 } 00297 else 00298 { 00299 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument , 00300 "Intrepid::ProductTopology::lineProduct3D: illegal inputs" ); 00301 } 00302 } 00303 // FACES, these require two of the line dimensions to be 1 00304 else if (dim0 == 0 && dim1 == 1 && dim2 == 1) 00305 { 00306 resultdim = 2; 00307 if (entity0 == 0 && entity1 == 0 && entity2 == 0) 00308 { 00309 resultentity = 3; 00310 } 00311 else if (entity0 == 1 && entity1 == 0 && entity2 == 0) 00312 { 00313 resultentity = 1; 00314 } 00315 else 00316 { 00317 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument , 00318 "Intrepid::ProductTopology::lineProduct3D: illegal inputs" ); 00319 } 00320 } 00321 else if (dim0 == 1 && dim1 == 0 && dim2 == 1) 00322 { 00323 resultdim = 2; 00324 if (entity0 == 0 && entity1 == 0 && entity2 == 0) 00325 { 00326 resultentity = 0; 00327 } 00328 else if (entity0 == 0 && entity1 == 1 && entity2 == 0) 00329 { 00330 resultentity = 2; 00331 } 00332 else 00333 { 00334 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument , 00335 "Intrepid::ProductTopology::lineProduct3D: illegal inputs" ); 00336 } 00337 } 00338 else if (dim0 == 1 && dim1 == 1 && dim2 == 0) 00339 { 00340 resultdim = 2; 00341 if (entity0 == 0 && entity1 == 0 && entity2 == 0) 00342 { 00343 resultentity = 4; 00344 } 00345 else if (entity0 == 0 && entity1 == 0 && entity2 == 1) 00346 { 00347 resultentity = 5; 00348 } 00349 else 00350 { 00351 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument , 00352 "Intrepid::ProductTopology::lineProduct3D: illegal inputs" ); 00353 } 00354 } 00355 // CELL ITSELF 00356 else if (dim0 == 1 && dim1 == 1 && dim2 == 1) 00357 { 00358 resultdim = 3; 00359 if (entity0 == 0 && entity1 == 0 && entity2 == 0) 00360 { 00361 resultentity = 0; 00362 } 00363 else 00364 { 00365 TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument , 00366 "Intrepid::ProductTopology::lineProduct3D: illegal inputs" ); 00367 } 00368 } 00369 } 00370 00371 }; 00372 } 00373 00374 #endif
1.7.6.1