adjustments to balancing weights and factors, also XOR op for formulas, if, dump_modify thresh
This commit is contained in:
@ -43,7 +43,7 @@ fix 2 all wall/lj93 xlo 0.0 1 1 2.5 xhi $x 1 1 2.5
|
|||||||
fix 3 all wall/lj93 ylo 0.0 1 1 2.5 yhi $y 1 1 2.5
|
fix 3 all wall/lj93 ylo 0.0 1 1 2.5 yhi $y 1 1 2.5
|
||||||
|
|
||||||
comm_style tiled
|
comm_style tiled
|
||||||
comm_modify cutoff 7.5
|
comm_modify cutoff 10.0 # because bonds stretch a long ways
|
||||||
fix 10 all balance 50 0.9 rcb
|
fix 10 all balance 50 0.9 rcb
|
||||||
|
|
||||||
#compute 1 all property/atom proc
|
#compute 1 all property/atom proc
|
||||||
|
|||||||
@ -52,4 +52,3 @@ fix 0 all balance 50 1.0 shift x 5 1.0 &
|
|||||||
weight neigh 0.5 weight time 0.66 weight store WEIGHT
|
weight neigh 0.5 weight time 0.66 weight store WEIGHT
|
||||||
run 500
|
run 500
|
||||||
run 500
|
run 500
|
||||||
|
|
||||||
|
|||||||
@ -272,7 +272,7 @@ void Balance::command(int narg, char **arg)
|
|||||||
// imbinit = initial imbalance
|
// imbinit = initial imbalance
|
||||||
|
|
||||||
double maxinit;
|
double maxinit;
|
||||||
init_imbalance();
|
init_imbalance(0);
|
||||||
set_weights();
|
set_weights();
|
||||||
double imbinit = imbalance_factor(maxinit);
|
double imbinit = imbalance_factor(maxinit);
|
||||||
|
|
||||||
@ -543,12 +543,13 @@ void Balance::weight_storage(char *prefix)
|
|||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
invoke init() for each Imbalance class
|
invoke init() for each Imbalance class
|
||||||
|
flag = 0 for call from Balance, 1 for call from FixBalance
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void Balance::init_imbalance()
|
void Balance::init_imbalance(int flag)
|
||||||
{
|
{
|
||||||
if (!wtflag) return;
|
if (!wtflag) return;
|
||||||
for (int n = 0; n < nimbalance; n++) imbalances[n]->init();
|
for (int n = 0; n < nimbalance; n++) imbalances[n]->init(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
|
|||||||
@ -38,7 +38,7 @@ class Balance : protected Pointers {
|
|||||||
void command(int, char **);
|
void command(int, char **);
|
||||||
void options(int, int, char **);
|
void options(int, int, char **);
|
||||||
void weight_storage(char *);
|
void weight_storage(char *);
|
||||||
void init_imbalance();
|
void init_imbalance(int);
|
||||||
void set_weights();
|
void set_weights();
|
||||||
double imbalance_factor(double &);
|
double imbalance_factor(double &);
|
||||||
void shift_setup(char *, int, double);
|
void shift_setup(char *, int, double);
|
||||||
|
|||||||
@ -26,6 +26,7 @@
|
|||||||
#include "modify.h"
|
#include "modify.h"
|
||||||
#include "fix_store.h"
|
#include "fix_store.h"
|
||||||
#include "rcb.h"
|
#include "rcb.h"
|
||||||
|
#include "timer.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
@ -113,6 +114,7 @@ FixBalance::FixBalance(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
// only force reneighboring if nevery > 0
|
// only force reneighboring if nevery > 0
|
||||||
|
|
||||||
if (nevery) force_reneighbor = 1;
|
if (nevery) force_reneighbor = 1;
|
||||||
|
lastbalance = -1;
|
||||||
|
|
||||||
// compute initial outputs
|
// compute initial outputs
|
||||||
|
|
||||||
@ -153,7 +155,7 @@ void FixBalance::init()
|
|||||||
if (force->kspace) kspace_flag = 1;
|
if (force->kspace) kspace_flag = 1;
|
||||||
else kspace_flag = 0;
|
else kspace_flag = 0;
|
||||||
|
|
||||||
balance->init_imbalance();
|
balance->init_imbalance(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
@ -170,6 +172,12 @@ void FixBalance::setup(int vflag)
|
|||||||
|
|
||||||
void FixBalance::setup_pre_exchange()
|
void FixBalance::setup_pre_exchange()
|
||||||
{
|
{
|
||||||
|
// do not allow rebalancing twice on same timestep
|
||||||
|
// even if wanted to, can mess up elapsed time in ImbalanceTime
|
||||||
|
|
||||||
|
if (update->ntimestep == lastbalance) return;
|
||||||
|
lastbalance = update->ntimestep;
|
||||||
|
|
||||||
// insure atoms are in current box & update box via shrink-wrap
|
// insure atoms are in current box & update box via shrink-wrap
|
||||||
// has to be be done before rebalance() invokes Irregular::migrate_atoms()
|
// has to be be done before rebalance() invokes Irregular::migrate_atoms()
|
||||||
// since it requires atoms be inside simulation box
|
// since it requires atoms be inside simulation box
|
||||||
@ -202,6 +210,12 @@ void FixBalance::pre_exchange()
|
|||||||
|
|
||||||
if (nevery && update->ntimestep < next_reneighbor) return;
|
if (nevery && update->ntimestep < next_reneighbor) return;
|
||||||
|
|
||||||
|
// do not allow rebalancing twice on same timestep
|
||||||
|
// even if wanted to, can mess up elapsed time in ImbalanceTime
|
||||||
|
|
||||||
|
if (update->ntimestep == lastbalance) return;
|
||||||
|
lastbalance = update->ntimestep;
|
||||||
|
|
||||||
// insure atoms are in current box & update box via shrink-wrap
|
// insure atoms are in current box & update box via shrink-wrap
|
||||||
// no exchange() since doesn't matter if atoms are assigned to correct procs
|
// no exchange() since doesn't matter if atoms are assigned to correct procs
|
||||||
|
|
||||||
@ -284,7 +298,7 @@ void FixBalance::rebalance()
|
|||||||
if (kspace_flag) force->kspace->setup_grid();
|
if (kspace_flag) force->kspace->setup_grid();
|
||||||
|
|
||||||
// pending triggers pre_neighbor() to compute final imbalance factor
|
// pending triggers pre_neighbor() to compute final imbalance factor
|
||||||
// can only be done after atoms migrate in caller's comm->exchange()
|
// can only be done after atoms migrate in comm->exchange()
|
||||||
|
|
||||||
pending = 1;
|
pending = 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,6 +53,7 @@ class FixBalance : public Fix {
|
|||||||
int itercount; // iteration count of last call to Balance
|
int itercount; // iteration count of last call to Balance
|
||||||
int kspace_flag; // 1 if KSpace solver defined
|
int kspace_flag; // 1 if KSpace solver defined
|
||||||
int pending;
|
int pending;
|
||||||
|
bigint lastbalance; // last timestep balancing was attempted
|
||||||
|
|
||||||
class Balance *balance;
|
class Balance *balance;
|
||||||
class Irregular *irregular;
|
class Irregular *irregular;
|
||||||
|
|||||||
@ -25,13 +25,13 @@ class Imbalance : protected Pointers {
|
|||||||
virtual ~Imbalance() {};
|
virtual ~Imbalance() {};
|
||||||
|
|
||||||
// parse options. return number of arguments consumed (required)
|
// parse options. return number of arguments consumed (required)
|
||||||
virtual int options(int narg, char **arg) = 0;
|
virtual int options(int, char **) = 0;
|
||||||
// reinitialize internal data (needed for fix balance) (optional)
|
// reinitialize internal data (needed for fix balance) (optional)
|
||||||
virtual void init() {};
|
virtual void init(int) {};
|
||||||
// compute and apply weight factors to local atom array (required)
|
// compute and apply weight factors to local atom array (required)
|
||||||
virtual void compute(double *weights) = 0;
|
virtual void compute(double *) = 0;
|
||||||
// print information about the state of this imbalance compute (required)
|
// print information about the state of this imbalance compute (required)
|
||||||
virtual void info(FILE *fp) = 0;
|
virtual void info(FILE *) = 0;
|
||||||
|
|
||||||
// disallow default and copy constructor, assignment operator
|
// disallow default and copy constructor, assignment operator
|
||||||
// private:
|
// private:
|
||||||
|
|||||||
@ -19,9 +19,6 @@
|
|||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
|
||||||
// DEBUG
|
|
||||||
#include "update.h"
|
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
#define BIG 1.0e20
|
#define BIG 1.0e20
|
||||||
@ -41,12 +38,18 @@ int ImbalanceTime::options(int narg, char **arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
reset last, needed for fix balance caller
|
reset last and timers if necessary
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void ImbalanceTime::init()
|
void ImbalanceTime::init(int flag)
|
||||||
{
|
{
|
||||||
last = 0.0;
|
last = 0.0;
|
||||||
|
|
||||||
|
// flag = 1 if called from FixBalance at start of run
|
||||||
|
// init Timer, so accumulated time not carried over from previous run
|
||||||
|
// should NOT init Timer if called from Balance, it uses time from last run
|
||||||
|
|
||||||
|
if (flag) timer->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
@ -65,15 +68,6 @@ void ImbalanceTime::compute(double *weight)
|
|||||||
cost += timer->get_wall(Timer::BOND);
|
cost += timer->get_wall(Timer::BOND);
|
||||||
cost += timer->get_wall(Timer::KSPACE);
|
cost += timer->get_wall(Timer::KSPACE);
|
||||||
|
|
||||||
/*
|
|
||||||
printf("TIME %ld %d %g %g: %g %g %g %g\n",
|
|
||||||
update->ntimestep,atom->nlocal,last,cost,
|
|
||||||
timer->get_wall(Timer::PAIR),
|
|
||||||
timer->get_wall(Timer::NEIGH),
|
|
||||||
timer->get_wall(Timer::BOND),
|
|
||||||
timer->get_wall(Timer::KSPACE));
|
|
||||||
*/
|
|
||||||
|
|
||||||
double maxcost;
|
double maxcost;
|
||||||
MPI_Allreduce(&cost,&maxcost,1,MPI_DOUBLE,MPI_MAX,world);
|
MPI_Allreduce(&cost,&maxcost,1,MPI_DOUBLE,MPI_MAX,world);
|
||||||
if (maxcost <= 0.0) return;
|
if (maxcost <= 0.0) return;
|
||||||
|
|||||||
@ -27,7 +27,7 @@ class ImbalanceTime : public Imbalance {
|
|||||||
// parse options, return number of arguments consumed
|
// parse options, return number of arguments consumed
|
||||||
virtual int options(int, char **);
|
virtual int options(int, char **);
|
||||||
// reinitialize internal data
|
// reinitialize internal data
|
||||||
virtual void init();
|
virtual void init(int);
|
||||||
// compute and apply weight factors to local atom array
|
// compute and apply weight factors to local atom array
|
||||||
virtual void compute(double *);
|
virtual void compute(double *);
|
||||||
// print information about the state of this imbalance compute
|
// print information about the state of this imbalance compute
|
||||||
|
|||||||
@ -45,14 +45,14 @@ int ImbalanceVar::options(int narg, char **arg)
|
|||||||
int len = strlen(arg[0]) + 1;
|
int len = strlen(arg[0]) + 1;
|
||||||
name = new char[len];
|
name = new char[len];
|
||||||
memcpy(name,arg[0],len);
|
memcpy(name,arg[0],len);
|
||||||
init();
|
init(0);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
void ImbalanceVar::init()
|
void ImbalanceVar::init(int flag)
|
||||||
{
|
{
|
||||||
id = input->variable->find(name);
|
id = input->variable->find(name);
|
||||||
if (id < 0) {
|
if (id < 0) {
|
||||||
|
|||||||
@ -27,7 +27,7 @@ class ImbalanceVar : public Imbalance {
|
|||||||
// parse options. return number of arguments consumed.
|
// parse options. return number of arguments consumed.
|
||||||
virtual int options(int, char **);
|
virtual int options(int, char **);
|
||||||
// re-initialize internal data, e.g. variable ID
|
// re-initialize internal data, e.g. variable ID
|
||||||
virtual void init();
|
virtual void init(int);
|
||||||
// compute per-atom imbalance and apply to weight array
|
// compute per-atom imbalance and apply to weight array
|
||||||
virtual void compute(double *);
|
virtual void compute(double *);
|
||||||
// print information about the state of this imbalance compute (required)
|
// print information about the state of this imbalance compute (required)
|
||||||
|
|||||||
Reference in New Issue
Block a user