reorder operations in init() to fix a bug with compute chunk/atom deleting a fix

This commit is contained in:
Steve Plimpton 2018-10-25 08:23:10 -06:00
parent 7069b52a44
commit 0e213b80e9
1 changed files with 35 additions and 32 deletions

View File

@ -165,7 +165,40 @@ void Modify::init()
restart_deallocate(1);
// init each compute
// set invoked_scalar,vector,etc to -1 to force new run to re-compute them
// add initial timestep to all computes that store invocation times
// since any of them may be invoked by initial thermo
// do not clear out invocation times stored within a compute,
// b/c some may be holdovers from previous run, like for ave fixes
for (i = 0; i < ncompute; i++) {
compute[i]->init();
compute[i]->invoked_scalar = -1;
compute[i]->invoked_vector = -1;
compute[i]->invoked_array = -1;
compute[i]->invoked_peratom = -1;
compute[i]->invoked_local = -1;
}
addstep_compute_all(update->ntimestep);
// init each fix
// should not need to come before compute init
// used to b/c temperature computes called fix->dof() in their init,
// and fix rigid required its own init before its dof() could be called,
// but computes now do their DOF in setup()
for (i = 0; i < nfix; i++) fix[i]->init();
// set global flag if any fix has its restart_pbc flag set
restart_pbc_any = 0;
for (i = 0; i < nfix; i++)
if (fix[i]->restart_pbc) restart_pbc_any = 1;
// create lists of fixes to call at each stage of run
// needs to happen after init() of computes
// b/c a compute::init() can delete a fix, e.g. compute chunk/atom
list_init(INITIAL_INTEGRATE,n_initial_integrate,list_initial_integrate);
list_init(POST_INTEGRATE,n_post_integrate,list_post_integrate);
@ -199,41 +232,10 @@ void Modify::init()
list_init(MIN_POST_FORCE,n_min_post_force,list_min_post_force);
list_init(MIN_ENERGY,n_min_energy,list_min_energy);
// init each fix
// not sure if now needs to come before compute init
// used to b/c temperature computes called fix->dof() in their init,
// and fix rigid required its own init before its dof() could be called,
// but computes now do their DOF in setup()
for (i = 0; i < nfix; i++) fix[i]->init();
// set global flag if any fix has its restart_pbc flag set
restart_pbc_any = 0;
for (i = 0; i < nfix; i++)
if (fix[i]->restart_pbc) restart_pbc_any = 1;
// create list of computes that store invocation times
list_init_compute();
// init each compute
// set invoked_scalar,vector,etc to -1 to force new run to re-compute them
// add initial timestep to all computes that store invocation times
// since any of them may be invoked by initial thermo
// do not clear out invocation times stored within a compute,
// b/c some may be holdovers from previous run, like for ave fixes
for (i = 0; i < ncompute; i++) {
compute[i]->init();
compute[i]->invoked_scalar = -1;
compute[i]->invoked_vector = -1;
compute[i]->invoked_array = -1;
compute[i]->invoked_peratom = -1;
compute[i]->invoked_local = -1;
}
addstep_compute_all(update->ntimestep);
// error if any fix or compute is using a dynamic group when not allowed
for (i = 0; i < nfix; i++)
@ -248,7 +250,8 @@ void Modify::init()
if (!compute[i]->dynamic_group_allow &&
group->dynamic[compute[i]->igroup]) {
char str[128];
snprintf(str,128,"Compute %s does not allow use of dynamic group",fix[i]->id);
snprintf(str,128,"Compute %s does not allow use of dynamic group",
fix[i]->id);
error->all(FLERR,str);
}