1#ifndef IPPL_LOAD_BALANCER_H
2#define IPPL_LOAD_BALANCER_H
8template <
typename T,
unsigned Dim>
18 std::shared_ptr<ParticleContainer<T, Dim>>
pc_m;
19 std::shared_ptr<FieldSolver_t>
fs_m;
54 bool& isFirstRepartition) {
59 (*E_m).updateLayout(*fl);
60 (*rho_m).updateLayout(*fl);
62 if (
fs_m->getStype() ==
"CG" ||
fs_m->getStype() ==
"PCG") {
63 phi_m->updateLayout(*fl);
69 (*layout).updateLayout(*fl, *mesh);
73 if (!isFirstRepartition) {
84 bool& isFirstRepartition) {
90 bool res =
orb.binaryRepartition(*R, *fl, isFirstRepartition);
92 std::cout <<
"Could not repartition!" << std::endl;
97 if constexpr (
Dim == 2 ||
Dim == 3) {
98 if (
fs_m->getStype() ==
"FFT") {
101 if constexpr (
Dim == 3) {
102 if (
fs_m->getStype() ==
"TG") {
104 }
else if (
fs_m->getStype() ==
"OPEN") {
115 if (std::strcmp(
TestName,
"UniformPlasmaTest") == 0) {
120 double equalPart = (double)totalP /
ippl::Comm->size();
121 double dev = std::abs((
double)
pc_m->getLocalNum() - equalPart) / totalP;
125 MPI_Allgather(&local, 1, MPI_INT, res.data(), 1, MPI_INT,
128 for (
unsigned int i = 0; i < res.size(); i++) {
Field< Vector_t< T, Dim >, Dim, ViewArgs... > VField_t
ippl::detail::size_type size_type
Field< double, Dim, ViewArgs... > Field_t
typename ippl::ParticleSpatialLayout< T, Dim, Mesh_t< Dim > > PLayout_t
ippl::OrthogonalRecursiveBisection< Field< double, Dim >, T > ORB
ippl::Field< T, Dim, Mesh_t< Dim >, Centering_t< Dim >, ViewArgs... > Field
KOKKOS_INLINE_FUNCTION auto & get(::ippl::Tuple< Ts... > &t)
std::unique_ptr< mpi::Communicator > Comm
typename ippl::ParticleSpatialLayout< T, Dim >::particle_position_type particle_position_type
Timing::TimerRef TimerRef
static TimerRef getTimer(const char *nm)
static void stopTimer(TimerRef t)
static void startTimer(TimerRef t)
std::shared_ptr< FieldSolver_t > getFieldSolver() const
double loadbalancethreshold_m
void setParticleContainer(std::shared_ptr< ParticleContainer< T, Dim > > pc)
Field_t< Dim > * getRho() const
void setE(VField_t< T, Dim > *E)
void setLoadBalanceThreshold(double threshold)
Field< T, Dim > * getPhi()
LoadBalancer(double lbs, std::shared_ptr< FieldContainer< T, Dim > > &fc, std::shared_ptr< ParticleContainer< T, Dim > > &pc, std::shared_ptr< FieldSolver_t > &fs)
void setRho(Field_t< Dim > *rho)
bool balance(size_type totalP, const unsigned int nstep)
unsigned int loadbalancefreq_m
double getLoadBalanceThreshold() const
VField_t< T, Dim > * getE() const
ippl::FieldSolverBase< T, Dim > FieldSolver_t
void repartition(ippl::FieldLayout< Dim > *fl, ippl::UniformCartesian< T, Dim > *mesh, bool &isFirstRepartition)
ippl::ParticleBase< ippl::ParticleSpatialLayout< T, Dim > > Base
std::shared_ptr< FieldSolver_t > fs_m
void updateLayout(ippl::FieldLayout< Dim > *fl, ippl::UniformCartesian< T, Dim > *mesh, bool &isFirstRepartition)
std::shared_ptr< ParticleContainer< T, Dim > > getParticleContainer() const
void setPhi(Field< T, Dim > *phi)
void setFieldSolver(std::shared_ptr< FieldSolver_t > fs)
void initializeORB(ippl::FieldLayout< Dim > *fl, ippl::UniformCartesian< T, Dim > *mesh)
std::shared_ptr< ParticleContainer< T, Dim > > pc_m