Fixed initialization of arrays in computes

This commit is contained in:
Anders Hafreager 2016-08-24 15:57:06 +02:00 committed by Axel Kohlmeyer
parent e27196e91c
commit 0e7ce194eb
8 changed files with 22 additions and 27 deletions

View File

@ -38,10 +38,13 @@ int Compute::instance_total = 0;
/* ---------------------------------------------------------------------- */
Compute::Compute(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
Compute::Compute(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp),
id(NULL), style(NULL),
vector(NULL), array(NULL), vector_atom(NULL), array_atom(NULL), vector_local(NULL), array_local(NULL),
tlist(NULL)
{
instance_me = instance_total++;
if (narg < 3) error->all(FLERR,"Illegal compute command");
// compute ID, group, and style
@ -93,8 +96,7 @@ Compute::Compute(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
// setup list of timesteps
ntime = maxtime = 0;
tlist = NULL;
// data masks
datamask = ALL_MASK;
@ -105,11 +107,6 @@ Compute::Compute(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
datamask_modify = ALL_MASK;
copymode = 0;
// force init to zero in case these are used as logicals
vector = vector_atom = vector_local = NULL;
array = array_atom = array_local = NULL;
}
/* ---------------------------------------------------------------------- */

View File

@ -24,7 +24,8 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
ComputeAngle::ComputeAngle(LAMMPS *lmp, int narg, char **arg) :
Compute(lmp, narg, arg)
Compute(lmp, narg, arg),
emine(NULL)
{
if (narg != 3) error->all(FLERR,"Illegal compute angle command");

View File

@ -33,7 +33,8 @@ using namespace MathConst;
/* ---------------------------------------------------------------------- */
ComputeAngleLocal::ComputeAngleLocal(LAMMPS *lmp, int narg, char **arg) :
Compute(lmp, narg, arg)
Compute(lmp, narg, arg),
vector(NULL), array(NULL)
{
if (narg < 4) error->all(FLERR,"Illegal compute angle/local command");
@ -55,8 +56,6 @@ ComputeAngleLocal::ComputeAngleLocal(LAMMPS *lmp, int narg, char **arg) :
}
nmax = 0;
vector = NULL;
array = NULL;
}
/* ---------------------------------------------------------------------- */

View File

@ -26,7 +26,8 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
ComputeAngmomChunk::ComputeAngmomChunk(LAMMPS *lmp, int narg, char **arg) :
Compute(lmp, narg, arg)
Compute(lmp, narg, arg),
idchunk(NULL), massproc(NULL), masstotal(NULL), com(NULL), comall(NULL), angmom(NULL), angmomall(NULL)
{
if (narg != 4) error->all(FLERR,"Illegal compute angmom/chunk command");
@ -48,9 +49,6 @@ ComputeAngmomChunk::ComputeAngmomChunk(LAMMPS *lmp, int narg, char **arg) :
nchunk = 1;
maxchunk = 0;
massproc = masstotal = NULL;
com = comall = NULL;
angmom = angmomall = NULL;
allocate();
}

View File

@ -24,7 +24,8 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
ComputeBond::ComputeBond(LAMMPS *lmp, int narg, char **arg) :
Compute(lmp, narg, arg)
Compute(lmp, narg, arg),
emine(NULL)
{
if (narg != 3) error->all(FLERR,"Illegal compute bond command");

View File

@ -33,7 +33,8 @@ enum{DIST,ENG,FORCE};
/* ---------------------------------------------------------------------- */
ComputeBondLocal::ComputeBondLocal(LAMMPS *lmp, int narg, char **arg) :
Compute(lmp, narg, arg)
Compute(lmp, narg, arg),
bstyle(NULL), vector(NULL), array(NULL)
{
if (narg < 4) error->all(FLERR,"Illegal compute bond/local command");
@ -62,8 +63,6 @@ ComputeBondLocal::ComputeBondLocal(LAMMPS *lmp, int narg, char **arg) :
if (bstyle[i] != DIST) singleflag = 1;
nmax = 0;
vector = NULL;
array = NULL;
}
/* ---------------------------------------------------------------------- */

View File

@ -36,7 +36,8 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
ComputeCentroAtom::ComputeCentroAtom(LAMMPS *lmp, int narg, char **arg) :
Compute(lmp, narg, arg)
Compute(lmp, narg, arg),
distsq(NULL), nearest(NULL), centro(NULL)
{
if (narg < 4 || narg > 6) error->all(FLERR,"Illegal compute centro/atom command");
@ -69,11 +70,7 @@ ComputeCentroAtom::ComputeCentroAtom(LAMMPS *lmp, int narg, char **arg) :
else size_peratom_cols = 10;
nmax = 0;
centro = NULL;
maxneigh = 0;
distsq = NULL;
nearest = NULL;
array_atom = NULL;
}
/* ---------------------------------------------------------------------- */

View File

@ -56,7 +56,10 @@ ComputeChunkAtom *ComputeChunkAtom::cptr;
/* ---------------------------------------------------------------------- */
ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) :
Compute(lmp, narg, arg)
Compute(lmp, narg, arg),
id_fix(NULL), chunk(NULL), ichunk(NULL), exclude(NULL),
chunk_volume_vec(NULL), coord(NULL), chunkID(NULL), idregion(NULL), cfvid(NULL),
hash(NULL), varatom(NULL)
{
if (narg < 4) error->all(FLERR,"Illegal compute chunk/atom command");