16 #ifndef __INTREPID2_CUBATURE_CONTROLVOLUME_DEF_HPP__
17 #define __INTREPID2_CUBATURE_CONTROLVOLUME_DEF_HPP__
21 template <
typename DT,
typename PT,
typename WT>
26 primaryCellTopo_ = cellTopology;
29 switch (primaryCellTopo_.getDimension()) {
31 subcvCellTopo_ = shards::CellTopology(shards::getCellTopologyData<shards::Quadrilateral<4> >());
34 subcvCellTopo_ = shards::CellTopology(shards::getCellTopologyData<shards::Hexahedron<8> >());
42 const ordinal_type subcvDegree = 2;
43 auto subcvCubature = DefaultCubatureFactory::create<DT,PT,WT>(subcvCellTopo_, subcvDegree);
45 const ordinal_type numSubcvPoints = subcvCubature->getNumPoints();
46 const ordinal_type subcvDim = subcvCubature->getDimension();
48 subcvCubaturePoints_ = Kokkos::DynRankView<PT,DT>(
"CubatureControlVolume::subcvCubaturePoints_",
49 numSubcvPoints, subcvDim);
50 subcvCubatureWeights_ = Kokkos::DynRankView<WT,DT>(
"CubatureControlVolume::subcvCubatureWeights_",
53 subcvCubature->getCubature(subcvCubaturePoints_,
54 subcvCubatureWeights_);
57 template <
typename DT,
typename PT,
typename WT>
61 weightViewType cubWeights,
62 PointViewType cellCoords )
const {
63 #ifdef HAVE_INTREPID2_DEBUG
64 INTREPID2_TEST_FOR_EXCEPTION( cubPoints.rank() != 3, std::invalid_argument,
65 ">>> ERROR (CubatureControlVolume): cubPoints must have rank 3 (C,P,D).");
66 INTREPID2_TEST_FOR_EXCEPTION( cubWeights.rank() != 2, std::invalid_argument,
67 ">>> ERROR (CubatureControlVolume): cubWeights must have rank 2 (C,P).");
68 INTREPID2_TEST_FOR_EXCEPTION( cellCoords.rank() != 3, std::invalid_argument,
69 ">>> ERROR (CubatureControlVolume): cellCoords must have rank 3 of (C,P,D).");
71 INTREPID2_TEST_FOR_EXCEPTION( cubPoints.extent(0) != cellCoords.extent(0) ||
72 cubPoints.extent(0) != cubWeights.extent(0), std::invalid_argument,
73 ">>> ERROR (CubatureControlVolume): cubPoints, cubWeights and cellCoords dimension(0) are not consistent, numCells");
75 INTREPID2_TEST_FOR_EXCEPTION( cubPoints.extent(1) != cellCoords.extent(1) ||
76 cubPoints.extent(1) != cubWeights.extent(1), std::invalid_argument,
77 ">>> ERROR (CubatureControlVolume): cubPoints, cubWeights and cellCoords dimension(1) are not consistent, numNodesPerCell");
79 INTREPID2_TEST_FOR_EXCEPTION( cubPoints.extent(2) != cellCoords.extent(2) ||
80 static_cast<ordinal_type
>(cubPoints.extent(2)) != getDimension(), std::invalid_argument,
81 ">>> ERROR (CubatureControlVolume): cubPoints, cellCoords, this->getDimension() are not consistent, spaceDim.");
83 typedef Kokkos::DynRankView<PT,DT> tempPointViewType;
86 const ordinal_type numCells = cellCoords.extent(0);
87 const ordinal_type numNodesPerCell = cellCoords.extent(1);
88 const ordinal_type spaceDim = cellCoords.extent(2);
90 const ordinal_type numNodesPerSubcv = subcvCellTopo_.getNodeCount();
91 tempPointViewType subcvCoords(
"CubatureControlVolume::subcvCoords_",
92 numCells, numNodesPerCell, numNodesPerSubcv, spaceDim);
97 const ordinal_type numSubcvPoints = subcvCubaturePoints_.extent(0);
98 tempPointViewType subcvJacobian(
"CubatureControlVolume::subcvJacobian_",
99 numCells, numNodesPerCell, numSubcvPoints, spaceDim, spaceDim);
101 tempPointViewType subcvJacobianDet(
"CubatureControlVolume::subcvJacobDet_",
102 numCells, numNodesPerCell, numSubcvPoints);
105 for (ordinal_type node=0;node<numNodesPerCell;++node) {
106 auto subcvJacobianNode = Kokkos::subdynrankview(subcvJacobian, Kokkos::ALL(), node, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL());
107 auto subcvCoordsNode = Kokkos::subdynrankview(subcvCoords, Kokkos::ALL(), node, Kokkos::ALL(), Kokkos::ALL());
108 auto subcvJacobianDetNode = Kokkos::subdynrankview(subcvJacobianDet, Kokkos::ALL(), node, Kokkos::ALL());
111 subcvCubaturePoints_,
121 const auto loopSize = numCells;
122 Kokkos::RangePolicy<typename DT::execution_space,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
125 Kokkos::parallel_for( policy, FunctorType(cubPoints,
128 subcvCubatureWeights_,
virtual void getCubature(PointViewType cubPoints, weightViewType cubWeights, PointViewType cellCoords) const override
Returns cubature points and weights (return arrays must be pre-sized/pre-allocated).
CubatureControlVolume(const shards::CellTopology cellTopology)