forked from lijiext/lammps
Added initialization for grown arrays
This commit is contained in:
parent
d8845b6817
commit
bfa950a7e9
|
@ -41,16 +41,15 @@ FixReaxC::FixReaxC(LAMMPS *lmp,int narg, char **arg) :
|
||||||
{
|
{
|
||||||
// perform initial allocation of atom-based arrays
|
// perform initial allocation of atom-based arrays
|
||||||
// register with atom class
|
// register with atom class
|
||||||
|
|
||||||
|
oldnmax = 0;
|
||||||
num_bonds = NULL;
|
num_bonds = NULL;
|
||||||
num_hbonds = NULL;
|
num_hbonds = NULL;
|
||||||
grow_arrays(atom->nmax);
|
grow_arrays(atom->nmax);
|
||||||
atom->add_callback(0);
|
atom->add_callback(0);
|
||||||
|
|
||||||
// initialize arrays to MIN so atom migration is OK the 1st time
|
// initialize arrays to MIN so atom migration is OK the 1st time
|
||||||
|
// it is done in grow_arrays() now
|
||||||
for (int i = 0; i < atom->nmax; i++)
|
|
||||||
num_bonds[i] = num_hbonds[i] = MIN_REAX_BONDS;
|
|
||||||
|
|
||||||
// set comm sizes needed by this fix
|
// 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_bonds,nmax,"reaxc:num_bonds");
|
||||||
memory->grow(num_hbonds,nmax,"reaxc:num_hbonds");
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
|
|
|
@ -56,6 +56,7 @@ class FixReaxC : public Fix {
|
||||||
int maxhbonds; // max # of Hbonds for any atom
|
int maxhbonds; // max # of Hbonds for any atom
|
||||||
int *num_bonds; // # of bonds for each atom
|
int *num_bonds; // # of bonds for each atom
|
||||||
int *num_hbonds; // # of Hbonds for each atom
|
int *num_hbonds; // # of Hbonds for each atom
|
||||||
|
int oldnmax; // arrays' size before growing
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue