Intrepid2
Intrepid2_CubatureDirect.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_DIRECT_HPP__
50 #define __INTREPID2_CUBATURE_DIRECT_HPP__
51 
52 #include "Intrepid2_ConfigDefs.hpp"
53 #include "Intrepid2_Cubature.hpp"
54 
55 namespace Intrepid2 {
56 
73  template<typename DeviceType = void,
74  typename pointValueType = double,
75  typename weightValueType = double>
77  : public Cubature<DeviceType,pointValueType,weightValueType> {
78  protected:
79 
84 
87  ordinal_type numPoints_;
88 
92 
96  };
97 
101  struct CubatureData {
102 
105  ordinal_type numPoints_;
106 
109  Kokkos::DynRankView<pointValueType,DeviceType> points_;
110 
113  Kokkos::DynRankView<weightValueType,DeviceType> weights_;
114 
115  };
116 
120  ordinal_type degree_;
121 
124  ordinal_type dimension_;
125 
129 
136  template<typename cubPointValueType, class ...cubPointProperties,
137  typename cubWeightValueType, class ...cubWeightProperties>
138  void
139  getCubatureFromData( Kokkos::DynRankView<cubPointValueType, cubPointProperties...> cubPoints,
140  Kokkos::DynRankView<cubWeightValueType,cubWeightProperties...> cubWeights,
141  const CubatureData cubData) const {
142 #ifdef HAVE_INTREPID2_DEBUG
143  // check size of cubPoints and cubWeights
144  INTREPID2_TEST_FOR_EXCEPTION( cubPoints.rank() != 2, std::invalid_argument,
145  ">>> ERROR (CubatureDirect): cubPoints must be rank 2." );
146 
147  INTREPID2_TEST_FOR_EXCEPTION( cubWeights.rank() != 1, std::invalid_argument,
148  ">>> ERROR (CubatureDirect): cubPoints must be rank 1." );
149 
150  INTREPID2_TEST_FOR_EXCEPTION( static_cast<ordinal_type>(cubPoints.extent(0)) < this->getNumPoints() ||
151  static_cast<ordinal_type>(cubPoints.extent(1)) < this->getDimension(), std::out_of_range,
152  ">>> ERROR (CubatureDirect): Insufficient space allocated for cubature points.");
153 
154  INTREPID2_TEST_FOR_EXCEPTION( static_cast<ordinal_type>(cubWeights.extent(0)) < this->getNumPoints(), std::out_of_range,
155  ">>> ERROR (CubatureDirect): Insufficient space allocated for cubature weights.");
156 #endif
157  // need subview here
158  typedef Kokkos::pair<ordinal_type,ordinal_type> range_type;
159 
160  range_type pointRange(0, this->getNumPoints());
161  range_type dimRange (0, this->getDimension());
162  {
163  const auto src = Kokkos::subdynrankview(cubData.points_, pointRange, dimRange);
164  auto dst = Kokkos::subdynrankview(cubPoints, pointRange, dimRange);
165 
166  Kokkos::deep_copy( dst, src );
167  }
168  {
169  const auto src = Kokkos::subdynrankview(cubData.weights_, pointRange);
170  auto dst = Kokkos::subdynrankview(cubWeights, pointRange);
171 
172  Kokkos::deep_copy(dst ,src);
173  }
174  }
175 
176  public:
177 
178  //
179  // Cubature public functions
180  //
181  typedef typename Cubature<DeviceType,pointValueType,weightValueType>::PointViewType PointViewType;
182  typedef typename Cubature<DeviceType,pointValueType,weightValueType>::weightViewType weightViewType;
183 
185 
186  virtual
187  void
188  getCubature( PointViewType cubPoints,
189  weightViewType cubWeights ) const override {
190  this->getCubatureFromData(cubPoints, cubWeights, this->cubatureData_);
191  }
192 
195  virtual
196  ordinal_type
197  getNumPoints() const override {
198  return cubatureData_.numPoints_;
199  }
200 
203  virtual
204  ordinal_type
205  getDimension() const override {
206  return dimension_;
207  }
208 
211  virtual
212  const char*
213  getName() const override {
214  return "CubatureDirect";
215  }
216 
220  virtual
221  ordinal_type
222  getAccuracy() const override {
223  return degree_;
224  }
225 
227  : degree_(),
228  dimension_(),
229  cubatureData_() {}
230 
231  CubatureDirect(const CubatureDirect &b)
232  : degree_(b.degree_),
235 
236  CubatureDirect(const ordinal_type degree,
237  const ordinal_type dimension)
238  : degree_(degree),
239  dimension_(dimension),
240  cubatureData_() {}
241 
242  };
243 
244 } // end namespace Intrepid2
245 
246 
247 #endif
Header file for the Intrepid2::Cubature class.
Defines direct cubature (integration) rules in Intrepid.
void getCubatureFromData(Kokkos::DynRankView< cubPointValueType, cubPointProperties... > cubPoints, Kokkos::DynRankView< cubWeightValueType, cubWeightProperties... > cubWeights, const CubatureData cubData) const
Returns cubature points and weights.
virtual ordinal_type getAccuracy() const override
Returns max. degree of polynomials that are integrated exactly. The return vector has size 1.
ordinal_type dimension_
Dimension of integration domain.
CubatureData cubatureData_
Cubature data on device.
virtual const char * getName() const override
Returns cubature name.
ordinal_type degree_
The degree of polynomials that are integrated exactly by this cubature rule.
virtual ordinal_type getDimension() const override
Returns dimension of integration domain.
virtual ordinal_type getNumPoints() const override
Returns the number of cubature points.
Defines the base class for cubature (integration) rules in Intrepid.
static constexpr ordinal_type MaxIntegrationPoints
The maximum number of integration points for direct cubature rules.
static constexpr ordinal_type MaxDimension
The maximum ambient space dimension.
Cubature data is defined on the host space and is static.
weightValueType weights_[Parameters::MaxIntegrationPoints]
Array with the associated cubature weights.
ordinal_type numPoints_
Number of cubature points stored in the template.
pointValueType points_[Parameters::MaxIntegrationPoints][Parameters::MaxDimension]
Array with the (X,Y,Z) coordinates of the cubature points.
Cubature data is defined on exec space and deep-copied when an object is created.
Kokkos::DynRankView< pointValueType, DeviceType > points_
Array with the (X,Y,Z) coordinates of the cubature points.
ordinal_type numPoints_
Number of cubature points stored in the template.
Kokkos::DynRankView< weightValueType, DeviceType > weights_
Array with the associated cubature weights.