diff --git a/src/dump.cpp b/src/dump.cpp index df39f3738d..21c1b16f75 100644 --- a/src/dump.cpp +++ b/src/dump.cpp @@ -330,6 +330,8 @@ void Dump::write() if (delay_flag && update->ntimestep < delaystep) return; + printf("DUMP %ld\n",update->ntimestep); + // if file per timestep, open new file if (multifile) openfile(); diff --git a/src/fix_dt_reset.cpp b/src/fix_dt_reset.cpp index fbbe7d7c3e..b7ab63f2d7 100644 --- a/src/fix_dt_reset.cpp +++ b/src/fix_dt_reset.cpp @@ -198,6 +198,7 @@ void FixDtReset::end_of_step() laststep = update->ntimestep; // calls to other classes that need to know timestep size changed + // similar logic is in Input::timestep() update->update_time(); update->dt = dt; diff --git a/src/input.cpp b/src/input.cpp index 08f62bdb42..35b04946c0 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -1836,8 +1836,24 @@ void Input::timer_command() void Input::timestep() { if (narg != 1) error->all(FLERR,"Illegal timestep command"); + + update->update_time(); update->dt = utils::numeric(FLERR,arg[0],false,lmp); update->dt_default = 0; + + if (update->first_update == 0) return; + + // calls to other classes that need to know timestep size changed + // similar logic is in FixDtReset::end_of_step() + // only if a run has already occurred + + int respaflag = 0; + if (utils::strmatch(update->integrate_style, "^respa")) respaflag = 1; + if (respaflag) update->integrate->reset_dt(); + + if (force->pair) force->pair->reset_dt(); + for (int i = 0; i < modify->nfix; i++) modify->fix[i]->reset_dt(); + output->reset_dt(); } /* ---------------------------------------------------------------------- */ diff --git a/src/output.cpp b/src/output.cpp index fff3942780..d34aa8d3f7 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -565,42 +565,22 @@ void Output::write_restart(bigint ntimestep) /* ---------------------------------------------------------------------- timestep is being changed, called by update->reset_timestep() - reset next output values for dumps, restart, thermo output + for dumps, require that no dump is "active" + meaning that a snapshot has already been output + reset next output values restart and thermo output reset to smallest value >= new timestep if next timestep set by variable evaluation, eval for ntimestep-1, so current ntimestep can be returned if needed no guarantee that variable can be evaluated for ntimestep-1 - if it depends on computes, but live with that rare case for now + e.g. if it depends on computes, but live with that rare case for now ------------------------------------------------------------------------- */ void Output::reset_timestep(bigint ntimestep) { next_dump_any = MAXBIGINT; - for (int idump = 0; idump < ndump; idump++) { - if (every_dump[idump]) { - next_dump[idump] = (ntimestep/every_dump[idump])*every_dump[idump]; - if (next_dump[idump] < ntimestep) next_dump[idump] += every_dump[idump]; - } else { - // ivar_dump may not be initialized - if (ivar_dump[idump] < 0) { - ivar_dump[idump] = input->variable->find(var_dump[idump]); - if (ivar_dump[idump] < 0) - error->all(FLERR,"Variable name for dump every does not exist"); - if (!input->variable->equalstyle(ivar_dump[idump])) - error->all(FLERR,"Variable for dump every is invalid style"); - } - modify->clearstep_compute(); - update->ntimestep--; - bigint nextdump = static_cast - (input->variable->compute_equal(ivar_dump[idump])); - if (nextdump < ntimestep) - error->all(FLERR,"Dump every variable returned a bad timestep"); - update->ntimestep++; - next_dump[idump] = nextdump; - modify->addstep_compute(next_dump[idump]); - } - next_dump_any = MIN(next_dump_any,next_dump[idump]); - } + for (int idump = 0; idump < ndump; idump++) + if (last_dump[idump] >= 0) + error->all("Cannot reset timestep with active dump - must undump first"); if (restart_flag_single) { if (restart_every_single) { @@ -669,21 +649,30 @@ void Output::reset_timestep(bigint ntimestep) void Output::reset_dt() { - next_dump_any = MAXBIGINT; - bigint ntimestep = update->ntimestep; + next_dump_any = MAXBIGINT; + for (int idump = 0; idump < ndump; idump++) { if (mode_dump[idump] == 1) { - // reset next_dump for unchanged next_time_dump, 2 arg for reset_dt() + // reset next_dump but do not change next_time_dump, 2 arg for reset_dt() // do not invoke for a dump already scheduled for this step // use compute_all() b/c don't know what computes will be needed if (next_dump[idump] != ntimestep) { calculate_next_dump(2,idump,update->ntimestep); - if (dump[idump]->clearstep || var_dump[idump]) - modify->addstep_compute_all(next_dump[idump]); + + // NOTE: think I should not do this here + // for time dumps, calc_next_dump should calc the next timestep + // as one less and not add it to computes + // then on that step, write() should not actually write the dump + // but trigger it on next step and addstep_compute_all for that step + // b/c when write() is called, the next-step timestep is set + // unless run every timestep is invoked in-between! + + //if (dump[idump]->clearstep || var_dump[idump]) + // modify->addstep_compute_all(next_dump[idump]); } } diff --git a/src/update.cpp b/src/update.cpp index 10b4c573d7..da412ee89e 100644 --- a/src/update.cpp +++ b/src/update.cpp @@ -491,6 +491,7 @@ void Update::reset_timestep(bigint newstep) } // changes to output that depend on timestep + // no active dumps allowed output->reset_timestep(ntimestep); diff --git a/src/verlet.cpp b/src/verlet.cpp index 342dc3d951..348639ef05 100644 --- a/src/verlet.cpp +++ b/src/verlet.cpp @@ -252,6 +252,8 @@ void Verlet::run(int n) ntimestep = ++update->ntimestep; ev_set(ntimestep); + printf("VERLET %ld: %d %d\n",ntimestep,eflag,vflag); + // initial time integration timer->stamp();