20 #ifndef __pointFlagKernels_hpp__
21 #define __pointFlagKernels_hpp__
23 template<
typename ExecutionSpace>
28 Kokkos::IndexType<uint32>>;
31 aPoints(
"activePoints", activeRange_.end()+1);
35 "pFlow::pointFlag<ExecutionSpace>::getActivePoints",
36 rpAPoints(0,activeRange_.end()),
53 template<
typename ExecutionSpace>
60 Kokkos::IndexType<uint32>>;
72 indices(i) = flags[i] == DELETED;
78 Kokkos::parallel_reduce(
82 if(indices(i)!= indices(i+1) && indices(i)< numToGet)
84 emptyPoints(indices(i)) = i;
91 if(numFound < numToGet)
93 return Kokkos::subview(emptyPoints, Kokkos::make_pair(0u, numFound));
100 template<
typename ExecutionSpace>
108 Kokkos::IndexType<uint32>>;
112 uint32 start = activeRange().start();
113 uint32 end = activeRange().end();
120 Kokkos::parallel_reduce(
121 "pointFlagKernels::markOutOfBox",
122 rpScanFlag(start, end),
134 minUpdate = min(minUpdate,i);
135 maxUpdate = max(maxUpdate,i);
146 Kokkos::Min<uint32>(minRange),
147 Kokkos::Max<uint32>(maxRange),
151 if(numDeleted >= numActive_)
155 numDeleted = numActive_;
163 activeRange_ = {minRange, maxRange};
164 numActive_ = numActive_ - numDeleted;
166 (activeRange_.numElements() == numActive_)&& numActive_>0;
171 template<
typename ExecutionSpace>
178 if(points.extent(0)==0u)
return 0;
184 const auto& flag = flags_;
186 Kokkos::parallel_reduce(
187 "pointFlagKernels::addInternalPoints",
196 if( flag[idx] <= DELETED) addToUpdate ++;
197 minUpdate =
min(minUpdate,idx);
198 maxUpdate =
max(maxUpdate,idx);
199 flag[idx] = INTERNAL;
201 Kokkos::Min<uint32>(minRange),
202 Kokkos::Max<uint32>(maxRange),
208 minRange =
min(activeRange_.start(), minRange);
209 maxRange =
max(activeRange_.end(), maxRange);
211 activeRange_ = {minRange, maxRange};
212 numActive_ = numActive_ + numAdded;
214 isAllActive_ = activeRange_.numElements() == numActive_;
219 template<
typename ExecutionSpace>
225 if(points.
empty())
return true;
228 using policy = Kokkos::RangePolicy<
230 Kokkos::IndexType<uint32>>;
233 Kokkos::parallel_reduce
235 "pointFlagKernels::deletePoints",
243 flags_[
n] = Flag::DELETED;
249 if(numDeleted >= numActive_)
251 activeRange_ = {0, 0};
252 numDeleted = numActive_;
255 numActive_ = numActive_ - numDeleted;
257 (activeRange_.numElements() == numActive_)&& numActive_>0;
261 template<
typename ExecutionSpace>
269 if(s==0u)
return true;
271 using policy = Kokkos::RangePolicy<
273 Kokkos::IndexType<uint32>>;
276 Kokkos::parallel_reduce
278 "pointFlagKernels::deletePoints",
279 policy(0u, points.size()),
286 flags_[
n] = Flag::DELETED;
292 if(numDeleted >= numActive_)
294 activeRange_ = {0, 0};
295 numDeleted = numActive_;
298 numActive_ = numActive_ - numDeleted;
300 (activeRange_.numElements() == numActive_)&& numActive_>0;
306 template<
typename ExecutionSpace>
313 auto flg = getBoundaryFlag(boundaryIndex);
314 const auto& flags = flags_;
317 "pointFlag::changeFlags",
318 rPolicy(0, changePoints.size()),
321 flags[changePoints(i)] = flg;
328 template<
typename ExecutionSpace>
342 Kokkos::IndexType<uint32>>;
344 uint32 start = activeRange().start();
345 uint32 end = activeRange().end();
350 uint32 numMarkedDelete = 0;
351 uint32 nLeft = 0, nRight = 0;
352 uint32 nBottom = 0, nTop = 0;
353 uint32 nRear = 0, nFront = 0;
358 Kokkos::parallel_reduce(
359 "pointFlagKernels::markDeleteInDomain",
372 if(this->isActive(i))
384 minUpdate = min(minUpdate,i);
385 maxUpdate = max(maxUpdate,i);
387 if(dm.left().inPositiveDistance(p, leftLength))
393 if(dm.
right().inPositiveDistance(p, rightLength))
399 if(dm.
bottom().inPositiveDistance(p, bottomLength))
405 if(dm.
top().inPositiveDistance(p, topLength))
411 if(dm.
rear().inPositiveDistance(p, rearLength))
417 if(dm.
front().inPositiveDistance(p, frontLength))
423 flags_[i] = flg>
static_cast<uint8>(0)? flg: INTERNAL;
427 Kokkos::Min<uint32>(minRange),
428 Kokkos::Max<uint32>(maxRange),
440 if(numMarkedDelete>= numActive_)
444 numMarkedDelete = numActive_;
451 activeRange_ = {minRange, maxRange};
452 numActive_ -= numMarkedDelete;
453 isAllActive_ = (activeRange_.numElements() == numActive_)&& numActive_>0;
462 return numMarkedDelete;
465 template<
typename ExecutionSpace>
477 Kokkos::IndexType<uint32>>;
479 uint32 start = activeRange().start();
480 uint32 end = activeRange().end();
488 Kokkos::parallel_for(
489 "pointFlagKernels::markDeleteInDomain",
493 uint8 flg = flags_(i);
494 if(this->isBoundary(flg))
496 if(this->isLeft(flg)) leftList[Kokkos::atomic_fetch_add(&nElems[0],1)] = i;
497 if(this->isRight(flg))rightList[Kokkos::atomic_fetch_add(&nElems[1],1)] = i;
498 if(this->isBottom(flg))bottomList[Kokkos::atomic_fetch_add(&nElems[2],1)] = i;
499 if(this->isTop(flg))topList[Kokkos::atomic_fetch_add(&nElems[3],1)] = i;
500 if(this->isRear(flg))rearList[Kokkos::atomic_fetch_add(&nElems[4],1)] = i;
501 if(this->isFront(flg))frontList[Kokkos::atomic_fetch_add(&nElems[5],1)] = i;
508 template<
typename ExecutionSpace>
518 if(indices.size() == 0 )
return 0;
521 Kokkos::IndexType<uint32>>;
523 uint32 start = activeRange().start();
524 uint32 end = activeRange().end();
533 Kokkos::parallel_reduce(
534 "pointFlagKernels::markDelete",
535 rpScanFlag(0, indices.size()),
542 auto indx = indices(i);
546 flags_[indx] = DELETED;
552 minUpdate =
min(minUpdate,i);
553 maxUpdate =
max(maxUpdate,i);
557 Kokkos::Min<uint32>(minRange),
558 Kokkos::Max<uint32>(maxRange),
563 if(minRange<start || maxRange>end)
573 activeRange_ = {minRange, maxRange};
574 isAllActive_ = isAllActive_ && numMarked == 0;
575 numActive_ -= numMarked;
580 template<
typename ExecutionSpace>
587 uint32 oldCap = capacity();
589 uint32 emptySpots = newCap - numActive_;
591 while( emptySpots < reqEmptySpots )
594 emptySpots = newCap - numActive_;
597 viewType newFlags(flags_.label(), newCap);
599 copy(newFlags, 0u, flags_, 0u, oldCap);
600 fill(newFlags, oldCap, newCap,
static_cast<uint8>(DELETED));
608 #endif // __pointFlagKernels_hpp__