Introduce enums for energy and virial flags

This commit is contained in:
Richard Berger
2020-11-11 22:09:03 -05:00
parent c0a101192e
commit f24320d26a
3 changed files with 25 additions and 11 deletions

View File

@ -125,7 +125,7 @@ void Integrate::ev_setup()
vflag = 8 = per-atom centroid virial only
vflag = 9 or 10 = both global and per-atom centroid virial
vflag = 12 = both per-atom virial and per-atom centroid virial
vflag = 13 or 15 = global, per-atom virial and per-atom centroid virial
vflag = 13 or 14 = global, per-atom virial and per-atom centroid virial
------------------------------------------------------------------------- */
void Integrate::ev_set(bigint ntimestep)
@ -142,7 +142,7 @@ void Integrate::ev_set(bigint ntimestep)
int eflag_atom = 0;
for (i = 0; i < nelist_atom; i++)
if (elist_atom[i]->matchstep(ntimestep)) flag = 1;
if (flag) eflag_atom = 2;
if (flag) eflag_atom = ENERGY_PER_ATOM;
if (eflag_global) update->eflag_global = ntimestep;
if (eflag_atom) update->eflag_atom = ntimestep;
@ -158,13 +158,13 @@ void Integrate::ev_set(bigint ntimestep)
int vflag_atom = 0;
for (i = 0; i < nvlist_atom; i++)
if (vlist_atom[i]->matchstep(ntimestep)) flag = 1;
if (flag) vflag_atom = 4;
if (flag) vflag_atom = VIRIAL_PER_ATOM;
flag = 0;
int cvflag_atom = 0;
for (i = 0; i < ncvlist_atom; i++)
if (cvlist_atom[i]->matchstep(ntimestep)) flag = 1;
if (flag) cvflag_atom = 8;
if (flag) cvflag_atom = VIRIAL_PER_ATOM_CENTROID;
if (vflag_global) update->vflag_global = ntimestep;
if (vflag_atom || cvflag_atom) update->vflag_atom = ntimestep;

View File

@ -786,14 +786,14 @@ void Pair::ev_setup(int eflag, int vflag, int alloc)
evflag = 1;
eflag_either = eflag;
eflag_global = eflag % 2;
eflag_atom = eflag / 2;
eflag_global = eflag & ENERGY_GLOBAL;
eflag_atom = eflag & ENERGY_PER_ATOM;
vflag_global = vflag % 4;
vflag_atom = vflag & 4;
vflag_global = vflag & (VIRIAL_GLOBAL_PW_SUM | VIRIAL_GLOBAL_PW_FDOTR_W_GHOSTS);
vflag_atom = vflag & VIRIAL_PER_ATOM;
cvflag_atom = 0;
if (vflag & 8) {
if (vflag & VIRIAL_PER_ATOM_CENTROID) {
if (centroidstressflag & 2) {
cvflag_atom = 1;
} else {
@ -869,11 +869,11 @@ void Pair::ev_setup(int eflag, int vflag, int alloc)
}
}
// if vflag_global = 2 and pair::compute() calls virial_fdotr_compute()
// if vflag_global = VIRIAL_GLOBAL_PW_FDOTR_W_GHOSTS and pair::compute() calls virial_fdotr_compute()
// compute global virial via (F dot r) instead of via pairwise summation
// unset other flags as appropriate
if (vflag_global == 2 && no_virial_fdotr_compute == 0) {
if (vflag_global == VIRIAL_GLOBAL_PW_FDOTR_W_GHOSTS && no_virial_fdotr_compute == 0) {
vflag_fdotr = 1;
vflag_global = 0;
if (vflag_atom == 0 && cvflag_atom == 0) vflag_either = 0;

View File

@ -18,6 +18,20 @@
namespace LAMMPS_NS {
enum {
ENERGY_NO_COMPUTATION = 0x00,
ENERGY_GLOBAL = 0x01,
ENERGY_PER_ATOM = 0x02
};
enum {
VIRIAL_NO_COMPUTATION = 0x00,
VIRIAL_GLOBAL_PW_SUM = 0x01,
VIRIAL_GLOBAL_PW_FDOTR_W_GHOSTS = 0x02,
VIRIAL_PER_ATOM = 0x04,
VIRIAL_PER_ATOM_CENTROID = 0x08
};
class Pair : protected Pointers {
friend class AngleSDK;
friend class AngleSDKOMP;