diff --git a/src/comm.cpp b/src/comm.cpp index 02999fd541..1b1546f893 100644 --- a/src/comm.cpp +++ b/src/comm.cpp @@ -75,6 +75,7 @@ Comm::Comm(LAMMPS *lmp) : Pointers(lmp) maxexchange = maxexchange_atom = maxexchange_fix = 0; maxexchange_fix_dynamic = 0; bufextra = BUFEXTRA; + bufextra_max = bufextra; grid2proc = nullptr; xsplit = ysplit = zsplit = nullptr; diff --git a/src/comm.h b/src/comm.h index fde4c3b81f..8515866dff 100644 --- a/src/comm.h +++ b/src/comm.h @@ -140,6 +140,7 @@ class Comm : protected Pointers { int maxexchange_fix; // static contribution to maxexchange from Fixes int maxexchange_fix_dynamic; // 1 if a fix has a dynamic contribution int bufextra; // augment send buf size for an exchange atom + int bufextra_max; int gridflag; // option for creating 3d grid int mapflag; // option for mapping procs to 3d grid diff --git a/src/comm_brick.cpp b/src/comm_brick.cpp index cf38271029..c75b183584 100644 --- a/src/comm_brick.cpp +++ b/src/comm_brick.cpp @@ -133,9 +133,11 @@ void CommBrick::init() { Comm::init(); - int bufextra_old = bufextra; init_exchange(); - if (bufextra > bufextra_old) grow_send(maxsend+bufextra,2); + if (bufextra > bufextra_max) { + grow_send(maxsend+bufextra,2); + bufextra_max = bufextra; + } // memory for multi style communication // allocate in setup @@ -672,9 +674,11 @@ void CommBrick::exchange() // only need to reset if a fix can dynamically add to size of single atom if (maxexchange_fix_dynamic) { - int bufextra_old = bufextra; init_exchange(); - if (bufextra > bufextra_old) grow_send(maxsend+bufextra,2); + if (bufextra > bufextra_max) { + grow_send(maxsend+bufextra,2); + bufextra_max = bufextra; + } } // subbox bounds for orthogonal or triclinic diff --git a/src/comm_tiled.cpp b/src/comm_tiled.cpp index b864e0523d..f4657c4790 100644 --- a/src/comm_tiled.cpp +++ b/src/comm_tiled.cpp @@ -943,9 +943,11 @@ void CommTiled::exchange() // only need to reset if a fix can dynamically add to size of single atom if (maxexchange_fix_dynamic) { - int bufextra_old = bufextra; init_exchange(); - if (bufextra > bufextra_old) grow_send(maxsend+bufextra,2); + if (bufextra > bufextra_max) { + grow_send(maxsend+bufextra,2); + bufextra = bufextra_max; + } } // domain properties used in exchange method and methods it calls