Intrepid2
Intrepid2_CubatureTensorPyr.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_PYR_HPP__
17 #define __INTREPID2_CUBATURE_TENSOR_PYR_HPP__
18 
20 
21 namespace Intrepid2 {
22 
26  template<typename DeviceType = void,
27  typename pointValueType = double,
28  typename weightValueType = double>
30  : public CubatureTensor<DeviceType,pointValueType,weightValueType> {
31  public:
32  using TensorPointDataType = typename CubatureTensor<DeviceType,pointValueType,weightValueType>::TensorPointDataType;
33  using TensorWeightDataType = typename CubatureTensor<DeviceType,pointValueType,weightValueType>::TensorWeightDataType;
35  using WeightViewTypeAllocatable = typename CubatureTensor<DeviceType,pointValueType,weightValueType>::WeightViewTypeAllocatable;
36 
37  template<typename cubPointViewType,
38  typename cubWeightViewType>
39  struct Functor {
40  cubPointViewType _cubPoints;
41  cubWeightViewType _cubWeights;
42 
43  KOKKOS_INLINE_FUNCTION
44  Functor( cubPointViewType cubPoints_,
45  cubWeightViewType cubWeights_)
46  : _cubPoints(cubPoints_), _cubWeights(cubWeights_) {}
47 
48  KOKKOS_INLINE_FUNCTION
49  void operator()(const ordinal_type i) const {
50  const auto tmp = 0.5*(1.0 - _cubPoints(i,2));
51  _cubPoints(i,0) *= tmp;
52  _cubPoints(i,1) *= tmp;
53  _cubPoints(i,2) = 1.0 - tmp;
54 
55  _cubWeights(i) /= 8.0; // when line jacobi20 is used (exact)
56  //_cubWeights(i) *= (tmp*tmp*.5); // when gauss integration rule is used (need over-integration)
57  }
58  };
59 
60  template<typename cubPointValueType, class ...cubPointProperties,
61  typename cubWeightValueType, class ...cubWeightProperties>
62  void
63  getCubatureImpl( Kokkos::DynRankView<cubPointValueType, cubPointProperties...> cubPoints,
64  Kokkos::DynRankView<cubWeightValueType,cubWeightProperties...> cubWeights ) const;
65 
66  using typename Cubature<DeviceType,pointValueType,weightValueType>::PointViewType;
67  using typename Cubature<DeviceType,pointValueType,weightValueType>::weightViewType;
68 
70  using typename CubatureTensor<DeviceType,pointValueType,weightValueType>::ExecSpaceType;
71 
72  virtual
73  void
74  getCubature( PointViewType cubPoints,
75  weightViewType cubWeights ) const override {
76  getCubatureImpl( cubPoints,
77  cubWeights );
78  }
79 
81  : CubatureTensor<DeviceType,pointValueType,weightValueType>() {}
82 
83  CubatureTensorPyr(const CubatureTensorPyr &b)
84  : CubatureTensor<DeviceType,pointValueType,weightValueType>(b) {}
85 
86  template<typename CubatureLineType>
87  CubatureTensorPyr( const CubatureLineType line )
88  : CubatureTensor<DeviceType,pointValueType,weightValueType>(line, line, line) {}
89 
90  template<typename CubatureLineType0,
91  typename CubatureLineType1,
92  typename CubatureLineType2>
93  CubatureTensorPyr( const CubatureLineType0 line0,
94  const CubatureLineType1 line1,
95  const CubatureLineType2 line2 )
96  : CubatureTensor<DeviceType,pointValueType,weightValueType>(line0, line1, line2) {}
97 
98 
104  {
105  std::vector< PointViewTypeAllocatable > cubaturePointComponents(1);
106 
107  int numCubatures = this->getNumCubatures();
108  int numPoints = 1;
109  for (ordinal_type i=0;i<numCubatures;++i)
110  {
111  numPoints *= this->getCubatureComponent(i).getNumPoints();
112  }
113 
114  const int dim = 3;
115  cubaturePointComponents[0] = PointViewTypeAllocatable("cubature points", numPoints, dim);
116 
117  return TensorPointDataType(cubaturePointComponents);
118  }
119 
125  {
126  using WeightDataType = Data<weightValueType,DeviceType>;
127 
128  std::vector< WeightDataType > cubatureWeightComponents(1);
129  int numPoints = 1;
130  int numCubatures = this->getNumCubatures();
131  for (ordinal_type i=0;i<numCubatures;++i)
132  {
133  numPoints *= this->getCubatureComponent(i).getNumPoints();
134  }
135 
136  cubatureWeightComponents[0] = WeightDataType(WeightViewTypeAllocatable("cubature weights", numPoints));
137 
138  return TensorWeightDataType(cubatureWeightComponents);
139  }
140 
146  virtual
147  void
148  getCubature( const TensorPointDataType & tensorCubPoints,
149  const TensorWeightDataType & tensorCubWeights) const override {
150  // tensorCubPoints/Weights should have trivial tensor structure
151  auto points = tensorCubPoints.getTensorComponent(0);
152  auto weights = tensorCubWeights.getTensorComponent(0).getUnderlyingView();
153  this->getCubature(points,weights);
154  }
155  };
156 }
157 
159 
160 #endif
virtual TensorWeightDataType allocateCubatureWeights() const override
Returns a weight container appropriate for passing to getCubature().
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.
Defines tensor-product cubature (integration) rules in Intrepid.
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.
Wrapper around a Kokkos::View that allows data that is constant or repeating in various logical dimen...
KOKKOS_INLINE_FUNCTION const Data< Scalar, DeviceType > & getTensorComponent(const ordinal_type &r) const
Returns the requested tensor component.
virtual void getCubature(PointViewType cubPoints, weightViewType cubWeights) const override
Returns cubature points and weights (return arrays must be pre-sized/pre-allocated).
CubatureDirect< DeviceType, pointValueType, weightValueType > getCubatureComponent(ordinal_type i) const
Return the number of cubatures.
virtual TensorPointDataType allocateCubaturePoints() const override
Returns a points container appropriate for passing to getCubature().
Definition file for the Intrepid2::CubatureTensorPyr class.
Header file for the Intrepid2::CubatureTensor class.
View-like interface to tensor data; tensor components are stored separately and multiplied together a...
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...
KOKKOS_INLINE_FUNCTION ScalarView< PointScalar, DeviceType > getTensorComponent(const ordinal_type &r) const
Returns the requested tensor component.