From 3ee6203e5a6c79c82217437fa071bd1781c381f9 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Wed, 18 Nov 2020 12:51:24 -0700 Subject: [PATCH] simplification to Pair::ev_setup() --- src/pair.cpp | 39 ++++++++++++++------------------------- 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/src/pair.cpp b/src/pair.cpp index 2cb0b2b210..bf43168407 100644 --- a/src/pair.cpp +++ b/src/pair.cpp @@ -779,21 +779,19 @@ void Pair::del_tally_callback(Compute *ptr) setup for energy, virial computation see integrate::ev_set() for bitwise settings of eflag/vflag set the following flags, values are otherwise 0: - evflag != 0 if any bits of eflag or vflag are set eflag_global != 0 if ENERGY_GLOBAL bit of eflag set eflag_atom != 0 if ENERGY_ATOM bit of eflag set eflag_either != 0 if eflag_global or eflag_atom is set - vflag_global = VIRIAL_PAIR if VIRIAL_PAIR bit of vflag set - vflag_global = VIRIAL_FDOTR if VIRIAL_FDOTR bit of vflag set - this setting also sets vflag_dotr = 1 if pair style supports it, - which unsets vflag_global and can also thus change other flags, - see logic at end of method + vflag_global != 0 if VIRIAL_PAIR bit of vflag set + vflag_global != 0 if VIRIAL_FDOTR bit of vflag is set but no_virial_fdotr = 1 + vflag_fdotr != 0 if VIRIAL_FDOTR bit of vflag set and no_virial_fdotr = 0 vflag_atom != 0 if VIRIAL_ATOM bit of vflag set vflag_atom != 0 if VIRIAL_CENTROID bit of vflag set and centroidstressflag != CENTROID_AVAIL cvflag_atom != 0 if VIRIAL_CENTROID bit of vflag set and centroidstressflag = CENTROID_AVAIL vflag_either != 0 if any of vflag_global, vflag_atom, cvflag_atom is set + evflag != 0 if eflag_either or vflag_either is set centroidstressflag is set by the pair style to one of these values: CENTROID_SAME = same as two-body stress CENTROID_AVAIL = different and implemented @@ -804,20 +802,20 @@ void Pair::ev_setup(int eflag, int vflag, int alloc) { int i,n; - evflag = 1; - eflag_either = eflag; eflag_global = eflag & ENERGY_GLOBAL; eflag_atom = eflag & ENERGY_ATOM; - - vflag_global = vflag & (VIRIAL_PAIR | VIRIAL_FDOTR); + + vflag_global = vflag & VIRIAL_PAIR; + if (vflag & VIRIAL_FDOTR && no_virial_fdotr_compute == 1) vflag_global = 1; + if (vflag & VIRIAL_FDOTR && no_virial_fdotr_compute == 0) vflag_fdotr = 1; vflag_atom = vflag & VIRIAL_ATOM; - if (vflag & VIRIAL_CENTROID && centroidstressflag != CENTROID_AVAIL) - vflag_atom = 1; - if (vflag & VIRIAL_CENTROID && centroidstressflag == CENTROID_AVAIL) - cvflag_atom = 1; + if (vflag & VIRIAL_CENTROID && centroidstressflag != CENTROID_AVAIL) vflag_atom = 1; + if (vflag & VIRIAL_CENTROID && centroidstressflag == CENTROID_AVAIL) cvflag_atom = 1; vflag_either = vflag_global || vflag_atom || cvflag_atom; + evflag = eflag_either || vflag_either; + // reallocate per-atom arrays if necessary if (eflag_atom && atom->nmax > maxeatom) { @@ -882,17 +880,6 @@ void Pair::ev_setup(int eflag, int vflag, int alloc) } } - // if vflag_global = VIRIAL_FDOTR 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 == VIRIAL_FDOTR && no_virial_fdotr_compute == 0) { - vflag_fdotr = 1; - vflag_global = 0; - if (!vflag_atom == 0 && !cvflag_atom) vflag_either = 0; - if (!vflag_either == 0 && !eflag_either) evflag = 0; - } else vflag_fdotr = 0; - // run ev_setup option for USER-TALLY computes if (num_tally_compute > 0) { @@ -1575,6 +1562,8 @@ void Pair::virial_fdotr_compute() double **x = atom->x; double **f = atom->f; + for (int i = 0; i < 6; i++) virial[i] = 0.0; + // sum over force on all particles including ghosts if (neighbor->includegroup == 0) {