Intrepid
http://trilinos.sandia.gov/packages/docs/r10.12/packages/intrepid/src/Discretization/Integration/Intrepid_DefaultCubatureFactoryDef.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 // first create method
00052 template<class Scalar, class ArrayPoint, class ArrayWeight>
00053 Teuchos::RCP<Cubature<Scalar,ArrayPoint,ArrayWeight> > DefaultCubatureFactory<Scalar,ArrayPoint,ArrayWeight>::create(
00054   const shards::CellTopology & cellTopology,
00055   const std::vector<int> & degree) {
00056 
00057   // Create generic cubature.
00058   Teuchos::RCP<Cubature<Scalar,ArrayPoint,ArrayWeight> > pickCubature;
00059 
00060   switch (cellTopology.getBaseCellTopologyData()->key) {
00061 
00062     case shards::Line<>::key:
00063       TEUCHOS_TEST_FOR_EXCEPTION( (degree.size() < 1), std::invalid_argument,
00064                           ">>> ERROR (DefaultCubatureFactory): Provided degree array is of insufficient length.");
00065       pickCubature = Teuchos::rcp(new CubatureDirectLineGauss<Scalar,ArrayPoint,ArrayWeight>(degree[0]));
00066       break;
00067 
00068     case shards::Triangle<>::key:
00069       TEUCHOS_TEST_FOR_EXCEPTION( (degree.size() < 1), std::invalid_argument,
00070                           ">>> ERROR (DefaultCubatureFactory): Provided degree array is of insufficient length.");
00071       pickCubature = Teuchos::rcp(new CubatureDirectTriDefault<Scalar,ArrayPoint,ArrayWeight>(degree[0]));
00072       break;
00073 
00074     case shards::Quadrilateral<>::key:
00075       TEUCHOS_TEST_FOR_EXCEPTION( (degree.size() < 2), std::invalid_argument,
00076                           ">>> ERROR (DefaultCubatureFactory): Provided degree array is of insufficient length.");
00077       {
00078       std::vector< Teuchos::RCP< Cubature<Scalar,ArrayPoint,ArrayWeight> > > lineCubs(2);
00079       lineCubs[0]  = Teuchos::rcp(new CubatureDirectLineGauss<Scalar,ArrayPoint,ArrayWeight>(degree[0]));
00080       lineCubs[1]  = Teuchos::rcp(new CubatureDirectLineGauss<Scalar,ArrayPoint,ArrayWeight>(degree[1]));
00081       pickCubature = Teuchos::rcp(new CubatureTensor<Scalar,ArrayPoint,ArrayWeight>(lineCubs));
00082       }
00083       break;
00084 
00085     case shards::Tetrahedron<>::key:
00086       if (cellTopology.getCellTopologyData()->key == shards::Tetrahedron<11>::key)
00087       {
00088         TEUCHOS_TEST_FOR_EXCEPTION( (degree.size() < 1), std::invalid_argument,
00089                             ">>> ERROR (DefaultCubatureFactory): Provided degree array is of insufficient length.");
00090         pickCubature = Teuchos::rcp(new CubatureCompositeTet<Scalar,ArrayPoint,ArrayWeight>(degree[0]));
00091       } 
00092       else
00093       {
00094         TEUCHOS_TEST_FOR_EXCEPTION( (degree.size() < 1), std::invalid_argument,
00095                             ">>> ERROR (DefaultCubatureFactory): Provided degree array is of insufficient length.");
00096         pickCubature = Teuchos::rcp(new CubatureDirectTetDefault<Scalar,ArrayPoint,ArrayWeight>(degree[0]));
00097       }
00098       break;
00099     case shards::Hexahedron<>::key:
00100       TEUCHOS_TEST_FOR_EXCEPTION( (degree.size() < 3), std::invalid_argument,
00101                           ">>> ERROR (DefaultCubatureFactory): Provided degree array is of insufficient length.");
00102       {
00103       std::vector< Teuchos::RCP< Cubature<Scalar,ArrayPoint,ArrayWeight> > > lineCubs(3);
00104       lineCubs[0]  = Teuchos::rcp(new CubatureDirectLineGauss<Scalar,ArrayPoint,ArrayWeight>(degree[0]));
00105       lineCubs[1]  = Teuchos::rcp(new CubatureDirectLineGauss<Scalar,ArrayPoint,ArrayWeight>(degree[1]));
00106       lineCubs[2]  = Teuchos::rcp(new CubatureDirectLineGauss<Scalar,ArrayPoint,ArrayWeight>(degree[2]));
00107       pickCubature = Teuchos::rcp(new CubatureTensor<Scalar,ArrayPoint,ArrayWeight>(lineCubs));
00108       }
00109       break;
00110 
00111     case shards::Wedge<>::key:
00112       TEUCHOS_TEST_FOR_EXCEPTION( (degree.size() < 2), std::invalid_argument,
00113                           ">>> ERROR (DefaultCubatureFactory): Provided degree array is of insufficient length.")
00114       {
00115       std::vector< Teuchos::RCP< Cubature<Scalar,ArrayPoint,ArrayWeight> > > miscCubs(2);
00116       miscCubs[0]  = Teuchos::rcp(new CubatureDirectTriDefault<Scalar,ArrayPoint,ArrayWeight>(degree[0]));
00117       miscCubs[1]  = Teuchos::rcp(new CubatureDirectLineGauss<Scalar,ArrayPoint,ArrayWeight>(degree[1]));
00118       pickCubature = Teuchos::rcp(new CubatureTensor<Scalar,ArrayPoint,ArrayWeight>(miscCubs));
00119       }
00120       break;
00121 
00122     default:
00123       TEUCHOS_TEST_FOR_EXCEPTION( ( (cellTopology.getBaseCellTopologyData()->key != shards::Line<>::key)             &&
00124                             (cellTopology.getBaseCellTopologyData()->key != shards::Triangle<>::key)         &&
00125                             (cellTopology.getBaseCellTopologyData()->key != shards::Quadrilateral<>::key)    &&
00126                             (cellTopology.getBaseCellTopologyData()->key != shards::Tetrahedron<>::key)      &&
00127                             (cellTopology.getBaseCellTopologyData()->key != shards::Hexahedron<>::key)       &&
00128                             (cellTopology.getBaseCellTopologyData()->key != shards::Wedge<>::key) ),
00129                           std::invalid_argument,
00130                           ">>> ERROR (DefaultCubatureFactory): Invalid cell topology prevents cubature creation.");
00131   }
00132 
00133   return pickCubature;
00134 }
00135 
00136 
00137 
00138 // second create method
00139 template<class Scalar, class ArrayPoint, class ArrayWeight>
00140 Teuchos::RCP<Cubature<Scalar,ArrayPoint,ArrayWeight> > DefaultCubatureFactory<Scalar,ArrayPoint,ArrayWeight>::create(
00141   const shards::CellTopology & cellTopology, int degree) {
00142   std::vector<int> d(3);
00143   d[0] = degree; d[1] = degree; d[2] = degree;
00144   return create(cellTopology, d);
00145 }
00146 
00147 // third create method for polygons
00148 template<class Scalar, class ArrayPoint, class ArrayWeight>
00149 Teuchos::RCP<Cubature<Scalar,ArrayPoint,ArrayWeight> > DefaultCubatureFactory<Scalar,ArrayPoint,ArrayWeight>::create(const shards::CellTopology& cellTopology,
00150                                                                                                                      const ArrayPoint& cellVertices,
00151                                                                                                                      int degree){
00152   return Teuchos::rcp(new CubaturePolygon<Scalar,ArrayPoint,ArrayWeight>(cellTopology,cellVertices, degree));
00153 }
00154 
00155 
00156 
00157 
00158 } // namespace Intrepid