guard against not setting extscalar, extvector, or extarray when required

This commit is contained in:
Axel Kohlmeyer
2024-04-22 19:55:52 -04:00
parent d896f307ba
commit a88e8757e3
4 changed files with 38 additions and 3 deletions

View File

@ -81,6 +81,7 @@ Fix::Fix(LAMMPS *lmp, int /*narg*/, char **arg) :
diam_flag = 0;
scalar_flag = vector_flag = array_flag = 0;
extscalar = extvector = extarray = -1;
peratom_flag = local_flag = pergrid_flag = 0;
global_freq = local_freq = peratom_freq = pergrid_freq = -1;
size_vector_variable = size_array_rows_variable = 0;
@ -119,13 +120,28 @@ Fix::~Fix()
{
if (copymode) return;
delete [] id;
delete [] style;
delete[] id;
delete[] style;
memory->destroy(eatom);
memory->destroy(vatom);
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
if unknown param, call modify_param specific to the fix