refactor group access, enable and apply clang-format

This commit is contained in:
Axel Kohlmeyer
2022-04-14 22:01:48 -04:00
parent 4b400fb4a6
commit 69d9c5187e
187 changed files with 3016 additions and 2927 deletions

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -36,23 +35,21 @@ CreateBox::CreateBox(LAMMPS *lmp) : Command(lmp) {}
void CreateBox::command(int narg, char **arg)
{
if (narg < 2) error->all(FLERR,"Illegal create_box command");
if (narg < 2) error->all(FLERR, "Illegal create_box command");
if (domain->box_exist)
error->all(FLERR,"Cannot create_box after simulation box is defined");
if (domain->box_exist) error->all(FLERR, "Cannot create_box after simulation box is defined");
if (domain->dimension == 2 && domain->zperiodic == 0)
error->all(FLERR,"Cannot run 2d simulation with nonperiodic Z dimension");
error->all(FLERR, "Cannot run 2d simulation with nonperiodic Z dimension");
domain->box_exist = 1;
// region check
int iregion = domain->find_region(arg[1]);
if (iregion == -1) error->all(FLERR,"Create_box region ID does not exist");
if (domain->regions[iregion]->bboxflag == 0)
error->all(FLERR,"Create_box region does not support a bounding box");
auto region = domain->get_region_by_id(arg[1]);
if (!region) error->all(FLERR, "Create_box region {} does not exist", arg[1]);
if (region->bboxflag == 0) error->all(FLERR, "Create_box region does not support a bounding box");
domain->regions[iregion]->init();
region->init();
// if region not prism:
// setup orthogonal domain
@ -61,27 +58,27 @@ void CreateBox::command(int narg, char **arg)
// seutp triclinic domain
// set simulation domain params from prism params
if (strcmp(domain->regions[iregion]->style,"prism") != 0) {
if (strcmp(region->style, "prism") != 0) {
domain->triclinic = 0;
domain->boxlo[0] = domain->regions[iregion]->extent_xlo;
domain->boxhi[0] = domain->regions[iregion]->extent_xhi;
domain->boxlo[1] = domain->regions[iregion]->extent_ylo;
domain->boxhi[1] = domain->regions[iregion]->extent_yhi;
domain->boxlo[2] = domain->regions[iregion]->extent_zlo;
domain->boxhi[2] = domain->regions[iregion]->extent_zhi;
domain->boxlo[0] = region->extent_xlo;
domain->boxhi[0] = region->extent_xhi;
domain->boxlo[1] = region->extent_ylo;
domain->boxhi[1] = region->extent_yhi;
domain->boxlo[2] = region->extent_zlo;
domain->boxhi[2] = region->extent_zhi;
} else {
domain->triclinic = 1;
auto region = dynamic_cast<RegPrism *>( domain->regions[iregion]);
domain->boxlo[0] = region->xlo;
domain->boxhi[0] = region->xhi;
domain->boxlo[1] = region->ylo;
domain->boxhi[1] = region->yhi;
domain->boxlo[2] = region->zlo;
domain->boxhi[2] = region->zhi;
domain->xy = region->xy;
domain->xz = region->xz;
domain->yz = region->yz;
auto prism = dynamic_cast<RegPrism *>(region);
domain->boxlo[0] = prism->xlo;
domain->boxhi[0] = prism->xhi;
domain->boxlo[1] = prism->ylo;
domain->boxhi[1] = prism->yhi;
domain->boxlo[2] = prism->zlo;
domain->boxhi[2] = prism->zhi;
domain->xy = prism->xy;
domain->xz = prism->xz;
domain->yz = prism->yz;
}
// if molecular, zero out topology info
@ -99,7 +96,7 @@ void CreateBox::command(int narg, char **arg)
// set atom and topology type quantities
atom->ntypes = utils::inumeric(FLERR,arg[0],false,lmp);
atom->ntypes = utils::inumeric(FLERR, arg[0], false, lmp);
atom->nbondtypes = 0;
atom->nangletypes = 0;
atom->ndihedraltypes = 0;
@ -109,60 +106,57 @@ void CreateBox::command(int narg, char **arg)
int iarg = 2;
while (iarg < narg) {
if (strcmp(arg[iarg],"bond/types") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal create_box command");
if (!atom->avec->bonds_allow)
error->all(FLERR,"No bonds allowed with this atom style");
atom->nbondtypes = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
if (strcmp(arg[iarg], "bond/types") == 0) {
if (iarg + 2 > narg) error->all(FLERR, "Illegal create_box command");
if (!atom->avec->bonds_allow) error->all(FLERR, "No bonds allowed with this atom style");
atom->nbondtypes = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"angle/types") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal create_box command");
if (!atom->avec->angles_allow)
error->all(FLERR,"No angles allowed with this atom style");
atom->nangletypes = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
} else if (strcmp(arg[iarg], "angle/types") == 0) {
if (iarg + 2 > narg) error->all(FLERR, "Illegal create_box command");
if (!atom->avec->angles_allow) error->all(FLERR, "No angles allowed with this atom style");
atom->nangletypes = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"dihedral/types") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal create_box command");
} else if (strcmp(arg[iarg], "dihedral/types") == 0) {
if (iarg + 2 > narg) error->all(FLERR, "Illegal create_box command");
if (!atom->avec->dihedrals_allow)
error->all(FLERR,"No dihedrals allowed with this atom style");
atom->ndihedraltypes = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
error->all(FLERR, "No dihedrals allowed with this atom style");
atom->ndihedraltypes = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"improper/types") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal create_box command");
} else if (strcmp(arg[iarg], "improper/types") == 0) {
if (iarg + 2 > narg) error->all(FLERR, "Illegal create_box command");
if (!atom->avec->impropers_allow)
error->all(FLERR,"No impropers allowed with this atom style");
atom->nimpropertypes = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
error->all(FLERR, "No impropers allowed with this atom style");
atom->nimpropertypes = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"extra/bond/per/atom") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal create_box command");
if (!atom->avec->bonds_allow)
error->all(FLERR,"No bonds allowed with this atom style");
atom->bond_per_atom = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
} else if (strcmp(arg[iarg], "extra/bond/per/atom") == 0) {
if (iarg + 2 > narg) error->all(FLERR, "Illegal create_box command");
if (!atom->avec->bonds_allow) error->all(FLERR, "No bonds allowed with this atom style");
atom->bond_per_atom = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"extra/angle/per/atom") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal create_box command");
if (!atom->avec->angles_allow)
error->all(FLERR,"No angles allowed with this atom style");
atom->angle_per_atom = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
} else if (strcmp(arg[iarg], "extra/angle/per/atom") == 0) {
if (iarg + 2 > narg) error->all(FLERR, "Illegal create_box command");
if (!atom->avec->angles_allow) error->all(FLERR, "No angles allowed with this atom style");
atom->angle_per_atom = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"extra/dihedral/per/atom") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal create_box command");
} else if (strcmp(arg[iarg], "extra/dihedral/per/atom") == 0) {
if (iarg + 2 > narg) error->all(FLERR, "Illegal create_box command");
if (!atom->avec->dihedrals_allow)
error->all(FLERR,"No dihedrals allowed with this atom style");
atom->dihedral_per_atom = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
error->all(FLERR, "No dihedrals allowed with this atom style");
atom->dihedral_per_atom = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"extra/improper/per/atom") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal create_box command");
} else if (strcmp(arg[iarg], "extra/improper/per/atom") == 0) {
if (iarg + 2 > narg) error->all(FLERR, "Illegal create_box command");
if (!atom->avec->impropers_allow)
error->all(FLERR,"No impropers allowed with this atom style");
atom->improper_per_atom = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
error->all(FLERR, "No impropers allowed with this atom style");
atom->improper_per_atom = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"extra/special/per/atom") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal create_box command");
force->special_extra = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
} else if (strcmp(arg[iarg], "extra/special/per/atom") == 0) {
if (iarg + 2 > narg) error->all(FLERR, "Illegal create_box command");
force->special_extra = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
atom->maxspecial += force->special_extra;
iarg += 2;
} else error->all(FLERR,"Illegal create_box command");
} else
error->all(FLERR, "Illegal create_box command");
}
// problem setup using info from header