diff --git a/src/USER-MISC/fix_bond_react.cpp b/src/USER-MISC/fix_bond_react.cpp index ceac93178d1c617a6b0f976f8be607c1f704532e..a6f08a7376b8dacb33b424091390f2e757406d68 100644 --- a/src/USER-MISC/fix_bond_react.cpp +++ b/src/USER-MISC/fix_bond_react.cpp @@ -961,6 +961,10 @@ void FixBondReact::superimpose_algorithm() local_num_mega = 0; ghostly_num_mega = 0; + // indicates local ghosts of other procs + int tmp; + localsendlist = (int *) comm->extract("localsendlist",tmp); + // quick description of important global indices you'll see floating about: // 'pion' is the pioneer loop index // 'neigh' in the first neighbor index @@ -1857,17 +1861,24 @@ if so, flag for broadcasting for perusal by all processors void FixBondReact::glove_ghostcheck() { - // it appears this little loop was deemed important enough for its own function! - // noteworthy: it's only relevant for parallel - // here we add glove to either local_mega_glove or ghostly_mega_glove - int ghostly = 1; - //for (int i = 0; i < onemol->natoms; i++) { - // if (atom->map(glove[i][1]) >= atom->nlocal) { - // ghostly = 1; - // break; - // } - //} + // ghostly_mega_glove includes atoms that are ghosts, either of this proc or another + // 'ghosts of another' indication taken from comm->sendlist + + int ghostly = 0; + if (comm->style == 0) { + for (int i = 0; i < onemol->natoms; i++) { + int ilocal = atom->map(glove[i][1]); + if (ilocal >= atom->nlocal || localsendlist[ilocal] == 1) { + ghostly = 1; + break; + } + } + } else { + #if !defined(MPI_STUBS) + ghostly = 1; + #endif + } if (ghostly == 1) { ghostly_mega_glove[0][ghostly_num_mega] = rxnID; diff --git a/src/USER-MISC/fix_bond_react.h b/src/USER-MISC/fix_bond_react.h index 8ff71141f8abf66e2ea221db207983ecc9b7eae5..08756f8131cf504cf172f50c3b4cc7c1a7e2c365 100644 --- a/src/USER-MISC/fix_bond_react.h +++ b/src/USER-MISC/fix_bond_react.h @@ -122,6 +122,7 @@ class FixBondReact : public Fix { tagint **local_mega_glove; // consolidation local of reaction instances tagint **ghostly_mega_glove; // consolidation nonlocal of reaction instances tagint **global_mega_glove; // consolidation (inter-processor) of gloves containing nonlocal atoms + int *localsendlist; // indicates ghosts of other procs int local_num_mega; // num of local reaction instances int ghostly_num_mega; // num of ghostly reaction instances int global_megasize; // num of reaction instances in global_mega_glove diff --git a/src/comm.h b/src/comm.h index 298f435c3d94f2e04af2077cfadb21ef3372896c..2579f9b283bd5bbab6d09d9c207265fd241f6ced 100644 --- a/src/comm.h +++ b/src/comm.h @@ -112,6 +112,9 @@ class Comm : protected Pointers { int read_lines_from_file(FILE *, int, int, char *); int read_lines_from_file_universe(FILE *, int, int, char *); + // extract data useful to other classes + virtual void *extract(const char *, int &) {return NULL;} + protected: int bordergroup; // only communicate this group in borders diff --git a/src/comm_brick.cpp b/src/comm_brick.cpp index 49c9db172f585f3be93eddd9b46fe82ef5c863c2..4015240af890523eb23ef7acfd1143a72880f87c 100644 --- a/src/comm_brick.cpp +++ b/src/comm_brick.cpp @@ -55,7 +55,8 @@ CommBrick::CommBrick(LAMMPS *lmp) : size_reverse_send(NULL), size_reverse_recv(NULL), slablo(NULL), slabhi(NULL), multilo(NULL), multihi(NULL), cutghostmulti(NULL), pbc_flag(NULL), pbc(NULL), firstrecv(NULL), - sendlist(NULL), maxsendlist(NULL), buf_send(NULL), buf_recv(NULL) + sendlist(NULL), localsendlist(NULL), maxsendlist(NULL), + buf_send(NULL), buf_recv(NULL) { style = 0; layout = Comm::LAYOUT_UNIFORM; @@ -74,6 +75,7 @@ CommBrick::~CommBrick() } if (sendlist) for (int i = 0; i < maxswap; i++) memory->destroy(sendlist[i]); + if (localsendlist) memory->destroy(localsendlist); memory->sfree(sendlist); memory->destroy(maxsendlist); @@ -1469,6 +1471,33 @@ void CommBrick::free_multi() multilo = multihi = NULL; } +/* ---------------------------------------------------------------------- + extract data potentially useful to other classes +------------------------------------------------------------------------- */ + +void *CommBrick::extract(const char *str, int &dim) +{ + if (strcmp(str,"localsendlist") == 0) { + int i, iswap, isend; + if (!localsendlist) + memory->create(localsendlist,atom->nlocal,"comm:localsendlist"); + else + memory->grow(localsendlist,atom->nlocal,"comm:localsendlist"); + + for (i = 0; i < atom->nlocal; i++) + localsendlist[i] = 0; + + for (iswap = 0; iswap < nswap; iswap++) + for (isend = 0; isend < sendnum[iswap]; isend++) + if (sendlist[iswap][isend] < atom->nlocal) + localsendlist[sendlist[iswap][isend]] = 1; + + return (void *) localsendlist; + } + + return NULL; +} + /* ---------------------------------------------------------------------- return # of bytes of allocated memory ------------------------------------------------------------------------- */ diff --git a/src/comm_brick.h b/src/comm_brick.h index 461ee84b408f19f1582b9815f9eecfa41ee79d0d..b3a3a7e094c73ed41fde518a211afc4f5db52f24 100644 --- a/src/comm_brick.h +++ b/src/comm_brick.h @@ -46,6 +46,7 @@ class CommBrick : public Comm { void forward_comm_array(int, double **); // forward comm of array int exchange_variable(int, double *, double *&); // exchange on neigh stencil + void *extract(const char *,int &); virtual bigint memory_usage(); protected: @@ -67,6 +68,7 @@ class CommBrick : public Comm { int *firstrecv; // where to put 1st recv atom in each swap int **sendlist; // list of atoms to send in each swap + int *localsendlist; // indexed list of local sendlist atoms int *maxsendlist; // max size of send list for each swap double *buf_send; // send buffer for all comm