From d8845b681778adb5776165f19e99b730eb4ff66c Mon Sep 17 00:00:00 2001 From: mkanski Date: Fri, 1 Mar 2019 13:13:11 +0100 Subject: [PATCH 1/2] Added initialization of the entire num_bonds and num_hbonds arrays --- src/USER-REAXC/fix_reaxc.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/USER-REAXC/fix_reaxc.cpp b/src/USER-REAXC/fix_reaxc.cpp index c470173663..1323ff4da7 100644 --- a/src/USER-REAXC/fix_reaxc.cpp +++ b/src/USER-REAXC/fix_reaxc.cpp @@ -49,8 +49,7 @@ FixReaxC::FixReaxC(LAMMPS *lmp,int narg, char **arg) : // initialize arrays to MIN so atom migration is OK the 1st time - int nlocal = atom->nlocal; - for (int i = 0; i < nlocal; i++) + for (int i = 0; i < atom->nmax; i++) num_bonds[i] = num_hbonds[i] = MIN_REAX_BONDS; // set comm sizes needed by this fix From bfa950a7e906b0f09233b72f177a978887fdeaa7 Mon Sep 17 00:00:00 2001 From: mkanski Date: Tue, 5 Mar 2019 22:40:10 +0100 Subject: [PATCH 2/2] Added initialization for grown arrays --- src/USER-REAXC/fix_reaxc.cpp | 12 ++++++++---- src/USER-REAXC/fix_reaxc.h | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/USER-REAXC/fix_reaxc.cpp b/src/USER-REAXC/fix_reaxc.cpp index 1323ff4da7..361733f3ca 100644 --- a/src/USER-REAXC/fix_reaxc.cpp +++ b/src/USER-REAXC/fix_reaxc.cpp @@ -41,16 +41,15 @@ FixReaxC::FixReaxC(LAMMPS *lmp,int narg, char **arg) : { // perform initial allocation of atom-based arrays // register with atom class - + + oldnmax = 0; num_bonds = NULL; num_hbonds = NULL; grow_arrays(atom->nmax); atom->add_callback(0); // initialize arrays to MIN so atom migration is OK the 1st time - - for (int i = 0; i < atom->nmax; i++) - num_bonds[i] = num_hbonds[i] = MIN_REAX_BONDS; + // it is done in grow_arrays() now // set comm sizes needed by this fix @@ -98,6 +97,11 @@ void FixReaxC::grow_arrays(int nmax) { memory->grow(num_bonds,nmax,"reaxc:num_bonds"); memory->grow(num_hbonds,nmax,"reaxc:num_hbonds"); + for (int i = oldnmax; i < nmax; i++) { + num_hbonds[i] = MIN_REAX_HBONDS; + num_bonds[i] = MIN_REAX_BONDS; + } + oldnmax = nmax; } /* ---------------------------------------------------------------------- diff --git a/src/USER-REAXC/fix_reaxc.h b/src/USER-REAXC/fix_reaxc.h index 0e173f5ece..6a37002847 100644 --- a/src/USER-REAXC/fix_reaxc.h +++ b/src/USER-REAXC/fix_reaxc.h @@ -56,6 +56,7 @@ class FixReaxC : public Fix { int maxhbonds; // max # of Hbonds for any atom int *num_bonds; // # of bonds for each atom int *num_hbonds; // # of Hbonds for each atom + int oldnmax; // arrays' size before growing }; }