change error checks for computes that are not current

This commit is contained in:
Steve Plimpton
2023-05-08 08:55:40 -06:00
parent b3130a2878
commit 49ac79fcdd
7 changed files with 83 additions and 134 deletions

View File

@ -294,21 +294,15 @@ int DumpVTK::count()
}
// invoke Computes for per-atom quantities
// only if within a run or minimize
// else require that computes are current
// this prevents a compute from being invoked by the WriteDump class
// cannot invoke before first run, otherwise invoke if necessary
if (ncompute) {
if (update->whichflag == 0) {
for (i = 0; i < ncompute; i++)
if (compute[i]->invoked_peratom != update->ntimestep)
error->all(FLERR,"Compute used in dump between runs is not current");
} else {
for (i = 0; i < ncompute; i++) {
if (!(compute[i]->invoked_flag & Compute::INVOKED_PERATOM)) {
compute[i]->compute_peratom();
compute[i]->invoked_flag |= Compute::INVOKED_PERATOM;
}
if (update->first_update == 0)
error->all(FLERR,"Dump compute cannot be invoked before first run");
for (i = 0; i < ncompute; i++) {
if (!(compute[i]->invoked_flag & Compute::INVOKED_PERATOM)) {
compute[i]->compute_peratom();
compute[i]->invoked_flag |= Compute::INVOKED_PERATOM;
}
}
}

View File

@ -556,21 +556,15 @@ int DumpCustom::count()
}
// invoke Computes for per-atom quantities
// only if within a run or minimize
// else require that computes are current
// this prevents a compute from being invoked by the WriteDump class
// cannot invoke before first run, otherwise invoke if necessary
if (ncompute) {
if (update->whichflag == 0) {
for (i = 0; i < ncompute; i++)
if (compute[i]->invoked_peratom != update->ntimestep)
error->all(FLERR,"Compute used in dump between runs is not current");
} else {
for (i = 0; i < ncompute; i++) {
if (!(compute[i]->invoked_flag & Compute::INVOKED_PERATOM)) {
compute[i]->compute_peratom();
compute[i]->invoked_flag |= Compute::INVOKED_PERATOM;
}
if (update->first_update == 0)
error->all(FLERR,"Dump compute cannot be invoked before first run");
for (i = 0; i < ncompute; i++) {
if (!(compute[i]->invoked_flag & Compute::INVOKED_PERATOM)) {
compute[i]->compute_peratom();
compute[i]->invoked_flag |= Compute::INVOKED_PERATOM;
}
}
}

View File

@ -522,21 +522,15 @@ int DumpGrid::count()
}
// invoke Computes for per-grid quantities
// only if within a run or minimize
// else require that computes are current
// this prevents a compute from being invoked by the WriteDump class
// cannot invoke before first run, otherwise invoke if necessary
if (ncompute) {
if (update->whichflag == 0) {
for (i = 0; i < ncompute; i++)
if (compute[i]->invoked_pergrid != update->ntimestep)
error->all(FLERR,"Compute {} used in dump between runs is not current", compute[i]->id);
} else {
for (i = 0; i < ncompute; i++) {
if (!(compute[i]->invoked_flag & Compute::INVOKED_PERGRID)) {
compute[i]->compute_pergrid();
compute[i]->invoked_flag |= Compute::INVOKED_PERGRID;
}
if (update->first_update == 0)
error->all(FLERR,"Dump compute cannot be invoked before first run");
for (i = 0; i < ncompute; i++) {
if (!(compute[i]->invoked_flag & Compute::INVOKED_PERGRID)) {
compute[i]->compute_pergrid();
compute[i]->invoked_flag |= Compute::INVOKED_PERGRID;
}
}
}

View File

@ -664,20 +664,14 @@ void DumpImage::write()
}
// invoke Compute for per-grid quantities
// only if within a run or minimize
// else require the compute is current
// this prevents the compute from being invoked by the WriteDump class
// cannot invoke before first run, otherwise invoke if necessary
if (grid_compute) {
if (update->whichflag == 0) {
if (grid_compute->invoked_pergrid != update->ntimestep)
error->all(FLERR,"Grid compute {} used in dump image between runs is not current",
grid_compute->id);
} else {
if (!(grid_compute->invoked_flag & Compute::INVOKED_PERGRID)) {
grid_compute->compute_pergrid();
grid_compute->invoked_flag |= Compute::INVOKED_PERGRID;
}
if (update->first_update == 0)
error->all(FLERR,"Grid compute used in dump image cannot be invoked before first run");
if (!(grid_compute->invoked_flag & Compute::INVOKED_PERGRID)) {
grid_compute->compute_pergrid();
grid_compute->invoked_flag |= Compute::INVOKED_PERGRID;
}
}

View File

@ -325,21 +325,15 @@ int DumpLocal::count()
int i;
// invoke Computes for local quantities
// only if within a run or minimize
// else require that computes are current
// this prevents a compute from being invoked by the WriteDump class
// cannot invoke before first run, otherwise invoke if necessary
if (ncompute) {
if (update->whichflag == 0) {
for (i = 0; i < ncompute; i++)
if (compute[i]->invoked_local != update->ntimestep)
error->all(FLERR,"Compute used in dump between runs is not current");
} else {
for (i = 0; i < ncompute; i++) {
if (!(compute[i]->invoked_flag & Compute::INVOKED_LOCAL)) {
compute[i]->compute_local();
compute[i]->invoked_flag |= Compute::INVOKED_LOCAL;
}
if (update->first_update == 0)
error->all(FLERR,"Dump compute cannot be invoked before first run");
for (i = 0; i < ncompute; i++) {
if (!(compute[i]->invoked_flag & Compute::INVOKED_LOCAL)) {
compute[i]->compute_local();
compute[i]->invoked_flag |= Compute::INVOKED_LOCAL;
}
}
}

View File

@ -1118,7 +1118,7 @@ int Thermo::add_variable(const char *id)
}
/* ----------------------------------------------------------------------
check whether temperature compute is defined, available, and current
check whether temperature compute is defined, active, and needs invoking
------------------------------------------------------------------------- */
void Thermo::check_temp(const std::string &keyword)
@ -1126,18 +1126,16 @@ void Thermo::check_temp(const std::string &keyword)
if (!temperature)
error->all(FLERR, "Thermo keyword {} in variable requires thermo to use/init temperature",
keyword);
if (update->whichflag == 0) {
if (temperature->invoked_scalar != update->ntimestep)
error->all(FLERR, "Compute {} {} used in variable thermo keyword between runs is not current",
temperature->style, temperature->id);
} else if (!(temperature->invoked_flag & Compute::INVOKED_SCALAR)) {
if (update->first_update == 0)
error->all(FLERR,"Thermo keyword {} cannot be invoked before first run",keyword);
if (!(temperature->invoked_flag & Compute::INVOKED_SCALAR)) {
temperature->compute_scalar();
temperature->invoked_flag |= Compute::INVOKED_SCALAR;
}
}
/* ----------------------------------------------------------------------
check whether potential energy compute is defined, available, and current
check whether potential energy compute is defined, active, and needs invoking
------------------------------------------------------------------------- */
void Thermo::check_pe(const std::string &keyword)
@ -1147,47 +1145,41 @@ void Thermo::check_pe(const std::string &keyword)
if (!pe)
error->all(FLERR, "Thermo keyword {} in variable requires thermo to use/init potential energy",
keyword);
if (update->whichflag == 0) {
if (pe->invoked_scalar != update->ntimestep)
error->all(FLERR, "Compute {} {} used in variable thermo keyword between runs is not current",
pe->style, pe->id);
} else {
if (update->first_update == 0)
error->all(FLERR,"Thermo keyword {} cannot be invoked before first run",keyword);
if (!(pe->invoked_flag & Compute::INVOKED_SCALAR)) {
pe->compute_scalar();
pe->invoked_flag |= Compute::INVOKED_SCALAR;
}
}
/* ----------------------------------------------------------------------
check whether scalar pressure compute is defined, available, and current
check whether scalar pressure compute is defined, active, and needs invoking
------------------------------------------------------------------------- */
void Thermo::check_press_scalar(const std::string &keyword)
{
if (!pressure)
error->all(FLERR, "Thermo keyword {} in variable requires thermo to use/init press", keyword);
if (update->whichflag == 0) {
if (pressure->invoked_scalar != update->ntimestep)
error->all(FLERR, "Compute {} {} used in variable thermo keyword between runs is not current",
pressure->style, pressure->id);
} else if (!(pressure->invoked_flag & Compute::INVOKED_SCALAR)) {
if (update->first_update == 0)
error->all(FLERR,"Thermo keyword {} cannot be invoked before first run",keyword);
if (!(pressure->invoked_flag & Compute::INVOKED_SCALAR)) {
pressure->compute_scalar();
pressure->invoked_flag |= Compute::INVOKED_SCALAR;
}
}
/* ----------------------------------------------------------------------
check whether pressure tensor compute is defined, available, and current
check whether tensor pressure compute is defined, active, and needs invoking
------------------------------------------------------------------------- */
void Thermo::check_press_vector(const std::string &keyword)
{
if (!pressure)
error->all(FLERR, "Thermo keyword {} in variable requires thermo to use/init press", keyword);
if (update->whichflag == 0) {
if (pressure->invoked_vector != update->ntimestep)
error->all(FLERR, "Compute {} {} used in variable thermo keyword between runs is not current",
pressure->style, pressure->id);
} else if (!(pressure->invoked_flag & Compute::INVOKED_VECTOR)) {
if (update->first_update == 0)
error->all(FLERR,"Thermo keyword {} cannot be invoked before first run",keyword);
if (!(pressure->invoked_flag & Compute::INVOKED_VECTOR)) {
pressure->compute_vector();
pressure->invoked_flag |= Compute::INVOKED_VECTOR;
}
@ -1214,8 +1206,6 @@ int Thermo::evaluate_keyword(const std::string &word, double *answer)
// invoke a lo-level thermo routine to compute the variable value
// if keyword requires a compute, error if thermo doesn't use the compute
// if inbetween runs and needed compute is not current, error
// if in middle of run and needed compute is not current, invoke it
// for keywords that use energy (evdwl, ebond, etc):
// check if energy was tallied on this timestep and set pe->invoked_flag
// this will trigger next timestep for energy tallying via addstep()

View File

@ -1440,10 +1440,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar)
if (nbracket == 0 && compute->scalar_flag && lowercase) {
if (update->whichflag == 0) {
if (compute->invoked_scalar != update->ntimestep)
print_var_error(FLERR,"Compute used in variable between runs is not current",ivar);
} else if (!(compute->invoked_flag & Compute::INVOKED_SCALAR)) {
if (update->first_update == 0)
print_var_error(FLERR,"Variable formula compute cannot be invoked before first run",ivar);
if (!(compute->invoked_flag & Compute::INVOKED_SCALAR)) {
compute->compute_scalar();
compute->invoked_flag |= Compute::INVOKED_SCALAR;
}
@ -1463,10 +1462,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar)
if (index1 > compute->size_vector &&
compute->size_vector_variable == 0)
print_var_error(FLERR,"Variable formula compute vector is accessed out-of-range",ivar,0);
if (update->whichflag == 0) {
if (compute->invoked_vector != update->ntimestep)
print_var_error(FLERR,"Compute used in variable between runs is not current",ivar);
} else if (!(compute->invoked_flag & Compute::INVOKED_VECTOR)) {
if (update->first_update == 0)
print_var_error(FLERR,"Variable formula compute cannot be invoked before first run",ivar);
if (!(compute->invoked_flag & Compute::INVOKED_VECTOR)) {
compute->compute_vector();
compute->invoked_flag |= Compute::INVOKED_VECTOR;
}
@ -1490,10 +1488,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar)
print_var_error(FLERR,"Variable formula compute array is accessed out-of-range",ivar,0);
if (index2 > compute->size_array_cols)
print_var_error(FLERR,"Variable formula compute array is accessed out-of-range",ivar,0);
if (update->whichflag == 0) {
if (compute->invoked_array != update->ntimestep)
print_var_error(FLERR,"Compute used in variable between runs is not current",ivar);
} else if (!(compute->invoked_flag & Compute::INVOKED_ARRAY)) {
if (update->first_update == 0)
print_var_error(FLERR,"Variable formula compute cannot be invoked before first run",ivar);
if (!(compute->invoked_flag & Compute::INVOKED_ARRAY)) {
compute->compute_array();
compute->invoked_flag |= Compute::INVOKED_ARRAY;
}
@ -1518,10 +1515,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar)
print_var_error(FLERR,"Compute global vector in atom-style variable formula",ivar);
if (compute->size_vector == 0)
print_var_error(FLERR,"Variable formula compute vector is zero length",ivar);
if (update->whichflag == 0) {
if (compute->invoked_vector != update->ntimestep)
print_var_error(FLERR,"Compute used in variable between runs is not current",ivar);
} else if (!(compute->invoked_flag & Compute::INVOKED_VECTOR)) {
if (update->first_update == 0)
print_var_error(FLERR,"Variable formula compute cannot be invoked before first run",ivar);
if (!(compute->invoked_flag & Compute::INVOKED_VECTOR)) {
compute->compute_vector();
compute->invoked_flag |= Compute::INVOKED_VECTOR;
}
@ -1543,10 +1539,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar)
print_var_error(FLERR,"Compute global vector in atom-style variable formula",ivar);
if (compute->size_array_rows == 0)
print_var_error(FLERR,"Variable formula compute array is zero length",ivar);
if (update->whichflag == 0) {
if (compute->invoked_array != update->ntimestep)
print_var_error(FLERR,"Compute used in variable between runs is not current",ivar);
} else if (!(compute->invoked_flag & Compute::INVOKED_ARRAY)) {
if (update->first_update == 0)
print_var_error(FLERR,"Variable formula compute cannot be invoked before first run",ivar);
if (!(compute->invoked_flag & Compute::INVOKED_ARRAY)) {
compute->compute_array();
compute->invoked_flag |= Compute::INVOKED_ARRAY;
}
@ -1563,10 +1558,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar)
} else if (nbracket == 1 && compute->peratom_flag &&
compute->size_peratom_cols == 0) {
if (update->whichflag == 0) {
if (compute->invoked_peratom != update->ntimestep)
print_var_error(FLERR,"Compute used in variable between runs is not current",ivar);
} else if (!(compute->invoked_flag & Compute::INVOKED_PERATOM)) {
if (update->first_update == 0)
print_var_error(FLERR,"Variable formula compute cannot be invoked before first run",ivar);
if (!(compute->invoked_flag & Compute::INVOKED_PERATOM)) {
compute->compute_peratom();
compute->invoked_flag |= Compute::INVOKED_PERATOM;
}
@ -1581,10 +1575,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar)
if (index2 > compute->size_peratom_cols)
print_var_error(FLERR,"Variable formula compute array is accessed out-of-range",ivar,0);
if (update->whichflag == 0) {
if (compute->invoked_peratom != update->ntimestep)
print_var_error(FLERR,"Compute used in variable between runs is not current",ivar);
} else if (!(compute->invoked_flag & Compute::INVOKED_PERATOM)) {
if (update->first_update == 0)
print_var_error(FLERR,"Variable formula compute cannot be invoked before first run",ivar);
if (!(compute->invoked_flag & Compute::INVOKED_PERATOM)) {
compute->compute_peratom();
compute->invoked_flag |= Compute::INVOKED_PERATOM;
}
@ -1605,10 +1598,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar)
print_var_error(FLERR,"Per-atom compute in equal-style variable formula",ivar);
if (treetype == VECTOR)
print_var_error(FLERR,"Per-atom compute in vector-style variable formula",ivar);
if (update->whichflag == 0) {
if (compute->invoked_peratom != update->ntimestep)
print_var_error(FLERR,"Compute used in variable between runs is not current",ivar);
} else if (!(compute->invoked_flag & Compute::INVOKED_PERATOM)) {
if (update->first_update == 0)
print_var_error(FLERR,"Variable formula compute cannot be invoked before first run",ivar);
if (!(compute->invoked_flag & Compute::INVOKED_PERATOM)) {
compute->compute_peratom();
compute->invoked_flag |= Compute::INVOKED_PERATOM;
}
@ -1630,10 +1622,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar)
print_var_error(FLERR,"Per-atom compute in vector-style variable formula",ivar);
if (index1 > compute->size_peratom_cols)
print_var_error(FLERR,"Variable formula compute array is accessed out-of-range",ivar,0);
if (update->whichflag == 0) {
if (compute->invoked_peratom != update->ntimestep)
print_var_error(FLERR,"Compute used in variable between runs is not current",ivar);
} else if (!(compute->invoked_flag & Compute::INVOKED_PERATOM)) {
if (update->first_update == 0)
print_var_error(FLERR,"Variable formula compute cannot be invoked before first run",ivar);
if (!(compute->invoked_flag & Compute::INVOKED_PERATOM)) {
compute->compute_peratom();
compute->invoked_flag |= Compute::INVOKED_PERATOM;
}
@ -4050,10 +4041,9 @@ int Variable::special_function(char *word, char *contents, Tree **tree, Tree **t
print_var_error(FLERR,mesg,ivar);
}
if (index == 0 && compute->vector_flag) {
if (update->whichflag == 0) {
if (compute->invoked_vector != update->ntimestep)
print_var_error(FLERR,"Compute used in variable between runs is not current",ivar);
} else if (!(compute->invoked_flag & Compute::INVOKED_VECTOR)) {
if (update->first_update == 0)
print_var_error(FLERR,"Variable formula compute cannot be invoked before first run",ivar);
if (!(compute->invoked_flag & Compute::INVOKED_VECTOR)) {
compute->compute_vector();
compute->invoked_flag |= Compute::INVOKED_VECTOR;
}
@ -4062,10 +4052,9 @@ int Variable::special_function(char *word, char *contents, Tree **tree, Tree **t
} else if (index && compute->array_flag) {
if (index > compute->size_array_cols)
print_var_error(FLERR,"Variable formula compute array is accessed out-of-range",ivar,0);
if (update->whichflag == 0) {
if (compute->invoked_array != update->ntimestep)
print_var_error(FLERR,"Compute used in variable between runs is not current",ivar);
} else if (!(compute->invoked_flag & Compute::INVOKED_ARRAY)) {
if (update->first_update == 0)
print_var_error(FLERR,"Variable formula compute cannot be invoked before first run",ivar);
if (!(compute->invoked_flag & Compute::INVOKED_ARRAY)) {
compute->compute_array();
compute->invoked_flag |= Compute::INVOKED_ARRAY;
}