Intrepid2
Intrepid2_CubatureTensor.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_TENSOR_HPP__
17 #define __INTREPID2_CUBATURE_TENSOR_HPP__
18 
19 #include "Intrepid2_ConfigDefs.hpp"
20 #include "Intrepid2_Cubature.hpp"
22 
23 namespace Intrepid2 {
24 
28  template<typename DeviceType = void,
29  typename pointValueType = double,
30  typename weightValueType = double>
32  : public Cubature<DeviceType,pointValueType,weightValueType> {
33  private:
34 
37  ordinal_type numCubatures_;
38 
40 
43  ordinal_type dimension_;
44 
45  public:
46 
47  template<typename cubPointValueType, class ...cubPointProperties,
48  typename cubWeightValueType, class ...cubWeightProperties>
49  void
50  getCubatureImpl( Kokkos::DynRankView<cubPointValueType, cubPointProperties...> cubPoints,
51  Kokkos::DynRankView<cubWeightValueType,cubWeightProperties...> cubWeights ) const;
52 
53  using PointViewType = typename Cubature<DeviceType,pointValueType,weightValueType>::PointViewType;
54  using weightViewType = typename Cubature<DeviceType,pointValueType,weightValueType>::weightViewType;
55 
57  using PointViewTypeAllocatable = typename Cubature<DeviceType,pointValueType,weightValueType>::PointViewTypeAllocatable;
58  using WeightViewTypeAllocatable = typename Cubature<DeviceType,pointValueType,weightValueType>::WeightViewTypeAllocatable;
61 
63 
64  virtual
65  void
66  getCubature( PointViewType cubPoints,
67  weightViewType cubWeights ) const override {
68  getCubatureImpl( cubPoints,
69  cubWeights );
70  }
71 
77  {
78  std::vector< PointViewTypeAllocatable > cubaturePointComponents(numCubatures_);
79 
80  for (ordinal_type i=0;i<numCubatures_;++i)
81  {
82  cubaturePointComponents[i] = PointViewTypeAllocatable("cubature points", cubatures_[i].getNumPoints(), cubatures_[i].getDimension());
83  }
84 
85  return TensorPointDataType(cubaturePointComponents);
86  }
87 
93  {
94  using WeightDataType = Data<weightValueType,DeviceType>;
95 
96  std::vector< WeightDataType > cubatureWeightComponents(numCubatures_);
97  for (ordinal_type i=0;i<numCubatures_;++i)
98  {
99  cubatureWeightComponents[i] = WeightDataType(WeightViewTypeAllocatable("cubature weights", cubatures_[i].getNumPoints()));
100  }
101 
102  return TensorWeightDataType(cubatureWeightComponents);
103  }
104 
110  virtual
111  void
112  getCubature( const TensorPointDataType & tensorCubPoints,
113  const TensorWeightDataType & tensorCubWeights) const override {
114  for (ordinal_type i=0;i<numCubatures_;++i)
115  {
116  cubatures_[i].getCubature(tensorCubPoints.getTensorComponent(i), tensorCubWeights.getTensorComponent(i).getUnderlyingView());
117  }
118  }
119 
122  virtual
123  ordinal_type
124  getNumPoints() const override {
125  ordinal_type numCubPoints = 1;
126  for (ordinal_type i=0;i<numCubatures_;++i)
127  numCubPoints *= cubatures_[i].getNumPoints();
128  return numCubPoints;
129  }
130 
133  virtual
134  ordinal_type
135  getDimension() const override {
136  return dimension_;
137  }
138 
141  virtual
142  const char*
143  getName() const override {
144  return "CubatureTensor";
145  }
146 
147  virtual
148  ordinal_type
149  getAccuracy() const override {
150  ordinal_type r_val = 0;
151  for (ordinal_type i=0;i<numCubatures_;++i)
152  r_val = Util<ordinal_type>::max(r_val, cubatures_[i].getAccuracy());
153  return r_val;
154  }
155 
158  ordinal_type getNumCubatures() const {
159  return numCubatures_;
160  }
161 
165  return cubatures_[i];
166  }
167 
170  void getAccuracy( ordinal_type *accuracy ) const {
171  for (ordinal_type i=0;i<numCubatures_;++i)
172  accuracy[i] = cubatures_[i].getAccuracy();
173  }
174 
175  CubatureTensor()
176  : numCubatures_(0),
177  dimension_(0) {}
178 
179  CubatureTensor(const CubatureTensor &b)
182  for (ordinal_type i=0;i<numCubatures_;++i)
183  cubatures_[i] = b.cubatures_[i];
184  }
185 
191  template<typename CubatureType0,
192  typename CubatureType1>
193  CubatureTensor( const CubatureType0 cubature0,
194  const CubatureType1 cubature1 )
195  : numCubatures_(2),
196  dimension_(cubature0.getDimension()+cubature1.getDimension()) {
197  cubatures_[0] = cubature0;
198  cubatures_[1] = cubature1;
199  }
200 
207  template<typename CubatureType0,
208  typename CubatureType1,
209  typename CubatureType2>
210  CubatureTensor( const CubatureType0 cubature0,
211  const CubatureType1 cubature1,
212  const CubatureType2 cubature2 )
213  : numCubatures_(3),
214  dimension_(cubature0.getDimension()+cubature1.getDimension()+cubature2.getDimension()) {
215  cubatures_[0] = cubature0;
216  cubatures_[1] = cubature1;
217  cubatures_[2] = cubature2;
218  }
219 
225  template<typename DirectCubature>
226  CubatureTensor( const CubatureTensor cubatureTensor,
227  const DirectCubature cubatureExtension )
228  : numCubatures_(cubatureTensor.getNumCubatures()+1),
229  dimension_(cubatureTensor.getDimension()+cubatureExtension.getDimension()) {
230  for (ordinal_type i=0;i<cubatureTensor.getNumCubatures();++i)
231  cubatures_[i] = cubatureTensor.cubatures_[i];
232  cubatures_[cubatureTensor.getNumCubatures()] = cubatureExtension;
233  }
234  };
235 
236 
237 } // end namespace Intrepid2
238 
239 
240 // include templated definitions
242 
243 #endif
Defines the base class for cubature (integration) rules in Intrepid.
virtual ordinal_type getAccuracy() const override
Returns dimension of the integration domain.
small utility functions
View-like interface to tensor points; point components are stored separately; the appropriate coordin...
typename Cubature< DeviceType, pointValueType, weightValueType >::PointViewTypeAllocatable PointViewTypeAllocatable
KK: following should be updated with nate&#39;s tensor work.
ordinal_type getNumCubatures() const
Return the number of cubatures.
KOKKOS_INLINE_FUNCTION enable_if_t< rank==1, const Kokkos::View< typename RankExpander< DataScalar, rank >::value_type, DeviceType > & > getUnderlyingView() const
Returns the underlying view. Throws an exception if the underlying view is not rank 1...
Defines tensor-product cubature (integration) rules in Intrepid.
virtual ordinal_type getDimension() const override
Returns dimension of integration domain.
CubatureTensor(const CubatureTensor cubatureTensor, const DirectCubature cubatureExtension)
Constructor for extending an existing CubatureTensor object with an additional direct cubature rule...
Wrapper around a Kokkos::View that allows data that is constant or repeating in various logical dimen...
ordinal_type numCubatures_
Array of cubature rules.
void getAccuracy(ordinal_type *accuracy) const
Returns max. degree of polynomials that are integrated exactly.
KOKKOS_INLINE_FUNCTION const Data< Scalar, DeviceType > & getTensorComponent(const ordinal_type &r) const
Returns the requested tensor component.
virtual ordinal_type getNumPoints() const override
Returns the number of cubature points.
virtual void getCubature(const TensorPointDataType &tensorCubPoints, const TensorWeightDataType &tensorCubWeights) const override
Returns tensor cubature points and weights. For non-tensor cubatures, the tensor structures are trivi...
void getCubatureImpl(Kokkos::DynRankView< cubPointValueType, cubPointProperties...> cubPoints, Kokkos::DynRankView< cubWeightValueType, cubWeightProperties...> cubWeights) const
CubatureTensor(const CubatureType0 cubature0, const CubatureType1 cubature1)
Constructor.
Header file for the Intrepid2::Cubature class.
virtual TensorWeightDataType allocateCubatureWeights() const override
Returns a weight container appropriate for passing to getCubature().
CubatureDirect< DeviceType, pointValueType, weightValueType > getCubatureComponent(ordinal_type i) const
Return the number of cubatures.
virtual void getCubature(PointViewType cubPoints, weightViewType cubWeights) const override
Returns cubature points and weights (return arrays must be pre-sized/pre-allocated).
ordinal_type dimension_
Dimension of integration domain.
virtual const char * getName() const override
Returns cubature name.
Definition file for the Intrepid2::CubatureTensor class.
Defines direct cubature (integration) rules in Intrepid.
View-like interface to tensor data; tensor components are stored separately and multiplied together a...
virtual TensorPointDataType allocateCubaturePoints() const override
Returns a points container appropriate for passing to getCubature().
KOKKOS_INLINE_FUNCTION ScalarView< PointScalar, DeviceType > getTensorComponent(const ordinal_type &r) const
Returns the requested tensor component.
Header file for the Intrepid2::CubatureDirect class.
static constexpr ordinal_type MaxTensorComponents
Maximum number of tensor/Cartesian products that can be taken: this allows hypercube basis in 7D to b...
CubatureTensor(const CubatureType0 cubature0, const CubatureType1 cubature1, const CubatureType2 cubature2)
Constructor.