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 = rank(_basisVals);
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 const ordinal_type subcellOrd_;
116 const ordinal_type sideDim_;
118 KOKKOS_INLINE_FUNCTION
120 const paramPointsViewType paramPoints,
121 const subcellMapViewType subcellMap,
122 ordinal_type subcellOrd)
123 : refSubcellPoints_(refSubcellPoints), paramPoints_(paramPoints), subcellMap_(subcellMap),
124 subcellOrd_(subcellOrd), sideDim_(paramPoints_.extent(1)){};
126 KOKKOS_INLINE_FUNCTION
127 void operator()(
const size_type pt,
const size_type d)
const {
129 refSubcellPoints_(pt, d) = subcellMap_(subcellOrd_, d, 0);
130 for(ordinal_type k=0; k<sideDim_; ++k)
131 refSubcellPoints_(pt, d) += subcellMap_(subcellOrd_, d, k+1)*paramPoints_(pt, k);
135 template<
typename refSubcellViewType,
136 typename paramPointsViewType,
137 typename subcellMapViewType,
138 typename ordViewType>
140 refSubcellViewType refSubcellPoints_;
141 const paramPointsViewType paramPoints_;
142 const subcellMapViewType subcellMap_;
143 const ordViewType subcellOrd_;
144 const ordinal_type sideDim_;
146 KOKKOS_INLINE_FUNCTION
148 const paramPointsViewType paramPoints,
149 const subcellMapViewType subcellMap,
150 ordViewType subcellOrd)
151 : refSubcellPoints_(refSubcellPoints), paramPoints_(paramPoints), subcellMap_(subcellMap),
152 subcellOrd_(subcellOrd), sideDim_(paramPoints_.extent(1)){};
154 KOKKOS_INLINE_FUNCTION
155 void operator()(
const size_type isc,
const size_type pt,
const size_type d)
const {
157 refSubcellPoints_(isc, pt, d) = subcellMap_(subcellOrd_(isc), d, 0);
158 for(ordinal_type k=0; k<sideDim_; ++k)
159 refSubcellPoints_(isc, pt, d) += subcellMap_(subcellOrd_(isc), d, k+1)*paramPoints_(pt, k);
164 template<
typename DeviceType>
165 template<
typename PhysPointViewType,
166 typename RefPointViewType,
167 typename WorksetType,
168 typename HGradBasisPtrType>
172 const RefPointViewType refPoints,
173 const WorksetType worksetCell,
174 const HGradBasisPtrType basis ) {
175 #ifdef HAVE_INTREPID2_DEBUG
176 CellTools_mapToPhysicalFrameArgs( physPoints, refPoints, worksetCell, basis->getBaseCellTopology() );
178 constexpr
bool are_accessible =
179 Kokkos::Impl::MemorySpaceAccess<MemSpaceType,
180 typename decltype(physPoints)::memory_space>::accessible &&
181 Kokkos::Impl::MemorySpaceAccess<MemSpaceType,
182 typename decltype(refPoints)::memory_space>::accessible;
184 static_assert(are_accessible,
"CellTools<DeviceType>::mapToPhysicalFrame(..): input/output views' memory spaces are not compatible with DeviceType");
186 const auto cellTopo = basis->getBaseCellTopology();
187 const auto numCells = worksetCell.extent(0);
190 const auto refPointRank = refPoints.rank();
191 const auto numPoints = (refPointRank == 2 ? refPoints.extent(0) : refPoints.extent(1));
192 const auto basisCardinality = basis->getCardinality();
193 auto vcprop = Kokkos::common_view_alloc_prop(physPoints);
195 using valViewType = Kokkos::DynRankView<decltype(basis->getDummyOutputValue()),DeviceType>;
199 switch (refPointRank) {
202 vals = valViewType(Kokkos::view_alloc(
"CellTools::mapToPhysicalFrame::vals", vcprop), basisCardinality, numPoints);
203 basis->getValues(vals,
211 vals = valViewType(Kokkos::view_alloc(
"CellTools::mapToPhysicalFrame::vals", vcprop), numCells, basisCardinality, numPoints);
212 for (size_type cell=0;cell<numCells;++cell)
213 basis->getValues(Kokkos::subdynrankview( vals, cell, Kokkos::ALL(), Kokkos::ALL() ),
214 Kokkos::subdynrankview( refPoints, cell, Kokkos::ALL(), Kokkos::ALL() ),
220 using FunctorType = FunctorCellTools::F_mapToPhysicalFrame<PhysPointViewType,WorksetType,valViewType>;
222 const auto loopSize = physPoints.extent(0)*physPoints.extent(1);
223 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
224 Kokkos::parallel_for( policy, FunctorType(physPoints, worksetCell, vals) );
227 template<
typename DeviceType>
228 template<
typename refSubcellViewType,
typename paramViewType>
232 const paramViewType paramPoints,
233 const ordinal_type subcellDim,
234 const ordinal_type subcellOrd,
235 const shards::CellTopology parentCell ) {
236 #ifdef HAVE_INTREPID2_DEBUG
237 ordinal_type parentCellDim = parentCell.getDimension();
238 INTREPID2_TEST_FOR_EXCEPTION( !hasReferenceCell(parentCell), std::invalid_argument,
239 ">>> ERROR (Intrepid2::CellTools::mapToReferenceSubcell): the specified cell topology does not have a reference cell.");
241 INTREPID2_TEST_FOR_EXCEPTION( subcellDim < 1 ||
242 subcellDim > parentCellDim-1, std::invalid_argument,
243 ">>> ERROR (Intrepid2::CellTools::mapToReferenceSubcell): method defined only for subcells with dimension greater than 0 and less than the cell dimension");
245 INTREPID2_TEST_FOR_EXCEPTION( subcellOrd < 0 ||
246 subcellOrd >= static_cast<ordinal_type>(parentCell.getSubcellCount(subcellDim)), std::invalid_argument,
247 ">>> ERROR (Intrepid2::CellTools::mapToReferenceSubcell): subcell ordinal out of range.");
250 INTREPID2_TEST_FOR_EXCEPTION( refSubcellPoints.rank() != 2, std::invalid_argument,
251 ">>> ERROR (Intrepid2::CellTools::mapToReferenceSubcell): refSubcellPoints must have rank 2.");
252 INTREPID2_TEST_FOR_EXCEPTION( refSubcellPoints.extent(1) != parentCell.getDimension(), std::invalid_argument,
253 ">>> ERROR (Intrepid2::CellTools::mapToReferenceSubcell): refSubcellPoints dimension (1) does not match to parent cell dimension.");
256 INTREPID2_TEST_FOR_EXCEPTION( paramPoints.rank() != 2, std::invalid_argument,
257 ">>> ERROR (Intrepid2::CellTools::mapToReferenceSubcell): paramPoints must have rank 2.");
258 INTREPID2_TEST_FOR_EXCEPTION( static_cast<ordinal_type>(paramPoints.extent(1)) != subcellDim, std::invalid_argument,
259 ">>> ERROR (Intrepid2::CellTools::mapToReferenceSubcell): paramPoints dimension (1) does not match to subcell dimension.");
262 INTREPID2_TEST_FOR_EXCEPTION( refSubcellPoints.extent(0) != paramPoints.extent(0), std::invalid_argument,
263 ">>> ERROR (Intrepid2::CellTools::mapToReferenceSubcell): refSubcellPoints dimension (0) does not match to paramPoints dimension(0).");
269 mapToReferenceSubcell(refSubcellPoints, paramPoints, subcellMap, subcellOrd);
272 template<
typename DeviceType>
273 template<
typename refSubcellViewType,
typename paramViewType>
277 const paramViewType paramPoints,
278 const typename RefSubcellParametrization<DeviceType>::ConstViewType subcellParametrization,
279 const ordinal_type subcellOrd) {
281 constexpr
bool are_accessible =
282 Kokkos::Impl::MemorySpaceAccess<MemSpaceType,
283 typename decltype(refSubcellPoints)::memory_space>::accessible &&
284 Kokkos::Impl::MemorySpaceAccess<MemSpaceType,
285 typename decltype(paramPoints)::memory_space>::accessible;
286 static_assert(are_accessible,
"CellTools<DeviceType>::mapToReferenceSubcell(..): input/output views' memory spaces are not compatible with DeviceType");
289 #ifdef HAVE_INTREPID2_DEBUG
290 const bool ranks_and_dims_compatible = (refSubcellPoints.rank() == 2) && (paramPoints.rank() == 2) && (subcellParametrization.rank() == 3) &&
291 (refSubcellPoints.extent(0) == paramPoints.extent(0)) &&
292 (refSubcellPoints.extent(1) == subcellParametrization.extent(1)) &&
293 (paramPoints.extent(1) == subcellParametrization.extent(2)-1);
295 INTREPID2_TEST_FOR_EXCEPTION(!ranks_and_dims_compatible, std::invalid_argument,
"CellTools<DeviceType>::mapToReferenceSubcell(..): input/output views' ranks and dimensions are not compatible");
298 const ordinal_type parentCellDim = subcellParametrization.extent(1);
299 const ordinal_type numPts = paramPoints.extent(0);
302 using FunctorType = FunctorCellTools::F_mapReferenceSubcell<decltype(refSubcellPoints), decltype(paramPoints), decltype(subcellParametrization)>;
304 Kokkos::MDRangePolicy<ExecSpaceType,Kokkos::Rank<2>> rangePolicy({0,0},{numPts,parentCellDim});
307 Kokkos::parallel_for( rangePolicy, FunctorType(refSubcellPoints, paramPoints, subcellParametrization, subcellOrd) );
310 template<
typename DeviceType>
311 template<
typename refSubcellViewType,
typename paramViewType,
typename ordViewType>
315 const paramViewType paramPoints,
316 const typename RefSubcellParametrization<DeviceType>::ConstViewType subcellParametrization,
317 const ordViewType subcellOrd) {
319 constexpr
bool are_accessible =
320 Kokkos::Impl::MemorySpaceAccess<MemSpaceType,
321 typename decltype(refSubcellPoints)::memory_space>::accessible &&
322 Kokkos::Impl::MemorySpaceAccess<MemSpaceType,
323 typename decltype(paramPoints)::memory_space>::accessible &&
324 Kokkos::Impl::MemorySpaceAccess<MemSpaceType,
325 typename decltype(subcellOrd)::memory_space>::accessible;
326 static_assert(are_accessible,
"CellTools<DeviceType>::mapToReferenceSubcell(..): input/output views' memory spaces are not compatible with DeviceType");
329 #ifdef HAVE_INTREPID2_DEBUG
330 const bool ranks_and_dims_compatible = (refSubcellPoints.rank() == 3) && (paramPoints.rank() == 2) && (subcellParametrization.rank() == 3) &&
331 (refSubcellPoints.extent(0) == subcellOrd.extent(0)) &&
332 (refSubcellPoints.extent(1) == paramPoints.extent(0)) &&
333 (refSubcellPoints.extent(2) == subcellParametrization.extent(1)) &&
334 (paramPoints.extent(1) == subcellParametrization.extent(2)-1);
336 INTREPID2_TEST_FOR_EXCEPTION(!ranks_and_dims_compatible, std::invalid_argument,
"CellTools<DeviceType>::mapToReferenceSubcell(..): input/output views' ranks and dimensions are not compatible");
339 const ordinal_type numSubCells = refSubcellPoints.extent(0);
340 const ordinal_type parentCellDim = subcellParametrization.extent(1);
341 const ordinal_type numPts = paramPoints.extent(0);
345 using FunctorType = FunctorCellTools::F_mapReferenceSubcellBatch<decltype(refSubcellPoints), decltype(paramPoints), decltype(subcellParametrization), decltype(subcellOrd)>;
347 Kokkos::MDRangePolicy<ExecSpaceType,Kokkos::Rank<3>> rangePolicy({0,0,0},{numSubCells,numPts,parentCellDim});
350 Kokkos::parallel_for( rangePolicy, FunctorType(refSubcellPoints, paramPoints, subcellParametrization, subcellOrd) );
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...