From d476b251e92973ce5a651704cfd74ea3fd3bd8d6 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Thu, 20 Nov 2014 18:16:39 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@12753 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/comm.cpp | 29 ++++------------------------- src/domain.cpp | 30 ++++++++++++++++++++++++++++++ src/domain.h | 1 + src/fix_balance.cpp | 6 +++++- 4 files changed, 40 insertions(+), 26 deletions(-) diff --git a/src/comm.cpp b/src/comm.cpp index 07bc10762b..9fb604ae42 100644 --- a/src/comm.cpp +++ b/src/comm.cpp @@ -162,33 +162,12 @@ void Comm::init() triclinic = domain->triclinic; map_style = atom->map_style; - // warn if any proc's sub-box is smaller than neigh skin - // since may lead to lost atoms in exchange() + // check warn if any proc's subbox is smaller than neigh skin + // since may lead to lost atoms in exchange() // really should check every exchange() in case box size is shrinking - // but seems overkill to do that + // but seems overkill to do that (fix balance does perform this check) - int flag = 0; - if (!triclinic) { - if (domain->subhi[0] - domain->sublo[0] < neighbor->skin) flag = 1; - if (domain->subhi[1] - domain->sublo[1] < neighbor->skin) flag = 1; - if (domain->dimension == 3) - if (domain->subhi[2] - domain->sublo[2] < neighbor->skin) flag = 1; - } else { - double delta = domain->subhi_lamda[0] - domain->sublo_lamda[0]; - if (delta*domain->prd[0] < neighbor->skin) flag = 1; - delta = domain->subhi_lamda[1] - domain->sublo_lamda[1]; - if (delta*domain->prd[1] < neighbor->skin) flag = 1; - if (domain->dimension == 3) { - delta = domain->subhi_lamda[2] - domain->sublo_lamda[2]; - if (delta*domain->prd[2] < neighbor->skin) flag = 1; - } - } - - int flagall; - MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); - if (flagall && me == 0) - error->warning(FLERR,"Proc sub-domain size < neighbor skin - " - "could lead to lost atoms"); + domain->subbox_too_small_check(neighbor->skin); // comm_only = 1 if only x,f are exchanged in forward/reverse comm // comm_x_only = 0 if ghost_velocity since velocities are added diff --git a/src/domain.cpp b/src/domain.cpp index 0afd37da78..378a25264f 100644 --- a/src/domain.cpp +++ b/src/domain.cpp @@ -800,6 +800,36 @@ void Domain::box_too_small_check() "Bond/angle/dihedral extent > half of periodic box length"); } +/* ---------------------------------------------------------------------- + check warn if any proc's subbox is smaller than thresh + since may lead to lost atoms in comm->exchange() + current callers set thresh = neighbor skin +------------------------------------------------------------------------- */ + +void Domain::subbox_too_small_check(double thresh) +{ + int flag = 0; + if (!triclinic) { + if (subhi[0]-sublo[0] < thresh || subhi[1]-sublo[1] < thresh) flag = 1; + if (dimension == 3 && subhi[2]-sublo[2] < thresh) flag = 1; + } else { + double delta = subhi_lamda[0] - sublo_lamda[0]; + if (delta*prd[0] < thresh) flag = 1; + delta = subhi_lamda[1] - sublo_lamda[1]; + if (delta*prd[1] < thresh) flag = 1; + if (dimension == 3) { + delta = subhi_lamda[2] - sublo_lamda[2]; + if (delta*prd[2] < thresh) flag = 1; + } + } + + int flagall; + MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); + if (flagall && comm->me == 0) + error->warning(FLERR,"Proc sub-domain size < neighbor skin, " + "could lead to lost atoms"); +} + /* ---------------------------------------------------------------------- minimum image convention use 1/2 of box size as test diff --git a/src/domain.h b/src/domain.h index 9bb50f551a..c5f74f6b28 100644 --- a/src/domain.h +++ b/src/domain.h @@ -101,6 +101,7 @@ class Domain : protected Pointers { virtual void pbc(); void image_check(); void box_too_small_check(); + void subbox_too_small_check(double); void minimum_image(double &, double &, double &); void minimum_image(double *); int closest_image(int, int); diff --git a/src/fix_balance.cpp b/src/fix_balance.cpp index 3495523c7e..f4dc2e76cb 100644 --- a/src/fix_balance.cpp +++ b/src/fix_balance.cpp @@ -16,9 +16,10 @@ #include "fix_balance.h" #include "balance.h" #include "update.h" -#include "domain.h" #include "atom.h" #include "comm.h" +#include "domain.h" +#include "neighbor.h" #include "irregular.h" #include "force.h" #include "kspace.h" @@ -263,9 +264,12 @@ void FixBalance::rebalance() if (outflag) balance->dumpout(update->ntimestep,fp); // reset proc sub-domains + // check and warn if any proc's subbox is smaller than neigh skin + // since may lead to lost atoms in exchange() if (domain->triclinic) domain->set_lamda_box(); domain->set_local_box(); + domain->subbox_too_small_check(neighbor->skin); // move atoms to new processors via irregular() // only needed if migrate_check() says an atom moves to far