Merge pull request #1099 from jrgissing/bond/react-efficient-competing_reactions

bond/react: efficient competing reactions
This commit is contained in:
Richard Berger
2018-09-11 21:18:41 -04:00
committed by GitHub
5 changed files with 57 additions and 11 deletions

View File

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

View File

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

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