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

@ -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