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;
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<
unsigned cellTopologyKey,
91 typename OutputViewType,
92 typename InputViewType>
93 struct checkPointInclusionFunctor {
94 OutputViewType output_;
96 using ScalarType =
typename ScalarTraits<typename InputViewType::value_type>::scalar_type;
97 ScalarType threshold_;
99 KOKKOS_INLINE_FUNCTION
100 checkPointInclusionFunctor( OutputViewType output,
101 const InputViewType input,
102 const ScalarType threshold)
105 threshold_(threshold) {}
107 KOKKOS_INLINE_FUNCTION
109 operator()(
const ordinal_type i)
const {
110 const auto in = Kokkos::subview(input_,i,Kokkos::ALL());
115 KOKKOS_INLINE_FUNCTION
117 operator()(
const ordinal_type i,
const ordinal_type j)
const {
118 const auto in = Kokkos::subview(input_,i,j,Kokkos::ALL());
120 output_(i,j) = check;
125 template<
typename DeviceType>
126 template<
unsigned cellTopologyKey,
127 typename OutputViewType,
128 typename InputViewType>
131 const InputViewType points,
132 const typename ScalarTraits<typename InputViewType::value_type>::scalar_type threshold) {
135 if (points.rank() == 2) {
136 Kokkos::RangePolicy<typename DeviceType::execution_space> policy(0, points.extent(0));
137 Kokkos::parallel_for(policy, FunctorType(inCell, points, threshold));
139 Kokkos::MDRangePolicy<typename DeviceType::execution_space,Kokkos::Rank<2>> policy({0,0},{points.extent(0),points.extent(1)});
140 Kokkos::parallel_for(policy, FunctorType(inCell, points, threshold));
145 template<
typename DeviceType>
146 template<
typename InCellViewType,
147 typename InputViewType>
151 const InputViewType points,
152 const shards::CellTopology cellTopo,
153 const typename ScalarTraits<typename InputViewType::value_type>::scalar_type threshold ) {
154#ifdef HAVE_INTREPID2_DEBUG
156 INTREPID2_TEST_FOR_EXCEPTION( (inCell.rank() != 1) && (inCell.rank() != 2), std::invalid_argument,
157 ">>> ERROR (Intrepid2::CellTools::checkPointwiseInclusion): InCell must have rank 1 or 2. ");
158 INTREPID2_TEST_FOR_EXCEPTION( points.extent(points.rank()-1) != cellTopo.getDimension(), std::invalid_argument,
159 ">>> ERROR (Intrepid2::CellTools::checkPointInclusion): Points and cell dimensions do not match. ");
160 INTREPID2_TEST_FOR_EXCEPTION( inCell.rank() != (points.rank()-1), std::invalid_argument,
161 ">>> ERROR (Intrepid2::CellTools::checkPointwiseInclusion): rank difference between inCell and points is 1.");
162 const ordinal_type iend = inCell.rank();
164 for (ordinal_type i=0;i<iend;++i) {
165 INTREPID2_TEST_FOR_EXCEPTION( inCell.extent(i) != points.extent(i), std::invalid_argument,
166 ">>> ERROR (Intrepid2::CellTools::checkPointwiseInclusion): dimension mismatch between inCell and points. " );
171 const auto key = cellTopo.getBaseKey();
174 case shards::Line<>::key :
175 checkPointwiseInclusion<shards::Line<>::key,
decltype(inCell),
decltype(points)>(inCell, points, threshold);
178 case shards::Beam<>::key :
179 checkPointwiseInclusion<shards::Beam<>::key,
decltype(inCell),
decltype(points)>(inCell, points, threshold);
182 case shards::ShellLine<>::key :
183 checkPointwiseInclusion<shards::ShellLine<>::key,
decltype(inCell),
decltype(points)>(inCell, points, threshold);
186 case shards::Triangle<>::key :
187 checkPointwiseInclusion<shards::Triangle<>::key,
decltype(inCell),
decltype(points)>(inCell, points, threshold);
190 case shards::ShellTriangle<>::key :
191 checkPointwiseInclusion<shards::ShellTriangle<>::key,
decltype(inCell),
decltype(points)>(inCell, points, threshold);
194 case shards::Quadrilateral<>::key :
195 checkPointwiseInclusion<shards::Quadrilateral<>::key,
decltype(inCell),
decltype(points)>(inCell, points, threshold);
198 case shards::ShellQuadrilateral<>::key :
199 checkPointwiseInclusion<shards::ShellQuadrilateral<>::key,
decltype(inCell),
decltype(points)>(inCell, points, threshold);
202 case shards::Tetrahedron<>::key :
203 checkPointwiseInclusion<shards::Tetrahedron<>::key,
decltype(inCell),
decltype(points)>(inCell, points, threshold);
206 case shards::Hexahedron<>::key :
207 checkPointwiseInclusion<shards::Hexahedron<>::key,
decltype(inCell),
decltype(points)>(inCell, points, threshold);
210 case shards::Wedge<>::key :
211 checkPointwiseInclusion<shards::Wedge<>::key,
decltype(inCell),
decltype(points)>(inCell, points, threshold);
214 case shards::Pyramid<>::key :
215 checkPointwiseInclusion<shards::Pyramid<>::key,
decltype(inCell),
decltype(points)>(inCell, points, threshold);
219 INTREPID2_TEST_FOR_EXCEPTION(
true,
220 std::invalid_argument,
221 ">>> ERROR (Intrepid2::CellTools::checkPointInclusion): Invalid cell topology. ");
225 template<
typename DeviceType>
226 template<
typename inCellValueType,
class ...inCellProperties,
227 typename pointValueType,
class ...pointProperties,
228 typename cellWorksetValueType,
class ...cellWorksetProperties>
232 const Kokkos::DynRankView<pointValueType,pointProperties...> points,
233 const Kokkos::DynRankView<cellWorksetValueType,cellWorksetProperties...> cellWorkset,
234 const shards::CellTopology cellTopo,
235 const typename ScalarTraits<pointValueType>::scalar_type threshold,
236 const typename ScalarTraits<pointValueType>::scalar_type shellThickness ) {
237#ifdef HAVE_INTREPID2_DEBUG
239 const auto key = cellTopo.getBaseKey();
240 const bool isShellorBeam = (key == shards::Beam<>::key) || (key == shards::ShellLine<>::key) || (key == shards::ShellTriangle<>::key) || (key == shards::ShellQuadrilateral<>::key);
241 INTREPID2_TEST_FOR_EXCEPTION( key != shards::Line<>::key &&
242 key != shards::Triangle<>::key &&
243 key != shards::Quadrilateral<>::key &&
244 key != shards::Tetrahedron<>::key &&
245 key != shards::Hexahedron<>::key &&
246 key != shards::Wedge<>::key &&
247 key != shards::Pyramid<>::key &&
249 std::invalid_argument,
250 ">>> ERROR (Intrepid2::CellTools::checkPointwiseInclusion): cell topology not supported");
251 INTREPID2_TEST_FOR_EXCEPTION( inCell.rank() != 2, std::invalid_argument,
252 ">>> ERROR (Intrepid2::CellTools::checkPointwiseInclusion): InCell must have rank 2. ");
253 INTREPID2_TEST_FOR_EXCEPTION( cellWorkset.rank() != 3, std::invalid_argument,
254 ">>> ERROR (Intrepid2::CellTools::checkPointwiseInclusion): cellWorkset must have rank 3. ");
255 INTREPID2_TEST_FOR_EXCEPTION( (points.rank() == 3) && (points.extent(0) != cellWorkset.extent(0)) , std::invalid_argument,
256 ">>> ERROR (Intrepid2::CellTools::checkPointInclusion): cellWorkset and points have incompatible dimensions. ");
257 INTREPID2_TEST_FOR_EXCEPTION( isShellorBeam && (shellThickness < 0.0) , std::invalid_argument,
258 ">>> ERROR (Intrepid2::CellTools::checkPointInclusion): beam and shell topologies require cell thickness information. ");
262 numCells = cellWorkset.extent(0),
263 numPoints = points.extent(points.rank()-2),
264 spaceDim = cellTopo.getDimension();
271 if(points.rank() == 3)
274 auto cellPoints =
Impl::createMatchingDynRankView(points,
"CellTools::checkPointwiseInclusion::physCellPoints", numCells, numPoints, points.extent_int(1));
276 isValid =
mapToReferenceFrame(refPoints, cellPoints, cellWorkset, cellTopo, shellThickness);
DeduceDynRankView< InViewType >::type createMatchingDynRankView(const InViewType &view, const CtorProp &prop, const Dims... dims)
Creates and returns a view that matches the value_type of the provided view The output view type is d...
virtual ordinal_type getDimension() const
Returns dimension of the integration domain.
This class implements a distance function that computes the parametric distance of a point in a refer...