intial refactoring of THERMO_ENERGY mask
This commit is contained in:
51
src/fix.cpp
51
src/fix.cpp
@ -63,9 +63,11 @@ Fix::Fix(LAMMPS *lmp, int /*narg*/, char **arg) :
|
||||
box_change = NO_BOX_CHANGE;
|
||||
thermo_energy = 0;
|
||||
thermo_virial = 0;
|
||||
energy_global_flag = energy_atom_flag = 0;
|
||||
virial_global_flag = virial_atom_flag = 0;
|
||||
ecouple_flag = 0;
|
||||
rigid_flag = 0;
|
||||
peatom_flag = 0;
|
||||
virial_flag = 0;
|
||||
no_change_box = 0;
|
||||
time_integrate = 0;
|
||||
time_depend = 0;
|
||||
@ -150,8 +152,7 @@ void Fix::modify_params(int narg, char **arg)
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix_modify command");
|
||||
if (strcmp(arg[iarg+1],"no") == 0) thermo_energy = 0;
|
||||
else if (strcmp(arg[iarg+1],"yes") == 0) {
|
||||
if (!(THERMO_ENERGY & setmask()))
|
||||
error->all(FLERR,"Illegal fix_modify command");
|
||||
if (energy_flag == 0) error->all(FLERR,"Illegal fix_modify command");
|
||||
thermo_energy = 1;
|
||||
} else error->all(FLERR,"Illegal fix_modify command");
|
||||
iarg += 2;
|
||||
@ -159,8 +160,7 @@ void Fix::modify_params(int narg, char **arg)
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix_modify command");
|
||||
if (strcmp(arg[iarg+1],"no") == 0) thermo_virial = 0;
|
||||
else if (strcmp(arg[iarg+1],"yes") == 0) {
|
||||
if (virial_flag == 0)
|
||||
error->all(FLERR,"Illegal fix_modify command");
|
||||
if (virial_flag == 0) error->all(FLERR,"Illegal fix_modify command");
|
||||
thermo_virial = 1;
|
||||
} else error->all(FLERR,"Illegal fix_modify command");
|
||||
iarg += 2;
|
||||
@ -180,9 +180,12 @@ void Fix::modify_params(int narg, char **arg)
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
setup for energy, virial computation
|
||||
setup for peratom energy and global/peratom virial computation
|
||||
see integrate::ev_set() for values of eflag (0-3) and vflag (0-6)
|
||||
fixes call this if they use ev_tally()
|
||||
fixes call Fix::ev_init() if tally energy and virial values
|
||||
if thermo_energy is not set, energy tallying is disabled
|
||||
if thermo_virial is not set, virial tallying is disabled
|
||||
global energy is tallied separately, output by compute_scalar() method
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Fix::ev_setup(int eflag, int vflag)
|
||||
@ -191,13 +194,19 @@ void Fix::ev_setup(int eflag, int vflag)
|
||||
|
||||
evflag = 1;
|
||||
|
||||
eflag_either = eflag;
|
||||
eflag_global = eflag & ENERGY_GLOBAL;
|
||||
eflag_atom = eflag & ENERGY_ATOM;
|
||||
if (!thermo_energy) eflag_either = eflag_global = eflag_atom = 0;
|
||||
else {
|
||||
eflag_either = eflag;
|
||||
eflag_global = eflag & ENERGY_GLOBAL;
|
||||
eflag_atom = eflag & ENERGY_ATOM;
|
||||
}
|
||||
|
||||
vflag_either = vflag;
|
||||
vflag_global = vflag & (VIRIAL_PAIR | VIRIAL_FDOTR);
|
||||
vflag_atom = vflag & (VIRIAL_ATOM | VIRIAL_CENTROID);
|
||||
if (!thermo_virial) vflag_either = vflag_global = vflag_atom = 0;
|
||||
else {
|
||||
vflag_either = vflag;
|
||||
vflag_global = vflag & (VIRIAL_PAIR | VIRIAL_FDOTR);
|
||||
vflag_atom = vflag & (VIRIAL_ATOM | VIRIAL_CENTROID);
|
||||
}
|
||||
|
||||
// reallocate per-atom arrays if necessary
|
||||
|
||||
@ -235,24 +244,17 @@ void Fix::ev_setup(int eflag, int vflag)
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
if thermo_virial is on:
|
||||
setup for virial computation
|
||||
see integrate::ev_set() for values of vflag
|
||||
fixes call this if use v_tally()
|
||||
else: set evflag=0
|
||||
setup for global/peratom virial computation
|
||||
see integrate::ev_set() for values of vflag (0-6)
|
||||
fixes call Fix::v_init() if tally virial values but not energy
|
||||
if thermo_virial is not set, virial tallying is disabled
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Fix::v_setup(int vflag)
|
||||
{
|
||||
int i,n;
|
||||
|
||||
if (!thermo_virial) {
|
||||
evflag = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
evflag = 1;
|
||||
|
||||
vflag_global = vflag & (VIRIAL_PAIR | VIRIAL_FDOTR);
|
||||
vflag_atom = vflag & (VIRIAL_ATOM | VIRIAL_CENTROID);
|
||||
|
||||
@ -304,7 +306,6 @@ void Fix::ev_tally(int n, int *list, double total, double eng, double *v)
|
||||
v_tally(n,list,total,v);
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
tally virial into global and per-atom accumulators
|
||||
n = # of local owned atoms involved, with local indices in list
|
||||
|
||||
Reference in New Issue
Block a user