Intrepid
http://trilinos.sandia.gov/packages/docs/r10.12/packages/intrepid/src/Discretization/Basis/Intrepid_ProductTopologyDef.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   void ProductTopology::lineProduct2d( const int dim0 ,
00052                                        const int entity0 ,
00053                                        const int dim1 ,
00054                                        const int entity1 ,
00055                                        int &resultdim ,
00056                                        int &resultentity )
00057   {
00058     // two vertices
00059     if (dim0 == 0 && dim1 == 0) {
00060       resultdim = 0;
00061       if (entity0 == 0 && entity1 == 0) {
00062         resultentity = 0;
00063       }
00064       else if (entity0 == 0 && entity1 == 1) {
00065         resultentity = 3;
00066       }
00067       else if (entity0 == 1 && entity1 == 0) {
00068         resultentity = 1;
00069       }
00070       else if (entity0 == 1 && entity1 == 1) {
00071         resultentity = 2;
00072       } 
00073       else {
00074         TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
00075                             "Intrepid::ProductTopology::lineProduct2D: illegal inputs" );
00076       }
00077     }
00078     else if (dim0 == 0 && dim1 == 1) {
00079       resultdim = 1;
00080       if (entity0 == 0 && entity1 == 0) {
00081         resultentity = 3;
00082       }
00083       else if (entity0 == 1 && entity1 == 0) {
00084         resultentity = 1;
00085       }
00086       else {
00087         TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
00088                             "Intrepid::ProductTopology::lineProduct2D: illegal inputs" );
00089       }
00090     }
00091     else if (dim0 == 1 && dim1 == 0) {
00092       resultdim = 1;
00093       if (entity0 == 0 && entity1 == 0) {
00094         resultentity = 0;
00095       }
00096       else if (entity0 == 0 && entity1 == 1) {
00097         resultentity = 2;
00098       }
00099       else {
00100         TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
00101                             "Intrepid::ProductTopology::lineProduct2D: illegal inputs" );
00102       }
00103     }
00104     else if (dim0 == 1 && dim1 == 1) {
00105       resultdim = 2;
00106       if (entity0 == 0 && entity1 == 0) {
00107         resultentity = 0;
00108       }
00109       else {
00110         TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
00111                             "Intrepid::ProductTopology::lineProduct2D: illegal inputs" );
00112       }
00113     }
00114     else {
00115       TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
00116                           "Intrepid::ProductTopology::lineProduct2D: illegal inputs" );
00117     }
00118 
00119   }
00120 
00121   void ProductTopology::lineProduct3d( const int dim0 ,
00122                                        const int entity0 ,
00123                                        const int dim1 ,
00124                                        const int entity1 ,
00125                                        const int dim2 ,
00126                                        const int entity2 ,
00127                                        int &resultdim ,
00128                                        int &resultentity ) 
00129   {
00130     // on vertex
00131     if (dim0 == 0 && dim1 == 0 && dim2 == 0) {
00132       resultdim = 0;
00133       if (entity0 == 0 && entity1 == 0 && entity2 == 0 ) {
00134         resultentity = 0;
00135       }
00136       else if (entity0 == 0 && entity1 == 0 && entity2 == 1 ) {
00137         resultentity = 4;
00138       }
00139       else if (entity0 == 0 && entity1 == 1 && entity2 == 0 ) {
00140         resultentity = 3;
00141       }
00142       else if (entity0 == 0 && entity1 == 1 && entity2 == 1 ) {
00143         resultentity = 7;
00144       }
00145       else if (entity0 == 1 && entity1 == 0 && entity2 == 0) {
00146         resultentity = 1;
00147       }
00148       else if (entity0 == 1 && entity1 == 0 && entity2 == 1) {
00149         resultentity = 5;
00150       }
00151       else if (entity0 == 1 && entity1 == 1 && entity2 == 0) {
00152         resultentity = 2;
00153       }
00154       else if (entity0 == 1 && entity1 == 1 && entity2 == 1) {
00155         resultentity = 6;
00156       }
00157       else {
00158         TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
00159                             "Intrepid::ProductTopology::lineProduct3D: illegal inputs" );
00160       }
00161     }
00162     // LINES
00163     // z coord is on line, other two on vertex, this makes an ascending vertical edge
00164     else if (dim0 == 0 && dim1 == 0 && dim2 == 1) {
00165       resultdim = 1;
00166       if (entity0 == 0 && entity1 == 0 && entity2 == 0) {
00167         resultentity = 8;
00168       }
00169       else if (entity0 == 0 && entity1 == 1 && entity2 == 0) {
00170         resultentity = 11;
00171       }
00172       else if (entity0 == 1 && entity1 == 0 && entity2 == 0) {
00173         resultentity = 9;
00174       }
00175       else if (entity0 == 1 && entity1 == 1 && entity2 == 0) {
00176         resultentity = 10;
00177       }
00178       else {
00179         TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
00180                             "Intrepid::ProductTopology::lineProduct3D: illegal inputs" );
00181       }
00182     }
00183     // only y coord is on line, other two on vertex, this makes line along y axis
00184     else if (dim0 == 0 && dim1 == 1 && dim2 == 0) {
00185       resultdim = 1;
00186       if (entity0 == 0 && entity1 == 0 && entity2 == 0) {
00187         resultentity = 3;
00188       }
00189       else if (entity0 == 0 && entity1 == 0 && entity2 == 1) {
00190         resultentity = 7;
00191       }
00192       else if (entity0 == 1 && entity1 == 0 && entity2 == 0) {
00193         resultentity = 1;
00194       }
00195       else if (entity0 == 1 && entity1 == 0 && entity2 == 1) {
00196         resultentity = 5;
00197       }
00198       else {
00199         TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
00200                             "Intrepid::ProductTopology::lineProduct3D: illegal inputs" );
00201       }
00202     }
00203     // x dof is on line, others on vertex.  
00204     else if (dim0 == 1 && dim1 == 0 && dim2 == 0) {
00205       resultdim = 1;
00206       if (entity0 == 0 && entity1 == 0 && entity2 == 0) {
00207         resultentity = 0;
00208       }
00209       else if (entity0 == 0 && entity1 == 0 && entity2 == 1) {
00210         resultentity = 4;
00211       }
00212       else if (entity0 == 0 && entity1 == 1 && entity2 == 0) {
00213         resultentity = 2;
00214       }
00215       else if (entity0 == 0 && entity1 == 1 && entity2 == 1) {
00216         resultentity = 6;
00217       }
00218       else {
00219         TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
00220                             "Intrepid::ProductTopology::lineProduct3D: illegal inputs" );
00221       }
00222     }
00223     // FACES, these require two of the line dimensions to be 1
00224     else if (dim0 == 0 && dim1 == 1 && dim2 == 1) {
00225       resultdim = 2;
00226       if (entity0 == 0 && entity1 == 0 && entity2 == 0) { 
00227         resultentity = 3;
00228       }
00229       else if (entity0 == 1 && entity1 == 0 && entity2 == 0) { 
00230         resultentity = 1;
00231       }
00232       else {
00233         TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
00234                             "Intrepid::ProductTopology::lineProduct3D: illegal inputs" );
00235       }
00236     }
00237     else if (dim0 == 1 && dim1 == 0 && dim2 == 1) {
00238       resultdim = 2;
00239       if (entity0 == 0 && entity1 == 0 && entity2 == 0) { 
00240         resultentity = 0;
00241       }
00242       else if (entity0 == 0 && entity1 == 1 && entity2 == 0) { 
00243         resultentity = 2;
00244       }
00245       else {
00246         TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
00247                             "Intrepid::ProductTopology::lineProduct3D: illegal inputs" );
00248       }
00249     }
00250     else if (dim0 == 1 && dim1 == 1 && dim2 == 0) {
00251       resultdim = 2;
00252       if (entity0 == 0 && entity1 == 0 && entity2 == 0) { 
00253         resultentity = 4;
00254       }
00255       else if (entity0 == 0 && entity1 == 0 && entity2 == 1) { 
00256         resultentity = 5;
00257       }
00258       else {
00259         TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
00260                             "Intrepid::ProductTopology::lineProduct3D: illegal inputs" );
00261       }
00262     }
00263     // CELL ITSELF
00264     else if (dim0 == 1 && dim1 == 1 && dim2 == 1) {
00265       resultdim = 3;
00266       if (entity0 == 0 && entity1 == 0 && entity2 == 0) {
00267         resultentity = 0;
00268       }
00269       else {
00270         TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
00271                             "Intrepid::ProductTopology::lineProduct3D: illegal inputs" );
00272       }
00273     }
00274   }
00275 }