IPPL (Independent Parallel Particle Layer)
IPPL
Loading...
Searching...
No Matches
ParticleSpatialLayout.h
Go to the documentation of this file.
1
2//
3// Class ParticleSpatialLayout
4// Particle layout based on spatial decomposition.
5//
6// This is a specialized version of ParticleLayout, which places particles
7// on processors based on their spatial location relative to a fixed grid.
8// In particular, this can maintain particles on processors based on a
9// specified FieldLayout or RegionLayout, so that particles are always on
10// the same node as the node containing the Field region to which they are
11// local. This may also be used if there is no associated Field at all,
12// in which case a grid is selected based on an even distribution of
13// particles among processors.
14//
15// After each 'time step' in a calculation, which is defined as a period
16// in which the particle positions may change enough to affect the global
17// layout, the user must call the 'update' routine, which will move
18// particles between processors, etc. After the Nth call to update, a
19// load balancing routine will be called instead. The user may set the
20// frequency of load balancing (N), or may supply a function to
21// determine if load balancing should be done or not.
22//
23#ifndef IPPL_PARTICLE_SPATIAL_LAYOUT_H
24#define IPPL_PARTICLE_SPATIAL_LAYOUT_H
25
26#include "Types/IpplTypes.h"
27
31#include "Region/RegionLayout.h"
32
33#include "Communicate/Window.h"
34#include <vector>
35
36namespace ippl {
37
44 template <typename T, unsigned Dim, class Mesh = UniformCartesian<T, Dim>,
45 typename... PositionProperties>
46 class ParticleSpatialLayout : public detail::ParticleLayout<T, Dim, PositionProperties...> {
47 public:
48 using Base = detail::ParticleLayout<T, Dim, PositionProperties...>;
50
54
59
61
62 public:
63 // constructor: this one also takes a Mesh
65
67 : detail::ParticleLayout<T, Dim, PositionProperties...>() {}
68
70
72
73 template <class ParticleContainer>
75
76 const RegionLayout_t& getRegionLayout() const { return rlayout_m; }
77
78 protected:
81
84
85
86 // Vector keeping track of the recieves from all ranks
87 std::vector<size_type> nRecvs_m;
88
89 // MPI RMA window for one-sided communication
91
93 using region_view_type = typename RegionLayout_t::view_type;
95 using region_type = typename region_view_type::value_type;
98
99 template <size_t... Idx>
100 KOKKOS_INLINE_FUNCTION constexpr static bool positionInRegion(
101 const std::index_sequence<Idx...>&, const vector_type& pos, const region_type& region);
102
109 size_type getNeighborSize(const neighbor_list& neighbors) const;
110
111 public:
122 template <typename ParticleContainer>
123 std::pair<size_type,size_type> locateParticles(const ParticleContainer& pc, locate_type& ranks,
124 bool_type& invalid, locate_type& nSends_dview, locate_type& sends_dview) const;
125
131 void fillHash(int rank, const locate_type& ranks, hash_type& hash);
132
137 size_t numberOfSends(int rank, const locate_type& ranks);
138 };
139} // namespace ippl
140
142
143#endif
144
constexpr unsigned Dim
Definition Archive.h:20
typename detail::ViewType< int, 1, MemorySpace >::view_type hash_type
Definition ViewTypes.h:49
std::size_t size_type
Definition IpplTypes.h:13
std::array< rank_list, detail::countHypercubes(Dim) - 1 > neighbor_list
typename particle_position_type::memory_space position_memory_space
typename particle_position_type::execution_space position_execution_space
size_t numberOfSends(int rank, const locate_type &ranks)
void update(ParticleContainer &pc)
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
KOKKOS_INLINE_FUNCTION static constexpr bool positionInRegion(const std::index_sequence< Idx... > &, const vector_type &pos, const region_type &region)
size_type getNeighborSize(const neighbor_list &neighbors) const
ParticleSpatialLayout(FieldLayout< Dim > &, Mesh &)
typename ippl::FieldLayout< Dim > FieldLayout_t
typename region_view_type::value_type region_type
Type of a single Region object.
void fillHash(int rank, const locate_type &ranks, hash_type &hash)
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
Type of the Kokkos view containing the local regions.
void updateLayout(FieldLayout< Dim > &, Mesh &)
std::pair< size_type, size_type > locateParticles(const ParticleContainer &pc, locate_type &ranks, bool_type &invalid, locate_type &nSends_dview, locate_type &sends_dview) const
typename FieldLayout_t::neighbor_list neighbor_list
Array of N rank lists, where N = number of hypercubes for the dimension Dim.
detail::ParticleLayout< T, Dim, PositionProperties... > Base
const RegionLayout_t & getRegionLayout() const
typename Base::vector_type vector_type
typename CreateUniformType< base_type, view_type >::type uniform_type
Kokkos::View< typename NPtr< T, Dim >::type, Properties... > view_type
Definition ViewTypes.h:45