use new bitmap accessor function and simplify code

This commit is contained in:
Axel Kohlmeyer
2024-06-01 17:57:31 -04:00
parent 5f2c81804d
commit a0939c4fcc
11 changed files with 23 additions and 50 deletions

View File

@ -2284,7 +2284,7 @@ void Atom::first_reorder()
// nfirst = index of first atom not in firstgroup
// when find firstgroup atom out of place, swap it with atom nfirst
int bitmask = group->bitmask[firstgroup];
const int bitmask = group->get_bitmask_by_id(FLERR, firstgroupname, "Atom::first_reorder");
nfirst = 0;
while (nfirst < nlocal && mask[nfirst] & bitmask) nfirst++;

View File

@ -52,9 +52,7 @@ void ChangeBox::command(int narg, char **arg)
// group
int igroup = group->find(arg[0]);
if (igroup == -1) error->all(FLERR,"Could not find change_box group ID {}", arg[0]);
int groupbit = group->bitmask[igroup];
int groupbit = group->get_bitmask_by_id(FLERR, arg[0], "change_box");
// parse operation arguments
// allocate ops to max possible length

View File

@ -48,11 +48,11 @@ Compute::Compute(LAMMPS *lmp, int narg, char **arg) :
id = utils::strdup(arg[0]);
if (!utils::is_id(id))
error->all(FLERR,"Compute ID must be alphanumeric or underscore characters");
error->all(FLERR,"Compute ID {} must only have alphanumeric or underscore characters", id);
groupbit = group->get_bitmask_by_id(FLERR, arg[1], fmt::format("compute {}", arg[2]));
igroup = group->find(arg[1]);
if (igroup == -1) error->all(FLERR,"Could not find compute group ID");
groupbit = group->bitmask[igroup];
if (igroup == -1) error->all(FLERR,"Could not find compute group ID {}", arg[1]);
style = utils::strdup(arg[2]);

View File

