49 #ifndef __INTREPID2_CELLTOOLS_DEF_REF_TO_PHYS_HPP__ 50 #define __INTREPID2_CELLTOOLS_DEF_REF_TO_PHYS_HPP__ 53 #if defined (__clang__) && !defined (__INTEL_COMPILER) 54 #pragma clang system_header 65 namespace FunctorCellTools {
69 template<
typename physPointViewType,
70 typename worksetCellType,
71 typename basisValType>
73 physPointViewType _physPoints;
74 const worksetCellType _worksetCells;
75 const basisValType _basisVals;
77 KOKKOS_INLINE_FUNCTION
79 worksetCellType worksetCells_,
80 basisValType basisVals_ )
81 : _physPoints(physPoints_), _worksetCells(worksetCells_), _basisVals(basisVals_) {}
83 KOKKOS_INLINE_FUNCTION
84 void operator()(
const size_type iter)
const {
86 unrollIndex( cell, pt,
87 _physPoints.extent(0),
88 _physPoints.extent(1),
90 auto phys = Kokkos::subdynrankview( _physPoints, cell, pt, Kokkos::ALL());
92 const auto valRank = _basisVals.rank();
93 const auto val = ( valRank == 2 ? Kokkos::subdynrankview( _basisVals, Kokkos::ALL(), pt) :
94 Kokkos::subdynrankview( _basisVals, cell, Kokkos::ALL(), pt));
96 const ordinal_type dim = phys.extent(0);
97 const ordinal_type cardinality = val.extent(0);
99 for (ordinal_type i=0;i<dim;++i) {
101 for (ordinal_type bf=0;bf<cardinality;++bf)
102 phys(i) += _worksetCells(cell, bf, i)*val(bf);
108 template<
typename refSubcellViewType,
109 typename paramPointsViewType,
110 typename subcellMapViewType>
112 refSubcellViewType refSubcellPoints_;
113 const paramPointsViewType paramPoints_;
114 const subcellMapViewType subcellMap_;
115 ordinal_type subcellOrd_, dim_;
117 KOKKOS_INLINE_FUNCTION
119 const paramPointsViewType paramPoints,
120 const subcellMapViewType subcellMap,
121 ordinal_type subcellOrd,
123 : refSubcellPoints_(refSubcellPoints), paramPoints_(paramPoints), subcellMap_(subcellMap),
124 subcellOrd_(subcellOrd), dim_(dim){};
126 KOKKOS_INLINE_FUNCTION
127 void operator()(
const size_type pt)
const {
129 const auto u = paramPoints_(pt, 0);
130 const auto v = paramPoints_(pt, 1);
133 for (ordinal_type i=0;i<dim_;++i)
134 refSubcellPoints_(pt, i) = subcellMap_(subcellOrd_, i, 0) + ( subcellMap_(subcellOrd_, i, 1)*u +
135 subcellMap_(subcellOrd_, i, 2)*v );
139 template<
typename refSubcellViewType,
140 typename paramPointsViewType,
141 typename subcellMapViewType>
143 refSubcellViewType refSubcellPoints_;
144 const paramPointsViewType paramPoints_;
145 const subcellMapViewType subcellMap_;
146 ordinal_type subcellOrd_, dim_;
148 KOKKOS_INLINE_FUNCTION
150 const paramPointsViewType paramPoints,
151 const subcellMapViewType subcellMap,
152 ordinal_type subcellOrd,
154 : refSubcellPoints_(refSubcellPoints), paramPoints_(paramPoints), subcellMap_(subcellMap),
155 subcellOrd_(subcellOrd), dim_(dim){};
157 KOKKOS_INLINE_FUNCTION
158 void operator()(
const size_type pt)
const {
159 const auto u = paramPoints_(pt, 0);
160 for (ordinal_type i=0;i<dim_;++i)
161 refSubcellPoints_(pt, i) = subcellMap_(subcellOrd_, i, 0) + ( subcellMap_(subcellOrd_, i, 1)*u );
187 template<
typename DeviceType>
188 template<
typename physPointValueType,
class ...physPointProperties,
189 typename refPointValueType,
class ...refPointProperties,
190 typename WorksetType,
191 typename HGradBasisPtrType>
195 const Kokkos::DynRankView<refPointValueType,refPointProperties...> refPoints,
196 const WorksetType worksetCell,
197 const HGradBasisPtrType basis ) {
198 #ifdef HAVE_INTREPID2_DEBUG 201 constexpr
bool are_accessible =
202 Kokkos::Impl::MemorySpaceAccess<MemSpaceType,
203 typename decltype(physPoints)::memory_space>::accessible &&
204 Kokkos::Impl::MemorySpaceAccess<MemSpaceType,
205 typename decltype(refPoints)::memory_space>::accessible;
207 static_assert(are_accessible,
"CellTools<DeviceType>::mapToPhysicalFrame(..): input/output views' memory spaces are not compatible with DeviceType");
209 const auto cellTopo = basis->getBaseCellTopology();
210 const auto numCells = worksetCell.extent(0);
213 const auto refPointRank = refPoints.rank();
214 const auto numPoints = (refPointRank == 2 ? refPoints.extent(0) : refPoints.extent(1));
215 const auto basisCardinality = basis->getCardinality();
216 auto vcprop = Kokkos::common_view_alloc_prop(physPoints);
218 using physPointViewType =Kokkos::DynRankView<physPointValueType,physPointProperties...>;
219 using valViewType = Kokkos::DynRankView<decltype(basis->getDummyOutputValue()),DeviceType>;
223 switch (refPointRank) {
226 vals = valViewType(Kokkos::view_alloc(
"CellTools::mapToPhysicalFrame::vals", vcprop), basisCardinality, numPoints);
227 basis->getValues(vals,
235 vals = valViewType(Kokkos::view_alloc(
"CellTools::mapToPhysicalFrame::vals", vcprop), numCells, basisCardinality, numPoints);
236 for (size_type cell=0;cell<numCells;++cell)
237 basis->getValues(Kokkos::subdynrankview( vals, cell, Kokkos::ALL(), Kokkos::ALL() ),
238 Kokkos::subdynrankview( refPoints, cell, Kokkos::ALL(), Kokkos::ALL() ),
246 const auto loopSize = physPoints.extent(0)*physPoints.extent(1);
247 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
248 Kokkos::parallel_for( policy, FunctorType(physPoints, worksetCell, vals) );
251 template<
typename DeviceType>
252 template<
typename refSubcellPointValueType,
class ...refSubcellPointProperties,
253 typename paramPointValueType,
class ...paramPointProperties>
257 const Kokkos::DynRankView<paramPointValueType,paramPointProperties...> paramPoints,
258 const ordinal_type subcellDim,
259 const ordinal_type subcellOrd,
260 const shards::CellTopology parentCell ) {
261 ordinal_type parentCellDim = parentCell.getDimension();
262 #ifdef HAVE_INTREPID2_DEBUG 263 INTREPID2_TEST_FOR_EXCEPTION( !hasReferenceCell(parentCell), std::invalid_argument,
264 ">>> ERROR (Intrepid2::CellTools::mapToReferenceSubcell): the specified cell topology does not have a reference cell.");
266 INTREPID2_TEST_FOR_EXCEPTION( subcellDim < 1 ||
267 subcellDim > parentCellDim-1, std::invalid_argument,
268 ">>> ERROR (Intrepid2::CellTools::mapToReferenceSubcell): method defined only for subcells with dimension greater than 0 and less than the cell dimension");
270 INTREPID2_TEST_FOR_EXCEPTION( subcellOrd < 0 ||
271 subcellOrd >= static_cast<ordinal_type>(parentCell.getSubcellCount(subcellDim)), std::invalid_argument,
272 ">>> ERROR (Intrepid2::CellTools::mapToReferenceSubcell): subcell ordinal out of range.");
275 INTREPID2_TEST_FOR_EXCEPTION( refSubcellPoints.rank() != 2, std::invalid_argument,
276 ">>> ERROR (Intrepid2::CellTools::mapToReferenceSubcell): refSubcellPoints must have rank 2.");
277 INTREPID2_TEST_FOR_EXCEPTION( refSubcellPoints.extent(1) != parentCell.getDimension(), std::invalid_argument,
278 ">>> ERROR (Intrepid2::CellTools::mapToReferenceSubcell): refSubcellPoints dimension (1) does not match to parent cell dimension.");
281 INTREPID2_TEST_FOR_EXCEPTION( paramPoints.rank() != 2, std::invalid_argument,
282 ">>> ERROR (Intrepid2::CellTools::mapToReferenceSubcell): paramPoints must have rank 2.");
283 INTREPID2_TEST_FOR_EXCEPTION( static_cast<ordinal_type>(paramPoints.extent(1)) != subcellDim, std::invalid_argument,
284 ">>> ERROR (Intrepid2::CellTools::mapToReferenceSubcell): paramPoints dimension (1) does not match to subcell dimension.");
287 INTREPID2_TEST_FOR_EXCEPTION( refSubcellPoints.extent(0) < paramPoints.extent(0), std::invalid_argument,
288 ">>> ERROR (Intrepid2::CellTools::mapToReferenceSubcell): refSubcellPoints dimension (0) does not match to paramPoints dimension(0).");
291 constexpr
bool are_accessible =
292 Kokkos::Impl::MemorySpaceAccess<MemSpaceType,
293 typename decltype(refSubcellPoints)::memory_space>::accessible &&
294 Kokkos::Impl::MemorySpaceAccess<MemSpaceType,
295 typename decltype(paramPoints)::memory_space>::accessible;
297 static_assert(are_accessible,
"CellTools<DeviceType>::mapToReferenceSubcell(..): input/output views' memory spaces are not compatible with DeviceType");
302 const ordinal_type numPts = paramPoints.extent(0);
308 Kokkos::RangePolicy<ExecSpaceType> policy(0, numPts);
310 switch (subcellDim) {
312 Kokkos::parallel_for( policy, FunctorType2(refSubcellPoints, paramPoints, subcellMap, subcellOrd, parentCellDim) );
316 Kokkos::parallel_for( policy, FunctorType1(refSubcellPoints, paramPoints, subcellMap, subcellOrd, parentCellDim) );
static ConstViewType get(const ordinal_type subcellDim, const unsigned parentCellKey)
Returns a Kokkos view with the coefficients of the parametrization maps for the edges or faces of a r...