From d0b0c0940205a71534b96c4649aeffd983c4f9cf Mon Sep 17 00:00:00 2001 From: Remi Lehe Date: Fri, 11 Oct 2019 16:00:03 -0700 Subject: Fix particle partition in buffers --- Source/Particles/Sorting/SortingUtils.H | 70 ++++++++++++++++++++++++++++++--- 1 file changed, 64 insertions(+), 6 deletions(-) (limited to 'Source/Particles/Sorting/SortingUtils.H') diff --git a/Source/Particles/Sorting/SortingUtils.H b/Source/Particles/Sorting/SortingUtils.H index 852b8a73f..28a1b73b7 100644 --- a/Source/Particles/Sorting/SortingUtils.H +++ b/Source/Particles/Sorting/SortingUtils.H @@ -78,27 +78,84 @@ int iteratorDistance(ForwardIterator const first, /* \brief Functor that fills the elements of the particle array `inexflag` * with the value of the spatial array `bmasks`, at the corresponding particle position. * - * This is done only for the elements from `start_index` to the end of `inexflag` - * * \param[in] pti Contains information on the particle positions * \param[in] bmasks Spatial array, that contains a flag indicating * whether each cell is part of the gathering/deposition buffers * \param[out] inexflag Vector to be filled with the value of `bmasks` * \param[in] geom Geometry object, necessary to locate particles within the array `bmasks` - * \param[in] start_index Index that which elements start to be modified + * */ class fillBufferFlag { public: fillBufferFlag( WarpXParIter const& pti, amrex::iMultiFab const* bmasks, amrex::Gpu::DeviceVector& inexflag, - amrex::Geometry const& geom, long const start_index=0 ) : + amrex::Geometry const& geom ) { + + // Extract simple structure that can be used directly on the GPU + m_particles = &(pti.GetArrayOfStructs()[0]); + m_buffer_mask = (*bmasks)[pti].array(); + m_inexflag_ptr = inexflag.dataPtr(); + m_domain = geom.Domain(); + for (int idim=0; idim m_prob_lo; + amrex::GpuArray m_inv_cell_size; + amrex::Box m_domain; + int* m_inexflag_ptr; + WarpXParticleContainer::ParticleType const* m_particles; + amrex::Array4 m_buffer_mask; +}; + +/* \brief Functor that fills the elements of the particle array `inexflag` + * with the value of the spatial array `bmasks`, at the corresponding particle position. + * + * Contrary to `fillBufferFlag`, here this is done only for the particles that + * the last elements of `particle_indices` point to (from the element at + * index `start_index` in `particle_indices`, to the last element of `particle_indices`) + * + * \param[in] pti Contains information on the particle positions + * \param[in] bmasks Spatial array, that contains a flag indicating + * whether each cell is part of the gathering/deposition buffers + * \param[out] inexflag Vector to be filled with the value of `bmasks` + * \param[in] geom Geometry object, necessary to locate particles within the array `bmasks` + * \param[in] start_index Index that which elements start to be modified + */ +class fillBufferFlagRemainingParticles +{ + public: + fillBufferFlagRemainingParticles( + WarpXParIter const& pti, + amrex::iMultiFab const* bmasks, + amrex::Gpu::DeviceVector& inexflag, + amrex::Geometry const& geom, + amrex::Gpu::DeviceVector const& particle_indices, + long const start_index ) : m_start_index(start_index) { // Extract simple structure that can be used directly on the GPU m_particles = &(pti.GetArrayOfStructs()[0]); m_buffer_mask = (*bmasks)[pti].array(); m_inexflag_ptr = inexflag.dataPtr(); + m_indices_ptr = particle_indices.dataPtr(); m_domain = geom.Domain(); for (int idim=0; idim m_buffer_mask; long const m_start_index; + long const* m_indices_ptr; }; /* \brief Functor that copies the elements of `src` into `dst`, -- cgit v1.2.3