update to use new accessor APIs

This commit is contained in:
Axel Kohlmeyer
2021-10-16 22:31:23 -04:00
parent 064e7fde2f
commit 702d861a58
2 changed files with 52 additions and 41 deletions

View File

@ -451,24 +451,29 @@ void PairGranHookeHistory::init_style()
// check for FixFreeze and set freeze_group_bit
int ifreeze = modify->find_fix_by_style("^freeze");
if (ifreeze < 0)
auto fixlist = modify->get_fix_by_style("^freeze");
if (fixlist.size() == 0)
freeze_group_bit = 0;
else if (fixlist.size() > 1)
error->all(FLERR, "Only one fix freeze command at a time allowed");
else
freeze_group_bit = modify->fix[ifreeze]->groupbit;
freeze_group_bit = fixlist.front()->groupbit;
// check for FixRigid so can extract rigid body masses
// FIXME: this only catches the first rigid fix, there may be multiple.
fix_rigid = nullptr;
for (i = 0; i < modify->nfix; i++)
if (modify->fix[i]->rigid_flag) break;
if (i < modify->nfix) fix_rigid = modify->fix[i];
for (const auto &ifix : modify->get_fix_list()) {
if (ifix->rigid_flag) {
if (fix_rigid)
error->all(FLERR, "Only one fix rigid command at a time allowed");
else fix_rigid = ifix;
}
}
// check for FixPour and FixDeposit so can extract particle radii
int ipour = modify->find_fix_by_style("^pour");
int idep = modify->find_fix_by_style("^deposit");
auto pours = modify->get_fix_by_style("^pour");
auto deps = modify->get_fix_by_style("^deposit");
// set maxrad_dynamic and maxrad_frozen for each type
// include future FixPour and FixDeposit particles as dynamic
@ -476,13 +481,15 @@ void PairGranHookeHistory::init_style()
int itype;
for (i = 1; i <= atom->ntypes; i++) {
onerad_dynamic[i] = onerad_frozen[i] = 0.0;
if (ipour >= 0) {
for (auto ipour : pours) {
itype = i;
onerad_dynamic[i] = *((double *) modify->fix[ipour]->extract("radius", itype));
double maxrad = *((double *) ipour->extract("radius", itype));
if (maxrad > 0.0) onerad_dynamic[i] = maxrad;
}
if (idep >= 0) {
for (auto idep : deps) {
itype = i;
onerad_dynamic[i] = *((double *) modify->fix[idep]->extract("radius", itype));
double maxrad = *((double *) idep->extract("radius", itype));
if (maxrad > 0.0) onerad_dynamic[i] = maxrad;
}
}
@ -491,11 +498,12 @@ void PairGranHookeHistory::init_style()
int *type = atom->type;
int nlocal = atom->nlocal;
for (i = 0; i < nlocal; i++)
for (i = 0; i < nlocal; i++) {
if (mask[i] & freeze_group_bit)
onerad_frozen[type[i]] = MAX(onerad_frozen[type[i]], radius[i]);
else
onerad_dynamic[type[i]] = MAX(onerad_dynamic[type[i]], radius[i]);
}
MPI_Allreduce(&onerad_dynamic[1], &maxrad_dynamic[1], atom->ntypes, MPI_DOUBLE, MPI_MAX, world);
MPI_Allreduce(&onerad_frozen[1], &maxrad_frozen[1], atom->ntypes, MPI_DOUBLE, MPI_MAX, world);
@ -503,9 +511,8 @@ void PairGranHookeHistory::init_style()
// set fix which stores history info
if (history) {
int ifix = modify->find_fix("NEIGH_HISTORY_HH" + std::to_string(instance_me));
if (ifix < 0) error->all(FLERR, "Could not find pair fix neigh history ID");
fix_history = (FixNeighHistory *) modify->fix[ifix];
fix_history = (FixNeighHistory *) modify->get_fix_by_id("NEIGH_HISTORY_HH" + std::to_string(instance_me));
if (!fix_history) error->all(FLERR,"Could not find pair fix neigh history ID");
}
}

View File

@ -1130,22 +1130,29 @@ void PairGranular::init_style()
// check for FixFreeze and set freeze_group_bit
int ifix = modify->find_fix_by_style("^freeze");
if (ifix < 0) freeze_group_bit = 0;
else freeze_group_bit = modify->fix[ifix]->groupbit;
auto fixlist = modify->get_fix_by_style("^freeze");
if (fixlist.size() == 0)
freeze_group_bit = 0;
else if (fixlist.size() > 1)
error->all(FLERR, "Only one fix freeze command at a time allowed");
else
freeze_group_bit = fixlist.front()->groupbit;
// check for FixRigid so can extract rigid body masses
// FIXME: this only catches the first rigid fix, there may be multiple.
fix_rigid = nullptr;
for (i = 0; i < modify->nfix; i++)
if (modify->fix[i]->rigid_flag) break;
if (i < modify->nfix) fix_rigid = modify->fix[i];
for (const auto &ifix : modify->get_fix_list()) {
if (ifix->rigid_flag) {
if (fix_rigid)
error->all(FLERR, "Only one fix rigid command at a time allowed");
else fix_rigid = ifix;
}
}
// check for FixPour and FixDeposit so can extract particle radii
int ipour = modify->find_fix_by_style("^pour");
int idep = modify->find_fix_by_style("^deposit");
auto pours = modify->get_fix_by_style("^pour");
auto deps = modify->get_fix_by_style("^deposit");
// set maxrad_dynamic and maxrad_frozen for each type
// include future FixPour and FixDeposit particles as dynamic
@ -1153,15 +1160,15 @@ void PairGranular::init_style()
int itype;
for (i = 1; i <= atom->ntypes; i++) {
onerad_dynamic[i] = onerad_frozen[i] = 0.0;
if (ipour >= 0) {
for (auto ipour : pours) {
itype = i;
double radmax = *((double *) modify->fix[ipour]->extract("radius",itype));
onerad_dynamic[i] = radmax;
double maxrad = *((double *) ipour->extract("radius", itype));
if (maxrad > 0.0) onerad_dynamic[i] = maxrad;
}
if (idep >= 0) {
for (auto idep : deps) {
itype = i;
double radmax = *((double *) modify->fix[idep]->extract("radius",itype));
onerad_dynamic[i] = radmax;
double maxrad = *((double *) idep->extract("radius", itype));
if (maxrad > 0.0) onerad_dynamic[i] = maxrad;
}
}
@ -1171,12 +1178,10 @@ void PairGranular::init_style()
int nlocal = atom->nlocal;
for (i = 0; i < nlocal; i++) {
double radius_cut = radius[i];
if (mask[i] & freeze_group_bit) {
onerad_frozen[type[i]] = MAX(onerad_frozen[type[i]],radius_cut);
} else {
onerad_dynamic[type[i]] = MAX(onerad_dynamic[type[i]],radius_cut);
}
if (mask[i] & freeze_group_bit)
onerad_frozen[type[i]] = MAX(onerad_frozen[type[i]], radius[i]);
else
onerad_dynamic[type[i]] = MAX(onerad_dynamic[type[i]], radius[i]);
}
MPI_Allreduce(&onerad_dynamic[1],&maxrad_dynamic[1],atom->ntypes,MPI_DOUBLE,MPI_MAX,world);
@ -1185,9 +1190,8 @@ void PairGranular::init_style()
// set fix which stores history info
if (size_history > 0) {
int ifix = modify->find_fix("NEIGH_HISTORY_GRANULAR");
if (ifix < 0) error->all(FLERR,"Could not find pair fix neigh history ID");
fix_history = (FixNeighHistory *) modify->fix[ifix];
fix_history = (FixNeighHistory *) modify->get_fix_by_id("NEIGH_HISTORY_GRANULAR");
if (!fix_history) error->all(FLERR,"Could not find pair fix neigh history ID");
}
}