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  pickCubature = Teuchos::rcp(new CubatureDirectTetDefault<Scalar,ArrayPoint,ArrayWeight>(degree[0]));
92  }
93  else
94  {
95  TEUCHOS_TEST_FOR_EXCEPTION( (degree.size() < 1), std::invalid_argument,
96  ">>> ERROR (DefaultCubatureFactory): Provided degree array is of insufficient length.");
97  pickCubature = Teuchos::rcp(new CubatureDirectTetDefault<Scalar,ArrayPoint,ArrayWeight>(degree[0]));
98  }
99  break;
100  case shards::Hexahedron<>::key:
101  TEUCHOS_TEST_FOR_EXCEPTION( (degree.size() < 3), std::invalid_argument,
102  ">>> ERROR (DefaultCubatureFactory): Provided degree array is of insufficient length.");
103  {
104  std::vector< Teuchos::RCP< Cubature<Scalar,ArrayPoint,ArrayWeight> > > lineCubs(3);
105  lineCubs[0] = Teuchos::rcp(new CubatureDirectLineGauss<Scalar,ArrayPoint,ArrayWeight>(degree[0]));
106  lineCubs[1] = Teuchos::rcp(new CubatureDirectLineGauss<Scalar,ArrayPoint,ArrayWeight>(degree[1]));
107  lineCubs[2] = Teuchos::rcp(new CubatureDirectLineGauss<Scalar,ArrayPoint,ArrayWeight>(degree[2]));
108  pickCubature = Teuchos::rcp(new CubatureTensor<Scalar,ArrayPoint,ArrayWeight>(lineCubs));
109  }
110  break;
111 
112  case shards::Wedge<>::key:
113  TEUCHOS_TEST_FOR_EXCEPTION( (degree.size() < 2), std::invalid_argument,
114  ">>> ERROR (DefaultCubatureFactory): Provided degree array is of insufficient length.")
115  {
116  std::vector< Teuchos::RCP< Cubature<Scalar,ArrayPoint,ArrayWeight> > > miscCubs(2);
117  miscCubs[0] = Teuchos::rcp(new CubatureDirectTriDefault<Scalar,ArrayPoint,ArrayWeight>(degree[0]));
118  miscCubs[1] = Teuchos::rcp(new CubatureDirectLineGauss<Scalar,ArrayPoint,ArrayWeight>(degree[1]));
119  pickCubature = Teuchos::rcp(new CubatureTensor<Scalar,ArrayPoint,ArrayWeight>(miscCubs));
120  }
121  break;
122 
123  case shards::Pyramid<>::key:
124  TEUCHOS_TEST_FOR_EXCEPTION( (degree.size() < 3), std::invalid_argument,
125  ">>> ERROR (DefaultCubatureFactory): Provided degree array is of insufficient length.");
126  {
127  std::vector< Teuchos::RCP< Cubature<Scalar,ArrayPoint,ArrayWeight> > > lineCubs(3);
128  lineCubs[0] = Teuchos::rcp(new CubatureDirectLineGauss<Scalar,ArrayPoint,ArrayWeight>(degree[0]));
129  lineCubs[1] = Teuchos::rcp(new CubatureDirectLineGauss<Scalar,ArrayPoint,ArrayWeight>(degree[1]));
130  lineCubs[2] = Teuchos::rcp(new CubatureDirectLineGaussJacobi20<Scalar,ArrayPoint,ArrayWeight>(degree[2]));
131  pickCubature = Teuchos::rcp(new CubatureTensorPyr<Scalar,ArrayPoint,ArrayWeight>(lineCubs));
132  }
133  break;
134 
135  default:
136  TEUCHOS_TEST_FOR_EXCEPTION( ( (cellTopology.getBaseCellTopologyData()->key != shards::Line<>::key) &&
137  (cellTopology.getBaseCellTopologyData()->key != shards::Triangle<>::key) &&
138  (cellTopology.getBaseCellTopologyData()->key != shards::Quadrilateral<>::key) &&
139  (cellTopology.getBaseCellTopologyData()->key != shards::Tetrahedron<>::key) &&
140  (cellTopology.getBaseCellTopologyData()->key != shards::Hexahedron<>::key) &&
141  (cellTopology.getBaseCellTopologyData()->key != shards::Pyramid<>::key) &&
142  (cellTopology.getBaseCellTopologyData()->key != shards::Wedge<>::key) ),
143  std::invalid_argument,
144  ">>> ERROR (DefaultCubatureFactory): Invalid cell topology prevents cubature creation.");
145  }
146 
147  return pickCubature;
148 }
149 
150 
151 
152 // second create method
153 template<class Scalar, class ArrayPoint, class ArrayWeight>
154 Teuchos::RCP<Cubature<Scalar,ArrayPoint,ArrayWeight> > DefaultCubatureFactory<Scalar,ArrayPoint,ArrayWeight>::create(
155  const shards::CellTopology & cellTopology, int degree) {
156  std::vector<int> d(3);
157  d[0] = degree; d[1] = degree; d[2] = degree;
158  return create(cellTopology, d);
159 }
160 
161 // third create method for polygons
162 template<class Scalar, class ArrayPoint, class ArrayWeight>
163 Teuchos::RCP<Cubature<Scalar,ArrayPoint,ArrayWeight> > DefaultCubatureFactory<Scalar,ArrayPoint,ArrayWeight>::create(const shards::CellTopology& cellTopology,
164  const ArrayPoint& cellVertices,
165  int degree){
166  return Teuchos::rcp(new CubaturePolygon<Scalar,ArrayPoint,ArrayWeight>(cellTopology,cellVertices, degree));
167 }
168 
169 
170 
171 
172 } // namespace Intrepid
Defines Gauss integration rules on a line.
Defines direct integration rules on a tetrahedron.
Defines tensor-product cubature (integration) rules in Intrepid.
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 tensor-product cubature (integration) rules in Intrepid.
Defines GaussJacobi20 integration rules on a line.