guard against not setting extscalar, extvector, or extarray when required
This commit is contained in:
@ -59,6 +59,7 @@ Compute::Compute(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
// set child class defaults
|
// set child class defaults
|
||||||
|
|
||||||
scalar_flag = vector_flag = array_flag = 0;
|
scalar_flag = vector_flag = array_flag = 0;
|
||||||
|
extscalar = extvector = extarray = -1;
|
||||||
peratom_flag = local_flag = pergrid_flag = 0;
|
peratom_flag = local_flag = pergrid_flag = 0;
|
||||||
size_vector_variable = size_array_rows_variable = 0;
|
size_vector_variable = size_array_rows_variable = 0;
|
||||||
|
|
||||||
@ -116,6 +117,16 @@ void Compute::init_flags()
|
|||||||
initialized_flag = 1;
|
initialized_flag = 1;
|
||||||
invoked_scalar = invoked_vector = invoked_array = -1;
|
invoked_scalar = invoked_vector = invoked_array = -1;
|
||||||
invoked_peratom = invoked_local = -1;
|
invoked_peratom = invoked_local = -1;
|
||||||
|
|
||||||
|
if (scalar_flag && (extscalar < 0))
|
||||||
|
error->all(FLERR, "Must set 'extscalar' when setting 'scalar_flag' for compute {}. "
|
||||||
|
"Contact the developer.", style);
|
||||||
|
if (vector_flag && (extvector < 0))
|
||||||
|
error->all(FLERR, "Must set 'extvector' when setting 'vector_flag' for compute {}. "
|
||||||
|
"Contact the developer.", style);
|
||||||
|
if (array_flag && (extarray < 0))
|
||||||
|
error->all(FLERR, "Must set 'extarray' when setting 'array_flag' for compute {}. "
|
||||||
|
"Contact the developer.", style);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|||||||
20
src/fix.cpp
20
src/fix.cpp
@ -81,6 +81,7 @@ Fix::Fix(LAMMPS *lmp, int /*narg*/, char **arg) :
|
|||||||
diam_flag = 0;
|
diam_flag = 0;
|
||||||
|
|
||||||
scalar_flag = vector_flag = array_flag = 0;
|
scalar_flag = vector_flag = array_flag = 0;
|
||||||
|
extscalar = extvector = extarray = -1;
|
||||||
peratom_flag = local_flag = pergrid_flag = 0;
|
peratom_flag = local_flag = pergrid_flag = 0;
|
||||||
global_freq = local_freq = peratom_freq = pergrid_freq = -1;
|
global_freq = local_freq = peratom_freq = pergrid_freq = -1;
|
||||||
size_vector_variable = size_array_rows_variable = 0;
|
size_vector_variable = size_array_rows_variable = 0;
|
||||||
@ -119,13 +120,28 @@ Fix::~Fix()
|
|||||||
{
|
{
|
||||||
if (copymode) return;
|
if (copymode) return;
|
||||||
|
|
||||||
delete [] id;
|
delete[] id;
|
||||||
delete [] style;
|
delete[] style;
|
||||||
memory->destroy(eatom);
|
memory->destroy(eatom);
|
||||||
memory->destroy(vatom);
|
memory->destroy(vatom);
|
||||||
memory->destroy(cvatom);
|
memory->destroy(cvatom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void Fix::init_flags()
|
||||||
|
{
|
||||||
|
if (scalar_flag && (extscalar < 0))
|
||||||
|
error->all(FLERR, "Must set 'extscalar' when setting 'scalar_flag' for fix {}. "
|
||||||
|
"Contact the developer.", style);
|
||||||
|
if (vector_flag && (extvector < 0))
|
||||||
|
error->all(FLERR, "Must set 'extvector' when setting 'vector_flag' for fix {}. "
|
||||||
|
"Contact the developer.", style);
|
||||||
|
if (array_flag && (extarray < 0))
|
||||||
|
error->all(FLERR, "Must set 'extarray' when setting 'array_flag' for fix {}. "
|
||||||
|
"Contact the developer.", style);
|
||||||
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
process params common to all fixes here
|
process params common to all fixes here
|
||||||
if unknown param, call modify_param specific to the fix
|
if unknown param, call modify_param specific to the fix
|
||||||
|
|||||||
@ -145,6 +145,7 @@ class Fix : protected Pointers {
|
|||||||
|
|
||||||
virtual void post_constructor() {}
|
virtual void post_constructor() {}
|
||||||
virtual void init() {}
|
virtual void init() {}
|
||||||
|
void init_flags();
|
||||||
virtual void init_list(int, class NeighList *) {}
|
virtual void init_list(int, class NeighList *) {}
|
||||||
virtual void setup(int) {}
|
virtual void setup(int) {}
|
||||||
virtual void setup_pre_exchange() {}
|
virtual void setup_pre_exchange() {}
|
||||||
|
|||||||
@ -188,6 +188,8 @@ void Modify::init()
|
|||||||
// since any of them may be invoked by initial thermo
|
// since any of them may be invoked by initial thermo
|
||||||
// do not clear out invocation times stored within a compute,
|
// do not clear out invocation times stored within a compute,
|
||||||
// b/c some may be holdovers from previous run, like for ave fixes
|
// b/c some may be holdovers from previous run, like for ave fixes
|
||||||
|
// perform check whether extscalar, extvector, and extarray have been
|
||||||
|
// set when scalar_flag, vector_flag, or array_flag are true.
|
||||||
|
|
||||||
for (i = 0; i < ncompute; i++) {
|
for (i = 0; i < ncompute; i++) {
|
||||||
compute[i]->init();
|
compute[i]->init();
|
||||||
@ -200,8 +202,13 @@ void Modify::init()
|
|||||||
// used to b/c temperature computes called fix->dof() in their 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,
|
// and fix rigid required its own init before its dof() could be called,
|
||||||
// but computes now do their DOF in setup()
|
// but computes now do their DOF in setup()
|
||||||
|
// perform check whether extscalar, extvector, and extarray have been
|
||||||
|
// set when scalar_flag, vector_flag, or array_flag are true.
|
||||||
|
|
||||||
for (i = 0; i < nfix; i++) fix[i]->init();
|
for (i = 0; i < nfix; i++) {
|
||||||
|
fix[i]->init();
|
||||||
|
fix[i]->init_flags();
|
||||||
|
}
|
||||||
|
|
||||||
// set global flag if any fix has its restart_pbc flag set
|
// set global flag if any fix has its restart_pbc flag set
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user