Intrepid
/usr/src/RPM/BUILD/trilinos10-10.6.4/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 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Pavel Bochev (pbboche@sandia.gov) or
00025 //                    Denis Ridzal (dridzal@sandia.gov).
00026 //
00027 // ************************************************************************
00028 // @HEADER
00029 
00035 namespace Intrepid {
00036 
00037 // first create method
00038 template<class Scalar, class ArrayPoint, class ArrayWeight>
00039 Teuchos::RCP<Cubature<Scalar,ArrayPoint,ArrayWeight> > DefaultCubatureFactory<Scalar,ArrayPoint,ArrayWeight>::create(
00040   const shards::CellTopology & cellTopology,
00041   const std::vector<int> & degree) {
00042 
00043   // Create generic cubature.
00044   Teuchos::RCP<Cubature<Scalar,ArrayPoint,ArrayWeight> > pickCubature;
00045 
00046   switch (cellTopology.getBaseTopology()->key) {
00047 
00048     case shards::Line<>::key:
00049       TEST_FOR_EXCEPTION( (degree.size() < 1), std::invalid_argument,
00050                           ">>> ERROR (DefaultCubatureFactory): Provided degree array is of insufficient length.");
00051       pickCubature = Teuchos::rcp(new CubatureDirectLineGauss<Scalar,ArrayPoint,ArrayWeight>(degree[0]));
00052       break;
00053 
00054     case shards::Triangle<>::key:
00055       TEST_FOR_EXCEPTION( (degree.size() < 1), std::invalid_argument,
00056                           ">>> ERROR (DefaultCubatureFactory): Provided degree array is of insufficient length.");
00057       pickCubature = Teuchos::rcp(new CubatureDirectTriDefault<Scalar,ArrayPoint,ArrayWeight>(degree[0]));
00058       break;
00059 
00060     case shards::Quadrilateral<>::key:
00061       TEST_FOR_EXCEPTION( (degree.size() < 2), std::invalid_argument,
00062                           ">>> ERROR (DefaultCubatureFactory): Provided degree array is of insufficient length.");
00063       {
00064       std::vector< Teuchos::RCP< Cubature<Scalar,ArrayPoint,ArrayWeight> > > lineCubs(2);
00065       lineCubs[0]  = Teuchos::rcp(new CubatureDirectLineGauss<Scalar,ArrayPoint,ArrayWeight>(degree[0]));
00066       lineCubs[1]  = Teuchos::rcp(new CubatureDirectLineGauss<Scalar,ArrayPoint,ArrayWeight>(degree[1]));
00067       pickCubature = Teuchos::rcp(new CubatureTensor<Scalar,ArrayPoint,ArrayWeight>(lineCubs));
00068       }
00069       break;
00070 
00071     case shards::Tetrahedron<>::key:
00072       TEST_FOR_EXCEPTION( (degree.size() < 1), std::invalid_argument,
00073                           ">>> ERROR (DefaultCubatureFactory): Provided degree array is of insufficient length.");
00074       pickCubature = Teuchos::rcp(new CubatureDirectTetDefault<Scalar,ArrayPoint,ArrayWeight>(degree[0]));
00075       break;
00076 
00077     case shards::Hexahedron<>::key:
00078       TEST_FOR_EXCEPTION( (degree.size() < 3), std::invalid_argument,
00079                           ">>> ERROR (DefaultCubatureFactory): Provided degree array is of insufficient length.");
00080       {
00081       std::vector< Teuchos::RCP< Cubature<Scalar,ArrayPoint,ArrayWeight> > > lineCubs(3);
00082       lineCubs[0]  = Teuchos::rcp(new CubatureDirectLineGauss<Scalar,ArrayPoint,ArrayWeight>(degree[0]));
00083       lineCubs[1]  = Teuchos::rcp(new CubatureDirectLineGauss<Scalar,ArrayPoint,ArrayWeight>(degree[1]));
00084       lineCubs[2]  = Teuchos::rcp(new CubatureDirectLineGauss<Scalar,ArrayPoint,ArrayWeight>(degree[2]));
00085       pickCubature = Teuchos::rcp(new CubatureTensor<Scalar,ArrayPoint,ArrayWeight>(lineCubs));
00086       }
00087       break;
00088 
00089     case shards::Wedge<>::key:
00090       TEST_FOR_EXCEPTION( (degree.size() < 2), std::invalid_argument,
00091                           ">>> ERROR (DefaultCubatureFactory): Provided degree array is of insufficient length.")
00092       {
00093       std::vector< Teuchos::RCP< Cubature<Scalar,ArrayPoint,ArrayWeight> > > miscCubs(2);
00094       miscCubs[0]  = Teuchos::rcp(new CubatureDirectTriDefault<Scalar,ArrayPoint,ArrayWeight>(degree[0]));
00095       miscCubs[1]  = Teuchos::rcp(new CubatureDirectLineGauss<Scalar,ArrayPoint,ArrayWeight>(degree[1]));
00096       pickCubature = Teuchos::rcp(new CubatureTensor<Scalar,ArrayPoint,ArrayWeight>(miscCubs));
00097       }
00098       break;
00099 
00100     default:
00101       TEST_FOR_EXCEPTION( ( (cellTopology.getBaseTopology()->key != shards::Line<>::key)             &&
00102                             (cellTopology.getBaseTopology()->key != shards::Triangle<>::key)         &&
00103                             (cellTopology.getBaseTopology()->key != shards::Quadrilateral<>::key)    &&
00104                             (cellTopology.getBaseTopology()->key != shards::Tetrahedron<>::key)      &&
00105                             (cellTopology.getBaseTopology()->key != shards::Hexahedron<>::key)       &&
00106                             (cellTopology.getBaseTopology()->key != shards::Wedge<>::key) ),
00107                           std::invalid_argument,
00108                           ">>> ERROR (DefaultCubatureFactory): Invalid cell topology prevents cubature creation.");
00109   }
00110 
00111   return pickCubature;
00112 }
00113 
00114 
00115 
00116 // second create method
00117 template<class Scalar, class ArrayPoint, class ArrayWeight>
00118 Teuchos::RCP<Cubature<Scalar,ArrayPoint,ArrayWeight> > DefaultCubatureFactory<Scalar,ArrayPoint,ArrayWeight>::create(
00119   const shards::CellTopology & cellTopology, int degree) {
00120   std::vector<int> d(3);
00121   d[0] = degree; d[1] = degree; d[2] = degree;
00122   return create(cellTopology, d);
00123 }
00124 
00125 
00126 } // namespace Intrepid