49 #ifndef __INTREPID2_CUBATURE_CONTROLVOLUME_DEF_HPP__
50 #define __INTREPID2_CUBATURE_CONTROLVOLUME_DEF_HPP__
54 template <
typename SpT,
typename PT,
typename WT>
59 primaryCellTopo_ = cellTopology;
62 switch (primaryCellTopo_.getDimension()) {
64 subcvCellTopo_ = shards::CellTopology(shards::getCellTopologyData<shards::Quadrilateral<4> >());
67 subcvCellTopo_ = shards::CellTopology(shards::getCellTopologyData<shards::Hexahedron<8> >());
75 const ordinal_type subcvDegree = 2;
76 auto subcvCubature = DefaultCubatureFactory::create<SpT,PT,WT>(subcvCellTopo_, subcvDegree);
78 const ordinal_type numSubcvPoints = subcvCubature->getNumPoints();
79 const ordinal_type subcvDim = subcvCubature->getDimension();
81 subcvCubaturePoints_ = Kokkos::DynRankView<PT,SpT>(
"CubatureControlVolume::subcvCubaturePoints_",
82 numSubcvPoints, subcvDim);
83 subcvCubatureWeights_ = Kokkos::DynRankView<WT,SpT>(
"CubatureControlVolume::subcvCubatureWeights_",
86 subcvCubature->getCubature(subcvCubaturePoints_,
87 subcvCubatureWeights_);
90 template <
typename SpT,
typename PT,
typename WT>
94 weightViewType cubWeights,
95 pointViewType cellCoords )
const {
96 #ifdef HAVE_INTREPID2_DEBUG
97 INTREPID2_TEST_FOR_EXCEPTION( cubPoints.rank() != 3, std::invalid_argument,
98 ">>> ERROR (CubatureControlVolume): cubPoints must have rank 3 (C,P,D).");
99 INTREPID2_TEST_FOR_EXCEPTION( cubWeights.rank() != 2, std::invalid_argument,
100 ">>> ERROR (CubatureControlVolume): cubWeights must have rank 2 (C,P).");
101 INTREPID2_TEST_FOR_EXCEPTION( cellCoords.rank() != 3, std::invalid_argument,
102 ">>> ERROR (CubatureControlVolume): cellCoords must have rank 3 of (C,P,D).");
104 INTREPID2_TEST_FOR_EXCEPTION( cubPoints.extent(0) != cellCoords.extent(0) ||
105 cubPoints.extent(0) != cubWeights.extent(0), std::invalid_argument,
106 ">>> ERROR (CubatureControlVolume): cubPoints, cubWeights and cellCoords dimension(0) are not consistent, numCells");
108 INTREPID2_TEST_FOR_EXCEPTION( cubPoints.extent(1) != cellCoords.extent(1) ||
109 cubPoints.extent(1) != cubWeights.extent(1), std::invalid_argument,
110 ">>> ERROR (CubatureControlVolume): cubPoints, cubWeights and cellCoords dimension(1) are not consistent, numNodesPerCell");
112 INTREPID2_TEST_FOR_EXCEPTION( cubPoints.extent(2) != cellCoords.extent(2) ||
113 static_cast<ordinal_type
>(cubPoints.extent(2)) != getDimension(), std::invalid_argument,
114 ">>> ERROR (CubatureControlVolume): cubPoints, cellCoords, this->getDimension() are not consistent, spaceDim.");
116 typedef Kokkos::DynRankView<PT,SpT> tempPointViewType;
119 const ordinal_type numCells = cellCoords.extent(0);
120 const ordinal_type numNodesPerCell = cellCoords.extent(1);
121 const ordinal_type spaceDim = cellCoords.extent(2);
123 const ordinal_type numNodesPerSubcv = subcvCellTopo_.getNodeCount();
124 tempPointViewType subcvCoords(
"CubatureControlVolume::subcvCoords_",
125 numCells, numNodesPerCell, numNodesPerSubcv, spaceDim);
130 const ordinal_type numSubcvPoints = subcvCubaturePoints_.extent(0);
131 tempPointViewType subcvJacobian(
"CubatureControlVolume::subcvJacobian_",
132 numCells, numNodesPerCell, numSubcvPoints, spaceDim, spaceDim);
134 tempPointViewType subcvJacobianDet(
"CubatureControlVolume::subcvJacobDet_",
135 numCells, numNodesPerCell, numSubcvPoints);
138 for (ordinal_type node=0;node<numNodesPerCell;++node) {
139 auto subcvJacobianNode = Kokkos::subdynrankview(subcvJacobian, Kokkos::ALL(), node, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL());
140 auto subcvCoordsNode = Kokkos::subdynrankview(subcvCoords, Kokkos::ALL(), node, Kokkos::ALL(), Kokkos::ALL());
141 auto subcvJacobianDetNode = Kokkos::subdynrankview(subcvJacobianDet, Kokkos::ALL(), node, Kokkos::ALL());
144 subcvCubaturePoints_,
152 typedef typename ExecSpace<typename pointViewType::execution_space,SpT>::ExecSpaceType ExecSpaceType;
154 const auto loopSize = numCells;
155 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
158 Kokkos::parallel_for( policy, FunctorType(cubPoints,
161 subcvCubatureWeights_,
virtual void getCubature(pointViewType cubPoints, weightViewType cubWeights, pointViewType cellCoords) const
Returns cubature points and weights (return arrays must be pre-sized/pre-allocated).
CubatureControlVolume(const shards::CellTopology cellTopology)