17#ifndef IPPL_PARTICLE_SPATIAL_OVERLAP_LAYOUT_H
18#define IPPL_PARTICLE_SPATIAL_OVERLAP_LAYOUT_H
37 template <
typename T,
unsigned Dim,
class Mesh = UniformCartesian<T, Dim>,
38 typename... PositionProperties>
56 using index_t =
typename hash_type::value_type;
69 using locate_type_nd = Kokkos::View<index_t * [1 << Dim], position_memory_space>;
127 template <
class ParticleContainer>
137 template <
typename ExecutionSpace,
typename Functor>
206 template <
typename ParticleContainer>
275 template <
class ParticleContainer>
283 template <
class ParticleContainer>
291 template <
class ParticleContainer>
302 template <std::size_t... Idx>
330 template <std::size_t... Idx>
332 const std::index_sequence<Idx...>&,
const CellIndex_t& index,
341 template <std::size_t... Idx>
366 const hash_type& cellPermutationForward);
KOKKOS_INLINE_FUNCTION constexpr unsigned int countHypercubes(unsigned int dim)
std::array< rank_list, detail::countHypercubes(Dim) - 1 > neighbor_list
typename particle_position_type::memory_space position_memory_space
ParticleAttrib< vector_type, PositionProperties... > particle_position_type
typename particle_position_type::execution_space position_execution_space
typename detail::ViewType< bool, 1, position_memory_space >::view_type bool_type
typename detail::RegionLayout< T, Dim, Mesh, position_memory_space >::uniform_type RegionLayout_t
ParticleSpatialLayout(FieldLayout< Dim > &, Mesh &)
typename ippl::FieldLayout< Dim > FieldLayout_t
typename region_view_type::value_type region_type
typename detail::ViewType< int, 1, position_memory_space >::view_type locate_type
detail::hash_type< position_memory_space > hash_type
typename RegionLayout_t::view_type region_view_type
typename Base::vector_type vector_type
Vector< size_type, Dim > numCells_m
! number of cells in each dimension
ParticleNeighborData getParticleNeighborData() const
void fillHash(int rank, const locate_type &ranks, const locate_type &offsets, hash_type &hash)
utility function to collect all indices of particles to send to given rank
Kokkos::View< index_t *[1<< Dim], position_memory_space > locate_type_nd
Vector< size_type, Dim > cellStrides_m
! strides to compute cell indices
static constexpr size_type numGhostCellsPerDim_m
! number of ghost cells
KOKKOS_INLINE_FUNCTION static constexpr cell_particle_neighbor_list_type getCellNeighbors(const CellIndex_t &cellIndex, const Vector< size_type, Dim > &cellStrides, const hash_type &cellPermutationForward)
get all indices of cell neighbors of a given nd-cell-index
void updateLayout(FieldLayout< Dim > &, Mesh &)
size_type numGhostCells_m
! the number of interior cells
KOKKOS_INLINE_FUNCTION static constexpr CellIndex_t toCellIndex(FlatCellIndex_t nonPermutedIndex, const Vector< size_type, Dim > &numCells)
size_type numberOfSends(int rank, const locate_type &ranks)
utility function to compute how many particles to sent to a given rank
locate_type getNonNeighborRanks(const locate_type &neighbors_view) const
utility function to get a view of all non-neighboring ranks
KOKKOS_INLINE_FUNCTION static constexpr bool isLocalCellIndex(const std::index_sequence< Idx... > &, const CellIndex_t &index, const Vector< size_type, Dim > &numCells)
determines whether cell index is local cell index
ParticleSpatialLayout< T, Dim, Mesh, PositionProperties... > Base
KOKKOS_INLINE_FUNCTION static constexpr FlatCellIndex_t toFlatCellIndex(const CellIndex_t &cellIndex, const Vector< size_type, Dim > &cellStrides, hash_type cellPermutationForward)
convert a nd-cell-index to flat cell index
static KOKKOS_FUNCTION particle_neighbor_list_type getParticleNeighbors(index_t particleIndex, const ParticleNeighborData &particleNeighborData)
Function to get particle neighbors depending on index (possible inside Kokkos parallel region) make s...
~ParticleSpatialOverlapLayout()=default
const T rcutoff_m
! overlap in each dimension
void particleExchange(ParticleContainer &pc)
exchange particles by scanning neighbor ranks first, only scan other ranks if needed....
hash_type cellPermutationBackward_m
! the inverse of cellPermutationForward_m
size_type numLocalParticles_m
! the number of local particles (particles in local cells)
hash_type cellParticleCount_m
! view of number of particles in each cell
detail::size_type size_type
hash_type cellStartingIdx_m
! cell i contains particles cellStartingIdx_m(i), ..., cellStartingIdx_m(i + 1) - 1
typename FieldLayout_t::neighbor_list neighbor_list
Array of N rank lists, where N = number of hypercubes for the dimension Dim.
Vector< size_type, Dim > CellIndex_t
std::pair< detail::size_type, detail::size_type > locateParticles(const ParticleContainer &pc, locate_type &ranks, locate_type &rankOffsets, bool_type &invalid, locate_type &nSends_dview, locate_type &sends_dview) const
This function determines to which rank particles need to be sent after the iteration step....
typename hash_type::value_type index_t
KOKKOS_INLINE_FUNCTION static constexpr CellIndex_t getCellIndex(const vector_type &pos, const region_type ®ion, const Vector< T, Dim > &cellWidth)
get the nd-cell-index of a position
void createPeriodicGhostParticles(ParticleContainer &pc)
copies particles close to the boundary and offsets them to their closest periodic image
KOKKOS_INLINE_FUNCTION static constexpr bool positionInRegion(const std::index_sequence< Idx... > &, const vector_type &pos, const region_type ®ion, T overlap)
determines whether a position is in a region including its overlap
size_type totalCells_m
! the number of total cells
KOKKOS_INLINE_FUNCTION static constexpr bool isCloseToBoundary(const std::index_sequence< Idx... > &, const vector_type &pos, const region_type ®ion, Vector< bool, Dim > periodic, T overlap)
determines whether a position is within overlap to the boundary of a region
void update(ParticleContainer &pc)
updates particles by exchanging them across ranks according to their positions. then constructs the p...
ParticleSpatialOverlapLayout()
hash_type particle_neighbor_list_type
typename CellIndex_t::value_type FlatCellIndex_t
ParticleSpatialOverlapLayout(FieldLayout< Dim > &fl, Mesh &mesh, const T &rcutoff)
void forEachPair(Functor &&f) const
call functor for each combination i, j. make sure to call update first
size_type numLocalCells_m
! the number of ghost cells
hash_type cellPermutationForward_m
void buildCells(ParticleContainer &pc)
builds the cell structure, sorts the particles according to the cells and makes sure only local parti...
locate_type getFlatNeighbors(const neighbor_list &neighbors) const
utility function to get a flat view of all neighbor processes
void initializeCells()
initializes all data necessary for the cells
Kokkos::Array< size_type, detail::countHypercubes(Dim)> cell_particle_neighbor_list_type
Vector< T, Dim > cellWidth_m
! width of cells in each dimension
Vector< size_type, Dim > cellStrides
hash_type cellPermutationBackward
friend class ParticleSpatialOverlapLayout
hash_type cellParticleCount
hash_type cellPermutationForward
hash_type cellStartingIdx
size_type numLocalParticles
ParticleNeighborData(size_type numLocalParticles, Vector< size_type, Dim > cellStrides, Vector< size_type, Dim > numCells, Vector< T, Dim > cellWidth, region_type region, hash_type cellStartingIdx, hash_type cellIndex, hash_type cellParticleCount, hash_type cellPermutationForward, hash_type cellPermutationBackward)
Vector< T, Dim > cellWidth
Vector< size_type, Dim > numCells