@ -39,8 +39,7 @@ ComputeCoordAtom::ComputeCoordAtom(LAMMPS *lmp, int narg, char **arg) :
{
if (narg < 5) error->all(FLERR, "Illegal compute coord/atom command");
jgroup = group->find("all");
jgroupbit = group->bitmask[jgroup];
jgroupbit = group->get_bitmask_by_id(FLERR, "all", "compute coord/atom");
cstyle = NONE;
if (strcmp(arg[3], "cutoff") == 0) {
@ -50,11 +49,10 @@ ComputeCoordAtom::ComputeCoordAtom(LAMMPS *lmp, int narg, char **arg) :
int iarg = 5;
if ((narg > 6) && (strcmp(arg[5], "group") == 0)) {
delete[] group2;
group2 = utils::strdup(arg[6]);
iarg += 2;
jgroup = group->find(group2);
if (jgroup == -1) error->all(FLERR, "Compute coord/atom group2 ID does not exist");
jgroupbit = group->bitmask[jgroup];
jgroupbit = group->get_bitmask_by_id(FLERR, group2, "compute coord/atom");
}
ncol = narg - iarg + 1;

View File

@ -46,7 +46,7 @@ class ComputeCoordAtom : public Compute {
double **carray;
char *group2;
int jgroup, jgroupbit;
int jgroupbit;
class ComputeOrientOrderAtom *c_orientorder;
char *id_orientorder;

View File

@ -54,9 +54,7 @@ ComputeGroupGroup::ComputeGroupGroup(LAMMPS *lmp, int narg, char **arg) :
extvector = 1;
group2 = utils::strdup(arg[3]);
jgroup = group->find(group2);
if (jgroup == -1) error->all(FLERR, "Compute group/group group ID does not exist");
jgroupbit = group->bitmask[jgroup];
jgroupbit = group->get_bitmask_by_id(FLERR, group2, "compute group/group");
pairflag = 1;
kspaceflag = 0;
@ -147,9 +145,7 @@ void ComputeGroupGroup::init()
// recheck that group 2 has not been deleted
jgroup = group->find(group2);
if (jgroup == -1) error->all(FLERR, "Compute group/group group ID does not exist");
jgroupbit = group->bitmask[jgroup];
jgroupbit = group->get_bitmask_by_id(FLERR, group2, "compute group/group");
// need an occasional half neighbor list

View File

@ -35,7 +35,7 @@ class ComputeGroupGroup : public Compute {
private:
char *group2;
int jgroup, jgroupbit, othergroupbit;
int jgroupbit;
double **cutsq;
double e_self, e_correction;
int pairflag, kspaceflag, boundaryflag, molflag;

View File

@ -59,12 +59,8 @@ void CreateBonds::command(int narg, char **arg)
if (strcmp(arg[0], "many") == 0) {
style = MANY;
if (narg != 6) error->all(FLERR, "No optional keywords allowed with create_bonds many");
igroup = group->find(arg[1]);
if (igroup == -1) error->all(FLERR, "Cannot find create_bonds first group ID {}", arg[1]);
group1bit = group->bitmask[igroup];
igroup = group->find(arg[2]);
if (igroup == -1) error->all(FLERR, "Cannot find create_bonds second group ID {}", arg[2]);
group2bit = group->bitmask[igroup];
group1bit = group->get_bitmask_by_id(FLERR, arg[1], "create_bonds");
group2bit = group->get_bitmask_by_id(FLERR, arg[2], "create_bonds");
btype = utils::inumeric(FLERR, arg[3], false, lmp);
rmin = utils::numeric(FLERR, arg[4], false, lmp);
rmax = utils::numeric(FLERR, arg[5], false, lmp);

View File

@ -30,7 +30,7 @@ class CreateBonds : public Command {
void command(int, char **) override;
private:
int igroup, group1bit, group2bit;
int group1bit, group2bit;
int btype, atype, dtype;
tagint batom1, batom2, aatom1, aatom2, aatom3, datom1, datom2, datom3, datom4;
double rmin, rmax;

View File

@ -86,8 +86,8 @@ void DeleteAtoms::command(int narg, char **arg)
error->all(FLERR, "Unknown delete_atoms sub-command: {}", arg[0]);
if (allflag) {
int igroup = group->find("all");
if ((igroup >= 0) && modify->check_rigid_group_overlap(group->bitmask[igroup]))
int igroupbit = group->get_bitmask_by_id(FLERR, "all", "delete_atoms");
if (modify->check_rigid_group_overlap(igroupbit))
error->warning(FLERR, "Attempting to delete atoms in rigid bodies");
} else {
if (modify->check_rigid_list_overlap(dlist))
@ -215,8 +215,7 @@ void DeleteAtoms::delete_group(int narg, char **arg)
{
if (narg < 2) utils::missing_cmd_args(FLERR, "delete_atoms group", error);
int igroup = group->find(arg[1]);
if (igroup == -1) error->all(FLERR, "Could not find delete_atoms group ID {}", arg[1]);
int groupbit = group->get_bitmask_by_id(FLERR, arg[1], "delete_atoms");
options(narg - 2, &arg[2]);
// check for special case of group = all
@ -233,8 +232,6 @@ void DeleteAtoms::delete_group(int narg, char **arg)
for (int i = 0; i < nlocal; i++) dlist[i] = 0;
int *mask = atom->mask;
int groupbit = group->bitmask[igroup];
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) dlist[i] = 1;
}
@ -280,18 +277,11 @@ void DeleteAtoms::delete_overlap(int narg, char **arg)
const double cut = utils::numeric(FLERR, arg[1], false, lmp);
const double cutsq = cut * cut;
const int group1bit = group->get_bitmask_by_id(FLERR, arg[2], "delete_atoms");
const int group2bit = group->get_bitmask_by_id(FLERR, arg[3], "delete_atoms");
int igroup1 = group->find(arg[2]);
if (igroup1 < 0)
error->all(FLERR, "Could not find delete_atoms overlap first group ID {}", arg[2]);
int igroup2 = group->find(arg[3]);
if (igroup2 < 0)
error->all(FLERR, "Could not find delete_atoms overlap second group ID {}", arg[3]);
options(narg - 4, &arg[4]);
const int group1bit = group->bitmask[igroup1];
const int group2bit = group->bitmask[igroup2];
if (comm->me == 0) utils::logmesg(lmp, "System init for delete_atoms ...\n");
// request a full neighbor list for use by this command
@ -453,9 +443,7 @@ void DeleteAtoms::delete_random(int narg, char **arg)
error->all(FLERR, "Unknown delete_atoms random style: {}", arg[1]);
}
int igroup = group->find(arg[4]);
if (igroup == -1) error->all(FLERR, "Could not find delete_atoms random group ID {}", arg[4]);
int groupbit = group->get_bitmask_by_id(FLERR, arg[4], "delete_atoms");
auto region = domain->get_region_by_id(arg[5]);
if (!region && (strcmp(arg[5], "NULL") != 0))
error->all(FLERR, "Could not find delete_atoms random region ID {}", arg[5]);
@ -476,7 +464,6 @@ void DeleteAtoms::delete_random(int narg, char **arg)
double **x = atom->x;
int *mask = atom->mask;
int groupbit = group->bitmask[igroup];
if (region) region->prematch();
// delete approximate fraction of atoms in both group and region

View File

@ -56,11 +56,9 @@ void DeleteBonds::command(int narg, char **arg)
if (comm->me == 0) utils::logmesg(lmp,"Deleting bonds ...\n");
// identify group
// get group bitmask
int igroup = group->find(arg[0]);
if (igroup == -1) error->all(FLERR,"Cannot find delete_bonds group ID");
int groupbit = group->bitmask[igroup];
int groupbit = group->get_bitmask_by_id(FLERR, arg[0], "delete_bonds");
// set style and which = type value