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());
91 const auto dofs = Kokkos::subdynrankview( _worksetCells, cell, Kokkos::ALL(), Kokkos::ALL());
93 const auto valRank = _basisVals.rank();
94 const auto val = ( valRank == 2 ? Kokkos::subdynrankview( _basisVals, Kokkos::ALL(), pt) :
95 Kokkos::subdynrankview( _basisVals, cell, Kokkos::ALL(), pt));
97 const ordinal_type dim = phys.extent(0);
98 const ordinal_type cardinality = val.extent(0);
100 for (ordinal_type i=0;i<dim;++i) {
102 for (ordinal_type bf=0;bf<cardinality;++bf)
103 phys(i) += dofs(bf, i)*val(bf);
129 template<
typename SpT>
130 template<
typename physPointValueType,
class ...physPointProperties,
131 typename refPointValueType,
class ...refPointProperties,
132 typename worksetCellValueType,
class ...worksetCellProperties,
133 typename HGradBasisPtrType>
137 const Kokkos::DynRankView<refPointValueType,refPointProperties...> refPoints,
138 const Kokkos::DynRankView<worksetCellValueType,worksetCellProperties...> worksetCell,
139 const HGradBasisPtrType basis ) {
140 #ifdef HAVE_INTREPID2_DEBUG
141 CellTools_mapToPhysicalFrameArgs( physPoints, refPoints, worksetCell, basis->getBaseCellTopology() );
143 const auto cellTopo = basis->getBaseCellTopology();
144 const auto numCells = worksetCell.extent(0);
147 const auto refPointRank = refPoints.rank();
148 const auto numPoints = (refPointRank == 2 ? refPoints.extent(0) : refPoints.extent(1));
149 const auto basisCardinality = basis->getCardinality();
150 auto vcprop = Kokkos::common_view_alloc_prop(physPoints);
152 typedef Kokkos::DynRankView<physPointValueType,physPointProperties...> physPointViewType;
153 typedef Kokkos::DynRankView<decltype(basis->getDummyOutputValue()),SpT> valViewType;
157 switch (refPointRank) {
160 vals = valViewType(Kokkos::view_alloc(
"CellTools::mapToPhysicalFrame::vals", vcprop), basisCardinality, numPoints);
161 basis->getValues(vals,
169 vals = valViewType(Kokkos::view_alloc(
"CellTools::mapToPhysicalFrame::vals", vcprop), numCells, basisCardinality, numPoints);
170 for (size_type cell=0;cell<numCells;++cell)
171 basis->getValues(Kokkos::subdynrankview( vals, cell, Kokkos::ALL(), Kokkos::ALL() ),
172 Kokkos::subdynrankview( refPoints, cell, Kokkos::ALL(), Kokkos::ALL() ),
178 typedef Kokkos::DynRankView<worksetCellValueType,worksetCellProperties...> worksetCellViewType;
180 typedef typename ExecSpace<typename worksetCellViewType::execution_space,SpT>::ExecSpaceType ExecSpaceType;
182 const auto loopSize = physPoints.extent(0)*physPoints.extent(1);
183 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
184 Kokkos::parallel_for( policy, FunctorType(physPoints, worksetCell, vals) );
187 template<
typename SpT>
188 template<
typename refSubcellPointValueType,
class ...refSubcellPointProperties,
189 typename paramPointValueType,
class ...paramPointProperties>
193 const Kokkos::DynRankView<paramPointValueType,paramPointProperties...> paramPoints,
194 const ordinal_type subcellDim,
195 const ordinal_type subcellOrd,
196 const shards::CellTopology parentCell ) {
197 #ifdef HAVE_INTREPID2_DEBUG
198 INTREPID2_TEST_FOR_EXCEPTION( !hasReferenceCell(parentCell), std::invalid_argument,
199 ">>> ERROR (Intrepid2::CellTools::mapToReferenceSubcell): the specified cell topology does not have a reference cell.");
201 INTREPID2_TEST_FOR_EXCEPTION( subcellDim != 1 &&
202 subcellDim != 2, std::invalid_argument,
203 ">>> ERROR (Intrepid2::CellTools::mapToReferenceSubcell): method defined only for 1 and 2-dimensional subcells.");
205 INTREPID2_TEST_FOR_EXCEPTION( subcellOrd < 0 ||
206 subcellOrd >= static_cast<ordinal_type>(parentCell.getSubcellCount(subcellDim)), std::invalid_argument,
207 ">>> ERROR (Intrepid2::CellTools::mapToReferenceSubcell): subcell ordinal out of range.");
210 INTREPID2_TEST_FOR_EXCEPTION( refSubcellPoints.rank() != 2, std::invalid_argument,
211 ">>> ERROR (Intrepid2::CellTools::mapToReferenceSubcell): refSubcellPoints must have rank 2.");
212 INTREPID2_TEST_FOR_EXCEPTION( refSubcellPoints.extent(1) != parentCell.getDimension(), std::invalid_argument,
213 ">>> ERROR (Intrepid2::CellTools::mapToReferenceSubcell): refSubcellPoints dimension (1) does not match to parent cell dimension.");
216 INTREPID2_TEST_FOR_EXCEPTION( paramPoints.rank() != 2, std::invalid_argument,
217 ">>> ERROR (Intrepid2::CellTools::mapToReferenceSubcell): paramPoints must have rank 2.");
218 INTREPID2_TEST_FOR_EXCEPTION( static_cast<ordinal_type>(paramPoints.extent(1)) != subcellDim, std::invalid_argument,
219 ">>> ERROR (Intrepid2::CellTools::mapToReferenceSubcell): paramPoints dimension (1) does not match to subcell dimension.");
222 INTREPID2_TEST_FOR_EXCEPTION( refSubcellPoints.extent(0) < paramPoints.extent(0), std::invalid_argument,
223 ">>> ERROR (Intrepid2::CellTools::mapToReferenceSubcell): refSubcellPoints dimension (0) does not match to paramPoints dimension(0).");
226 if(!isSubcellParametrizationSet_)
227 setSubcellParametrization();
229 INTREPID2_TEST_FOR_EXCEPTION( subcellDim != 1 &&
230 subcellDim != 2, std::invalid_argument,
231 ">>> ERROR (Intrepid2::CellTools::mapToReferenceSubcell): method defined only for 1 and 2-subcells");
235 subcellParamViewType subcellMap;
236 getSubcellParametrization( subcellMap,
241 mapToReferenceSubcell( refSubcellPoints, paramPoints, subcellMap, subcellDim, subcellOrd, parentCell.getDimension());
245 template<
typename SpT>
246 template<
typename refSubcellPointValueType,
class ...refSubcellPointProperties,
247 typename paramPointValueType,
class ...paramPointProperties>
249 KOKKOS_INLINE_FUNCTION
252 const Kokkos::DynRankView<paramPointValueType,paramPointProperties...> paramPoints,
253 const subcellParamViewType subcellMap,
254 const ordinal_type subcellDim,
255 const ordinal_type subcellOrd,
256 const ordinal_type parentCellDim ) {
258 const ordinal_type numPts = paramPoints.extent(0);
261 switch (subcellDim) {
263 for (ordinal_type pt=0;pt<numPts;++pt) {
264 const auto u = paramPoints(pt, 0);
265 const auto v = paramPoints(pt, 1);
268 for (ordinal_type i=0;i<parentCellDim;++i)
269 refSubcellPoints(pt, i) = subcellMap(subcellOrd, i, 0) + ( subcellMap(subcellOrd, i, 1)*u +
270 subcellMap(subcellOrd, i, 2)*v );
275 for (ordinal_type pt=0;pt<numPts;++pt) {
276 const auto u = paramPoints(pt, 0);
277 for (ordinal_type i=0;i<parentCellDim;++i)
278 refSubcellPoints(pt, i) = subcellMap(subcellOrd, i, 0) + ( subcellMap(subcellOrd, i, 1)*u );