1#ifndef OPAL_LOAD_BALANCER_H
2#define OPAL_LOAD_BALANCER_H
8template <
typename T,
unsigned Dim>
11template <
typename T,
unsigned Dim>
21 std::shared_ptr<ParticleContainer<T, Dim>>
pc_m;
22 std::shared_ptr<FieldSolver_t>
fs_m;
85 bool& isFirstRepartition) {
90 (*E_m).updateLayout(*fl);
91 (*rho_m).updateLayout(*fl);
93 if (
fs_m->getStype() ==
"CG") {
100 (*layout).updateLayout(*fl, *mesh);
104 if (!isFirstRepartition) {
116 bool& isFirstRepartition) {
123 bool res =
orb.binaryRepartition(*R, *fl, isFirstRepartition);
125 std::cout <<
"Could not repartition!" <<
std::endl;
130 if constexpr (
Dim == 2 ||
Dim == 3) {
131 if (
fs_m->getStype() ==
"FFT") {
132 std::get<FFTSolver_t<T, Dim>>(
fs_m->getSolver()).setRhs(*
rho_m);
134 if constexpr (
Dim == 3) {
135 if (
fs_m->getStype() ==
"TG") {
136 std::get<FFTTruncatedGreenSolver_t<T, Dim>>(
fs_m->getSolver()).setRhs(*
rho_m);
137 }
else if (
fs_m->getStype() ==
"OPEN") {
138 std::get<OpenSolver_t<T, Dim>>(
fs_m->getSolver()).setRhs(*
rho_m);
151 double equalPart = (double)totalP /
ippl::Comm->size();
152 double dev = std::abs((
double)
pc_m->getLocalNum() - equalPart) / totalP;
157 &local, 1, MPI_INT, res.data(), 1, MPI_INT,
ippl::Comm->getCommunicator());
159 for (
unsigned int i = 0; i < res.size(); i++) {
typename ippl::ParticleSpatialLayout< T, Dim, Mesh_t< Dim > > PLayout_t
ippl::detail::size_type size_type
Inform & endl(Inform &inf)
std::unique_ptr< mpi::Communicator > Comm
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)
unsigned int loadbalancefreq_m
double getLoadBalanceThreshold() const
VField_t< T, Dim > * getE() const
void repartition(ippl::FieldLayout< Dim > *fl, ippl::UniformCartesian< T, Dim > *mesh, bool &isFirstRepartition)
std::shared_ptr< FieldSolver_t > fs_m
void updateLayout(ippl::FieldLayout< Dim > *fl, ippl::UniformCartesian< T, Dim > *mesh, bool &isFirstRepartition)
bool balance(size_type totalP)
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
void updateLayout(Layout_t &, int nghost=1)
void setFieldBC(BConds_t &bc)
typename PLayout::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)