Intrepid
/usr/src/RPM/BUILD/trilinos-11.12.1/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         pickCubature = Teuchos::rcp(new CubatureDirectTetDefault<Scalar,ArrayPoint,ArrayWeight>(degree[0]));
00092       } 
00093       else
00094       {
00095         TEUCHOS_TEST_FOR_EXCEPTION( (degree.size() < 1), std::invalid_argument,
00096                             ">>> ERROR (DefaultCubatureFactory): Provided degree array is of insufficient length.");
00097         pickCubature = Teuchos::rcp(new CubatureDirectTetDefault<Scalar,ArrayPoint,ArrayWeight>(degree[0]));
00098       }
00099       break;
00100     case shards::Hexahedron<>::key:
00101       TEUCHOS_TEST_FOR_EXCEPTION( (degree.size() < 3), std::invalid_argument,
00102                           ">>> ERROR (DefaultCubatureFactory): Provided degree array is of insufficient length.");
00103       {
00104       std::vector< Teuchos::RCP< Cubature<Scalar,ArrayPoint,ArrayWeight> > > lineCubs(3);
00105       lineCubs[0]  = Teuchos::rcp(new CubatureDirectLineGauss<Scalar,ArrayPoint,ArrayWeight>(degree[0]));
00106       lineCubs[1]  = Teuchos::rcp(new CubatureDirectLineGauss<Scalar,ArrayPoint,ArrayWeight>(degree[1]));
00107       lineCubs[2]  = Teuchos::rcp(new CubatureDirectLineGauss<Scalar,ArrayPoint,ArrayWeight>(degree[2]));
00108       pickCubature = Teuchos::rcp(new CubatureTensor<Scalar,ArrayPoint,ArrayWeight>(lineCubs));
00109       }
00110       break;
00111 
00112     case shards::Wedge<>::key:
00113       TEUCHOS_TEST_FOR_EXCEPTION( (degree.size() < 2), std::invalid_argument,
00114                           ">>> ERROR (DefaultCubatureFactory): Provided degree array is of insufficient length.")
00115       {
00116       std::vector< Teuchos::RCP< Cubature<Scalar,ArrayPoint,ArrayWeight> > > miscCubs(2);
00117       miscCubs[0]  = Teuchos::rcp(new CubatureDirectTriDefault<Scalar,ArrayPoint,ArrayWeight>(degree[0]));
00118       miscCubs[1]  = Teuchos::rcp(new CubatureDirectLineGauss<Scalar,ArrayPoint,ArrayWeight>(degree[1]));
00119       pickCubature = Teuchos::rcp(new CubatureTensor<Scalar,ArrayPoint,ArrayWeight>(miscCubs));
00120       }
00121       break;
00122 
00123     case shards::Pyramid<>::key:
00124           TEUCHOS_TEST_FOR_EXCEPTION( (degree.size() < 3), std::invalid_argument,
00125                                                   ">>> ERROR (DefaultCubatureFactory): Provided degree array is of insufficient length.");
00126           {
00127           std::vector< Teuchos::RCP< Cubature<Scalar,ArrayPoint,ArrayWeight> > > lineCubs(3);
00128           lineCubs[0]  = Teuchos::rcp(new CubatureDirectLineGauss<Scalar,ArrayPoint,ArrayWeight>(degree[0]));
00129           lineCubs[1]  = Teuchos::rcp(new CubatureDirectLineGauss<Scalar,ArrayPoint,ArrayWeight>(degree[1]));
00130           lineCubs[2]  = Teuchos::rcp(new CubatureDirectLineGaussJacobi20<Scalar,ArrayPoint,ArrayWeight>(degree[2]));
00131           pickCubature = Teuchos::rcp(new CubatureTensorPyr<Scalar,ArrayPoint,ArrayWeight>(lineCubs));
00132           }
00133           break;
00134 
00135     default:
00136       TEUCHOS_TEST_FOR_EXCEPTION( ( (cellTopology.getBaseCellTopologyData()->key != shards::Line<>::key)             &&
00137                             (cellTopology.getBaseCellTopologyData()->key != shards::Triangle<>::key)         &&
00138                             (cellTopology.getBaseCellTopologyData()->key != shards::Quadrilateral<>::key)    &&
00139                             (cellTopology.getBaseCellTopologyData()->key != shards::Tetrahedron<>::key)      &&
00140                             (cellTopology.getBaseCellTopologyData()->key != shards::Hexahedron<>::key)       &&
00141                             (cellTopology.getBaseCellTopologyData()->key != shards::Pyramid<>::key)       &&
00142                             (cellTopology.getBaseCellTopologyData()->key != shards::Wedge<>::key) ),
00143                           std::invalid_argument,
00144                           ">>> ERROR (DefaultCubatureFactory): Invalid cell topology prevents cubature creation.");
00145   }
00146 
00147   return pickCubature;
00148 }
00149 
00150 
00151 
00152 // second create method
00153 template<class Scalar, class ArrayPoint, class ArrayWeight>
00154 Teuchos::RCP<Cubature<Scalar,ArrayPoint,ArrayWeight> > DefaultCubatureFactory<Scalar,ArrayPoint,ArrayWeight>::create(
00155   const shards::CellTopology & cellTopology, int degree) {
00156   std::vector<int> d(3);
00157   d[0] = degree; d[1] = degree; d[2] = degree;
00158   return create(cellTopology, d);
00159 }
00160 
00161 // third create method for polygons
00162 template<class Scalar, class ArrayPoint, class ArrayWeight>
00163 Teuchos::RCP<Cubature<Scalar,ArrayPoint,ArrayWeight> > DefaultCubatureFactory<Scalar,ArrayPoint,ArrayWeight>::create(const shards::CellTopology& cellTopology,
00164                                                                                                                      const ArrayPoint& cellVertices,
00165                                                                                                                      int degree){
00166   return Teuchos::rcp(new CubaturePolygon<Scalar,ArrayPoint,ArrayWeight>(cellTopology,cellVertices, degree));
00167 }
00168 
00169 
00170 
00171 
00172 } // namespace Intrepid