From fa6fc947f231d639672457bcdf79bc3e65a54931 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 28 Nov 2017 11:28:15 -0500 Subject: [PATCH] fix issues in FixNeighHistory and FixNeighHistoryOMP reported in https://sourceforge.net/p/lammps/mailman/message/36138319/ This supersedes and closes PR #734 --- src/USER-OMP/fix_neigh_history_omp.cpp | 2 +- src/fix_neigh_history.cpp | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/USER-OMP/fix_neigh_history_omp.cpp b/src/USER-OMP/fix_neigh_history_omp.cpp index ecc3147ed5..1b212732de 100644 --- a/src/USER-OMP/fix_neigh_history_omp.cpp +++ b/src/USER-OMP/fix_neigh_history_omp.cpp @@ -356,7 +356,7 @@ void FixNeighHistoryOMP::pre_exchange_newton() #endif { maxpartner = MAX(m,maxpartner); - comm->maxexchange_fix = MAX(comm->maxexchange_fix,4*maxpartner+1); + comm->maxexchange_fix = MAX(comm->maxexchange_fix,(dnum+1)*maxpartner+1); } } diff --git a/src/fix_neigh_history.cpp b/src/fix_neigh_history.cpp index 322c8d5561..623fbff756 100644 --- a/src/fix_neigh_history.cpp +++ b/src/fix_neigh_history.cpp @@ -35,7 +35,7 @@ enum{DEFAULT,NPARTNER,PERPARTNER}; // also set in fix neigh/history/omp FixNeighHistory::FixNeighHistory(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), - npartner(NULL), partner(NULL), valuepartner(NULL), pair(NULL), + npartner(NULL), partner(NULL), valuepartner(NULL), pair(NULL), ipage_atom(NULL), dpage_atom(NULL), ipage_neigh(NULL), dpage_neigh(NULL) { if (narg != 4) error->all(FLERR,"Illegal fix NEIGH_HISTORY command"); @@ -295,7 +295,7 @@ void FixNeighHistory::pre_exchange_onesided() // set maxpartner = max # of partners of any owned atom // bump up comm->maxexchange_fix if necessary - + maxpartner = 0; for (i = 0; i < nlocal_neigh; i++) maxpartner = MAX(maxpartner,npartner[i]); comm->maxexchange_fix = MAX(comm->maxexchange_fix,(dnum+1)*maxpartner+1); @@ -318,7 +318,7 @@ void FixNeighHistory::pre_exchange_newton() int *allflags; double *allvalues,*onevalues,*jvalues; - // NOTE: all operations until very end are with + // NOTE: all operations until very end are with // nlocal_neigh <= current nlocal and nall_neigh // b/c previous neigh list was built with nlocal_neigh & nghost_neigh // nlocal can be larger if other fixes added atoms at this pre_exchange() @@ -424,7 +424,7 @@ void FixNeighHistory::pre_exchange_newton() maxpartner = 0; for (i = 0; i < nlocal_neigh; i++) maxpartner = MAX(maxpartner,npartner[i]); - comm->maxexchange_fix = MAX(comm->maxexchange_fix,4*maxpartner+1); + comm->maxexchange_fix = MAX(comm->maxexchange_fix,(dnum+1)*maxpartner+1); // zero npartner values from previous nlocal_neigh to current nlocal @@ -526,7 +526,7 @@ void FixNeighHistory::pre_exchange_no_newton() // set maxpartner = max # of partners of any owned atom // bump up comm->maxexchange_fix if necessary - + maxpartner = 0; for (i = 0; i < nlocal_neigh; i++) maxpartner = MAX(maxpartner,npartner[i]); comm->maxexchange_fix = MAX(comm->maxexchange_fix,(dnum+1)*maxpartner+1); @@ -571,9 +571,9 @@ void FixNeighHistory::post_neighbor() memory->sfree(firstflag); memory->sfree(firstvalue); maxatom = nall; - firstflag = (int **) + firstflag = (int **) memory->smalloc(maxatom*sizeof(int *),"neighbor_history:firstflag"); - firstvalue = (double **) + firstvalue = (double **) memory->smalloc(maxatom*sizeof(double *),"neighbor_history:firstvalue"); } @@ -720,7 +720,7 @@ int FixNeighHistory::pack_reverse_comm_size(int n, int first) last = first + n; for (i = first; i < last; i++) - m += 1 + 4*npartner[i]; + m += 1 + (dnum+1)*npartner[i]; return m; }