Intrepid2
Intrepid2_CubatureDirect.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Intrepid2 Package
4//
5// Copyright 2007 NTESS and the Intrepid2 contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
16#ifndef __INTREPID2_CUBATURE_DIRECT_HPP__
17#define __INTREPID2_CUBATURE_DIRECT_HPP__
18
19#include "Intrepid2_ConfigDefs.hpp"
21
22namespace Intrepid2 {
23
40 template<typename DeviceType = void,
41 typename pointValueType = double,
42 typename weightValueType = double>
44 : public Cubature<DeviceType,pointValueType,weightValueType> {
45 protected:
46
64
68 struct CubatureData {
69
72 ordinal_type numPoints_;
73
76 Kokkos::DynRankView<pointValueType,DeviceType> points_;
77
80 Kokkos::DynRankView<weightValueType,DeviceType> weights_;
81
82 };
83
87 ordinal_type degree_;
88
91 ordinal_type dimension_;
92
96
103 template<typename cubPointValueType, class ...cubPointProperties,
104 typename cubWeightValueType, class ...cubWeightProperties>
105 void
106 getCubatureFromData( Kokkos::DynRankView<cubPointValueType, cubPointProperties...> cubPoints,
107 Kokkos::DynRankView<cubWeightValueType,cubWeightProperties...> cubWeights,
108 const CubatureData cubData) const {
109#ifdef HAVE_INTREPID2_DEBUG
110 // check size of cubPoints and cubWeights
111 INTREPID2_TEST_FOR_EXCEPTION( rank(cubPoints) != 2, std::invalid_argument,
112 ">>> ERROR (CubatureDirect): cubPoints must be rank 2." );
113
114 INTREPID2_TEST_FOR_EXCEPTION( rank(cubWeights) != 1, std::invalid_argument,
115 ">>> ERROR (CubatureDirect): cubPoints must be rank 1." );
116
117 INTREPID2_TEST_FOR_EXCEPTION( static_cast<ordinal_type>(cubPoints.extent(0)) < this->getNumPoints() ||
118 static_cast<ordinal_type>(cubPoints.extent(1)) < this->getDimension(), std::out_of_range,
119 ">>> ERROR (CubatureDirect): Insufficient space allocated for cubature points.");
120
121 INTREPID2_TEST_FOR_EXCEPTION( static_cast<ordinal_type>(cubWeights.extent(0)) < this->getNumPoints(), std::out_of_range,
122 ">>> ERROR (CubatureDirect): Insufficient space allocated for cubature weights.");
123#endif
124 // need subview here
125 typedef Kokkos::pair<ordinal_type,ordinal_type> range_type;
126
127 range_type pointRange(0, this->getNumPoints());
128 range_type dimRange (0, this->getDimension());
129 {
130 const auto src = Kokkos::subdynrankview(cubData.points_, pointRange, dimRange);
131 auto dst = Kokkos::subdynrankview(cubPoints, pointRange, dimRange);
132
133 Kokkos::deep_copy( dst, src );
134 }
135 {
136 const auto src = Kokkos::subdynrankview(cubData.weights_, pointRange);
137 auto dst = Kokkos::subdynrankview(cubWeights, pointRange);
138
139 Kokkos::deep_copy(dst ,src);
140 }
141 }
142
143 public:
144
145 //
146 // Cubature public functions
147 //
148 typedef typename Cubature<DeviceType,pointValueType,weightValueType>::PointViewType PointViewType;
149 typedef typename Cubature<DeviceType,pointValueType,weightValueType>::weightViewType weightViewType;
150
151 using Cubature<DeviceType,pointValueType,weightValueType>::getCubature;
152
153 virtual
154 void
155 getCubature( PointViewType cubPoints,
156 weightViewType cubWeights ) const override {
157 this->getCubatureFromData(cubPoints, cubWeights, this->cubatureData_);
158 }
159
162 virtual
163 ordinal_type
164 getNumPoints() const override {
166 }
167
170 virtual
171 ordinal_type
172 getDimension() const override {
173 return dimension_;
174 }
175
178 virtual
179 const char*
180 getName() const override {
181 return "CubatureDirect";
182 }
183
187 virtual
188 ordinal_type
189 getAccuracy() const override {
190 return degree_;
191 }
192
194 : degree_(),
195 dimension_(),
196 cubatureData_() {}
197
198 CubatureDirect(const CubatureDirect &b)
199 : degree_(b.degree_),
202
203 CubatureDirect& operator=(const CubatureDirect &b) {
204 this->degree_ = b.degree_;
205 this->dimension_ = b.dimension_;
206 this->cubatureData_ = b.cubatureData_;
207 return *this;
208 }
209
210 CubatureDirect(const ordinal_type degree,
211 const ordinal_type dimension)
212 : degree_(degree),
213 dimension_(dimension),
214 cubatureData_() {}
215
216 };
217
218} // end namespace Intrepid2
219
220
221#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 void getCubature(PointViewType cubPoints, weightViewType cubWeights) const override
Returns cubature points and weights (return arrays must be pre-sized/pre-allocated).
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.