From 02cd6e118b92b6bc7ff19a57e1811c41619b1722 Mon Sep 17 00:00:00 2001 From: sjplimp <sjplimp@f3b2605a-c512-4ea7-a41b-209d697bcdaa> Date: Wed, 18 Dec 2013 13:28:46 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@11125 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/atom.cpp | 11 ++++++++--- src/atom_vec.cpp | 9 +++++++++ src/atom_vec.h | 1 + 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/atom.cpp b/src/atom.cpp index 53300484d0..714449769c 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -288,7 +288,7 @@ void Atom::settings(Atom *old) /* ---------------------------------------------------------------------- create an AtomVec style - called from input script, restart file, replicate + called from lammps.cpp, input script, restart file, replicate ------------------------------------------------------------------------- */ void Atom::create_avec(const char *style, int narg, char **arg, char *suffix) @@ -308,13 +308,18 @@ void Atom::create_avec(const char *style, int narg, char **arg, char *suffix) vfrac_flag = spin_flag = eradius_flag = ervel_flag = erforce_flag = 0; // create instance of AtomVec - // use grow to initialize atom-based arrays to length 1 - // so that x[0][0] can be referenced even if proc has no atoms + // use grow() to initialize atom-based arrays to length 1 + // so that x[0][0] can always be referenced even if proc has no atoms + // but reset nmax = 0 + // so 2d arrays like bond_type will later be allocated correctly + // since currently, 2nd dimension bond_per_atom = 0 int sflag; avec = new_avec(style,suffix,sflag); avec->settings(narg,arg); avec->grow(1); + nmax = 0; + avec->reset(); if (sflag) { char estyle[256]; diff --git a/src/atom_vec.cpp b/src/atom_vec.cpp index 02b38db5cf..04964d5d1c 100644 --- a/src/atom_vec.cpp +++ b/src/atom_vec.cpp @@ -54,6 +54,15 @@ void AtomVec::init() error->all(FLERR,"USER-CUDA package requires a cuda enabled atom_style"); } +/* ---------------------------------------------------------------------- + reset nmax = 0, called by Atom::create_avec() when new atom style created +------------------------------------------------------------------------- */ + +void AtomVec::reset() +{ + nmax = 0; +} + /* ---------------------------------------------------------------------- unpack one line from Velocities section of data file ------------------------------------------------------------------------- */ diff --git a/src/atom_vec.h b/src/atom_vec.h index dca790b7fe..2731538a00 100644 --- a/src/atom_vec.h +++ b/src/atom_vec.h @@ -98,6 +98,7 @@ class AtomVec : protected Pointers { virtual void write_vel(FILE *, int, double **); virtual int write_vel_hybrid(FILE *, double *) {return 0;} + void reset(); int pack_bond(int **); void write_bond(FILE *, int, int **, int); int pack_angle(int **); -- GitLab