diff --git a/src/compute.cpp b/src/compute.cpp index a072afda4d..6472ca3ccd 100644 --- a/src/compute.cpp +++ b/src/compute.cpp @@ -119,6 +119,15 @@ void Compute::modify_params(int narg, char **arg) } } +/* ---------------------------------------------------------------------- + reset extra_dof to its default value +------------------------------------------------------------------------- */ + +void Compute::reset_extra_dof() +{ + extra_dof = domain->dimension; +} + /* ---------------------------------------------------------------------- add ntimestep to list of timesteps the compute will be called on do not add if already in list diff --git a/src/compute.h b/src/compute.h index 8eadb4a4e7..1c1cb5490b 100644 --- a/src/compute.h +++ b/src/compute.h @@ -58,12 +58,14 @@ class Compute : protected Pointers { double dof; // degrees-of-freedom for temperature - int comm_forward; // size of forward communication (0 if none) - int comm_reverse; // size of reverse communication (0 if none) + int comm_forward; // size of forward communication (0 if none) + int comm_reverse; // size of reverse communication (0 if none) Compute(class LAMMPS *, int, char **); virtual ~Compute(); void modify_params(int, char **); + void reset_extra_dof(); + virtual void init() = 0; virtual void init_list(int, class NeighList *) {} virtual double compute_scalar() {return 0.0;} diff --git a/src/input.cpp b/src/input.cpp index 80da0361ac..54acb3aba4 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -28,6 +28,7 @@ #include "pair.h" #include "min.h" #include "modify.h" +#include "compute.h" #include "bond.h" #include "angle.h" #include "dihedral.h" @@ -802,6 +803,14 @@ void Input::dimension() if (domain->box_exist) error->all("Dimension command after simulation box is defined"); domain->dimension = atoi(arg[0]); + if (domain->dimension != 2 && domain->dimension != 3) + error->all("Illegal dimension command"); + + // must reset default extra_dof of all computes + // since some were created before dimension command is encountered + + for (int i = 0; i < modify->ncompute; i++) + modify->compute[i]->reset_extra_dof(); } /* ---------------------------------------------------------------------- */