8 #ifndef WARPX_PARTICLES_SORTING_SORTINGUTILS_H_ 9 #define WARPX_PARTICLES_SORTING_SORTINGUTILS_H_ 45 template<
typename ForwardIterator >
47 ForwardIterator
const index_end,
53 int N =
static_cast<int>(std::distance(index_begin, index_end));
57 ForwardIterator sep = index_begin;
58 std::advance(sep, num_true);
61 ForwardIterator
const sep = std::stable_partition(
62 index_begin, index_end,
63 [&predicate](
long i) {
return predicate[
i]; }
76 template<
typename ForwardIterator >
78 ForwardIterator
const last)
80 return std::distance( first, last );
105 for (
int idim=0; idim<AMREX_SPACEDIM; idim++) {
156 long const start_index ) :
157 m_start_index(start_index) {
163 m_indices_ptr = particle_indices.
dataPtr();
165 for (
int idim=0; idim<AMREX_SPACEDIM; idim++) {
175 auto const& p =
m_particles[m_indices_ptr[i+m_start_index]];
202 template <
typename T>
213 m_indices_ptr = indices.
dataPtr();
218 m_dst_ptr[ip] = m_src_ptr[ m_indices_ptr[ip] ];
227 #endif // WARPX_PARTICLES_SORTING_SORTINGUTILS_H_ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void operator()(const long i) const
Definition: SortingUtils.H:113
WarpXParticleContainer::ParticleType const * m_particles
Definition: SortingUtils.H:129
const Real * InvCellSize() const noexcept
fillBufferFlagRemainingParticles(WarpXParIter const &pti, amrex::iMultiFab const *bmasks, amrex::Gpu::DeviceVector< int > &inexflag, amrex::Geometry const &geom, amrex::Gpu::DeviceVector< long > const &particle_indices, long const start_index)
Definition: SortingUtils.H:150
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void operator()(const long i) const
Definition: SortingUtils.H:173
const Real * ProbLo() const noexcept
long const * m_indices_ptr
Definition: SortingUtils.H:192
WarpXParticleContainer::ParticleType const * m_particles
Definition: SortingUtils.H:189
data
Definition: run_alltests_1node.py:325
iterator begin() noexcept
AoSRef GetArrayOfStructs() const
long const m_start_index
Definition: SortingUtils.H:191
Functor that fills the elements of the particle array inexflag with the value of the spatial array bm...
Definition: SortingUtils.H:147
T const * m_src_ptr
Definition: SortingUtils.H:222
int * m_inexflag_ptr
Definition: SortingUtils.H:128
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > m_inv_cell_size
Definition: SortingUtils.H:186
Functor that copies the elements of src into dst, while reordering them according to indices ...
Definition: SortingUtils.H:203
long const * m_indices_ptr
Definition: SortingUtils.H:224
copyAndReorder(amrex::Gpu::DeviceVector< T > const &src, amrex::Gpu::DeviceVector< T > &dst, amrex::Gpu::DeviceVector< long > const &indices)
Definition: SortingUtils.H:206
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > m_prob_lo
Definition: SortingUtils.H:185
#define AMREX_FORCE_INLINE
amrex::Box m_domain
Definition: SortingUtils.H:187
#define AMREX_GPU_HOST_DEVICE
i
Definition: check_interp_points_and_weights.py:174
ForwardIterator stablePartition(ForwardIterator const index_begin, ForwardIterator const index_end, amrex::Gpu::DeviceVector< int > const &predicate)
Find the indices that would reorder the elements of predicate so that the elements with non-zero valu...
Definition: SortingUtils.H:46
amrex::Box m_domain
Definition: SortingUtils.H:127
#define AMREX_FOR_1D(...)
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > m_prob_lo
Definition: SortingUtils.H:125
Particle< NStructReal, NStructInt > ParticleType
const Box & Domain() const noexcept
int iteratorDistance(ForwardIterator const first, ForwardIterator const last)
Return the number of elements between first and last
Definition: SortingUtils.H:77
int * m_inexflag_ptr
Definition: SortingUtils.H:188
amrex::Array4< int const > m_buffer_mask
Definition: SortingUtils.H:130
size_type size() const noexcept
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > m_inv_cell_size
Definition: SortingUtils.H:126
T * m_dst_ptr
Definition: SortingUtils.H:223
int StablePartition(T *data, int beg, int end, F &&f)
Definition: WarpXParticleContainer.H:49
Functor that fills the elements of the particle array inexflag with the value of the spatial array bm...
Definition: SortingUtils.H:93
void fillWithConsecutiveIntegers(amrex::Gpu::DeviceVector< long > &v)
Fill the elements of the input vector with consecutive integer, starting from 0.
Definition: SortingUtils.H:22
amrex::Array4< int const > m_buffer_mask
Definition: SortingUtils.H:190
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVect getParticleCell(P const &p, amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > const &plo, amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > const &dxi, const Box &domain) noexcept
fillBufferFlag(WarpXParIter const &pti, amrex::iMultiFab const *bmasks, amrex::Gpu::DeviceVector< int > &inexflag, amrex::Geometry const &geom)
Definition: SortingUtils.H:96
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void operator()(const long ip) const
Definition: SortingUtils.H:217