move xhold checks caller-side

this also allows it to fall-back on do-nothing rather than crash
This commit is contained in:
Michele Ceriotti
2024-05-22 10:02:52 +02:00
parent b5ecea502a
commit 8f61bc57d2
2 changed files with 14 additions and 15 deletions

View File

@ -379,20 +379,21 @@ void FixIPI::initial_integrate(int /*vflag*/)
// snapshot at neighbor list creation, minimizing the
// number of neighbor list updates
auto xhold = neighbor->get_xhold();
for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) {
auto delx = x[i][0] - xhold[i][0];
auto dely = x[i][1] - xhold[i][1];
auto delz = x[i][2] - xhold[i][2];
if (xhold != NULL) { // don't wrap if xhold is not used in the NL
for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) {
auto delx = x[i][0] - xhold[i][0];
auto dely = x[i][1] - xhold[i][1];
auto delz = x[i][2] - xhold[i][2];
domain->minimum_image(delx, dely, delz);
domain->minimum_image(delx, dely, delz);
x[i][0] = xhold[i][0] + delx;
x[i][1] = xhold[i][1] + dely;
x[i][2] = xhold[i][2] + delz;
x[i][0] = xhold[i][0] + delx;
x[i][1] = xhold[i][1] + dely;
x[i][2] = xhold[i][2] + delz;
}
}
}
// move atoms to new processors via irregular()
// only needed if migrate_check() says an atom moves to far
if (domain->triclinic) domain->x2lamda(atom->nlocal);

View File

@ -2976,13 +2976,11 @@ bigint Neighbor::get_nneigh_half()
return nneighhalf;
}
/* ----------------------------------------------------------------------
return the pointer containing the last positions stored by the NL builder
------------------------------------------------------------------------- */
double **Neighbor::get_xhold()
{
// Returns the pointer containing the last positions stored by the NL builder,
// checking it has actually been initialized
if (maxhold == 0) {
error->all(FLERR, "trying to access uninitialized xhold list");
}
return xhold;
}