change to checking timestep for time dumps at start of each step
This commit is contained in:
@ -330,8 +330,6 @@ 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();
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
#include "kspace.h"
|
||||
#include "modify.h"
|
||||
#include "pair.h"
|
||||
#include "output.h"
|
||||
#include "update.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
@ -115,7 +116,13 @@ void Integrate::ev_setup()
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
set eflag,vflag for current iteration
|
||||
based on computes that need energy/virial info on this timestep
|
||||
based on
|
||||
(1) computes that need energy/virial info on this timestep
|
||||
(2) time dumps that need unknown per-atom info on this timestep
|
||||
NOTE: could not check time dumps if timestep size is not varying
|
||||
see NOTE in output.cpp
|
||||
also inefficient to add all per-atom eng/virial computes
|
||||
but don't know which ones the dump needs
|
||||
invoke matchstep() on all timestep-dependent computes to clear their arrays
|
||||
eflag: set any or no bits
|
||||
ENERGY_GLOBAL bit for global energy
|
||||
@ -133,6 +140,10 @@ void Integrate::ev_set(bigint ntimestep)
|
||||
{
|
||||
int i,flag;
|
||||
|
||||
int tdflag = 0;
|
||||
if (output->any_time_dumps)
|
||||
tdflag = output->check_time_dumps(ntimestep);
|
||||
|
||||
flag = 0;
|
||||
int eflag_global = 0;
|
||||
for (i = 0; i < nelist_global; i++)
|
||||
@ -143,7 +154,7 @@ void Integrate::ev_set(bigint ntimestep)
|
||||
int eflag_atom = 0;
|
||||
for (i = 0; i < nelist_atom; i++)
|
||||
if (elist_atom[i]->matchstep(ntimestep)) flag = 1;
|
||||
if (flag) eflag_atom = ENERGY_ATOM;
|
||||
if (flag || (tdflag && nelist_atom)) eflag_atom = ENERGY_ATOM;
|
||||
|
||||
if (eflag_global) update->eflag_global = ntimestep;
|
||||
if (eflag_atom) update->eflag_atom = ntimestep;
|
||||
@ -159,13 +170,13 @@ void Integrate::ev_set(bigint ntimestep)
|
||||
int vflag_atom = 0;
|
||||
for (i = 0; i < nvlist_atom; i++)
|
||||
if (vlist_atom[i]->matchstep(ntimestep)) flag = 1;
|
||||
if (flag) vflag_atom = VIRIAL_ATOM;
|
||||
if (flag || (tdflag && nvlist_atom)) vflag_atom = VIRIAL_ATOM;
|
||||
|
||||
flag = 0;
|
||||
int cvflag_atom = 0;
|
||||
for (i = 0; i < ncvlist_atom; i++)
|
||||
if (cvlist_atom[i]->matchstep(ntimestep)) flag = 1;
|
||||
if (flag) cvflag_atom = VIRIAL_CENTROID;
|
||||
if (flag || (tdflag && ncvlist_atom)) cvflag_atom = VIRIAL_CENTROID;
|
||||
|
||||
if (vflag_global) update->vflag_global = ntimestep;
|
||||
if (vflag_atom || cvflag_atom) update->vflag_atom = ntimestep;
|
||||
|
||||
@ -133,7 +133,9 @@ void Output::init()
|
||||
}
|
||||
|
||||
for (int i = 0; i < ndump; i++) dump[i]->init();
|
||||
for (int i = 0; i < ndump; i++)
|
||||
any_time_dumps = 0;
|
||||
for (int i = 0; i < ndump; i++) {
|
||||
if (mode_dump[i]) any_time_dumps = 1;
|
||||
if ((mode_dump[i] == 0 && every_dump[i] == 0) ||
|
||||
(mode_dump[i] == 1 && every_time_dump[i] == 0.0)) {
|
||||
ivar_dump[i] = input->variable->find(var_dump[i]);
|
||||
@ -142,6 +144,7 @@ void Output::init()
|
||||
if (!input->variable->equalstyle(ivar_dump[i]))
|
||||
error->all(FLERR,"Variable for dump every or delta is invalid style");
|
||||
}
|
||||
}
|
||||
|
||||
if (restart_flag_single && restart_every_single == 0) {
|
||||
ivar_restart_single = input->variable->find(var_restart_single);
|
||||
@ -176,9 +179,11 @@ void Output::setup(int memflag)
|
||||
if (ndump && update->restrict_output == 0) {
|
||||
for (int idump = 0; idump < ndump; idump++) {
|
||||
|
||||
// wrap dumps that invoke computes or do variable eval with clear/add
|
||||
// wrap step dumps that invoke computes or do variable eval with clear/add
|
||||
// see NOTE in write() about also wrapping time dumps
|
||||
|
||||
if (dump[idump]->clearstep || var_dump[idump])
|
||||
if (mode_dump[idump] == 0 &&
|
||||
(dump[idump]->clearstep || var_dump[idump]))
|
||||
modify->clearstep_compute();
|
||||
|
||||
// write a snapshot at setup only if any of these 3 conditions hold
|
||||
@ -226,7 +231,8 @@ void Output::setup(int memflag)
|
||||
// if dump not written now, use addstep_compute_all()
|
||||
// since don't know what computes the dump will invoke
|
||||
|
||||
if (dump[idump]->clearstep || var_dump[idump]) {
|
||||
if (mode_dump[idump] == 0 &&
|
||||
(dump[idump]->clearstep || var_dump[idump])) {
|
||||
if (writeflag) modify->addstep_compute(next_dump[idump]);
|
||||
else modify->addstep_compute_all(next_dump[idump]);
|
||||
}
|
||||
@ -318,7 +324,14 @@ void Output::write(bigint ntimestep)
|
||||
// but not if it was already written on this step
|
||||
// set next_dump and also next_time_dump for mode_dump = 1
|
||||
// set next_dump_any to smallest next_dump
|
||||
// wrap dumps that invoke computes or do variable eval with clear/add
|
||||
// wrap step dumps that invoke computes or do variable eval with clear/add
|
||||
// NOTE:
|
||||
// could wrap time dumps as well, if timestep size did not vary
|
||||
// if wrap when timestep size varies frequently,
|
||||
// then can do many unneeded addstep() --> inefficient
|
||||
// hard to know if timestep varies, since run every could change it
|
||||
// can't remove an uneeded addstep from a compute, b/c don't know
|
||||
// what other command may have added it
|
||||
|
||||
int writeflag;
|
||||
|
||||
@ -327,7 +340,8 @@ void Output::write(bigint ntimestep)
|
||||
if (next_dump[idump] == ntimestep) {
|
||||
if (last_dump[idump] == ntimestep) continue;
|
||||
|
||||
if (dump[idump]->clearstep || var_dump[idump])
|
||||
if (mode_dump[idump] == 0 &&
|
||||
(dump[idump]->clearstep || var_dump[idump]))
|
||||
modify->clearstep_compute();
|
||||
|
||||
// perform dump
|
||||
@ -337,7 +351,8 @@ void Output::write(bigint ntimestep)
|
||||
last_dump[idump] = ntimestep;
|
||||
calculate_next_dump(1,idump,ntimestep);
|
||||
|
||||
if (dump[idump]->clearstep || var_dump[idump])
|
||||
if (mode_dump[idump] == 0 &&
|
||||
(dump[idump]->clearstep || var_dump[idump]))
|
||||
modify->addstep_compute(next_dump[idump]);
|
||||
}
|
||||
|
||||
@ -535,6 +550,17 @@ void Output::write_dump(bigint ntimestep)
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int Output::check_time_dumps(bigint ntimestep)
|
||||
{
|
||||
int nowflag = 0;
|
||||
for (int i = 0; i < ndump; i++)
|
||||
if (mode_dump[i] && next_dump[i] == ntimestep) nowflag = 1;
|
||||
|
||||
return nowflag;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
force restart file(s) to be written
|
||||
called from PRD and TAD
|
||||
@ -567,7 +593,7 @@ void Output::write_restart(bigint ntimestep)
|
||||
timestep is being changed, called by update->reset_timestep()
|
||||
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 next output values for restart and thermo
|
||||
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
|
||||
@ -644,8 +670,10 @@ void Output::reset_timestep(bigint ntimestep)
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
timestep size is being changed, called by fix dt/reset (at end of step)
|
||||
timestep size is being changed
|
||||
reset next output values for dumps which have mode_dump=1
|
||||
called by fix dt/reset (at end of step)
|
||||
or called by timestep command via run every (also at end of step)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Output::reset_dt()
|
||||
@ -659,21 +687,10 @@ void Output::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
|
||||
// since timestep change affects next step
|
||||
|
||||
if (next_dump[idump] != ntimestep) {
|
||||
calculate_next_dump(2,idump,update->ntimestep);
|
||||
|
||||
// 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]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -684,6 +701,7 @@ void Output::reset_dt()
|
||||
next = MIN(next,next_thermo);
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
add a Dump to list of Dumps
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
@ -36,6 +36,7 @@ class Output : protected Pointers {
|
||||
int ndump; // # of Dumps defined
|
||||
int max_dump; // max size of Dump list
|
||||
bigint next_dump_any; // next timestep for any Dump
|
||||
int any_time_dumps; // 1 if any time dump defined
|
||||
int *mode_dump; // 0/1 if write every N timesteps or Delta in sim time
|
||||
int *every_dump; // dump every N timesteps, 0 if variable
|
||||
double *every_time_dump; // dump every Delta of sim time, 0.0 if variable
|
||||
@ -75,13 +76,14 @@ class Output : protected Pointers {
|
||||
void write(bigint); // output for current timestep
|
||||
void write_dump(bigint); // force output of dump snapshots
|
||||
void write_restart(bigint); // force output of a restart file
|
||||
void reset_timestep(bigint); // reset output which depeneds on timestep
|
||||
void reset_dt(); // reset output which depends on dt
|
||||
void reset_timestep(bigint); // reset output which depends on timestep
|
||||
void reset_dt(); // reset output which depends on timestep size
|
||||
|
||||
void add_dump(int, char **); // add a Dump to Dump list
|
||||
void modify_dump(int, char **); // modify a Dump
|
||||
void delete_dump(char *); // delete a Dump from Dump list
|
||||
int find_dump(const char *); // find a Dump ID
|
||||
int check_time_dumps(bigint); // check if any time dump is output now
|
||||
|
||||
void set_thermo(int, char **); // set thermo output freqquency
|
||||
void create_thermo(int, char **); // create a thermo style
|
||||
|
||||
@ -252,8 +252,6 @@ 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();
|
||||
|
||||
Reference in New Issue
Block a user