Intrepid2
Intrepid2_CubatureTensor.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ************************************************************************
3 //
4 // Intrepid2 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 Kyungjoo Kim (kyukim@sandia.gov), or
38 // Mauro Perego (mperego@sandia.gov)
39 //
40 // ************************************************************************
41 // @HEADER
42 
49 #ifndef __INTREPID2_CUBATURE_TENSOR_HPP__
50 #define __INTREPID2_CUBATURE_TENSOR_HPP__
51 
52 #include "Intrepid2_ConfigDefs.hpp"
53 #include "Intrepid2_Cubature.hpp"
55 
56 namespace Intrepid2 {
57 
61  template<typename ExecSpaceType = void,
62  typename pointValueType = double,
63  typename weightValueType = double>
65  : public Cubature<ExecSpaceType,pointValueType,weightValueType> {
66  private:
67 
70  ordinal_type numCubatures_;
71 
73 
76  ordinal_type dimension_;
77 
78  public:
79 
80  template<typename cubPointValueType, class ...cubPointProperties,
81  typename cubWeightValueType, class ...cubWeightProperties>
82  void
83  getCubatureImpl( Kokkos::DynRankView<cubPointValueType, cubPointProperties...> cubPoints,
84  Kokkos::DynRankView<cubWeightValueType,cubWeightProperties...> cubWeights ) const;
85 
86  typedef typename Cubature<ExecSpaceType,pointValueType,weightValueType>::PointViewType PointViewType;
87  typedef typename Cubature<ExecSpaceType,pointValueType,weightValueType>::weightViewType weightViewType;
88 
90 
91  virtual
92  void
93  getCubature( PointViewType cubPoints,
94  weightViewType cubWeights ) const {
95  getCubatureImpl( cubPoints,
96  cubWeights );
97  }
98 
101  virtual
102  ordinal_type
103  getNumPoints() const {
104  ordinal_type numCubPoints = 1;
105  for (ordinal_type i=0;i<numCubatures_;++i)
106  numCubPoints *= cubatures_[i].getNumPoints();
107  return numCubPoints;
108  }
109 
112  virtual
113  ordinal_type
114  getDimension() const {
115  return dimension_;
116  }
117 
120  virtual
121  const char*
122  getName() const {
123  return "CubatureTensor";
124  }
125 
126  virtual
127  ordinal_type
128  getAccuracy() const {
129  ordinal_type r_val = 0;
130  for (ordinal_type i=0;i<numCubatures_;++i)
131  r_val = Util<ordinal_type>::max(r_val, cubatures_[i].getAccuracy());
132  return r_val;
133  }
134 
137  ordinal_type getNumCubatures() const {
138  return numCubatures_;
139  }
140 
143  void getAccuracy( ordinal_type *accuracy ) const {
144  for (ordinal_type i=0;i<numCubatures_;++i)
145  accuracy[i] = cubatures_[i].getAccuracy();
146  }
147 
148  CubatureTensor()
149  : numCubatures_(0),
150  dimension_(0) {}
151 
152  CubatureTensor(const CubatureTensor &b)
155  for (ordinal_type i=0;i<numCubatures_;++i)
156  cubatures_[i] = b.cubatures_[i];
157  }
158 
164  template<typename CubatureType0,
165  typename CubatureType1>
166  CubatureTensor( const CubatureType0 cubature0,
167  const CubatureType1 cubature1 )
168  : numCubatures_(2),
169  dimension_(cubature0.getDimension()+cubature1.getDimension()) {
170  cubatures_[0] = cubature0;
171  cubatures_[1] = cubature1;
172  }
173 
180  template<typename CubatureType0,
181  typename CubatureType1,
182  typename CubatureType2>
183  CubatureTensor( const CubatureType0 cubature0,
184  const CubatureType1 cubature1,
185  const CubatureType2 cubature2 )
186  : numCubatures_(3),
187  dimension_(cubature0.getDimension()+cubature1.getDimension()+cubature2.getDimension()) {
188  cubatures_[0] = cubature0;
189  cubatures_[1] = cubature1;
190  cubatures_[2] = cubature2;
191  }
192 
193  };
194 
195 
196 } // end namespace Intrepid2
197 
198 
199 // include templated definitions
201 
202 #endif
ordinal_type numCubatures_
Array of cubature rules.
Defines the base class for cubature (integration) rules in Intrepid.
static constexpr ordinal_type MaxDimension
The maximum ambient space dimension.
virtual ordinal_type getAccuracy() const
Returns dimension of the integration domain.
small utility functions
virtual ordinal_type getNumPoints() const
Returns the number of cubature points.
virtual ordinal_type getDimension() const
Returns dimension of integration domain.
CubatureTensor(const CubatureType0 cubature0, const CubatureType1 cubature1)
Constructor.
Defines tensor-product cubature (integration) rules in Intrepid.
ordinal_type dimension_
Dimension of integration domain.
ordinal_type getNumCubatures() const
Return the number of cubatures.
Header file for the Intrepid2::Cubature class.
void getAccuracy(ordinal_type *accuracy) const
Returns max. degree of polynomials that are integrated exactly.
CubatureTensor(const CubatureType0 cubature0, const CubatureType1 cubature1, const CubatureType2 cubature2)
Constructor.
virtual void getCubature(PointViewType cubPoints, weightViewType cubWeights) const
Returns cubature points and weights (return arrays must be pre-sized/pre-allocated).
Definition file for the Intrepid2::CubatureTensor class.
Defines direct cubature (integration) rules in Intrepid.
Header file for the Intrepid2::CubatureDirect class.
virtual const char * getName() const
Returns cubature name.