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>
35 typename ScalarTraits<typename PointViewType::value_type>::scalar_type
38 const shards::CellTopology cellTopo) {
39#ifdef HAVE_INTREPID2_DEBUG
40 INTREPID2_TEST_FOR_EXCEPTION( point.rank() != 1, std::invalid_argument,
41 ">>> ERROR (Intrepid2::CellTools::parametricDistance): Point must have rank 1. ");
42 INTREPID2_TEST_FOR_EXCEPTION( point.extent(0) != cellTopo.getDimension(), std::invalid_argument,
43 ">>> ERROR (Intrepid2::CellTools::parametricDistance): Point and cell dimensions do not match. ");
48 const auto key = cellTopo.getBaseKey();
49 using scalar_type =
typename ScalarTraits<typename PointViewType::value_type>::scalar_type;
50 scalar_type distance(0);
52 case shards::Line<>::key :
55 case shards::ShellLine<>::key :
58 case shards::Triangle<>::key :
61 case shards::ShellTriangle<>::key :
64 case shards::ShellQuadrilateral<>::key :
67 case shards::Quadrilateral<>::key :
70 case shards::Tetrahedron<>::key :
73 case shards::Hexahedron<>::key :
76 case shards::Wedge<>::key :
79 case shards::Pyramid<>::key :
83 INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
84 ">>> ERROR (Intrepid2::CellTools::parametricDistance): Invalid cell topology. ");
90 template<
typename DeviceType>
91 template<
typename Po
intViewType>
95 const shards::CellTopology cellTopo,
96 const typename ScalarTraits<typename PointViewType::value_type>::scalar_type threshold) {
97 return parametricDistance(point, cellTopo) <= 1.0 + threshold;
102 template<
unsigned cellTopologyKey,
103 typename OutputViewType,
104 typename InputViewType>
106 OutputViewType output_;
107 InputViewType input_;
108 using ScalarType =
typename ScalarTraits<typename InputViewType::value_type>::scalar_type;
109 ScalarType threshold_;
111 KOKKOS_INLINE_FUNCTION
113 const InputViewType input,
114 const ScalarType threshold)
117 threshold_(threshold) {}
119 KOKKOS_INLINE_FUNCTION
121 operator()(
const ordinal_type i)
const {
122 const auto in = Kokkos::subview(input_,i,Kokkos::ALL());
127 KOKKOS_INLINE_FUNCTION
129 operator()(
const ordinal_type i,
const ordinal_type j)
const {
130 const auto in = Kokkos::subview(input_,i,j,Kokkos::ALL());
132 output_(i,j) = check;
137 template<
typename DeviceType>
138 template<
unsigned cellTopologyKey,
139 typename OutputViewType,
140 typename InputViewType>
143 const InputViewType points,
144 const typename ScalarTraits<typename InputViewType::value_type>::scalar_type threshold) {
147 if (points.rank() == 2) {
148 Kokkos::RangePolicy<typename DeviceType::execution_space> policy(0, points.extent(0));
149 Kokkos::parallel_for(policy, FunctorType(inCell, points, threshold));
151 Kokkos::MDRangePolicy<typename DeviceType::execution_space,Kokkos::Rank<2>> policy({0,0},{points.extent(0),points.extent(1)});
152 Kokkos::parallel_for(policy, FunctorType(inCell, points, threshold));
157 template<
typename DeviceType>
158 template<
typename InCellViewType,
159 typename InputViewType>
163 const InputViewType points,
164 const shards::CellTopology cellTopo,
165 const typename ScalarTraits<typename InputViewType::value_type>::scalar_type threshold ) {
166#ifdef HAVE_INTREPID2_DEBUG
168 INTREPID2_TEST_FOR_EXCEPTION( (inCell.rank() != 1) && (inCell.rank() != 2), std::invalid_argument,
169 ">>> ERROR (Intrepid2::CellTools::checkPointwiseInclusion): InCell must have rank 1 or 2. ");
170 INTREPID2_TEST_FOR_EXCEPTION( points.extent(points.rank()-1) != cellTopo.getDimension(), std::invalid_argument,
171 ">>> ERROR (Intrepid2::CellTools::checkPointInclusion): Points and cell dimensions do not match. ");
172 INTREPID2_TEST_FOR_EXCEPTION( inCell.rank() != (points.rank()-1), std::invalid_argument,
173 ">>> ERROR (Intrepid2::CellTools::checkPointwiseInclusion): rank difference between inCell and points is 1.");
174 const ordinal_type iend = inCell.rank();
176 for (ordinal_type i=0;i<iend;++i) {
177 INTREPID2_TEST_FOR_EXCEPTION( inCell.extent(i) != points.extent(i), std::invalid_argument,
178 ">>> ERROR (Intrepid2::CellTools::checkPointwiseInclusion): dimension mismatch between inCell and points. " );
183 const auto key = cellTopo.getBaseKey();
186 case shards::Line<>::key :
187 checkPointwiseInclusion<shards::Line<>::key,
decltype(inCell),
decltype(points)>(inCell, points, threshold);
190 case shards::Beam<>::key :
191 checkPointwiseInclusion<shards::Beam<>::key,
decltype(inCell),
decltype(points)>(inCell, points, threshold);
194 case shards::ShellLine<>::key :
195 checkPointwiseInclusion<shards::ShellLine<>::key,
decltype(inCell),
decltype(points)>(inCell, points, threshold);
198 case shards::Triangle<>::key :
199 checkPointwiseInclusion<shards::Triangle<>::key,
decltype(inCell),
decltype(points)>(inCell, points, threshold);
202 case shards::ShellTriangle<>::key :
203 checkPointwiseInclusion<shards::ShellTriangle<>::key,
decltype(inCell),
decltype(points)>(inCell, points, threshold);
206 case shards::Quadrilateral<>::key :
207 checkPointwiseInclusion<shards::Quadrilateral<>::key,
decltype(inCell),
decltype(points)>(inCell, points, threshold);
210 case shards::ShellQuadrilateral<>::key :
211 checkPointwiseInclusion<shards::ShellQuadrilateral<>::key,
decltype(inCell),
decltype(points)>(inCell, points, threshold);
214 case shards::Tetrahedron<>::key :
215 checkPointwiseInclusion<shards::Tetrahedron<>::key,
decltype(inCell),
decltype(points)>(inCell, points, threshold);
218 case shards::Hexahedron<>::key :
219 checkPointwiseInclusion<shards::Hexahedron<>::key,
decltype(inCell),
decltype(points)>(inCell, points, threshold);
222 case shards::Wedge<>::key :
223 checkPointwiseInclusion<shards::Wedge<>::key,
decltype(inCell),
decltype(points)>(inCell, points, threshold);
226 case shards::Pyramid<>::key :
227 checkPointwiseInclusion<shards::Pyramid<>::key,
decltype(inCell),
decltype(points)>(inCell, points, threshold);
231 INTREPID2_TEST_FOR_EXCEPTION(
true,
232 std::invalid_argument,
233 ">>> ERROR (Intrepid2::CellTools::checkPointInclusion): Invalid cell topology. ");
237 template<
typename DeviceType>
238 template<
typename inCellValueType,
class ...inCellProperties,
239 typename pointValueType,
class ...pointProperties,
240 typename cellWorksetValueType,
class ...cellWorksetProperties>
244 const Kokkos::DynRankView<pointValueType,pointProperties...> points,
245 const Kokkos::DynRankView<cellWorksetValueType,cellWorksetProperties...> cellWorkset,
246 const shards::CellTopology cellTopo,
247 const typename ScalarTraits<pointValueType>::scalar_type threshold,
248 const typename ScalarTraits<pointValueType>::scalar_type shellThickness ) {
249#ifdef HAVE_INTREPID2_DEBUG
251 const auto key = cellTopo.getBaseKey();
252 const bool isShellorBeam = (key == shards::Beam<>::key) || (key == shards::ShellLine<>::key) || (key == shards::ShellTriangle<>::key) || (key == shards::ShellQuadrilateral<>::key);
253 INTREPID2_TEST_FOR_EXCEPTION( key != shards::Line<>::key &&
254 key != shards::Triangle<>::key &&
255 key != shards::Quadrilateral<>::key &&
256 key != shards::Tetrahedron<>::key &&
257 key != shards::Hexahedron<>::key &&
258 key != shards::Wedge<>::key &&
259 key != shards::Pyramid<>::key &&
261 std::invalid_argument,
262 ">>> ERROR (Intrepid2::CellTools::checkPointwiseInclusion): cell topology not supported");
263 INTREPID2_TEST_FOR_EXCEPTION( inCell.rank() != 2, std::invalid_argument,
264 ">>> ERROR (Intrepid2::CellTools::checkPointwiseInclusion): InCell must have rank 2. ");
265 INTREPID2_TEST_FOR_EXCEPTION( cellWorkset.rank() != 3, std::invalid_argument,
266 ">>> ERROR (Intrepid2::CellTools::checkPointwiseInclusion): cellWorkset must have rank 3. ");
267 INTREPID2_TEST_FOR_EXCEPTION( (points.rank() == 3) && (points.extent(0) != cellWorkset.extent(0)) , std::invalid_argument,
268 ">>> ERROR (Intrepid2::CellTools::checkPointInclusion): cellWorkset and points have incompatible dimensions. ");
269 INTREPID2_TEST_FOR_EXCEPTION( isShellorBeam && (shellThickness < 0.0) , std::invalid_argument,
270 ">>> ERROR (Intrepid2::CellTools::checkPointInclusion): beam and shell topologies require cell thickness information. ");
274 numCells = cellWorkset.extent(0),
275 numPoints = points.extent(points.rank()-2),
276 spaceDim = cellTopo.getDimension();
278 auto refPoints = Impl::createMatchingDynRankView(points,
"CellTools::checkPointwiseInclusion::refPoints", numCells, numPoints, spaceDim);
283 if(points.rank() == 3)
284 isValid = mapToReferenceFrame(refPoints, points, cellWorkset, cellTopo, shellThickness);
286 auto cellPoints = Impl::createMatchingDynRankView(points,
"CellTools::checkPointwiseInclusion::physCellPoints", numCells, numPoints, points.extent_int(1));
288 isValid = mapToReferenceFrame(refPoints, cellPoints, cellWorkset, cellTopo, shellThickness);
290 checkPointwiseInclusion(inCell, refPoints, cellTopo, threshold);
This class implements a distance function that computes the parametric distance of a point in a refer...