add balance styles shift/report and rcb/report for reporting imbalances only
This commit is contained in:
@ -14,15 +14,15 @@ Syntax
|
||||
* balance = style name of this fix command
|
||||
* Nfreq = perform dynamic load balancing every this many steps
|
||||
* thresh = imbalance threshold that must be exceeded to perform a re-balance
|
||||
* style = *shift* or *rcb*
|
||||
* style = *shift* *shift/report* or *rcb* or *rcb/report*
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
shift args = dimstr Niter stopthresh
|
||||
*shift* or *shift/report* args = dimstr Niter stopthresh
|
||||
dimstr = sequence of letters containing *x* or *y* or *z*, each not more than once
|
||||
Niter = # of times to iterate within each dimension of dimstr sequence
|
||||
stopthresh = stop balancing when this imbalance threshold is reached
|
||||
*rcb* args = none
|
||||
*rcb* or *rcb/report* args = none
|
||||
|
||||
* zero or more keyword/arg pairs may be appended
|
||||
* keyword = *weight* or *out*
|
||||
@ -70,6 +70,13 @@ re-balancing is performed periodically during the simulation. To
|
||||
perform "static" balancing, before or between runs, see the
|
||||
:doc:`balance <balance>` command.
|
||||
|
||||
.. versionadded:: TBD
|
||||
|
||||
The *shift/report* and *rcb/report* styles only compute the
|
||||
load imbalance but do not attempt any re-balancing. This way
|
||||
the load imbalance information can be used otherwise, for
|
||||
instance for stopping a run with :doc:`fix halt <fix_halt>`.
|
||||
|
||||
Load-balancing is typically most useful if the particles in the
|
||||
simulation box have a spatially-varying density distribution or
|
||||
where the computational cost varies significantly between different
|
||||
|
||||
@ -61,9 +61,18 @@ FixBalance::FixBalance(LAMMPS *lmp, int narg, char **arg) :
|
||||
if (nevery < 0) error->all(FLERR,"Illegal fix balance command");
|
||||
thresh = utils::numeric(FLERR,arg[4],false,lmp);
|
||||
|
||||
if (strcmp(arg[5],"shift") == 0) lbstyle = SHIFT;
|
||||
else if (strcmp(arg[5],"rcb") == 0) lbstyle = BISECTION;
|
||||
else error->all(FLERR,"Illegal fix balance command");
|
||||
reportonly = 0;
|
||||
if (strcmp(arg[5],"shift") == 0) {
|
||||
lbstyle = SHIFT;
|
||||
} else if (strcmp(arg[5],"shift/report") == 0) {
|
||||
lbstyle = SHIFT;
|
||||
reportonly = 1;
|
||||
} else if (strcmp(arg[5],"rcb") == 0) {
|
||||
lbstyle = BISECTION;
|
||||
} else if (strcmp(arg[5],"rcb/report") == 0) {
|
||||
lbstyle = BISECTION;
|
||||
reportonly = 1;
|
||||
} else error->all(FLERR,"Unknown fix balance style {}", arg[5]);
|
||||
|
||||
int iarg = 5;
|
||||
if (lbstyle == SHIFT) {
|
||||
@ -75,7 +84,6 @@ FixBalance::FixBalance(LAMMPS *lmp, int narg, char **arg) :
|
||||
stopthresh = utils::numeric(FLERR,arg[iarg+3],false,lmp);
|
||||
if (stopthresh < 1.0) error->all(FLERR,"Illegal fix balance command");
|
||||
iarg += 4;
|
||||
|
||||
} else if (lbstyle == BISECTION) {
|
||||
iarg++;
|
||||
}
|
||||
@ -175,7 +183,7 @@ void FixBalance::setup(int /*vflag*/)
|
||||
void FixBalance::setup_pre_exchange()
|
||||
{
|
||||
// do not allow rebalancing twice on same timestep
|
||||
// even if wanted to, can mess up elapsed time in ImbalanceTime
|
||||
// even if you wanted to, it can mess up elapsed time in ImbalanceTime
|
||||
|
||||
if (update->ntimestep == lastbalance) return;
|
||||
lastbalance = update->ntimestep;
|
||||
@ -195,6 +203,7 @@ void FixBalance::setup_pre_exchange()
|
||||
|
||||
balance->set_weights();
|
||||
imbnow = balance->imbalance_factor(maxloadperproc);
|
||||
|
||||
if (imbnow > thresh) rebalance();
|
||||
|
||||
// next timestep to rebalance
|
||||
@ -263,6 +272,13 @@ void FixBalance::pre_neighbor()
|
||||
|
||||
void FixBalance::rebalance()
|
||||
{
|
||||
// return immediately if only reporting of the imbalance is requested
|
||||
|
||||
if (reportonly) {
|
||||
imbprev = imbfinal = imbnow;
|
||||
return;
|
||||
}
|
||||
|
||||
imbprev = imbnow;
|
||||
|
||||
// invoke balancer and reset comm->uniform flag
|
||||
|
||||
@ -45,6 +45,7 @@ class FixBalance : public Fix {
|
||||
std::string bstr;
|
||||
int wtflag; // 1 for weighted balancing
|
||||
int sortflag; // 1 for sorting comm messages
|
||||
int reportonly; // 1 if skipping rebalancing and only computing imbalance
|
||||
|
||||
double imbnow; // current imbalance factor
|
||||
double imbprev; // imbalance factor before last rebalancing
|
||||
|
||||
Reference in New Issue
Block a user