Intrepid
Intrepid_DefaultCubatureFactoryDef.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ************************************************************************
3 //
4 // Intrepid Package
5 // Copyright (2007) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Pavel Bochev (pbboche@sandia.gov)
38 // Denis Ridzal (dridzal@sandia.gov), or
39 // Kara Peterson (kjpeter@sandia.gov)
40 //
41 // ************************************************************************
42 // @HEADER
43 
49 namespace Intrepid {
50 
51 // first create method
52 template<class Scalar, class ArrayPoint, class ArrayWeight>
53 Teuchos::RCP<Cubature<Scalar,ArrayPoint,ArrayWeight> > DefaultCubatureFactory<Scalar,ArrayPoint,ArrayWeight>::create(
54  const shards::CellTopology & cellTopology,
55  const std::vector<int> & degree) {
56 
57  // Create generic cubature.
58  Teuchos::RCP<Cubature<Scalar,ArrayPoint,ArrayWeight> > pickCubature;
59 
60  switch (cellTopology.getBaseCellTopologyData()->key) {
61 
62  case shards::Line<>::key:
63  TEUCHOS_TEST_FOR_EXCEPTION( (degree.size() < 1), std::invalid_argument,
64  ">>> ERROR (DefaultCubatureFactory): Provided degree array is of insufficient length.");
65  pickCubature = Teuchos::rcp(new CubatureDirectLineGauss<Scalar,ArrayPoint,ArrayWeight>(degree[0]));
66  break;
67 
68  case shards::Triangle<>::key:
69  TEUCHOS_TEST_FOR_EXCEPTION( (degree.size() < 1), std::invalid_argument,
70  ">>> ERROR (DefaultCubatureFactory): Provided degree array is of insufficient length.");
71  pickCubature = Teuchos::rcp(new CubatureDirectTriDefault<Scalar,ArrayPoint,ArrayWeight>(degree[0]));
72  break;
73 
74  case shards::Quadrilateral<>::key:
75  TEUCHOS_TEST_FOR_EXCEPTION( (degree.size() < 2), std::invalid_argument,
76  ">>> ERROR (DefaultCubatureFactory): Provided degree array is of insufficient length.");
77  {
78  std::vector< Teuchos::RCP< Cubature<Scalar,ArrayPoint,ArrayWeight> > > lineCubs(2);
79  lineCubs[0] = Teuchos::rcp(new CubatureDirectLineGauss<Scalar,ArrayPoint,ArrayWeight>(degree[0]));
80  lineCubs[1] = Teuchos::rcp(new CubatureDirectLineGauss<Scalar,ArrayPoint,ArrayWeight>(degree[1]));
81  pickCubature = Teuchos::rcp(new CubatureTensor<Scalar,ArrayPoint,ArrayWeight>(lineCubs));
82  }
83  break;
84 
85  case shards::Tetrahedron<>::key:
86  if (cellTopology.getCellTopologyData()->key == shards::Tetrahedron<11>::key)
87  {
88  TEUCHOS_TEST_FOR_EXCEPTION( (degree.size() < 1), std::invalid_argument,
89  ">>> ERROR (DefaultCubatureFactory): Provided degree array is of insufficient length.");
90  pickCubature = Teuchos::rcp(new CubatureCompositeTet<Scalar,ArrayPoint,ArrayWeight>(degree[0]));
91  }
92  else
93  {
94  TEUCHOS_TEST_FOR_EXCEPTION( (degree.size() < 1), std::invalid_argument,
95  ">>> ERROR (DefaultCubatureFactory): Provided degree array is of insufficient length.");
96  pickCubature = Teuchos::rcp(new CubatureDirectTetDefault<Scalar,ArrayPoint,ArrayWeight>(degree[0]));
97  }
98  break;
99  case shards::Hexahedron<>::key:
100  TEUCHOS_TEST_FOR_EXCEPTION( (degree.size() < 3), std::invalid_argument,
101  ">>> ERROR (DefaultCubatureFactory): Provided degree array is of insufficient length.");
102  {
103  std::vector< Teuchos::RCP< Cubature<Scalar,ArrayPoint,ArrayWeight> > > lineCubs(3);
104  lineCubs[0] = Teuchos::rcp(new CubatureDirectLineGauss<Scalar,ArrayPoint,ArrayWeight>(degree[0]));
105  lineCubs[1] = Teuchos::rcp(new CubatureDirectLineGauss<Scalar,ArrayPoint,ArrayWeight>(degree[1]));
106  lineCubs[2] = Teuchos::rcp(new CubatureDirectLineGauss<Scalar,ArrayPoint,ArrayWeight>(degree[2]));
107  pickCubature = Teuchos::rcp(new CubatureTensor<Scalar,ArrayPoint,ArrayWeight>(lineCubs));
108  }
109  break;
110 
111  case shards::Wedge<>::key:
112  TEUCHOS_TEST_FOR_EXCEPTION( (degree.size() < 2), std::invalid_argument,
113  ">>> ERROR (DefaultCubatureFactory): Provided degree array is of insufficient length.")
114  {
115  std::vector< Teuchos::RCP< Cubature<Scalar,ArrayPoint,ArrayWeight> > > miscCubs(2);
116  miscCubs[0] = Teuchos::rcp(new CubatureDirectTriDefault<Scalar,ArrayPoint,ArrayWeight>(degree[0]));
117  miscCubs[1] = Teuchos::rcp(new CubatureDirectLineGauss<Scalar,ArrayPoint,ArrayWeight>(degree[1]));
118  pickCubature = Teuchos::rcp(new CubatureTensor<Scalar,ArrayPoint,ArrayWeight>(miscCubs));
119  }
120  break;
121 
122  default:
123  TEUCHOS_TEST_FOR_EXCEPTION( ( (cellTopology.getBaseCellTopologyData()->key != shards::Line<>::key) &&
124  (cellTopology.getBaseCellTopologyData()->key != shards::Triangle<>::key) &&
125  (cellTopology.getBaseCellTopologyData()->key != shards::Quadrilateral<>::key) &&
126  (cellTopology.getBaseCellTopologyData()->key != shards::Tetrahedron<>::key) &&
127  (cellTopology.getBaseCellTopologyData()->key != shards::Hexahedron<>::key) &&
128  (cellTopology.getBaseCellTopologyData()->key != shards::Wedge<>::key) ),
129  std::invalid_argument,
130  ">>> ERROR (DefaultCubatureFactory): Invalid cell topology prevents cubature creation.");
131  }
132 
133  return pickCubature;
134 }
135 
136 
137 
138 // second create method
139 template<class Scalar, class ArrayPoint, class ArrayWeight>
140 Teuchos::RCP<Cubature<Scalar,ArrayPoint,ArrayWeight> > DefaultCubatureFactory<Scalar,ArrayPoint,ArrayWeight>::create(
141  const shards::CellTopology & cellTopology, int degree) {
142  std::vector<int> d(3);
143  d[0] = degree; d[1] = degree; d[2] = degree;
144  return create(cellTopology, d);
145 }
146 
147 // third create method for polygons
148 template<class Scalar, class ArrayPoint, class ArrayWeight>
149 Teuchos::RCP<Cubature<Scalar,ArrayPoint,ArrayWeight> > DefaultCubatureFactory<Scalar,ArrayPoint,ArrayWeight>::create(const shards::CellTopology& cellTopology,
150  const ArrayPoint& cellVertices,
151  int degree){
152  return Teuchos::rcp(new CubaturePolygon<Scalar,ArrayPoint,ArrayWeight>(cellTopology,cellVertices, degree));
153 }
154 
155 
156 
157 
158 } // namespace Intrepid
Defines Gauss integration rules on a line.
Defines direct integration rules on a tetrahedron.
Defines direct integration rules on a triangle.
Teuchos::RCP< Cubature< Scalar, ArrayPoint, ArrayWeight > > create(const shards::CellTopology &cellTopology, const std::vector< int > &degree)
Factory method.
Defines integration rules for the composite tetrahedron.
Defines tensor-product cubature (integration) rules in Intrepid.