16 #ifndef __INTREPID2_CUBATURE_TENSOR_DEF_HPP__
17 #define __INTREPID2_CUBATURE_TENSOR_DEF_HPP__
21 template<
typename DT,
typename PT,
typename WT>
22 template<
typename cubPointValueType,
class ...cubPointProperties,
23 typename cubWeightValueType,
class ...cubWeightProperties>
26 getCubatureImpl( Kokkos::DynRankView<cubPointValueType, cubPointProperties...> cubPoints,
27 Kokkos::DynRankView<cubWeightValueType,cubWeightProperties...> cubWeights )
const {
28 #ifdef HAVE_INTREPID2_DEBUG
30 INTREPID2_TEST_FOR_EXCEPTION( static_cast<ordinal_type>(cubPoints.extent(0)) < this->getNumPoints() ||
31 static_cast<ordinal_type
>(cubPoints.extent(1)) < this->getDimension() ||
32 static_cast<ordinal_type
>(cubWeights.extent(0)) < this->getNumPoints(), std::out_of_range,
33 ">>> ERROR (CubatureTensor): Insufficient space allocated for cubature points or weights.");
35 using cubPointViewType = Kokkos::DynRankView<cubPointValueType, DT>;
36 using cubWeightViewType = Kokkos::DynRankView<cubWeightValueType,DT>;
44 for (
auto k=0;k<this->numCubatures_;++k) {
45 const auto &cub = this->cubatures_[k];
46 tmpPoints [k] = cubPointViewType (
"CubatureTensor::getCubature::tmpPoints", cub.getNumPoints(), cub.getDimension());
47 tmpWeights[k] = cubWeightViewType(
"CubatureTensor::getCubature::tmpWeights", cub.getNumPoints());
48 cub.getCubature(tmpPoints[k], tmpWeights[k]);
55 for (
auto k=0;k<this->numCubatures_;++k) {
56 offset[k+1] = offset[k] + this->cubatures_[k].getDimension();
58 ordinal_type ii = 0, i[3] = {};
60 cubPointViewType cubPoints_device(
"cubPoints_device", cubPoints.extent(0), cubPoints.extent(1));
61 cubWeightViewType cubWeights_device(
"cubWeights_device", cubWeights.extent(0));
63 auto cubPoints_host = Kokkos::create_mirror_view(Kokkos::HostSpace(), cubPoints_device);
64 auto cubWeights_host = Kokkos::create_mirror_view(Kokkos::HostSpace(), cubWeights_device);
66 Kokkos::deep_copy(cubPoints_host, 0.0);
67 Kokkos::deep_copy(cubWeights_host, 1.0);
69 switch (this->numCubatures_) {
71 const ordinal_type npts[] = { this->cubatures_[0].getNumPoints(), this->cubatures_[1].getNumPoints() };
72 const ordinal_type dim [] = { this->cubatures_[0].getDimension(), this->cubatures_[1].getDimension() };
75 typename cubWeightViewType::HostMirror tmpWeights_host[2];
76 tmpWeights_host[0] = Kokkos::create_mirror_view(tmpWeights[0]);
77 tmpWeights_host[1] = Kokkos::create_mirror_view(tmpWeights[1]);
78 Kokkos::deep_copy(tmpWeights_host[0], tmpWeights[0]);
79 Kokkos::deep_copy(tmpWeights_host[1], tmpWeights[1]);
81 typename cubPointViewType::HostMirror tmpPoints_host[2];
82 tmpPoints_host[0] = Kokkos::create_mirror_view(tmpPoints[0]);
83 tmpPoints_host[1] = Kokkos::create_mirror_view(tmpPoints[1]);
85 Kokkos::deep_copy(tmpPoints_host[0], tmpPoints[0]);
86 Kokkos::deep_copy(tmpPoints_host[1], tmpPoints[1]);
88 for (i[1]=0;i[1]<npts[1];++i[1])
89 for (i[0]=0;i[0]<npts[0];++i[0]) {
90 for (
auto nc=0;nc<2;++nc) {
91 cubWeights_host(ii) *= tmpWeights_host[nc](i[nc]);
92 for (ordinal_type j=0;j<dim[nc];++j)
93 cubPoints_host(ii, offset[nc]+j) = tmpPoints_host[nc](i[nc], j);
100 const ordinal_type npts[] = { this->cubatures_[0].getNumPoints(), this->cubatures_[1].getNumPoints(), this->cubatures_[2].getNumPoints() };
101 const ordinal_type dim [] = { this->cubatures_[0].getDimension(), this->cubatures_[1].getDimension(), this->cubatures_[2].getDimension() };
104 typename cubWeightViewType::HostMirror tmpWeights_host[3];
105 tmpWeights_host[0] = Kokkos::create_mirror_view(tmpWeights[0]);
106 tmpWeights_host[1] = Kokkos::create_mirror_view(tmpWeights[1]);
107 tmpWeights_host[2] = Kokkos::create_mirror_view(tmpWeights[2]);
109 Kokkos::deep_copy(tmpWeights_host[0], tmpWeights[0]);
110 Kokkos::deep_copy(tmpWeights_host[1], tmpWeights[1]);
111 Kokkos::deep_copy(tmpWeights_host[2], tmpWeights[2]);
113 typename cubPointViewType::HostMirror tmpPoints_host[3];
114 tmpPoints_host[0] = Kokkos::create_mirror_view(tmpPoints[0]);
115 tmpPoints_host[1] = Kokkos::create_mirror_view(tmpPoints[1]);
116 tmpPoints_host[2] = Kokkos::create_mirror_view(tmpPoints[2]);
118 Kokkos::deep_copy(tmpPoints_host[0], tmpPoints[0]);
119 Kokkos::deep_copy(tmpPoints_host[1], tmpPoints[1]);
120 Kokkos::deep_copy(tmpPoints_host[2], tmpPoints[2]);
122 for (i[2]=0;i[2]<npts[2];++i[2])
123 for (i[1]=0;i[1]<npts[1];++i[1])
124 for (i[0]=0;i[0]<npts[0];++i[0]) {
125 for (
auto nc=0;nc<3;++nc) {
126 cubWeights_host(ii) *= tmpWeights_host[nc](i[nc]);
127 for (ordinal_type j=0;j<dim[nc];++j)
128 cubPoints_host(ii, offset[nc]+j) = tmpPoints_host[nc](i[nc], j);
135 INTREPID2_TEST_FOR_EXCEPTION( !(this->numCubatures_ == 2 || this->numCubatures_ == 3), std::runtime_error,
136 ">>> ERROR (CubatureTensor::getCubature): CubatureTensor supports only 2 or 3 component direct cubatures.");
139 Kokkos::deep_copy(cubPoints_device, cubPoints_host);
140 Kokkos::deep_copy(cubWeights_device, cubWeights_host);
142 Kokkos::deep_copy(cubPoints, cubPoints_device);
143 Kokkos::deep_copy(cubWeights, cubWeights_device);
void getCubatureImpl(Kokkos::DynRankView< cubPointValueType, cubPointProperties...> cubPoints, Kokkos::DynRankView< cubWeightValueType, cubWeightProperties...> cubWeights) const
static constexpr ordinal_type MaxTensorComponents
Maximum number of tensor/Cartesian products that can be taken: this allows hypercube basis in 7D to b...