git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@11937 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp
2014-05-07 16:15:31 +00:00
parent 4ab16d5388
commit 4c9bba90f1
34 changed files with 146 additions and 215 deletions

View File

@ -24,8 +24,6 @@
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
#define DELTA 10000
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
AtomVecDipole::AtomVecDipole(LAMMPS *lmp) : AtomVec(lmp) AtomVecDipole::AtomVecDipole(LAMMPS *lmp) : AtomVec(lmp)
@ -48,13 +46,13 @@ AtomVecDipole::AtomVecDipole(LAMMPS *lmp) : AtomVec(lmp)
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
grow atom arrays grow atom arrays
n = 0 grows arrays by DELTA n = 0 grows arrays by a chunk
n > 0 allocates arrays to size n n > 0 allocates arrays to size n
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecDipole::grow(int n) void AtomVecDipole::grow(int n)
{ {
if (n == 0) nmax += DELTA; if (n == 0) grow_nmax();
else nmax = n; else nmax = n;
atom->nmax = nmax; atom->nmax = nmax;
if (nmax < 0 || nmax > MAXSMALLINT) if (nmax < 0 || nmax > MAXSMALLINT)

View File

@ -114,8 +114,8 @@ FixEfield::FixEfield(LAMMPS *lmp, int narg, char **arg) :
force_flag = 0; force_flag = 0;
fsum[0] = fsum[1] = fsum[2] = fsum[3] = 0.0; fsum[0] = fsum[1] = fsum[2] = fsum[3] = 0.0;
maxatom = 0; maxatom = atom->nmax;
efield = NULL; memory->create(efield,maxatom,4,"efield:efield");
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -332,24 +332,16 @@ void FixEfield::post_force(int vflag)
modify->clearstep_compute(); modify->clearstep_compute();
if (xstyle == EQUAL) ex = qe2f * input->variable->compute_equal(xvar); if (xstyle == EQUAL) ex = qe2f * input->variable->compute_equal(xvar);
else if (xstyle == ATOM) { else if (xstyle == ATOM)
if (efield) input->variable->compute_atom(xvar,igroup,&efield[0][0],3,0); input->variable->compute_atom(xvar,igroup,&efield[0][0],3,0);
else input->variable->compute_atom(xvar,igroup,NULL,3,0);
}
if (ystyle == EQUAL) ey = qe2f * input->variable->compute_equal(yvar); if (ystyle == EQUAL) ey = qe2f * input->variable->compute_equal(yvar);
else if (ystyle == ATOM) { else if (ystyle == ATOM)
if (efield) input->variable->compute_atom(yvar,igroup,&efield[0][1],3,0); input->variable->compute_atom(yvar,igroup,&efield[0][1],3,0);
else input->variable->compute_atom(yvar,igroup,NULL,3,0);
}
if (zstyle == EQUAL) ez = qe2f * input->variable->compute_equal(zvar); if (zstyle == EQUAL) ez = qe2f * input->variable->compute_equal(zvar);
else if (zstyle == ATOM) { else if (zstyle == ATOM)
if (efield) input->variable->compute_atom(zvar,igroup,&efield[0][2],3,0); input->variable->compute_atom(zvar,igroup,&efield[0][2],3,0);
else input->variable->compute_atom(zvar,igroup,NULL,3,0); if (estyle == ATOM)
} input->variable->compute_atom(evar,igroup,&efield[0][3],4,0);
if (estyle == ATOM) {
if (efield) input->variable->compute_atom(evar,igroup,&efield[0][3],4,0);
else input->variable->compute_atom(evar,igroup,NULL,4,0);
}
modify->addstep_compute(update->ntimestep + 1); modify->addstep_compute(update->ntimestep + 1);

View File

@ -23,8 +23,6 @@
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
#define DELTA 10000
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
AtomVecAngle::AtomVecAngle(LAMMPS *lmp) : AtomVec(lmp) AtomVecAngle::AtomVecAngle(LAMMPS *lmp) : AtomVec(lmp)
@ -47,13 +45,13 @@ AtomVecAngle::AtomVecAngle(LAMMPS *lmp) : AtomVec(lmp)
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
grow atom arrays grow atom arrays
n = 0 grows arrays by DELTA n = 0 grows arrays by a chunk
n > 0 allocates arrays to size n n > 0 allocates arrays to size n
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecAngle::grow(int n) void AtomVecAngle::grow(int n)
{ {
if (n == 0) nmax += DELTA; if (n == 0) grow_nmax();
else nmax = n; else nmax = n;
atom->nmax = nmax; atom->nmax = nmax;
if (nmax < 0 || nmax > MAXSMALLINT) if (nmax < 0 || nmax > MAXSMALLINT)

View File

@ -23,8 +23,6 @@
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
#define DELTA 10000
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
AtomVecBond::AtomVecBond(LAMMPS *lmp) : AtomVec(lmp) AtomVecBond::AtomVecBond(LAMMPS *lmp) : AtomVec(lmp)
@ -47,13 +45,13 @@ AtomVecBond::AtomVecBond(LAMMPS *lmp) : AtomVec(lmp)
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
grow atom arrays grow atom arrays
n = 0 grows arrays by DELTA n = 0 grows arrays by a chunk
n > 0 allocates arrays to size n n > 0 allocates arrays to size n
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecBond::grow(int n) void AtomVecBond::grow(int n)
{ {
if (n == 0) nmax += DELTA; if (n == 0) grow_nmax();
else nmax = n; else nmax = n;
atom->nmax = nmax; atom->nmax = nmax;
if (nmax < 0 || nmax > MAXSMALLINT) if (nmax < 0 || nmax > MAXSMALLINT)

View File

@ -23,8 +23,6 @@
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
#define DELTA 10000
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
AtomVecFull::AtomVecFull(LAMMPS *lmp) : AtomVec(lmp) AtomVecFull::AtomVecFull(LAMMPS *lmp) : AtomVec(lmp)
@ -47,13 +45,13 @@ AtomVecFull::AtomVecFull(LAMMPS *lmp) : AtomVec(lmp)
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
grow atom arrays grow atom arrays
n = 0 grows arrays by DELTA n = 0 grows arrays by a chunk
n > 0 allocates arrays to size n n > 0 allocates arrays to size n
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecFull::grow(int n) void AtomVecFull::grow(int n)
{ {
if (n == 0) nmax += DELTA; if (n == 0) grow_nmax();
else nmax = n; else nmax = n;
atom->nmax = nmax; atom->nmax = nmax;
if (nmax < 0 || nmax > MAXSMALLINT) if (nmax < 0 || nmax > MAXSMALLINT)

View File

@ -23,8 +23,6 @@
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
#define DELTA 10000
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
AtomVecMolecular::AtomVecMolecular(LAMMPS *lmp) : AtomVec(lmp) AtomVecMolecular::AtomVecMolecular(LAMMPS *lmp) : AtomVec(lmp)
@ -47,13 +45,13 @@ AtomVecMolecular::AtomVecMolecular(LAMMPS *lmp) : AtomVec(lmp)
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
grow atom arrays grow atom arrays
n = 0 grows arrays by DELTA n = 0 grows arrays by a chunk
n > 0 allocates arrays to size n n > 0 allocates arrays to size n
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecMolecular::grow(int n) void AtomVecMolecular::grow(int n)
{ {
if (n == 0) nmax += DELTA; if (n == 0) grow_nmax();
else nmax = n; else nmax = n;
atom->nmax = nmax; atom->nmax = nmax;
if (nmax < 0 || nmax > MAXSMALLINT) if (nmax < 0 || nmax > MAXSMALLINT)

View File

@ -25,8 +25,6 @@
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
#define DELTA 10000
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
AtomVecTemplate::AtomVecTemplate(LAMMPS *lmp) : AtomVec(lmp) AtomVecTemplate::AtomVecTemplate(LAMMPS *lmp) : AtomVec(lmp)
@ -90,13 +88,13 @@ void AtomVecTemplate::process_args(int narg, char **arg)
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
grow atom arrays grow atom arrays
n = 0 grows arrays by DELTA n = 0 grows arrays by a chunk
n > 0 allocates arrays to size n n > 0 allocates arrays to size n
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecTemplate::grow(int n) void AtomVecTemplate::grow(int n)
{ {
if (n == 0) nmax += DELTA; if (n == 0) grow_nmax();
else nmax = n; else nmax = n;
atom->nmax = nmax; atom->nmax = nmax;
if (nmax < 0 || nmax > MAXSMALLINT) if (nmax < 0 || nmax > MAXSMALLINT)

View File

@ -29,8 +29,6 @@
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
#define DELTA 10000
static const char cite_peri_package[] = static const char cite_peri_package[] =
"PERI package for Peridynamics:\n\n" "PERI package for Peridynamics:\n\n"
"@Article{Parks08,\n" "@Article{Parks08,\n"
@ -66,13 +64,13 @@ AtomVecPeri::AtomVecPeri(LAMMPS *lmp) : AtomVec(lmp)
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
grow atom arrays grow atom arrays
n = 0 grows arrays by DELTA n = 0 grows arrays by a chunk
n > 0 allocates arrays to size n n > 0 allocates arrays to size n
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecPeri::grow(int n) void AtomVecPeri::grow(int n)
{ {
if (n == 0) nmax += DELTA; if (n == 0) grow_nmax();
else nmax = n; else nmax = n;
atom->nmax = nmax; atom->nmax = nmax;
if (nmax < 0 || nmax > MAXSMALLINT) if (nmax < 0 || nmax > MAXSMALLINT)

View File

@ -29,8 +29,6 @@
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
#define DELTA 10000
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
AtomVecWavepacket::AtomVecWavepacket(LAMMPS *lmp) : AtomVec(lmp) AtomVecWavepacket::AtomVecWavepacket(LAMMPS *lmp) : AtomVec(lmp)
@ -58,13 +56,13 @@ AtomVecWavepacket::AtomVecWavepacket(LAMMPS *lmp) : AtomVec(lmp)
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
grow atom-electron arrays grow atom-electron arrays
n = 0 grows arrays by DELTA n = 0 grows arrays by a chunk
n > 0 allocates arrays to size n n > 0 allocates arrays to size n
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecWavepacket::grow(int n) void AtomVecWavepacket::grow(int n)
{ {
if (n == 0) nmax += DELTA; if (n == 0) grow_nmax();
else nmax = n; else nmax = n;
atom->nmax = nmax; atom->nmax = nmax;

View File

@ -52,7 +52,6 @@
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
#define DELTA 10000
#define BUFFACTOR 1.5 #define BUFFACTOR 1.5
#define BUFEXTRA 1000 #define BUFEXTRA 1000
#define NCUDAEXCHANGE 12 //nextra x y z vx vy vz tag type mask image molecule #define NCUDAEXCHANGE 12 //nextra x y z vx vy vz tag type mask image molecule

View File

@ -51,7 +51,6 @@
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
#define DELTA 10000
#define BUFFACTOR 1.5 #define BUFFACTOR 1.5
#define BUFEXTRA 1000 #define BUFEXTRA 1000
#define NCUDAEXCHANGE 11 //nextra x y z vx vy vz tag type mask image #define NCUDAEXCHANGE 11 //nextra x y z vx vy vz tag type mask image

View File

@ -51,7 +51,6 @@
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
#define DELTA 10000
#define BUFFACTOR 1.5 #define BUFFACTOR 1.5
#define BUFEXTRA 1000 #define BUFEXTRA 1000
#define NCUDAEXCHANGE 12 //nextra x y z vx vy vz tag type mask image q #define NCUDAEXCHANGE 12 //nextra x y z vx vy vz tag type mask image q

View File

@ -52,7 +52,6 @@
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
#define DELTA 10000
#define BUFFACTOR 1.5 #define BUFFACTOR 1.5
#define BUFEXTRA 1000 #define BUFEXTRA 1000
#define NCUDAEXCHANGE 13 //nextra x y z vx vy vz tag type mask image q molecule #define NCUDAEXCHANGE 13 //nextra x y z vx vy vz tag type mask image q molecule

View File

@ -30,8 +30,6 @@
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
#define DELTA 10000
static const char cite_user_eff_package[] = static const char cite_user_eff_package[] =
"USER-EFF package:\n\n" "USER-EFF package:\n\n"
"@Article{Jaramillo-Botero11,\n" "@Article{Jaramillo-Botero11,\n"
@ -71,13 +69,13 @@ AtomVecElectron::AtomVecElectron(LAMMPS *lmp) : AtomVec(lmp)
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
grow atom-electron arrays grow atom-electron arrays
n = 0 grows arrays by DELTA n = 0 grows arrays by a chunk
n > 0 allocates arrays to size n n > 0 allocates arrays to size n
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecElectron::grow(int n) void AtomVecElectron::grow(int n)
{ {
if (n == 0) nmax += DELTA; if (n == 0) grow_nmax();
else nmax = n; else nmax = n;
atom->nmax = nmax; atom->nmax = nmax;

View File

@ -23,8 +23,6 @@
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
#define DELTA 10000
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
AtomVecMeso::AtomVecMeso(LAMMPS *lmp) : AtomVec(lmp) AtomVecMeso::AtomVecMeso(LAMMPS *lmp) : AtomVec(lmp)
@ -50,15 +48,14 @@ AtomVecMeso::AtomVecMeso(LAMMPS *lmp) : AtomVec(lmp)
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
grow atom arrays grow atom arrays
n = 0 grows arrays by DELTA n = 0 grows arrays by a chunk
n > 0 allocates arrays to size n n > 0 allocates arrays to size n
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecMeso::grow(int n) { void AtomVecMeso::grow(int n)
if (n == 0) {
nmax += DELTA; if (n == 0) grow_nmax();
else else nmax = n;
nmax = n;
atom->nmax = nmax; atom->nmax = nmax;
if (nmax < 0 || nmax > MAXSMALLINT) if (nmax < 0 || nmax > MAXSMALLINT)
error->one(FLERR,"Per-processor system is too big"); error->one(FLERR,"Per-processor system is too big");

View File

@ -330,17 +330,12 @@ void Atom::create_avec(const char *style, int narg, char **arg, char *suffix)
// create instance of AtomVec // create instance of AtomVec
// use grow() to initialize atom-based arrays to length 1 // 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 // so that x[0][0] can always be referenced even if proc has no atoms
// but reset nmax = 0 in both Atom and AtomVec
// so 2d arrays like bond_type will later be allocated correctly
// since currently, 2nd dimension bond_per_atom = 0
int sflag; int sflag;
avec = new_avec(style,suffix,sflag); avec = new_avec(style,suffix,sflag);
avec->store_args(narg,arg); avec->store_args(narg,arg);
avec->process_args(narg,arg); avec->process_args(narg,arg);
avec->grow(1); avec->grow(1);
nmax = 0;
avec->reset();
if (sflag) { if (sflag) {
char estyle[256]; char estyle[256];
@ -640,6 +635,48 @@ int Atom::count_words(const char *line)
return n; return n;
} }
/* ----------------------------------------------------------------------
deallocate molecular topology arrays
done before realloc with (possibly) new 2nd dimension set to
correctly initialized per-atom values, e.g. bond_per_atom
needs to be called whenever 2nd dimensions are changed
and these arrays are already pre-allocated,
e.g. with 1st dimension of length 1 due to atom style creation
------------------------------------------------------------------------- */
void Atom::deallocate_topology()
{
memory->destroy(atom->bond_type);
memory->destroy(atom->bond_atom);
atom->bond_type = NULL;
atom->bond_atom = NULL;
memory->destroy(atom->angle_type);
memory->destroy(atom->angle_atom1);
memory->destroy(atom->angle_atom2);
memory->destroy(atom->angle_atom3);
atom->angle_type = NULL;
atom->angle_atom1 = atom->angle_atom2 = atom->angle_atom3 = NULL;
memory->destroy(atom->dihedral_type);
memory->destroy(atom->dihedral_atom1);
memory->destroy(atom->dihedral_atom2);
memory->destroy(atom->dihedral_atom3);
memory->destroy(atom->dihedral_atom4);
atom->dihedral_type = NULL;
atom->dihedral_atom1 = atom->dihedral_atom2 =
atom->dihedral_atom3 = atom->dihedral_atom4 = NULL;
memory->destroy(atom->improper_type);
memory->destroy(atom->improper_atom1);
memory->destroy(atom->improper_atom2);
memory->destroy(atom->improper_atom3);
memory->destroy(atom->improper_atom4);
atom->improper_type = NULL;
atom->improper_atom1 = atom->improper_atom2 =
atom->improper_atom3 = atom->improper_atom4 = NULL;
}
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
unpack n lines from Atom section of data file unpack n lines from Atom section of data file
call style-specific routine to parse line call style-specific routine to parse line

View File

@ -176,6 +176,8 @@ class Atom : protected Pointers {
int parse_data(const char *); int parse_data(const char *);
int count_words(const char *); int count_words(const char *);
void deallocate_topology();
void data_atoms(int, char *); void data_atoms(int, char *);
void data_vels(int, char *); void data_vels(int, char *);

View File

@ -21,6 +21,8 @@
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
#define DELTA 16384
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
AtomVec::AtomVec(LAMMPS *lmp) : Pointers(lmp) AtomVec::AtomVec(LAMMPS *lmp) : Pointers(lmp)
@ -82,12 +84,13 @@ void AtomVec::init()
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
reset nmax = 0, called by Atom::create_avec() when new atom style created grow nmax
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVec::reset() void AtomVec::grow_nmax()
{ {
nmax = 0; nmax = nmax/DELTA * DELTA;
nmax += DELTA;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View File

@ -103,7 +103,6 @@ class AtomVec : protected Pointers {
virtual void write_vel(FILE *, int, double **); virtual void write_vel(FILE *, int, double **);
virtual int write_vel_hybrid(FILE *, double *) {return 0;} virtual int write_vel_hybrid(FILE *, double *) {return 0;}
void reset();
int pack_bond(tagint **); int pack_bond(tagint **);
void write_bond(FILE *, int, tagint **, int); void write_bond(FILE *, int, tagint **, int);
int pack_angle(tagint **); int pack_angle(tagint **);
@ -139,6 +138,8 @@ class AtomVec : protected Pointers {
ubuf(int64_t arg) : i(arg) {} ubuf(int64_t arg) : i(arg) {}
ubuf(int arg) : i(arg) {} ubuf(int arg) : i(arg) {}
}; };
void grow_nmax();
}; };
} }

View File

@ -23,8 +23,6 @@
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
#define DELTA 10000
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
AtomVecAtomic::AtomVecAtomic(LAMMPS *lmp) : AtomVec(lmp) AtomVecAtomic::AtomVecAtomic(LAMMPS *lmp) : AtomVec(lmp)
@ -44,13 +42,13 @@ AtomVecAtomic::AtomVecAtomic(LAMMPS *lmp) : AtomVec(lmp)
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
grow atom arrays grow atom arrays
n = 0 grows arrays by DELTA n = 0 grows arrays by a chunk
n > 0 allocates arrays to size n n > 0 allocates arrays to size n
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecAtomic::grow(int n) void AtomVecAtomic::grow(int n)
{ {
if (n == 0) nmax += DELTA; if (n == 0) grow_nmax();
else nmax = n; else nmax = n;
atom->nmax = nmax; atom->nmax = nmax;
if (nmax < 0 || nmax > MAXSMALLINT) if (nmax < 0 || nmax > MAXSMALLINT)

View File

@ -28,8 +28,7 @@
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
#define DELTA 10000 #define DELTA_BONUS 8192
#define DELTA_BONUS 10000
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -111,13 +110,13 @@ void AtomVecBody::process_args(int narg, char **arg)
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
grow atom arrays grow atom arrays
n = 0 grows arrays by DELTA n = 0 grows arrays by a chunk
n > 0 allocates arrays to size n n > 0 allocates arrays to size n
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecBody::grow(int n) void AtomVecBody::grow(int n)
{ {
if (n == 0) nmax += DELTA; if (n == 0) grow_nmax();
else nmax = n; else nmax = n;
atom->nmax = nmax; atom->nmax = nmax;
if (nmax < 0 || nmax > MAXSMALLINT) if (nmax < 0 || nmax > MAXSMALLINT)

View File

@ -23,8 +23,6 @@
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
#define DELTA 10000
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
AtomVecCharge::AtomVecCharge(LAMMPS *lmp) : AtomVec(lmp) AtomVecCharge::AtomVecCharge(LAMMPS *lmp) : AtomVec(lmp)
@ -46,13 +44,13 @@ AtomVecCharge::AtomVecCharge(LAMMPS *lmp) : AtomVec(lmp)
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
grow atom arrays grow atom arrays
n = 0 grows arrays by DELTA n = 0 grows arrays by a chunk
n > 0 allocates arrays to size n n > 0 allocates arrays to size n
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecCharge::grow(int n) void AtomVecCharge::grow(int n)
{ {
if (n == 0) nmax += DELTA; if (n == 0) grow_nmax();
else nmax = n; else nmax = n;
atom->nmax = nmax; atom->nmax = nmax;
if (nmax < 0 || nmax > MAXSMALLINT) if (nmax < 0 || nmax > MAXSMALLINT)

View File

@ -31,8 +31,7 @@
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;
#define DELTA 10000 #define DELTA_BONUS 8192
#define DELTA_BONUS 10000
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -66,13 +65,13 @@ AtomVecEllipsoid::~AtomVecEllipsoid()
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
grow atom arrays grow atom arrays
n = 0 grows arrays by DELTA n = 0 grows arrays by a chunk
n > 0 allocates arrays to size n n > 0 allocates arrays to size n
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecEllipsoid::grow(int n) void AtomVecEllipsoid::grow(int n)
{ {
if (n == 0) nmax += DELTA; if (n == 0) grow_nmax();
else nmax = n; else nmax = n;
atom->nmax = nmax; atom->nmax = nmax;
if (nmax < 0 || nmax > MAXSMALLINT) if (nmax < 0 || nmax > MAXSMALLINT)

View File

@ -23,8 +23,6 @@
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
#define DELTA 10000
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
AtomVecHybrid::AtomVecHybrid(LAMMPS *lmp) : AtomVec(lmp) {} AtomVecHybrid::AtomVecHybrid(LAMMPS *lmp) : AtomVec(lmp) {}
@ -134,13 +132,13 @@ void AtomVecHybrid::init()
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
grow atom arrays grow atom arrays
n = 0 grows arrays by DELTA n = 0 grows arrays by a chunk
n > 0 allocates arrays to size n n > 0 allocates arrays to size n
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecHybrid::grow(int n) void AtomVecHybrid::grow(int n)
{ {
if (n == 0) nmax += DELTA; if (n == 0) grow_nmax();
else nmax = n; else nmax = n;
atom->nmax = nmax; atom->nmax = nmax;
if (nmax < 0 || nmax > MAXSMALLINT) if (nmax < 0 || nmax > MAXSMALLINT)

View File

@ -26,7 +26,6 @@
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
#define DELTA 10000
#define DELTA_BONUS 10000 #define DELTA_BONUS 10000
#define EPSILON 0.001 #define EPSILON 0.001
@ -73,13 +72,13 @@ void AtomVecLine::init()
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
grow atom arrays grow atom arrays
n = 0 grows arrays by DELTA n = 0 grows arrays by a chunk
n > 0 allocates arrays to size n n > 0 allocates arrays to size n
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecLine::grow(int n) void AtomVecLine::grow(int n)
{ {
if (n == 0) nmax += DELTA; if (n == 0) grow_nmax();
else nmax = n; else nmax = n;
atom->nmax = nmax; atom->nmax = nmax;
if (nmax < 0 || nmax > MAXSMALLINT) if (nmax < 0 || nmax > MAXSMALLINT)

View File

@ -29,8 +29,6 @@
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;
#define DELTA 10000
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
AtomVecSphere::AtomVecSphere(LAMMPS *lmp) : AtomVec(lmp) AtomVecSphere::AtomVecSphere(LAMMPS *lmp) : AtomVec(lmp)
@ -77,13 +75,13 @@ void AtomVecSphere::init()
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
grow atom arrays grow atom arrays
n = 0 grows arrays by DELTA n = 0 grows arrays by a chunk
n > 0 allocates arrays to size n n > 0 allocates arrays to size n
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecSphere::grow(int n) void AtomVecSphere::grow(int n)
{ {
if (n == 0) nmax += DELTA; if (n == 0) grow_nmax();
else nmax = n; else nmax = n;
atom->nmax = nmax; atom->nmax = nmax;
if (nmax < 0 || nmax > MAXSMALLINT) if (nmax < 0 || nmax > MAXSMALLINT)

View File

@ -27,7 +27,6 @@
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
#define DELTA 10000
#define DELTA_BONUS 10000 #define DELTA_BONUS 10000
#define EPSILON 0.001 #define EPSILON 0.001
@ -74,13 +73,13 @@ void AtomVecTri::init()
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
grow atom arrays grow atom arrays
n = 0 grows arrays by DELTA n = 0 grows arrays by a chunk
n > 0 allocates arrays to size n n > 0 allocates arrays to size n
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecTri::grow(int n) void AtomVecTri::grow(int n)
{ {
if (n == 0) nmax += DELTA; if (n == 0) grow_nmax();
else nmax = n; else nmax = n;
atom->nmax = nmax; atom->nmax = nmax;
if (nmax < 0 || nmax > MAXSMALLINT) if (nmax < 0 || nmax > MAXSMALLINT)

View File

@ -164,11 +164,14 @@ void CreateBox::command(int narg, char **arg)
} }
// problem setup using info from header // problem setup using info from header
// no call to atom->grow since create_atoms or fixes will do it // deallocate/grow insures any extra settings are used for topology arrays
// necessary in case no create_atoms is performed
update->ntimestep = 0; update->ntimestep = 0;
atom->allocate_type_arrays(); atom->allocate_type_arrays();
atom->deallocate_topology();
atom->avec->grow(atom->nmax);
domain->print_box("Created "); domain->print_box("Created ");
domain->set_initial_box(); domain->set_initial_box();

View File

@ -104,8 +104,8 @@ FixAddForce::FixAddForce(LAMMPS *lmp, int narg, char **arg) :
force_flag = 0; force_flag = 0;
foriginal[0] = foriginal[1] = foriginal[2] = foriginal[3] = 0.0; foriginal[0] = foriginal[1] = foriginal[2] = foriginal[3] = 0.0;
maxatom = 0; maxatom = atom->nmax;
sforce = NULL; memory->create(sforce,maxatom,4,"addforce:sforce");
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -274,24 +274,16 @@ void FixAddForce::post_force(int vflag)
modify->clearstep_compute(); modify->clearstep_compute();
if (xstyle == EQUAL) xvalue = input->variable->compute_equal(xvar); if (xstyle == EQUAL) xvalue = input->variable->compute_equal(xvar);
else if (xstyle == ATOM) { else if (xstyle == ATOM)
if (sforce) input->variable->compute_atom(xvar,igroup,&sforce[0][0],4,0); input->variable->compute_atom(xvar,igroup,&sforce[0][0],4,0);
else input->variable->compute_atom(xvar,igroup,NULL,4,0);
}
if (ystyle == EQUAL) yvalue = input->variable->compute_equal(yvar); if (ystyle == EQUAL) yvalue = input->variable->compute_equal(yvar);
else if (ystyle == ATOM) { else if (ystyle == ATOM)
if (sforce) input->variable->compute_atom(yvar,igroup,&sforce[0][1],4,0); input->variable->compute_atom(yvar,igroup,&sforce[0][1],4,0);
else input->variable->compute_atom(yvar,igroup,NULL,4,0);
}
if (zstyle == EQUAL) zvalue = input->variable->compute_equal(zvar); if (zstyle == EQUAL) zvalue = input->variable->compute_equal(zvar);
else if (zstyle == ATOM) { else if (zstyle == ATOM)
if (sforce) input->variable->compute_atom(zvar,igroup,&sforce[0][2],4,0); input->variable->compute_atom(zvar,igroup,&sforce[0][2],4,0);
else input->variable->compute_atom(zvar,igroup,NULL,4,0); if (estyle == ATOM)
} input->variable->compute_atom(evar,igroup,&sforce[0][3],4,0);
if (estyle == ATOM) {
if (sforce) input->variable->compute_atom(evar,igroup,&sforce[0][3],4,0);
else input->variable->compute_atom(evar,igroup,NULL,4,0);
}
modify->addstep_compute(update->ntimestep + 1); modify->addstep_compute(update->ntimestep + 1);

View File

@ -242,8 +242,9 @@ FixMove::FixMove(LAMMPS *lmp, int narg, char **arg) :
atom->add_callback(0); atom->add_callback(0);
atom->add_callback(1); atom->add_callback(1);
maxatom = 0; maxatom = atom->nmax;
displace = velocity = NULL; if (displaceflag) memory->create(displace,maxatom,3,"move:displace");
if (velocityflag) memory->create(velocity,maxatom,3,"move:velocity");
// xoriginal = initial unwrapped positions of atoms // xoriginal = initial unwrapped positions of atoms
@ -581,45 +582,27 @@ void FixMove::initial_integrate(int vflag)
if (xvarstr) { if (xvarstr) {
if (xvarstyle == EQUAL) dx = input->variable->compute_equal(xvar); if (xvarstyle == EQUAL) dx = input->variable->compute_equal(xvar);
else if (displace) else input->variable->compute_atom(xvar,igroup,&displace[0][0],3,0);
input->variable->compute_atom(xvar,igroup,&displace[0][0],3,0);
else
input->variable->compute_atom(xvar,igroup,NULL,3,0);
} }
if (yvarstr) { if (yvarstr) {
if (yvarstyle == EQUAL) dy = input->variable->compute_equal(yvar); if (yvarstyle == EQUAL) dy = input->variable->compute_equal(yvar);
else if (displace) else input->variable->compute_atom(yvar,igroup,&displace[0][1],3,0);
input->variable->compute_atom(yvar,igroup,&displace[0][1],3,0);
else
input->variable->compute_atom(yvar,igroup,NULL,3,0);
} }
if (zvarstr) { if (zvarstr) {
if (zvarstyle == EQUAL) dz = input->variable->compute_equal(zvar); if (zvarstyle == EQUAL) dz = input->variable->compute_equal(zvar);
else if (displace) else input->variable->compute_atom(zvar,igroup,&displace[0][2],3,0);
input->variable->compute_atom(zvar,igroup,&displace[0][2],3,0);
else
input->variable->compute_atom(zvar,igroup,NULL,3,0);
} }
if (vxvarstr) { if (vxvarstr) {
if (vxvarstyle == EQUAL) vx = input->variable->compute_equal(vxvar); if (vxvarstyle == EQUAL) vx = input->variable->compute_equal(vxvar);
else if (velocity) else input->variable->compute_atom(vxvar,igroup,&velocity[0][0],3,0);
input->variable->compute_atom(vxvar,igroup,&velocity[0][0],3,0);
else
input->variable->compute_atom(vxvar,igroup,NULL,3,0);
} }
if (vyvarstr) { if (vyvarstr) {
if (vyvarstyle == EQUAL) vy = input->variable->compute_equal(vyvar); if (vyvarstyle == EQUAL) vy = input->variable->compute_equal(vyvar);
else if (velocity) else input->variable->compute_atom(vyvar,igroup,&velocity[0][1],3,0);
input->variable->compute_atom(vyvar,igroup,&velocity[0][1],3,0);
else
input->variable->compute_atom(vyvar,igroup,NULL,3,0);
} }
if (vzvarstr) { if (vzvarstr) {
if (vzvarstyle == EQUAL) vz = input->variable->compute_equal(vzvar); if (vzvarstyle == EQUAL) vz = input->variable->compute_equal(vzvar);
else if (velocity) else input->variable->compute_atom(vzvar,igroup,&velocity[0][2],3,0);
input->variable->compute_atom(vzvar,igroup,&velocity[0][2],3,0);
else
input->variable->compute_atom(vzvar,igroup,NULL,3,0);
} }
modify->addstep_compute(update->ntimestep + 1); modify->addstep_compute(update->ntimestep + 1);

View File

@ -99,8 +99,8 @@ FixSetForce::FixSetForce(LAMMPS *lmp, int narg, char **arg) :
force_flag = 0; force_flag = 0;
foriginal[0] = foriginal[1] = foriginal[2] = 0.0; foriginal[0] = foriginal[1] = foriginal[2] = 0.0;
maxatom = 0; maxatom = atom->nmax;
sforce = NULL; memory->create(sforce,maxatom,3,"setforce:sforce");
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -257,20 +257,14 @@ void FixSetForce::post_force(int vflag)
modify->clearstep_compute(); modify->clearstep_compute();
if (xstyle == EQUAL) xvalue = input->variable->compute_equal(xvar); if (xstyle == EQUAL) xvalue = input->variable->compute_equal(xvar);
else if (xstyle == ATOM) { else if (xstyle == ATOM)
if (sforce) input->variable->compute_atom(xvar,igroup,&sforce[0][0],3,0); input->variable->compute_atom(xvar,igroup,&sforce[0][0],3,0);
else input->variable->compute_atom(xvar,igroup,NULL,3,0);
}
if (ystyle == EQUAL) yvalue = input->variable->compute_equal(yvar); if (ystyle == EQUAL) yvalue = input->variable->compute_equal(yvar);
else if (ystyle == ATOM) { else if (ystyle == ATOM)
if (sforce) input->variable->compute_atom(yvar,igroup,&sforce[0][1],3,0); input->variable->compute_atom(yvar,igroup,&sforce[0][1],3,0);
else input->variable->compute_atom(yvar,igroup,NULL,3,0);
}
if (zstyle == EQUAL) zvalue = input->variable->compute_equal(zvar); if (zstyle == EQUAL) zvalue = input->variable->compute_equal(zvar);
else if (zstyle == ATOM) { else if (zstyle == ATOM)
if (sforce) input->variable->compute_atom(zvar,igroup,&sforce[0][2],3,0); input->variable->compute_atom(zvar,igroup,&sforce[0][2],3,0);
else input->variable->compute_atom(zvar,igroup,NULL,3,0);
}
modify->addstep_compute(update->ntimestep + 1); modify->addstep_compute(update->ntimestep + 1);

View File

@ -304,7 +304,6 @@ FixStoreState::FixStoreState(LAMMPS *lmp, int narg, char **arg) :
// perform initial allocation of atom-based array // perform initial allocation of atom-based array
// register with Atom class // register with Atom class
values = NULL;
grow_arrays(atom->nmax); grow_arrays(atom->nmax);
atom->add_callback(0); atom->add_callback(0);
atom->add_callback(1); atom->add_callback(1);
@ -467,11 +466,9 @@ void FixStoreState::end_of_step()
// evaluate atom-style variable // evaluate atom-style variable
} else if (which[m] == VARIABLE) } else if (which[m] == VARIABLE) {
if (values) input->variable->compute_atom(n,igroup,&values[0][m],nvalues,0);
input->variable->compute_atom(n,igroup,&values[0][m],nvalues,0); }
else
input->variable->compute_atom(n,igroup,NULL,nvalues,0);
} }
} }

View File

@ -206,9 +206,9 @@ void ReadData::command(int narg, char **arg)
domain->box_exist = 1; domain->box_exist = 1;
update->ntimestep = 0; update->ntimestep = 0;
// insure extra settings are applied before grow(), // apply extra settings before grow(), even if no topology in file
// even if no topology in file // deallocate() insures new settings are used for topology arrays
// if topology is in file, realloc and another grow() is done below // if per-atom topology is in file, another grow() is done below
atom->bond_per_atom = atom->extra_bond_per_atom; atom->bond_per_atom = atom->extra_bond_per_atom;
atom->angle_per_atom = atom->extra_angle_per_atom; atom->angle_per_atom = atom->extra_angle_per_atom;
@ -220,6 +220,7 @@ void ReadData::command(int narg, char **arg)
else n = static_cast<int> (LB_FACTOR * atom->natoms / comm->nprocs); else n = static_cast<int> (LB_FACTOR * atom->natoms / comm->nprocs);
atom->allocate_type_arrays(); atom->allocate_type_arrays();
atom->deallocate_topology();
atom->avec->grow(n); atom->avec->grow(n);
domain->print_box(" "); domain->print_box(" ");
@ -497,49 +498,11 @@ void ReadData::command(int narg, char **arg)
firstpass = 0; firstpass = 0;
// reallocate bond,angle,diehdral,improper arrays via grow() // reallocate bond,angle,diehdral,improper arrays via grow()
// use new bond,angle,dihedral,improper per-atom values from 1st pass // will use new bond,angle,dihedral,improper per-atom values from 1st pass
// should leave other atom arrays unchanged, since already nmax in length // will also observe extra settings even if bond/etc topology not in file
// if bonds/etc not in data file, initialize per-atom size // leaves other atom arrays unchanged, since already nmax in length
// with extra settings before grow() of these topology arrays
if (bondflag) {
memory->destroy(atom->bond_type);
memory->destroy(atom->bond_atom);
atom->bond_type = NULL;
atom->bond_atom = NULL;
}
if (angleflag) {
memory->destroy(atom->angle_type);
memory->destroy(atom->angle_atom1);
memory->destroy(atom->angle_atom2);
memory->destroy(atom->angle_atom3);
atom->angle_type = NULL;
atom->angle_atom1 = atom->angle_atom2 = atom->angle_atom3 = NULL;
}
if (dihedralflag) {
memory->destroy(atom->dihedral_type);
memory->destroy(atom->dihedral_atom1);
memory->destroy(atom->dihedral_atom2);
memory->destroy(atom->dihedral_atom3);
memory->destroy(atom->dihedral_atom4);
atom->dihedral_type = NULL;
atom->dihedral_atom1 = atom->dihedral_atom2 =
atom->dihedral_atom3 = atom->dihedral_atom4 = NULL;
}
if (improperflag) {
memory->destroy(atom->improper_type);
memory->destroy(atom->improper_atom1);
memory->destroy(atom->improper_atom2);
memory->destroy(atom->improper_atom3);
memory->destroy(atom->improper_atom4);
atom->improper_type = NULL;
atom->improper_atom1 = atom->improper_atom2 =
atom->improper_atom3 = atom->improper_atom4 = NULL;
}
atom->deallocate_topology();
atom->avec->grow(atom->nmax); atom->avec->grow(atom->nmax);
} }

View File

@ -151,6 +151,7 @@ void ReadRestart::command(int narg, char **arg)
else n = static_cast<int> (LB_FACTOR * atom->natoms / nprocs); else n = static_cast<int> (LB_FACTOR * atom->natoms / nprocs);
atom->allocate_type_arrays(); atom->allocate_type_arrays();
atom->deallocate_topology();
atom->avec->grow(n); atom->avec->grow(n);
n = atom->nmax; n = atom->nmax;