diff --git a/src/respa.cpp b/src/respa.cpp index d80a652c50..f3f0d2b36a 100644 --- a/src/respa.cpp +++ b/src/respa.cpp @@ -277,6 +277,14 @@ void Respa::init() ev_setup(); + // set flags for what arrays to clear in force_clear() + // need to clear torques,eforce if arrays exists + + torqueflag = 0; + if (atom->torque_flag) torqueflag = 1; + eforceflag = 0; + if (atom->eforce_flag) eforceflag = 1; + // step[] = timestep for each level step[nlevels-1] = update->dt; @@ -581,6 +589,8 @@ void Respa::recurse(int ilevel) void Respa::force_clear(int newtonflag) { + int i; + // clear global force array // nall includes ghosts only if newton flag is set @@ -589,11 +599,26 @@ void Respa::force_clear(int newtonflag) else nall = atom->nlocal; double **f = atom->f; - for (int i = 0; i < nall; i++) { + for (i = 0; i < nall; i++) { f[i][0] = 0.0; f[i][1] = 0.0; f[i][2] = 0.0; } + + if (torqueflag) { + double **torque = atom->torque; + for (i = 0; i < nall; i++) { + torque[i][0] = 0.0; + torque[i][1] = 0.0; + torque[i][2] = 0.0; + } + } + + if (eforceflag) { + double *eforce = atom->eforce; + for (i = 0; i < nall; i++) + eforce[i] = 0.0; + } } /* ---------------------------------------------------------------------- diff --git a/src/respa.h b/src/respa.h index 0e13493331..dbb981068a 100644 --- a/src/respa.h +++ b/src/respa.h @@ -53,6 +53,8 @@ class Respa : public Integrate { private: int triclinic; // 0 if domain is orthog, 1 if triclinic + int torqueflag; // zero out arrays every step + int eforceflag; int *newton; // newton flag at each level class FixRespa *fix_respa; // Fix to store the force level array