small fixed and error checking
This commit is contained in:
30
src/comm.cpp
30
src/comm.cpp
@ -292,32 +292,24 @@ void Comm::modify_params(int narg, char **arg)
|
|||||||
// need to reset cutghostuser when switching comm mode
|
// need to reset cutghostuser when switching comm mode
|
||||||
if (mode == Comm::MULTI) cutghostuser = 0.0;
|
if (mode == Comm::MULTI) cutghostuser = 0.0;
|
||||||
if (mode == Comm::MULTIOLD) cutghostuser = 0.0;
|
if (mode == Comm::MULTIOLD) cutghostuser = 0.0;
|
||||||
if (cutusermulti) {
|
|
||||||
memory->destroy(cutusermulti);
|
memory->destroy(cutusermulti);
|
||||||
cutusermulti = nullptr;
|
|
||||||
}
|
|
||||||
if (cutusermultiold) {
|
|
||||||
memory->destroy(cutusermultiold);
|
memory->destroy(cutusermultiold);
|
||||||
cutusermultiold = nullptr;
|
|
||||||
}
|
|
||||||
mode = Comm::SINGLE;
|
mode = Comm::SINGLE;
|
||||||
} else if (strcmp(arg[iarg+1],"multi") == 0) {
|
} else if (strcmp(arg[iarg+1],"multi") == 0) {
|
||||||
|
if (neighbor->style != Neighbor::MULTI)
|
||||||
|
error->all(FLERR,"Cannot use comm mode 'multi' without 'multi' style neighbor lists");
|
||||||
// need to reset cutghostuser when switching comm mode
|
// need to reset cutghostuser when switching comm mode
|
||||||
if (mode == Comm::SINGLE) cutghostuser = 0.0;
|
if (mode == Comm::SINGLE) cutghostuser = 0.0;
|
||||||
if (mode == Comm::MULTIOLD) cutghostuser = 0.0;
|
if (mode == Comm::MULTIOLD) cutghostuser = 0.0;
|
||||||
if (cutusermultiold) {
|
|
||||||
memory->destroy(cutusermultiold);
|
memory->destroy(cutusermultiold);
|
||||||
cutusermultiold = nullptr;
|
|
||||||
}
|
|
||||||
mode = Comm::MULTI;
|
mode = Comm::MULTI;
|
||||||
} else if (strcmp(arg[iarg+1],"multi/old") == 0) {
|
} else if (strcmp(arg[iarg+1],"multi/old") == 0) {
|
||||||
|
if (neighbor->style == Neighbor::MULTI)
|
||||||
|
error->all(FLERR,"Cannot use comm mode 'multi/old' with 'multi' style neighbor lists");
|
||||||
// need to reset cutghostuser when switching comm mode
|
// need to reset cutghostuser when switching comm mode
|
||||||
if (mode == Comm::SINGLE) cutghostuser = 0.0;
|
if (mode == Comm::SINGLE) cutghostuser = 0.0;
|
||||||
if (mode == Comm::MULTI) cutghostuser = 0.0;
|
if (mode == Comm::MULTI) cutghostuser = 0.0;
|
||||||
if (cutusermulti) {
|
|
||||||
memory->destroy(cutusermulti);
|
memory->destroy(cutusermulti);
|
||||||
cutusermulti = nullptr;
|
|
||||||
}
|
|
||||||
mode = Comm::MULTIOLD;
|
mode = Comm::MULTIOLD;
|
||||||
} else error->all(FLERR,"Illegal comm_modify command");
|
} else error->all(FLERR,"Illegal comm_modify command");
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
@ -333,11 +325,9 @@ void Comm::modify_params(int narg, char **arg)
|
|||||||
} else if (strcmp(arg[iarg],"cutoff") == 0) {
|
} else if (strcmp(arg[iarg],"cutoff") == 0) {
|
||||||
if (iarg+2 > narg) error->all(FLERR,"Illegal comm_modify command");
|
if (iarg+2 > narg) error->all(FLERR,"Illegal comm_modify command");
|
||||||
if (mode == Comm::MULTI)
|
if (mode == Comm::MULTI)
|
||||||
error->all(FLERR,
|
error->all(FLERR, "Use cutoff/multi keyword to set cutoff in multi mode");
|
||||||
"Use cutoff/multi keyword to set cutoff in multi mode");
|
|
||||||
if (mode == Comm::MULTIOLD)
|
if (mode == Comm::MULTIOLD)
|
||||||
error->all(FLERR,
|
error->all(FLERR, "Use cutoff/multi/old keyword to set cutoff in multi mode");
|
||||||
"Use cutoff/multi/old keyword to set cutoff in multi mode");
|
|
||||||
cutghostuser = utils::numeric(FLERR,arg[iarg+1],false,lmp);
|
cutghostuser = utils::numeric(FLERR,arg[iarg+1],false,lmp);
|
||||||
if (cutghostuser < 0.0)
|
if (cutghostuser < 0.0)
|
||||||
error->all(FLERR,"Invalid cutoff in comm_modify command");
|
error->all(FLERR,"Invalid cutoff in comm_modify command");
|
||||||
@ -350,14 +340,13 @@ void Comm::modify_params(int narg, char **arg)
|
|||||||
if (mode == Comm::MULTIOLD)
|
if (mode == Comm::MULTIOLD)
|
||||||
error->all(FLERR,"Use cutoff/multi/old keyword to set cutoff in multi/old mode");
|
error->all(FLERR,"Use cutoff/multi/old keyword to set cutoff in multi/old mode");
|
||||||
if (domain->box_exist == 0)
|
if (domain->box_exist == 0)
|
||||||
error->all(FLERR,
|
error->all(FLERR, "Cannot set cutoff/multi before simulation box is defined");
|
||||||
"Cannot set cutoff/multi before simulation box is defined");
|
|
||||||
|
|
||||||
// Check if # of collections has changed, if so erase any previously defined cutoffs
|
// Check if # of collections has changed, if so erase any previously defined cutoffs
|
||||||
// Neighbor will reset ncollections if collections are redefined
|
// Neighbor will reset ncollections if collections are redefined
|
||||||
if (ncollections_cutoff != neighbor->ncollections) {
|
if (ncollections_cutoff != neighbor->ncollections) {
|
||||||
ncollections_cutoff = neighbor->ncollections;
|
ncollections_cutoff = neighbor->ncollections;
|
||||||
if (cutusermulti) memory->destroy(cutusermulti);
|
memory->destroy(cutusermulti);
|
||||||
memory->create(cutusermulti,ncollections_cutoff,"comm:cutusermulti");
|
memory->create(cutusermulti,ncollections_cutoff,"comm:cutusermulti");
|
||||||
for (i=0; i < ncollections_cutoff; ++i)
|
for (i=0; i < ncollections_cutoff; ++i)
|
||||||
cutusermulti[i] = -1.0;
|
cutusermulti[i] = -1.0;
|
||||||
@ -379,8 +368,7 @@ void Comm::modify_params(int narg, char **arg)
|
|||||||
if (mode == Comm::MULTI)
|
if (mode == Comm::MULTI)
|
||||||
error->all(FLERR,"Use cutoff/multi keyword to set cutoff in multi mode");
|
error->all(FLERR,"Use cutoff/multi keyword to set cutoff in multi mode");
|
||||||
if (domain->box_exist == 0)
|
if (domain->box_exist == 0)
|
||||||
error->all(FLERR,
|
error->all(FLERR, "Cannot set cutoff/multi before simulation box is defined");
|
||||||
"Cannot set cutoff/multi before simulation box is defined");
|
|
||||||
const int ntypes = atom->ntypes;
|
const int ntypes = atom->ntypes;
|
||||||
if (iarg+3 > narg)
|
if (iarg+3 > narg)
|
||||||
error->all(FLERR,"Illegal comm_modify command");
|
error->all(FLERR,"Illegal comm_modify command");
|
||||||
|
|||||||
@ -31,9 +31,9 @@ class Comm : protected Pointers {
|
|||||||
int me,nprocs; // proc info
|
int me,nprocs; // proc info
|
||||||
int ghost_velocity; // 1 if ghost atoms have velocity, 0 if not
|
int ghost_velocity; // 1 if ghost atoms have velocity, 0 if not
|
||||||
double cutghost[3]; // cutoffs used for acquiring ghost atoms
|
double cutghost[3]; // cutoffs used for acquiring ghost atoms
|
||||||
double cutghostuser; // user-specified ghost cutoff (mode == 0)
|
double cutghostuser; // user-specified ghost cutoff (mode == SINGLE)
|
||||||
double *cutusermulti; // per collection user ghost cutoff (mode == 1)
|
double *cutusermulti; // per collection user ghost cutoff (mode == MULTI)
|
||||||
double *cutusermultiold; // per type user ghost cutoff (mode == 2)
|
double *cutusermultiold; // per type user ghost cutoff (mode == MULTIOLD)
|
||||||
int ncollections; // # of collections known by comm, used to test if # has changed
|
int ncollections; // # of collections known by comm, used to test if # has changed
|
||||||
int ncollections_cutoff; // # of collections stored b cutoff/multi
|
int ncollections_cutoff; // # of collections stored b cutoff/multi
|
||||||
int recv_from_partition; // recv proc layout from this partition
|
int recv_from_partition; // recv proc layout from this partition
|
||||||
|
|||||||
Reference in New Issue
Block a user