diff --git a/src/USER-TALLY/compute_force_tally.cpp b/src/USER-TALLY/compute_force_tally.cpp index e97a1c751c..f4a056158b 100644 --- a/src/USER-TALLY/compute_force_tally.cpp +++ b/src/USER-TALLY/compute_force_tally.cpp @@ -69,18 +69,42 @@ void ComputeForceTally::init() else force->pair->add_tally_callback(this); - if (force->pair->single_enable == 0 || force->pair->manybody_flag) - error->warning(FLERR,"Compute force/tally used with incompatible pair style"); - - if ((comm->me == 0) && (force->bond || force->angle || force->dihedral - || force->improper || force->kspace)) - error->warning(FLERR,"Compute force/tally only called from pair style"); + if (comm->me == 0) { + if (force->pair->single_enable == 0 || force->pair->manybody_flag) + error->warning(FLERR,"Compute force/tally used with incompatible pair style"); + if (force->bond || force->angle || force->dihedral + || force->improper || force->kspace) + error->warning(FLERR,"Compute force/tally only called from pair style"); + } did_compute = -1; } +/* ---------------------------------------------------------------------- */ + +void ComputeForceTally::setup() +{ + const int ntotal = atom->nlocal + atom->nghost; + + if (atom->nmax > nmax) { + memory->destroy(fatom); + nmax = atom->nmax; + memory->create(fatom,nmax,size_peratom_cols,"force/tally:fatom"); + array_atom = fatom; + } + + // clear storage as needed + + for (int i=0; i < ntotal; ++i) + for (int j=0; j < size_peratom_cols; ++j) + fatom[i][j] = 0.0; + + for (int i=0; i < size_peratom_cols; ++i) + vector[i] = ftotal[i] = 0.0; +} /* ---------------------------------------------------------------------- */ + void ComputeForceTally::pair_tally_callback(int i, int j, int nlocal, int newton, double, double, double fpair, double dx, double dy, double dz) @@ -197,7 +221,7 @@ double ComputeForceTally::compute_scalar() void ComputeForceTally::compute_peratom() { invoked_peratom = update->ntimestep; - if ((did_compute != invoked_peratom) || (update->eflag_global != invoked_peratom)) + if (((atom->nlocal > 0) && (did_compute != invoked_peratom)) || (update->eflag_global != invoked_peratom)) error->all(FLERR,"Energy was not tallied on needed timestep"); // collect contributions from ghost atoms diff --git a/src/USER-TALLY/compute_force_tally.h b/src/USER-TALLY/compute_force_tally.h index 0f7bc35a6d..96de68cdf2 100644 --- a/src/USER-TALLY/compute_force_tally.h +++ b/src/USER-TALLY/compute_force_tally.h @@ -31,6 +31,7 @@ class ComputeForceTally : public Compute { virtual ~ComputeForceTally(); void init(); + void setup(); double compute_scalar(); void compute_peratom(); diff --git a/src/USER-TALLY/compute_heat_flux_tally.cpp b/src/USER-TALLY/compute_heat_flux_tally.cpp index 48cad538d5..0227de3160 100644 --- a/src/USER-TALLY/compute_heat_flux_tally.cpp +++ b/src/USER-TALLY/compute_heat_flux_tally.cpp @@ -68,13 +68,14 @@ void ComputeHeatFluxTally::init() else force->pair->add_tally_callback(this); - if (force->pair->single_enable == 0 || force->pair->manybody_flag) - error->warning(FLERR,"Compute heat/flux/tally used with incompatible pair style"); - - if ((comm->me == 0) && (force->bond || force->angle || force->dihedral - || force->improper || force->kspace)) - error->warning(FLERR,"Compute heat/flux/tally only called from pair style"); + if (comm->me == 0) { + if (force->pair->single_enable == 0 || force->pair->manybody_flag) + error->warning(FLERR,"Compute heat/flux/tally used with incompatible pair style"); + if (force->bond || force->angle || force->dihedral + || force->improper || force->kspace) + error->warning(FLERR,"Compute heat/flux/tally only called from pair style"); + } did_compute = -1; } diff --git a/src/USER-TALLY/compute_pe_mol_tally.cpp b/src/USER-TALLY/compute_pe_mol_tally.cpp index a30f2d6b9a..8c616b26fa 100644 --- a/src/USER-TALLY/compute_pe_mol_tally.cpp +++ b/src/USER-TALLY/compute_pe_mol_tally.cpp @@ -66,13 +66,14 @@ void ComputePEMolTally::init() if (atom->molecule_flag == 0) error->all(FLERR,"Compute pe/mol/tally requires molecule IDs"); - if (force->pair->single_enable == 0 || force->pair->manybody_flag) - error->warning(FLERR,"Compute pe/mol/tally used with incompatible pair style"); - - if ((comm->me == 0) && (force->bond || force->angle || force->dihedral - || force->improper || force->kspace)) - error->warning(FLERR,"Compute pe/mol/tally only called from pair style"); + if (comm->me == 0) { + if (force->pair->single_enable == 0 || force->pair->manybody_flag) + error->warning(FLERR,"Compute pe/mol/tally used with incompatible pair style"); + if (force->bond || force->angle || force->dihedral + || force->improper || force->kspace) + error->warning(FLERR,"Compute pe/mol/tally only called from pair style"); + } did_compute = -1; } diff --git a/src/USER-TALLY/compute_pe_tally.cpp b/src/USER-TALLY/compute_pe_tally.cpp index 2117f2cb15..16a90d0767 100644 --- a/src/USER-TALLY/compute_pe_tally.cpp +++ b/src/USER-TALLY/compute_pe_tally.cpp @@ -68,13 +68,14 @@ void ComputePETally::init() else force->pair->add_tally_callback(this); - if (force->pair->single_enable == 0 || force->pair->manybody_flag) - error->warning(FLERR,"Compute pe/tally used with incompatible pair style"); - - if ((comm->me == 0) && (force->bond || force->angle || force->dihedral - || force->improper || force->kspace)) - error->warning(FLERR,"Compute pe/tally only called from pair style"); + if (comm->me == 0) { + if (force->pair->single_enable == 0 || force->pair->manybody_flag) + error->warning(FLERR,"Compute pe/tally used with incompatible pair style"); + if (force->bond || force->angle || force->dihedral + || force->improper || force->kspace) + error->warning(FLERR,"Compute pe/tally only called from pair style"); + } did_compute = -1; } diff --git a/src/USER-TALLY/compute_stress_tally.cpp b/src/USER-TALLY/compute_stress_tally.cpp index 66df9f6e4f..153d788b8b 100644 --- a/src/USER-TALLY/compute_stress_tally.cpp +++ b/src/USER-TALLY/compute_stress_tally.cpp @@ -69,13 +69,14 @@ void ComputeStressTally::init() else force->pair->add_tally_callback(this); - if (force->pair->single_enable == 0 || force->pair->manybody_flag) - error->warning(FLERR,"Compute stress/tally used with incompatible pair style"); - - if ((comm->me == 0) && (force->bond || force->angle || force->dihedral - || force->improper || force->kspace)) - error->warning(FLERR,"Compute stress/tally only called from pair style"); + if (comm->me == 0) { + if (force->pair->single_enable == 0 || force->pair->manybody_flag) + error->warning(FLERR,"Compute stress/tally used with incompatible pair style"); + if (force->bond || force->angle || force->dihedral + || force->improper || force->kspace) + error->warning(FLERR,"Compute stress/tally only called from pair style"); + } did_compute = -1; }