bond/react: efficient competing reactions

This commit is contained in:
jrgissing 2018-09-04 22:06:49 -06:00
parent c471902db1
commit a5f7b418de
4 changed files with 53 additions and 8 deletions

View File

@ -1858,16 +1858,27 @@ 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
// 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;
for (int i = 0; i < onemol->natoms; i++) {
if (atom->map(glove[i][1]) >= atom->nlocal) {
ghostly = 1;
break;
if (comm->style == 0) {
int tmp;
int *localsendlist = (int *) comm->extract("localsendlist",tmp);
// create an indexed sendlist
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) {

View File

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

View File

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

View File

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