16 #ifndef __INTREPID2_CELLTOOLS_DEF_INCLUSION_HPP__
17 #define __INTREPID2_CELLTOOLS_DEF_INCLUSION_HPP__
20 #if defined (__clang__) && !defined (__INTEL_COMPILER)
21 #pragma clang system_header
33 template<
typename DeviceType>
34 template<
typename Po
intViewType>
38 const shards::CellTopology cellTopo,
39 const typename ScalarTraits<typename PointViewType::value_type>::scalar_type threshold) {
40 #ifdef HAVE_INTREPID2_DEBUG
41 INTREPID2_TEST_FOR_EXCEPTION( point.rank() != 1, std::invalid_argument,
42 ">>> ERROR (Intrepid2::CellTools::checkPointInclusion): Point must have rank 1. ");
43 INTREPID2_TEST_FOR_EXCEPTION( point.extent(0) != cellTopo.getDimension(), std::invalid_argument,
44 ">>> ERROR (Intrepid2::CellTools::checkPointInclusion): Point and cell dimensions do not match. ");
46 bool testResult =
true;
51 const auto key = cellTopo.getBaseKey();
54 case shards::Line<>::key :
57 case shards::Triangle<>::key :
60 case shards::Quadrilateral<>::key :
63 case shards::Tetrahedron<>::key :
66 case shards::Hexahedron<>::key :
69 case shards::Wedge<>::key :
72 case shards::Pyramid<>::key :
76 INTREPID2_TEST_FOR_EXCEPTION( !( (key == shards::Line<>::key ) ||
77 (key == shards::Triangle<>::key) ||
78 (key == shards::Quadrilateral<>::key) ||
79 (key == shards::Tetrahedron<>::key) ||
80 (key == shards::Hexahedron<>::key) ||
81 (key == shards::Wedge<>::key) ||
82 (key == shards::Pyramid<>::key) ),
83 std::invalid_argument,
84 ">>> ERROR (Intrepid2::CellTools::checkPointInclusion): Invalid cell topology. ");
91 template<
unsigned cellTopologyKey,
92 typename OutputViewType,
93 typename InputViewType>
95 OutputViewType output_;
98 ScalarType threshold_;
100 KOKKOS_INLINE_FUNCTION
102 const InputViewType input,
103 const ScalarType threshold)
106 threshold_(threshold) {}
108 KOKKOS_INLINE_FUNCTION
110 operator()(
const ordinal_type i)
const {
111 const auto in = Kokkos::subview(input_,i,Kokkos::ALL());
116 KOKKOS_INLINE_FUNCTION
118 operator()(
const ordinal_type i,
const ordinal_type j)
const {
119 const auto in = Kokkos::subview(input_,i,j,Kokkos::ALL());
121 output_(i,j) = check;
126 template<
typename DeviceType>
127 template<
unsigned cellTopologyKey,
128 typename OutputViewType,
129 typename InputViewType>
132 const InputViewType points,
136 if (points.rank() == 2) {
137 Kokkos::RangePolicy<typename DeviceType::execution_space> policy(0, points.extent(0));
138 Kokkos::parallel_for(policy, FunctorType(inCell, points, threshold));
140 Kokkos::MDRangePolicy<typename DeviceType::execution_space,Kokkos::Rank<2>> policy({0,0},{points.extent(0),points.extent(1)});
141 Kokkos::parallel_for(policy, FunctorType(inCell, points, threshold));
146 template<
typename DeviceType>
147 template<
typename InCellViewType,
148 typename InputViewType>
152 const InputViewType points,
153 const shards::CellTopology cellTopo,
155 #ifdef HAVE_INTREPID2_DEBUG
157 INTREPID2_TEST_FOR_EXCEPTION( (inCell.rank() != 1) && (inCell.rank() != 2), std::invalid_argument,
158 ">>> ERROR (Intrepid2::CellTools::checkPointwiseInclusion): InCell must have rank 1 or 2. ");
159 INTREPID2_TEST_FOR_EXCEPTION( points.extent(points.rank()-1) != cellTopo.getDimension(), std::invalid_argument,
160 ">>> ERROR (Intrepid2::CellTools::checkPointInclusion): Points and cell dimensions do not match. ");
161 INTREPID2_TEST_FOR_EXCEPTION( inCell.rank() != (points.rank()-1), std::invalid_argument,
162 ">>> ERROR (Intrepid2::CellTools::checkPointwiseInclusion): rank difference between inCell and points is 1.");
163 const ordinal_type iend = inCell.rank();
165 for (ordinal_type i=0;i<iend;++i) {
166 INTREPID2_TEST_FOR_EXCEPTION( inCell.extent(i) != points.extent(i), std::invalid_argument,
167 ">>> ERROR (Intrepid2::CellTools::checkPointwiseInclusion): dimension mismatch between inCell and points. " );
172 const auto key = cellTopo.getBaseKey();
175 case shards::Line<>::key :
176 checkPointwiseInclusion<shards::Line<>::key,decltype(inCell),decltype(points)>(inCell, points, threshold);
179 case shards::Triangle<>::key :
180 checkPointwiseInclusion<shards::Triangle<>::key,decltype(inCell),decltype(points)>(inCell, points, threshold);
183 case shards::Quadrilateral<>::key :
184 checkPointwiseInclusion<shards::Quadrilateral<>::key,decltype(inCell),decltype(points)>(inCell, points, threshold);
187 case shards::Tetrahedron<>::key :
188 checkPointwiseInclusion<shards::Tetrahedron<>::key,decltype(inCell),decltype(points)>(inCell, points, threshold);
191 case shards::Hexahedron<>::key :
192 checkPointwiseInclusion<shards::Hexahedron<>::key,decltype(inCell),decltype(points)>(inCell, points, threshold);
195 case shards::Wedge<>::key :
196 checkPointwiseInclusion<shards::Wedge<>::key,decltype(inCell),decltype(points)>(inCell, points, threshold);
199 case shards::Pyramid<>::key :
200 checkPointwiseInclusion<shards::Pyramid<>::key,decltype(inCell),decltype(points)>(inCell, points, threshold);
204 INTREPID2_TEST_FOR_EXCEPTION(
false,
205 std::invalid_argument,
206 ">>> ERROR (Intrepid2::CellTools::checkPointInclusion): Invalid cell topology. ");
210 template<
typename DeviceType>
211 template<
typename inCellValueType,
class ...inCellProperties,
212 typename pointValueType,
class ...pointProperties,
213 typename cellWorksetValueType,
class ...cellWorksetProperties>
217 const Kokkos::DynRankView<pointValueType,pointProperties...> points,
218 const Kokkos::DynRankView<cellWorksetValueType,cellWorksetProperties...> cellWorkset,
219 const shards::CellTopology cellTopo,
220 const typename ScalarTraits<pointValueType>::scalar_type threshold ) {
221 #ifdef HAVE_INTREPID2_DEBUG
223 const auto key = cellTopo.getBaseKey();
224 INTREPID2_TEST_FOR_EXCEPTION( key != shards::Line<>::key &&
225 key != shards::Triangle<>::key &&
226 key != shards::Quadrilateral<>::key &&
227 key != shards::Tetrahedron<>::key &&
228 key != shards::Hexahedron<>::key &&
229 key != shards::Wedge<>::key &&
230 key != shards::Pyramid<>::key,
231 std::invalid_argument,
232 ">>> ERROR (Intrepid2::CellTools::checkPointwiseInclusion): cell topology not supported");
233 INTREPID2_TEST_FOR_EXCEPTION( inCell.rank() != 2, std::invalid_argument,
234 ">>> ERROR (Intrepid2::CellTools::checkPointwiseInclusion): InCell must have rank 2. ");
235 INTREPID2_TEST_FOR_EXCEPTION( cellWorkset.rank() != 3, std::invalid_argument,
236 ">>> ERROR (Intrepid2::CellTools::checkPointwiseInclusion): cellWorkset must have rank 3. ");
237 INTREPID2_TEST_FOR_EXCEPTION( cellWorkset.extent(2) != cellTopo.getDimension(), std::invalid_argument,
238 ">>> ERROR (Intrepid2::CellTools::checkPointInclusion): cellWorkset and points have incompatible dimensions. ");
239 INTREPID2_TEST_FOR_EXCEPTION( (points.rank() == 3) && (points.extent(0) != cellWorkset.extent(0)) , std::invalid_argument,
240 ">>> ERROR (Intrepid2::CellTools::checkPointInclusion): cellWorkset and points have incompatible dimensions. ");
244 numCells = cellWorkset.extent(0),
245 numPoints = points.extent(points.rank()-2),
246 spaceDim = cellTopo.getDimension();
248 using result_layout =
typename DeduceLayout< decltype(points) >::result_layout;
249 auto vcprop = Kokkos::common_view_alloc_prop(points);
250 using common_value_type =
typename decltype(vcprop)::value_type;
251 Kokkos::DynRankView< common_value_type, result_layout, DeviceType > refPoints ( Kokkos::view_alloc(
"CellTools::checkPointwiseInclusion::refPoints", vcprop), numCells, numPoints, spaceDim);
254 if(points.rank() == 3)
255 mapToReferenceFrame(refPoints, points, cellWorkset, cellTopo);
257 Kokkos::DynRankView< common_value_type, result_layout, DeviceType > cellPoints ( Kokkos::view_alloc(
"CellTools::checkPointwiseInclusion::physCellPoints", vcprop), numCells, numPoints, spaceDim);
259 mapToReferenceFrame(refPoints, cellPoints, cellWorkset, cellTopo);
261 checkPointwiseInclusion(inCell, refPoints, cellTopo, threshold);
This class implements a check function that determines whether a given point is inside or outside the...