From 53db68362ec18d4e91d53a21c722d352161b9c91 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Wed, 7 May 2014 14:30:27 +0000 Subject: [PATCH 01/10] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@11935 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/ASPHERE/compute_temp_asphere.cpp | 7 +++---- src/USER-EFF/compute_temp_eff.cpp | 7 ++----- src/USER-MISC/compute_temp_rotate.cpp | 7 ++----- src/atom.cpp | 2 +- src/compute.cpp | 13 +++++++++++++ src/compute.h | 2 ++ src/compute_temp.cpp | 5 ++--- src/compute_temp.h | 1 - src/compute_temp_com.cpp | 7 ++----- src/compute_temp_deform.cpp | 5 ++--- src/compute_temp_partial.cpp | 7 ++----- src/compute_temp_profile.cpp | 9 +++------ src/compute_temp_ramp.cpp | 5 ++--- src/compute_temp_region.cpp | 1 - src/compute_temp_sphere.cpp | 7 +++---- src/modify.cpp | 2 +- 16 files changed, 40 insertions(+), 47 deletions(-) diff --git a/src/ASPHERE/compute_temp_asphere.cpp b/src/ASPHERE/compute_temp_asphere.cpp index 05b2819a97..12bc17852f 100755 --- a/src/ASPHERE/compute_temp_asphere.cpp +++ b/src/ASPHERE/compute_temp_asphere.cpp @@ -25,7 +25,6 @@ #include "force.h" #include "domain.h" #include "modify.h" -#include "fix.h" #include "group.h" #include "memory.h" #include "error.h" @@ -128,9 +127,7 @@ void ComputeTempAsphere::init() void ComputeTempAsphere::setup() { - fix_dof = 0; - for (int i = 0; i < modify->nfix; i++) - fix_dof += modify->fix[i]->dof(igroup); + fix_dof = -1; dof_compute(); } @@ -138,6 +135,8 @@ void ComputeTempAsphere::setup() void ComputeTempAsphere::dof_compute() { + if (fix_dof) adjust_dof_fix(); + // 6 dof for 3d, 3 dof for 2d // which dof are included also depends on mode // assume full rotation of extended particles diff --git a/src/USER-EFF/compute_temp_eff.cpp b/src/USER-EFF/compute_temp_eff.cpp index 035f6aa90d..9b06f05a24 100644 --- a/src/USER-EFF/compute_temp_eff.cpp +++ b/src/USER-EFF/compute_temp_eff.cpp @@ -23,8 +23,6 @@ #include "update.h" #include "force.h" #include "domain.h" -#include "modify.h" -#include "fix.h" #include "group.h" #include "error.h" @@ -58,9 +56,7 @@ ComputeTempEff::~ComputeTempEff() void ComputeTempEff::setup() { - fix_dof = 0; - for (int i = 0; i < modify->nfix; i++) - fix_dof += modify->fix[i]->dof(igroup); + fix_dof = -1; dof_compute(); } @@ -68,6 +64,7 @@ void ComputeTempEff::setup() void ComputeTempEff::dof_compute() { + if (fix_dof) adjust_dof_fix(); double natoms = group->count(igroup); dof = domain->dimension * natoms; dof -= extra_dof + fix_dof; diff --git a/src/USER-MISC/compute_temp_rotate.cpp b/src/USER-MISC/compute_temp_rotate.cpp index fa0567ac84..b34255be53 100644 --- a/src/USER-MISC/compute_temp_rotate.cpp +++ b/src/USER-MISC/compute_temp_rotate.cpp @@ -23,8 +23,6 @@ #include "update.h" #include "force.h" #include "group.h" -#include "modify.h" -#include "fix.h" #include "domain.h" #include "lattice.h" #include "error.h" @@ -70,9 +68,7 @@ void ComputeTempRotate::init() void ComputeTempRotate::setup() { - fix_dof = 0; - for (int i = 0; i < modify->nfix; i++) - fix_dof += modify->fix[i]->dof(igroup); + fix_dof = -1; dof_compute(); } @@ -80,6 +76,7 @@ void ComputeTempRotate::setup() void ComputeTempRotate::dof_compute() { + if (fix_dof) adjust_dof_fix(); double natoms = group->count(igroup); int nper = domain->dimension; dof = nper * natoms; diff --git a/src/atom.cpp b/src/atom.cpp index 723fedc736..dc6d2e2fa1 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -330,7 +330,7 @@ void Atom::create_avec(const char *style, int narg, char **arg, char *suffix) // create instance of AtomVec // 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 + // 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 diff --git a/src/compute.cpp b/src/compute.cpp index 9367983656..fde11f6c7f 100644 --- a/src/compute.cpp +++ b/src/compute.cpp @@ -21,6 +21,8 @@ #include "domain.h" #include "comm.h" #include "group.h" +#include "modify.h" +#include "fix.h" #include "atom_masks.h" #include "memory.h" #include "error.h" @@ -131,6 +133,17 @@ void Compute::modify_params(int narg, char **arg) } } +/* ---------------------------------------------------------------------- + calculate adjustment in DOF due to fixes +------------------------------------------------------------------------- */ + +void Compute::adjust_dof_fix() +{ + fix_dof = 0; + for (int i = 0; i < modify->nfix; i++) + fix_dof += modify->fix[i]->dof(igroup); +} + /* ---------------------------------------------------------------------- reset extra_dof to its default value ------------------------------------------------------------------------- */ diff --git a/src/compute.h b/src/compute.h index ee0b9e36a6..4a678eef65 100644 --- a/src/compute.h +++ b/src/compute.h @@ -86,6 +86,7 @@ class Compute : protected Pointers { Compute(class LAMMPS *, int, char **); virtual ~Compute(); void modify_params(int, char **); + void adjust_dof_fix(); void reset_extra_dof(); virtual void init() = 0; @@ -122,6 +123,7 @@ class Compute : protected Pointers { protected: int extra_dof; // extra DOF for temperature computes + int fix_dof; // DOF due to fixes int dynamic; // recount atoms for temperature computes int thermoflag; // 1 if include fix PE for PE computes diff --git a/src/compute_temp.cpp b/src/compute_temp.cpp index f58c2fadf0..e2d93e357b 100644 --- a/src/compute_temp.cpp +++ b/src/compute_temp.cpp @@ -52,9 +52,7 @@ ComputeTemp::~ComputeTemp() void ComputeTemp::setup() { - fix_dof = 0; - for (int i = 0; i < modify->nfix; i++) - fix_dof += modify->fix[i]->dof(igroup); + fix_dof = -1; dof_compute(); } @@ -62,6 +60,7 @@ void ComputeTemp::setup() void ComputeTemp::dof_compute() { + if (fix_dof) adjust_dof_fix(); double natoms = group->count(igroup); dof = domain->dimension * natoms; dof -= extra_dof + fix_dof; diff --git a/src/compute_temp.h b/src/compute_temp.h index ccd35f119a..055c4929fc 100644 --- a/src/compute_temp.h +++ b/src/compute_temp.h @@ -34,7 +34,6 @@ class ComputeTemp : public Compute { void compute_vector(); protected: - int fix_dof; double tfactor; virtual void dof_compute(); diff --git a/src/compute_temp_com.cpp b/src/compute_temp_com.cpp index 2d2537f11e..0c94d2a416 100644 --- a/src/compute_temp_com.cpp +++ b/src/compute_temp_com.cpp @@ -19,8 +19,6 @@ #include "update.h" #include "force.h" #include "group.h" -#include "modify.h" -#include "fix.h" #include "domain.h" #include "lattice.h" #include "error.h" @@ -62,9 +60,7 @@ void ComputeTempCOM::init() void ComputeTempCOM::setup() { - fix_dof = 0; - for (int i = 0; i < modify->nfix; i++) - fix_dof += modify->fix[i]->dof(igroup); + fix_dof = -1; dof_compute(); } @@ -72,6 +68,7 @@ void ComputeTempCOM::setup() void ComputeTempCOM::dof_compute() { + if (fix_dof) adjust_dof_fix(); double natoms = group->count(igroup); int nper = domain->dimension; dof = nper * natoms; diff --git a/src/compute_temp_deform.cpp b/src/compute_temp_deform.cpp index 536bdfbb9a..7c72e08f3b 100644 --- a/src/compute_temp_deform.cpp +++ b/src/compute_temp_deform.cpp @@ -86,9 +86,7 @@ void ComputeTempDeform::init() void ComputeTempDeform::setup() { - fix_dof = 0; - for (int i = 0; i < modify->nfix; i++) - fix_dof += modify->fix[i]->dof(igroup); + fix_dof = -1; dof_compute(); } @@ -96,6 +94,7 @@ void ComputeTempDeform::setup() void ComputeTempDeform::dof_compute() { + if (fix_dof) adjust_dof_fix(); double natoms = group->count(igroup); dof = domain->dimension * natoms; dof -= extra_dof + fix_dof; diff --git a/src/compute_temp_partial.cpp b/src/compute_temp_partial.cpp index 99181a56b1..baa316e847 100644 --- a/src/compute_temp_partial.cpp +++ b/src/compute_temp_partial.cpp @@ -18,8 +18,6 @@ #include "update.h" #include "force.h" #include "domain.h" -#include "modify.h" -#include "fix.h" #include "group.h" #include "memory.h" #include "error.h" @@ -63,9 +61,7 @@ ComputeTempPartial::~ComputeTempPartial() void ComputeTempPartial::setup() { - fix_dof = 0; - for (int i = 0; i < modify->nfix; i++) - fix_dof += modify->fix[i]->dof(igroup); + fix_dof = -1; dof_compute(); } @@ -76,6 +72,7 @@ void ComputeTempPartial::setup() void ComputeTempPartial::dof_compute() { + if (fix_dof) adjust_dof_fix(); double natoms = group->count(igroup); int nper = xflag+yflag+zflag; dof = nper * natoms; diff --git a/src/compute_temp_profile.cpp b/src/compute_temp_profile.cpp index fd759ed773..268162a463 100644 --- a/src/compute_temp_profile.cpp +++ b/src/compute_temp_profile.cpp @@ -161,9 +161,7 @@ ComputeTempProfile::~ComputeTempProfile() void ComputeTempProfile::init() { - fix_dof = 0; - for (int i = 0; i < modify->nfix; i++) - fix_dof += modify->fix[i]->dof(igroup); + fix_dof = -1; dof_compute(); // ptrs to domain data @@ -189,9 +187,7 @@ void ComputeTempProfile::init() void ComputeTempProfile::setup() { - fix_dof = 0; - for (int i = 0; i < modify->nfix; i++) - fix_dof += modify->fix[i]->dof(igroup); + fix_dof = -1; dof_compute(); } @@ -199,6 +195,7 @@ void ComputeTempProfile::setup() void ComputeTempProfile::dof_compute() { + if (fix_dof) adjust_dof_fix(); double natoms = group->count(igroup); int nper = domain->dimension; dof = nper * natoms; diff --git a/src/compute_temp_ramp.cpp b/src/compute_temp_ramp.cpp index f2636b1adc..288bc30abe 100644 --- a/src/compute_temp_ramp.cpp +++ b/src/compute_temp_ramp.cpp @@ -117,9 +117,7 @@ ComputeTempRamp::~ComputeTempRamp() void ComputeTempRamp::setup() { - fix_dof = 0; - for (int i = 0; i < modify->nfix; i++) - fix_dof += modify->fix[i]->dof(igroup); + fix_dof = -1; dof_compute(); } @@ -127,6 +125,7 @@ void ComputeTempRamp::setup() void ComputeTempRamp::dof_compute() { + if (fix_dof) adjust_dof_fix(); double natoms = group->count(igroup); int nper = domain->dimension; dof = nper * natoms; diff --git a/src/compute_temp_region.cpp b/src/compute_temp_region.cpp index 833ed0d5c3..bcd5864783 100644 --- a/src/compute_temp_region.cpp +++ b/src/compute_temp_region.cpp @@ -17,7 +17,6 @@ #include "atom.h" #include "update.h" #include "force.h" -#include "modify.h" #include "domain.h" #include "region.h" #include "memory.h" diff --git a/src/compute_temp_sphere.cpp b/src/compute_temp_sphere.cpp index 1c967f2a21..8ba73f3c54 100644 --- a/src/compute_temp_sphere.cpp +++ b/src/compute_temp_sphere.cpp @@ -20,7 +20,6 @@ #include "force.h" #include "domain.h" #include "modify.h" -#include "fix.h" #include "group.h" #include "error.h" @@ -109,9 +108,7 @@ void ComputeTempSphere::init() void ComputeTempSphere::setup() { - fix_dof = 0; - for (int i = 0; i < modify->nfix; i++) - fix_dof += modify->fix[i]->dof(igroup); + fix_dof = -1; dof_compute(); } @@ -121,6 +118,8 @@ void ComputeTempSphere::dof_compute() { int count,count_all; + if (fix_dof) adjust_dof_fix(); + // 6 or 3 dof for extended/point particles for 3d // 3 or 2 dof for extended/point particles for 2d // which dof are included also depends on mode diff --git a/src/modify.cpp b/src/modify.cpp index c454ff928c..8a193253f2 100644 --- a/src/modify.cpp +++ b/src/modify.cpp @@ -271,7 +271,7 @@ void Modify::init() void Modify::setup(int vflag) { // compute setup needs to come before fix setup - // b/c NH fixes need use DOF of temperature computes + // b/c NH fixes need DOF of temperature computes for (int i = 0; i < ncompute; i++) compute[i]->setup(); From 4ab16d538868f64858b33a3a34c5557f7a4e0655 Mon Sep 17 00:00:00 2001 From: athomps Date: Wed, 7 May 2014 16:05:35 +0000 Subject: [PATCH 02/10] Added viscosity estimate from diagonal shear stress git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@11936 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- examples/VISCOSITY/in.gk.2d | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/examples/VISCOSITY/in.gk.2d b/examples/VISCOSITY/in.gk.2d index 1438be5341..09fdef0a42 100644 --- a/examples/VISCOSITY/in.gk.2d +++ b/examples/VISCOSITY/in.gk.2d @@ -49,17 +49,28 @@ unfix 2 reset_timestep 0 +# Define distinct components of symmetric traceless stress tensor + variable pxy equal pxy +variable pxx equal pxx-press fix SS all ave/correlate $s $p $d & - v_pxy type auto file profile.gk.2d ave running + v_pxy v_pxx type auto file profile.gk.2d ave running + +# Diagonal components of SS are larger by factor 2-2/d, +# which is 4/3 for d=3, but 1 for d=2. +# See Daivis and Evans, J.Chem.Phys, 100, 541-547 (1994) variable scale equal 1.0/$t*vol*$s*dt -variable v11 equal trap(f_SS[3])*${scale} +variable diagfac equal 2-2/2 +variable vxy equal trap(f_SS[3])*${scale} +variable vxx equal trap(f_SS[4])*${scale}/${diagfac} -thermo_style custom step temp press pxy v_v11 +thermo_style custom step temp press pxy v_vxy v_vxx run 500000 -variable eta equal v_v11 +variable etaxy equal v_vxy +variable etaxx equal v_vxx +variable eta equal 0.5*(${etaxy}+${etaxx}) print "running average viscosity: ${eta}" From 4c9bba90f109728171dff52ba077062e9887368b Mon Sep 17 00:00:00 2001 From: sjplimp Date: Wed, 7 May 2014 16:15:31 +0000 Subject: [PATCH 03/10] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@11937 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/DIPOLE/atom_vec_dipole.cpp | 6 +-- src/MISC/fix_efield.cpp | 28 +++++--------- src/MOLECULE/atom_vec_angle.cpp | 6 +-- src/MOLECULE/atom_vec_bond.cpp | 6 +-- src/MOLECULE/atom_vec_full.cpp | 6 +-- src/MOLECULE/atom_vec_molecular.cpp | 6 +-- src/MOLECULE/atom_vec_template.cpp | 6 +-- src/PERI/atom_vec_peri.cpp | 6 +-- src/USER-AWPMD/atom_vec_wavepacket.cpp | 6 +-- src/USER-CUDA/atom_vec_angle_cuda.cpp | 1 - src/USER-CUDA/atom_vec_atomic_cuda.cpp | 1 - src/USER-CUDA/atom_vec_charge_cuda.cpp | 1 - src/USER-CUDA/atom_vec_full_cuda.cpp | 1 - src/USER-EFF/atom_vec_electron.cpp | 6 +-- src/USER-SPH/atom_vec_meso.cpp | 13 +++---- src/atom.cpp | 47 ++++++++++++++++++++--- src/atom.h | 2 + src/atom_vec.cpp | 9 +++-- src/atom_vec.h | 3 +- src/atom_vec_atomic.cpp | 6 +-- src/atom_vec_body.cpp | 7 ++-- src/atom_vec_charge.cpp | 6 +-- src/atom_vec_ellipsoid.cpp | 7 ++-- src/atom_vec_hybrid.cpp | 6 +-- src/atom_vec_line.cpp | 5 +-- src/atom_vec_sphere.cpp | 6 +-- src/atom_vec_tri.cpp | 5 +-- src/create_box.cpp | 5 ++- src/fix_addforce.cpp | 28 +++++--------- src/fix_move.cpp | 35 +++++------------ src/fix_setforce.cpp | 22 ++++------- src/fix_store_state.cpp | 9 ++--- src/read_data.cpp | 53 ++++---------------------- src/read_restart.cpp | 1 + 34 files changed, 146 insertions(+), 215 deletions(-) diff --git a/src/DIPOLE/atom_vec_dipole.cpp b/src/DIPOLE/atom_vec_dipole.cpp index 08067d567d..07c8d203d8 100644 --- a/src/DIPOLE/atom_vec_dipole.cpp +++ b/src/DIPOLE/atom_vec_dipole.cpp @@ -24,8 +24,6 @@ using namespace LAMMPS_NS; -#define DELTA 10000 - /* ---------------------------------------------------------------------- */ AtomVecDipole::AtomVecDipole(LAMMPS *lmp) : AtomVec(lmp) @@ -48,13 +46,13 @@ AtomVecDipole::AtomVecDipole(LAMMPS *lmp) : AtomVec(lmp) /* ---------------------------------------------------------------------- grow atom arrays - n = 0 grows arrays by DELTA + n = 0 grows arrays by a chunk n > 0 allocates arrays to size n ------------------------------------------------------------------------- */ void AtomVecDipole::grow(int n) { - if (n == 0) nmax += DELTA; + if (n == 0) grow_nmax(); else nmax = n; atom->nmax = nmax; if (nmax < 0 || nmax > MAXSMALLINT) diff --git a/src/MISC/fix_efield.cpp b/src/MISC/fix_efield.cpp index c175dcd0ef..c472bf9f16 100644 --- a/src/MISC/fix_efield.cpp +++ b/src/MISC/fix_efield.cpp @@ -114,8 +114,8 @@ FixEfield::FixEfield(LAMMPS *lmp, int narg, char **arg) : force_flag = 0; fsum[0] = fsum[1] = fsum[2] = fsum[3] = 0.0; - maxatom = 0; - efield = NULL; + maxatom = atom->nmax; + memory->create(efield,maxatom,4,"efield:efield"); } /* ---------------------------------------------------------------------- */ @@ -332,24 +332,16 @@ void FixEfield::post_force(int vflag) modify->clearstep_compute(); if (xstyle == EQUAL) ex = qe2f * input->variable->compute_equal(xvar); - else if (xstyle == ATOM) { - if (efield) input->variable->compute_atom(xvar,igroup,&efield[0][0],3,0); - else input->variable->compute_atom(xvar,igroup,NULL,3,0); - } + else if (xstyle == ATOM) + input->variable->compute_atom(xvar,igroup,&efield[0][0],3,0); if (ystyle == EQUAL) ey = qe2f * input->variable->compute_equal(yvar); - else if (ystyle == ATOM) { - if (efield) input->variable->compute_atom(yvar,igroup,&efield[0][1],3,0); - else input->variable->compute_atom(yvar,igroup,NULL,3,0); - } + else if (ystyle == ATOM) + input->variable->compute_atom(yvar,igroup,&efield[0][1],3,0); if (zstyle == EQUAL) ez = qe2f * input->variable->compute_equal(zvar); - else if (zstyle == ATOM) { - if (efield) input->variable->compute_atom(zvar,igroup,&efield[0][2],3,0); - else input->variable->compute_atom(zvar,igroup,NULL,3,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); - } + else if (zstyle == ATOM) + input->variable->compute_atom(zvar,igroup,&efield[0][2],3,0); + if (estyle == ATOM) + input->variable->compute_atom(evar,igroup,&efield[0][3],4,0); modify->addstep_compute(update->ntimestep + 1); diff --git a/src/MOLECULE/atom_vec_angle.cpp b/src/MOLECULE/atom_vec_angle.cpp index bafac2391f..8241c693aa 100644 --- a/src/MOLECULE/atom_vec_angle.cpp +++ b/src/MOLECULE/atom_vec_angle.cpp @@ -23,8 +23,6 @@ using namespace LAMMPS_NS; -#define DELTA 10000 - /* ---------------------------------------------------------------------- */ AtomVecAngle::AtomVecAngle(LAMMPS *lmp) : AtomVec(lmp) @@ -47,13 +45,13 @@ AtomVecAngle::AtomVecAngle(LAMMPS *lmp) : AtomVec(lmp) /* ---------------------------------------------------------------------- grow atom arrays - n = 0 grows arrays by DELTA + n = 0 grows arrays by a chunk n > 0 allocates arrays to size n ------------------------------------------------------------------------- */ void AtomVecAngle::grow(int n) { - if (n == 0) nmax += DELTA; + if (n == 0) grow_nmax(); else nmax = n; atom->nmax = nmax; if (nmax < 0 || nmax > MAXSMALLINT) diff --git a/src/MOLECULE/atom_vec_bond.cpp b/src/MOLECULE/atom_vec_bond.cpp index 030a86ac86..f53c71736e 100644 --- a/src/MOLECULE/atom_vec_bond.cpp +++ b/src/MOLECULE/atom_vec_bond.cpp @@ -23,8 +23,6 @@ using namespace LAMMPS_NS; -#define DELTA 10000 - /* ---------------------------------------------------------------------- */ AtomVecBond::AtomVecBond(LAMMPS *lmp) : AtomVec(lmp) @@ -47,13 +45,13 @@ AtomVecBond::AtomVecBond(LAMMPS *lmp) : AtomVec(lmp) /* ---------------------------------------------------------------------- grow atom arrays - n = 0 grows arrays by DELTA + n = 0 grows arrays by a chunk n > 0 allocates arrays to size n ------------------------------------------------------------------------- */ void AtomVecBond::grow(int n) { - if (n == 0) nmax += DELTA; + if (n == 0) grow_nmax(); else nmax = n; atom->nmax = nmax; if (nmax < 0 || nmax > MAXSMALLINT) diff --git a/src/MOLECULE/atom_vec_full.cpp b/src/MOLECULE/atom_vec_full.cpp index f132fdc599..006917ce49 100644 --- a/src/MOLECULE/atom_vec_full.cpp +++ b/src/MOLECULE/atom_vec_full.cpp @@ -23,8 +23,6 @@ using namespace LAMMPS_NS; -#define DELTA 10000 - /* ---------------------------------------------------------------------- */ AtomVecFull::AtomVecFull(LAMMPS *lmp) : AtomVec(lmp) @@ -47,13 +45,13 @@ AtomVecFull::AtomVecFull(LAMMPS *lmp) : AtomVec(lmp) /* ---------------------------------------------------------------------- grow atom arrays - n = 0 grows arrays by DELTA + n = 0 grows arrays by a chunk n > 0 allocates arrays to size n ------------------------------------------------------------------------- */ void AtomVecFull::grow(int n) { - if (n == 0) nmax += DELTA; + if (n == 0) grow_nmax(); else nmax = n; atom->nmax = nmax; if (nmax < 0 || nmax > MAXSMALLINT) diff --git a/src/MOLECULE/atom_vec_molecular.cpp b/src/MOLECULE/atom_vec_molecular.cpp index 766da9e354..3e347af5c9 100644 --- a/src/MOLECULE/atom_vec_molecular.cpp +++ b/src/MOLECULE/atom_vec_molecular.cpp @@ -23,8 +23,6 @@ using namespace LAMMPS_NS; -#define DELTA 10000 - /* ---------------------------------------------------------------------- */ AtomVecMolecular::AtomVecMolecular(LAMMPS *lmp) : AtomVec(lmp) @@ -47,13 +45,13 @@ AtomVecMolecular::AtomVecMolecular(LAMMPS *lmp) : AtomVec(lmp) /* ---------------------------------------------------------------------- grow atom arrays - n = 0 grows arrays by DELTA + n = 0 grows arrays by a chunk n > 0 allocates arrays to size n ------------------------------------------------------------------------- */ void AtomVecMolecular::grow(int n) { - if (n == 0) nmax += DELTA; + if (n == 0) grow_nmax(); else nmax = n; atom->nmax = nmax; if (nmax < 0 || nmax > MAXSMALLINT) diff --git a/src/MOLECULE/atom_vec_template.cpp b/src/MOLECULE/atom_vec_template.cpp index a2bc632952..546b442825 100644 --- a/src/MOLECULE/atom_vec_template.cpp +++ b/src/MOLECULE/atom_vec_template.cpp @@ -25,8 +25,6 @@ using namespace LAMMPS_NS; -#define DELTA 10000 - /* ---------------------------------------------------------------------- */ AtomVecTemplate::AtomVecTemplate(LAMMPS *lmp) : AtomVec(lmp) @@ -90,13 +88,13 @@ void AtomVecTemplate::process_args(int narg, char **arg) /* ---------------------------------------------------------------------- grow atom arrays - n = 0 grows arrays by DELTA + n = 0 grows arrays by a chunk n > 0 allocates arrays to size n ------------------------------------------------------------------------- */ void AtomVecTemplate::grow(int n) { - if (n == 0) nmax += DELTA; + if (n == 0) grow_nmax(); else nmax = n; atom->nmax = nmax; if (nmax < 0 || nmax > MAXSMALLINT) diff --git a/src/PERI/atom_vec_peri.cpp b/src/PERI/atom_vec_peri.cpp index c2791ce01f..165c9bc462 100644 --- a/src/PERI/atom_vec_peri.cpp +++ b/src/PERI/atom_vec_peri.cpp @@ -29,8 +29,6 @@ using namespace LAMMPS_NS; -#define DELTA 10000 - static const char cite_peri_package[] = "PERI package for Peridynamics:\n\n" "@Article{Parks08,\n" @@ -66,13 +64,13 @@ AtomVecPeri::AtomVecPeri(LAMMPS *lmp) : AtomVec(lmp) /* ---------------------------------------------------------------------- grow atom arrays - n = 0 grows arrays by DELTA + n = 0 grows arrays by a chunk n > 0 allocates arrays to size n ------------------------------------------------------------------------- */ void AtomVecPeri::grow(int n) { - if (n == 0) nmax += DELTA; + if (n == 0) grow_nmax(); else nmax = n; atom->nmax = nmax; if (nmax < 0 || nmax > MAXSMALLINT) diff --git a/src/USER-AWPMD/atom_vec_wavepacket.cpp b/src/USER-AWPMD/atom_vec_wavepacket.cpp index 9903e889fa..155ad88ca5 100644 --- a/src/USER-AWPMD/atom_vec_wavepacket.cpp +++ b/src/USER-AWPMD/atom_vec_wavepacket.cpp @@ -29,8 +29,6 @@ using namespace LAMMPS_NS; -#define DELTA 10000 - /* ---------------------------------------------------------------------- */ AtomVecWavepacket::AtomVecWavepacket(LAMMPS *lmp) : AtomVec(lmp) @@ -58,13 +56,13 @@ AtomVecWavepacket::AtomVecWavepacket(LAMMPS *lmp) : AtomVec(lmp) /* ---------------------------------------------------------------------- grow atom-electron arrays - n = 0 grows arrays by DELTA + n = 0 grows arrays by a chunk n > 0 allocates arrays to size n ------------------------------------------------------------------------- */ void AtomVecWavepacket::grow(int n) { - if (n == 0) nmax += DELTA; + if (n == 0) grow_nmax(); else nmax = n; atom->nmax = nmax; diff --git a/src/USER-CUDA/atom_vec_angle_cuda.cpp b/src/USER-CUDA/atom_vec_angle_cuda.cpp index 82a5b77dd2..2acc5d913e 100644 --- a/src/USER-CUDA/atom_vec_angle_cuda.cpp +++ b/src/USER-CUDA/atom_vec_angle_cuda.cpp @@ -52,7 +52,6 @@ using namespace LAMMPS_NS; -#define DELTA 10000 #define BUFFACTOR 1.5 #define BUFEXTRA 1000 #define NCUDAEXCHANGE 12 //nextra x y z vx vy vz tag type mask image molecule diff --git a/src/USER-CUDA/atom_vec_atomic_cuda.cpp b/src/USER-CUDA/atom_vec_atomic_cuda.cpp index bf8865b5cc..a2233fab6e 100644 --- a/src/USER-CUDA/atom_vec_atomic_cuda.cpp +++ b/src/USER-CUDA/atom_vec_atomic_cuda.cpp @@ -51,7 +51,6 @@ using namespace LAMMPS_NS; -#define DELTA 10000 #define BUFFACTOR 1.5 #define BUFEXTRA 1000 #define NCUDAEXCHANGE 11 //nextra x y z vx vy vz tag type mask image diff --git a/src/USER-CUDA/atom_vec_charge_cuda.cpp b/src/USER-CUDA/atom_vec_charge_cuda.cpp index f9cb3673e1..016e7fcca6 100644 --- a/src/USER-CUDA/atom_vec_charge_cuda.cpp +++ b/src/USER-CUDA/atom_vec_charge_cuda.cpp @@ -51,7 +51,6 @@ using namespace LAMMPS_NS; -#define DELTA 10000 #define BUFFACTOR 1.5 #define BUFEXTRA 1000 #define NCUDAEXCHANGE 12 //nextra x y z vx vy vz tag type mask image q diff --git a/src/USER-CUDA/atom_vec_full_cuda.cpp b/src/USER-CUDA/atom_vec_full_cuda.cpp index c430298cd6..a69c68c987 100644 --- a/src/USER-CUDA/atom_vec_full_cuda.cpp +++ b/src/USER-CUDA/atom_vec_full_cuda.cpp @@ -52,7 +52,6 @@ using namespace LAMMPS_NS; -#define DELTA 10000 #define BUFFACTOR 1.5 #define BUFEXTRA 1000 #define NCUDAEXCHANGE 13 //nextra x y z vx vy vz tag type mask image q molecule diff --git a/src/USER-EFF/atom_vec_electron.cpp b/src/USER-EFF/atom_vec_electron.cpp index c68e348035..41837f1263 100644 --- a/src/USER-EFF/atom_vec_electron.cpp +++ b/src/USER-EFF/atom_vec_electron.cpp @@ -30,8 +30,6 @@ using namespace LAMMPS_NS; -#define DELTA 10000 - static const char cite_user_eff_package[] = "USER-EFF package:\n\n" "@Article{Jaramillo-Botero11,\n" @@ -71,13 +69,13 @@ AtomVecElectron::AtomVecElectron(LAMMPS *lmp) : AtomVec(lmp) /* ---------------------------------------------------------------------- grow atom-electron arrays - n = 0 grows arrays by DELTA + n = 0 grows arrays by a chunk n > 0 allocates arrays to size n ------------------------------------------------------------------------- */ void AtomVecElectron::grow(int n) { - if (n == 0) nmax += DELTA; + if (n == 0) grow_nmax(); else nmax = n; atom->nmax = nmax; diff --git a/src/USER-SPH/atom_vec_meso.cpp b/src/USER-SPH/atom_vec_meso.cpp index 808595bb35..3a57776d94 100644 --- a/src/USER-SPH/atom_vec_meso.cpp +++ b/src/USER-SPH/atom_vec_meso.cpp @@ -23,8 +23,6 @@ using namespace LAMMPS_NS; -#define DELTA 10000 - /* ---------------------------------------------------------------------- */ AtomVecMeso::AtomVecMeso(LAMMPS *lmp) : AtomVec(lmp) @@ -50,15 +48,14 @@ AtomVecMeso::AtomVecMeso(LAMMPS *lmp) : AtomVec(lmp) /* ---------------------------------------------------------------------- grow atom arrays - n = 0 grows arrays by DELTA + n = 0 grows arrays by a chunk n > 0 allocates arrays to size n ------------------------------------------------------------------------- */ -void AtomVecMeso::grow(int n) { - if (n == 0) - nmax += DELTA; - else - nmax = n; +void AtomVecMeso::grow(int n) +{ + if (n == 0) grow_nmax(); + else nmax = n; atom->nmax = nmax; if (nmax < 0 || nmax > MAXSMALLINT) error->one(FLERR,"Per-processor system is too big"); diff --git a/src/atom.cpp b/src/atom.cpp index dc6d2e2fa1..e8e15806d2 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -330,17 +330,12 @@ void Atom::create_avec(const char *style, int narg, char **arg, char *suffix) // create instance of AtomVec // 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 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; avec = new_avec(style,suffix,sflag); avec->store_args(narg,arg); avec->process_args(narg,arg); avec->grow(1); - nmax = 0; - avec->reset(); if (sflag) { char estyle[256]; @@ -640,6 +635,48 @@ int Atom::count_words(const char *line) 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 call style-specific routine to parse line diff --git a/src/atom.h b/src/atom.h index 8138496052..5887b17c39 100644 --- a/src/atom.h +++ b/src/atom.h @@ -176,6 +176,8 @@ class Atom : protected Pointers { int parse_data(const char *); int count_words(const char *); + void deallocate_topology(); + void data_atoms(int, char *); void data_vels(int, char *); diff --git a/src/atom_vec.cpp b/src/atom_vec.cpp index 24e9e2d713..4825056f75 100644 --- a/src/atom_vec.cpp +++ b/src/atom_vec.cpp @@ -21,6 +21,8 @@ using namespace LAMMPS_NS; +#define DELTA 16384 + /* ---------------------------------------------------------------------- */ 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; } /* ---------------------------------------------------------------------- diff --git a/src/atom_vec.h b/src/atom_vec.h index f08709503e..a6d188d74b 100644 --- a/src/atom_vec.h +++ b/src/atom_vec.h @@ -103,7 +103,6 @@ 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(tagint **); void write_bond(FILE *, int, tagint **, int); int pack_angle(tagint **); @@ -139,6 +138,8 @@ class AtomVec : protected Pointers { ubuf(int64_t arg) : i(arg) {} ubuf(int arg) : i(arg) {} }; + + void grow_nmax(); }; } diff --git a/src/atom_vec_atomic.cpp b/src/atom_vec_atomic.cpp index 5d96dc139e..c23d81e3cc 100644 --- a/src/atom_vec_atomic.cpp +++ b/src/atom_vec_atomic.cpp @@ -23,8 +23,6 @@ using namespace LAMMPS_NS; -#define DELTA 10000 - /* ---------------------------------------------------------------------- */ AtomVecAtomic::AtomVecAtomic(LAMMPS *lmp) : AtomVec(lmp) @@ -44,13 +42,13 @@ AtomVecAtomic::AtomVecAtomic(LAMMPS *lmp) : AtomVec(lmp) /* ---------------------------------------------------------------------- grow atom arrays - n = 0 grows arrays by DELTA + n = 0 grows arrays by a chunk n > 0 allocates arrays to size n ------------------------------------------------------------------------- */ void AtomVecAtomic::grow(int n) { - if (n == 0) nmax += DELTA; + if (n == 0) grow_nmax(); else nmax = n; atom->nmax = nmax; if (nmax < 0 || nmax > MAXSMALLINT) diff --git a/src/atom_vec_body.cpp b/src/atom_vec_body.cpp index 39f20272c2..6876e13327 100644 --- a/src/atom_vec_body.cpp +++ b/src/atom_vec_body.cpp @@ -28,8 +28,7 @@ using namespace LAMMPS_NS; -#define DELTA 10000 -#define DELTA_BONUS 10000 +#define DELTA_BONUS 8192 /* ---------------------------------------------------------------------- */ @@ -111,13 +110,13 @@ void AtomVecBody::process_args(int narg, char **arg) /* ---------------------------------------------------------------------- grow atom arrays - n = 0 grows arrays by DELTA + n = 0 grows arrays by a chunk n > 0 allocates arrays to size n ------------------------------------------------------------------------- */ void AtomVecBody::grow(int n) { - if (n == 0) nmax += DELTA; + if (n == 0) grow_nmax(); else nmax = n; atom->nmax = nmax; if (nmax < 0 || nmax > MAXSMALLINT) diff --git a/src/atom_vec_charge.cpp b/src/atom_vec_charge.cpp index d8b4b7430c..da10ef42dd 100644 --- a/src/atom_vec_charge.cpp +++ b/src/atom_vec_charge.cpp @@ -23,8 +23,6 @@ using namespace LAMMPS_NS; -#define DELTA 10000 - /* ---------------------------------------------------------------------- */ AtomVecCharge::AtomVecCharge(LAMMPS *lmp) : AtomVec(lmp) @@ -46,13 +44,13 @@ AtomVecCharge::AtomVecCharge(LAMMPS *lmp) : AtomVec(lmp) /* ---------------------------------------------------------------------- grow atom arrays - n = 0 grows arrays by DELTA + n = 0 grows arrays by a chunk n > 0 allocates arrays to size n ------------------------------------------------------------------------- */ void AtomVecCharge::grow(int n) { - if (n == 0) nmax += DELTA; + if (n == 0) grow_nmax(); else nmax = n; atom->nmax = nmax; if (nmax < 0 || nmax > MAXSMALLINT) diff --git a/src/atom_vec_ellipsoid.cpp b/src/atom_vec_ellipsoid.cpp index 512f3ba74b..317a47ed1f 100755 --- a/src/atom_vec_ellipsoid.cpp +++ b/src/atom_vec_ellipsoid.cpp @@ -31,8 +31,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define DELTA 10000 -#define DELTA_BONUS 10000 +#define DELTA_BONUS 8192 /* ---------------------------------------------------------------------- */ @@ -66,13 +65,13 @@ AtomVecEllipsoid::~AtomVecEllipsoid() /* ---------------------------------------------------------------------- grow atom arrays - n = 0 grows arrays by DELTA + n = 0 grows arrays by a chunk n > 0 allocates arrays to size n ------------------------------------------------------------------------- */ void AtomVecEllipsoid::grow(int n) { - if (n == 0) nmax += DELTA; + if (n == 0) grow_nmax(); else nmax = n; atom->nmax = nmax; if (nmax < 0 || nmax > MAXSMALLINT) diff --git a/src/atom_vec_hybrid.cpp b/src/atom_vec_hybrid.cpp index 1af8ee0b98..210e5f5338 100644 --- a/src/atom_vec_hybrid.cpp +++ b/src/atom_vec_hybrid.cpp @@ -23,8 +23,6 @@ using namespace LAMMPS_NS; -#define DELTA 10000 - /* ---------------------------------------------------------------------- */ AtomVecHybrid::AtomVecHybrid(LAMMPS *lmp) : AtomVec(lmp) {} @@ -134,13 +132,13 @@ void AtomVecHybrid::init() /* ---------------------------------------------------------------------- grow atom arrays - n = 0 grows arrays by DELTA + n = 0 grows arrays by a chunk n > 0 allocates arrays to size n ------------------------------------------------------------------------- */ void AtomVecHybrid::grow(int n) { - if (n == 0) nmax += DELTA; + if (n == 0) grow_nmax(); else nmax = n; atom->nmax = nmax; if (nmax < 0 || nmax > MAXSMALLINT) diff --git a/src/atom_vec_line.cpp b/src/atom_vec_line.cpp index bd5a5ea2b3..d203ff8f75 100644 --- a/src/atom_vec_line.cpp +++ b/src/atom_vec_line.cpp @@ -26,7 +26,6 @@ using namespace LAMMPS_NS; -#define DELTA 10000 #define DELTA_BONUS 10000 #define EPSILON 0.001 @@ -73,13 +72,13 @@ void AtomVecLine::init() /* ---------------------------------------------------------------------- grow atom arrays - n = 0 grows arrays by DELTA + n = 0 grows arrays by a chunk n > 0 allocates arrays to size n ------------------------------------------------------------------------- */ void AtomVecLine::grow(int n) { - if (n == 0) nmax += DELTA; + if (n == 0) grow_nmax(); else nmax = n; atom->nmax = nmax; if (nmax < 0 || nmax > MAXSMALLINT) diff --git a/src/atom_vec_sphere.cpp b/src/atom_vec_sphere.cpp index acb1251981..de85a2eb15 100644 --- a/src/atom_vec_sphere.cpp +++ b/src/atom_vec_sphere.cpp @@ -29,8 +29,6 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define DELTA 10000 - /* ---------------------------------------------------------------------- */ AtomVecSphere::AtomVecSphere(LAMMPS *lmp) : AtomVec(lmp) @@ -77,13 +75,13 @@ void AtomVecSphere::init() /* ---------------------------------------------------------------------- grow atom arrays - n = 0 grows arrays by DELTA + n = 0 grows arrays by a chunk n > 0 allocates arrays to size n ------------------------------------------------------------------------- */ void AtomVecSphere::grow(int n) { - if (n == 0) nmax += DELTA; + if (n == 0) grow_nmax(); else nmax = n; atom->nmax = nmax; if (nmax < 0 || nmax > MAXSMALLINT) diff --git a/src/atom_vec_tri.cpp b/src/atom_vec_tri.cpp index 20528ff0d6..10d82a237f 100644 --- a/src/atom_vec_tri.cpp +++ b/src/atom_vec_tri.cpp @@ -27,7 +27,6 @@ using namespace LAMMPS_NS; -#define DELTA 10000 #define DELTA_BONUS 10000 #define EPSILON 0.001 @@ -74,13 +73,13 @@ void AtomVecTri::init() /* ---------------------------------------------------------------------- grow atom arrays - n = 0 grows arrays by DELTA + n = 0 grows arrays by a chunk n > 0 allocates arrays to size n ------------------------------------------------------------------------- */ void AtomVecTri::grow(int n) { - if (n == 0) nmax += DELTA; + if (n == 0) grow_nmax(); else nmax = n; atom->nmax = nmax; if (nmax < 0 || nmax > MAXSMALLINT) diff --git a/src/create_box.cpp b/src/create_box.cpp index 1e7ce40122..d5bf0712a5 100644 --- a/src/create_box.cpp +++ b/src/create_box.cpp @@ -164,11 +164,14 @@ void CreateBox::command(int narg, char **arg) } // 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; atom->allocate_type_arrays(); + atom->deallocate_topology(); + atom->avec->grow(atom->nmax); domain->print_box("Created "); domain->set_initial_box(); diff --git a/src/fix_addforce.cpp b/src/fix_addforce.cpp index 4f39d00d14..db2a78f2f6 100644 --- a/src/fix_addforce.cpp +++ b/src/fix_addforce.cpp @@ -104,8 +104,8 @@ FixAddForce::FixAddForce(LAMMPS *lmp, int narg, char **arg) : force_flag = 0; foriginal[0] = foriginal[1] = foriginal[2] = foriginal[3] = 0.0; - maxatom = 0; - sforce = NULL; + maxatom = atom->nmax; + memory->create(sforce,maxatom,4,"addforce:sforce"); } /* ---------------------------------------------------------------------- */ @@ -274,24 +274,16 @@ void FixAddForce::post_force(int vflag) modify->clearstep_compute(); if (xstyle == EQUAL) xvalue = input->variable->compute_equal(xvar); - else if (xstyle == ATOM) { - if (sforce) input->variable->compute_atom(xvar,igroup,&sforce[0][0],4,0); - else input->variable->compute_atom(xvar,igroup,NULL,4,0); - } + else if (xstyle == ATOM) + input->variable->compute_atom(xvar,igroup,&sforce[0][0],4,0); if (ystyle == EQUAL) yvalue = input->variable->compute_equal(yvar); - else if (ystyle == ATOM) { - if (sforce) input->variable->compute_atom(yvar,igroup,&sforce[0][1],4,0); - else input->variable->compute_atom(yvar,igroup,NULL,4,0); - } + else if (ystyle == ATOM) + input->variable->compute_atom(yvar,igroup,&sforce[0][1],4,0); if (zstyle == EQUAL) zvalue = input->variable->compute_equal(zvar); - else if (zstyle == ATOM) { - if (sforce) input->variable->compute_atom(zvar,igroup,&sforce[0][2],4,0); - else input->variable->compute_atom(zvar,igroup,NULL,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); - } + else if (zstyle == ATOM) + input->variable->compute_atom(zvar,igroup,&sforce[0][2],4,0); + if (estyle == ATOM) + input->variable->compute_atom(evar,igroup,&sforce[0][3],4,0); modify->addstep_compute(update->ntimestep + 1); diff --git a/src/fix_move.cpp b/src/fix_move.cpp index 120afdab73..0d80f5664f 100644 --- a/src/fix_move.cpp +++ b/src/fix_move.cpp @@ -242,8 +242,9 @@ FixMove::FixMove(LAMMPS *lmp, int narg, char **arg) : atom->add_callback(0); atom->add_callback(1); - maxatom = 0; - displace = velocity = NULL; + maxatom = atom->nmax; + if (displaceflag) memory->create(displace,maxatom,3,"move:displace"); + if (velocityflag) memory->create(velocity,maxatom,3,"move:velocity"); // xoriginal = initial unwrapped positions of atoms @@ -581,45 +582,27 @@ void FixMove::initial_integrate(int vflag) if (xvarstr) { if (xvarstyle == EQUAL) dx = input->variable->compute_equal(xvar); - else if (displace) - input->variable->compute_atom(xvar,igroup,&displace[0][0],3,0); - else - input->variable->compute_atom(xvar,igroup,NULL,3,0); + else input->variable->compute_atom(xvar,igroup,&displace[0][0],3,0); } if (yvarstr) { if (yvarstyle == EQUAL) dy = input->variable->compute_equal(yvar); - else if (displace) - input->variable->compute_atom(yvar,igroup,&displace[0][1],3,0); - else - input->variable->compute_atom(yvar,igroup,NULL,3,0); + else input->variable->compute_atom(yvar,igroup,&displace[0][1],3,0); } if (zvarstr) { if (zvarstyle == EQUAL) dz = input->variable->compute_equal(zvar); - else if (displace) - input->variable->compute_atom(zvar,igroup,&displace[0][2],3,0); - else - input->variable->compute_atom(zvar,igroup,NULL,3,0); + else input->variable->compute_atom(zvar,igroup,&displace[0][2],3,0); } if (vxvarstr) { if (vxvarstyle == EQUAL) vx = input->variable->compute_equal(vxvar); - else if (velocity) - input->variable->compute_atom(vxvar,igroup,&velocity[0][0],3,0); - else - input->variable->compute_atom(vxvar,igroup,NULL,3,0); + else input->variable->compute_atom(vxvar,igroup,&velocity[0][0],3,0); } if (vyvarstr) { if (vyvarstyle == EQUAL) vy = input->variable->compute_equal(vyvar); - else if (velocity) - input->variable->compute_atom(vyvar,igroup,&velocity[0][1],3,0); - else - input->variable->compute_atom(vyvar,igroup,NULL,3,0); + else input->variable->compute_atom(vyvar,igroup,&velocity[0][1],3,0); } if (vzvarstr) { if (vzvarstyle == EQUAL) vz = input->variable->compute_equal(vzvar); - else if (velocity) - input->variable->compute_atom(vzvar,igroup,&velocity[0][2],3,0); - else - input->variable->compute_atom(vzvar,igroup,NULL,3,0); + else input->variable->compute_atom(vzvar,igroup,&velocity[0][2],3,0); } modify->addstep_compute(update->ntimestep + 1); diff --git a/src/fix_setforce.cpp b/src/fix_setforce.cpp index 7c9ef0a5c7..a6e1ecb972 100644 --- a/src/fix_setforce.cpp +++ b/src/fix_setforce.cpp @@ -99,8 +99,8 @@ FixSetForce::FixSetForce(LAMMPS *lmp, int narg, char **arg) : force_flag = 0; foriginal[0] = foriginal[1] = foriginal[2] = 0.0; - maxatom = 0; - sforce = NULL; + maxatom = atom->nmax; + memory->create(sforce,maxatom,3,"setforce:sforce"); } /* ---------------------------------------------------------------------- */ @@ -257,20 +257,14 @@ void FixSetForce::post_force(int vflag) modify->clearstep_compute(); if (xstyle == EQUAL) xvalue = input->variable->compute_equal(xvar); - else if (xstyle == ATOM) { - if (sforce) input->variable->compute_atom(xvar,igroup,&sforce[0][0],3,0); - else input->variable->compute_atom(xvar,igroup,NULL,3,0); - } + else if (xstyle == ATOM) + input->variable->compute_atom(xvar,igroup,&sforce[0][0],3,0); if (ystyle == EQUAL) yvalue = input->variable->compute_equal(yvar); - else if (ystyle == ATOM) { - if (sforce) input->variable->compute_atom(yvar,igroup,&sforce[0][1],3,0); - else input->variable->compute_atom(yvar,igroup,NULL,3,0); - } + else if (ystyle == ATOM) + input->variable->compute_atom(yvar,igroup,&sforce[0][1],3,0); if (zstyle == EQUAL) zvalue = input->variable->compute_equal(zvar); - else if (zstyle == ATOM) { - if (sforce) input->variable->compute_atom(zvar,igroup,&sforce[0][2],3,0); - else input->variable->compute_atom(zvar,igroup,NULL,3,0); - } + else if (zstyle == ATOM) + input->variable->compute_atom(zvar,igroup,&sforce[0][2],3,0); modify->addstep_compute(update->ntimestep + 1); diff --git a/src/fix_store_state.cpp b/src/fix_store_state.cpp index 014c9a773d..838e1df18e 100644 --- a/src/fix_store_state.cpp +++ b/src/fix_store_state.cpp @@ -304,7 +304,6 @@ FixStoreState::FixStoreState(LAMMPS *lmp, int narg, char **arg) : // perform initial allocation of atom-based array // register with Atom class - values = NULL; grow_arrays(atom->nmax); atom->add_callback(0); atom->add_callback(1); @@ -467,11 +466,9 @@ void FixStoreState::end_of_step() // evaluate atom-style variable - } else if (which[m] == VARIABLE) - if (values) - input->variable->compute_atom(n,igroup,&values[0][m],nvalues,0); - else - input->variable->compute_atom(n,igroup,NULL,nvalues,0); + } else if (which[m] == VARIABLE) { + input->variable->compute_atom(n,igroup,&values[0][m],nvalues,0); + } } } diff --git a/src/read_data.cpp b/src/read_data.cpp index 7656ee922f..0932889114 100644 --- a/src/read_data.cpp +++ b/src/read_data.cpp @@ -206,9 +206,9 @@ void ReadData::command(int narg, char **arg) domain->box_exist = 1; update->ntimestep = 0; - // insure extra settings are applied before grow(), - // even if no topology in file - // if topology is in file, realloc and another grow() is done below + // apply extra settings before grow(), even if no topology in file + // deallocate() insures new settings are used for topology arrays + // if per-atom topology is in file, another grow() is done below atom->bond_per_atom = atom->extra_bond_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 (LB_FACTOR * atom->natoms / comm->nprocs); atom->allocate_type_arrays(); + atom->deallocate_topology(); atom->avec->grow(n); domain->print_box(" "); @@ -497,49 +498,11 @@ void ReadData::command(int narg, char **arg) firstpass = 0; // reallocate bond,angle,diehdral,improper arrays via grow() - // use new bond,angle,dihedral,improper per-atom values from 1st pass - // should leave other atom arrays unchanged, since already nmax in length - // if bonds/etc not in data file, initialize per-atom size - // 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; - } + // will use new bond,angle,dihedral,improper per-atom values from 1st pass + // will also observe extra settings even if bond/etc topology not in file + // leaves other atom arrays unchanged, since already nmax in length + atom->deallocate_topology(); atom->avec->grow(atom->nmax); } diff --git a/src/read_restart.cpp b/src/read_restart.cpp index f72ced2c53..a224bfa2e3 100644 --- a/src/read_restart.cpp +++ b/src/read_restart.cpp @@ -151,6 +151,7 @@ void ReadRestart::command(int narg, char **arg) else n = static_cast (LB_FACTOR * atom->natoms / nprocs); atom->allocate_type_arrays(); + atom->deallocate_topology(); atom->avec->grow(n); n = atom->nmax; From 59971d161674c23109464b21779683cf66da52a5 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Wed, 7 May 2014 16:25:27 +0000 Subject: [PATCH 04/10] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@11938 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/atom_vec.cpp | 14 +++++++++++++- src/atom_vec.h | 1 + src/atom_vec_body.cpp | 4 +--- src/atom_vec_ellipsoid.cpp | 4 +--- src/atom_vec_line.cpp | 3 +-- src/atom_vec_tri.cpp | 3 +-- 6 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/atom_vec.cpp b/src/atom_vec.cpp index 4825056f75..0fd8043d85 100644 --- a/src/atom_vec.cpp +++ b/src/atom_vec.cpp @@ -22,6 +22,7 @@ using namespace LAMMPS_NS; #define DELTA 16384 +#define DELTA_BONUS 8192 /* ---------------------------------------------------------------------- */ @@ -84,7 +85,7 @@ void AtomVec::init() } /* ---------------------------------------------------------------------- - grow nmax + grow nmax so it is a multiple of DELTA ------------------------------------------------------------------------- */ void AtomVec::grow_nmax() @@ -93,6 +94,17 @@ void AtomVec::grow_nmax() nmax += DELTA; } +/* ---------------------------------------------------------------------- + grow nmax_bonus so it is a multiple of DELTA_BONUS +------------------------------------------------------------------------- */ + +int AtomVec::grow_nmax_bonus(int nmax_bonus) +{ + nmax_bonus = nmax_bonus/DELTA_BONUS * DELTA_BONUS; + nmax_bonus += DELTA_BONUS; + return nmax_bonus; +} + /* ---------------------------------------------------------------------- unpack one line from Velocities section of data file ------------------------------------------------------------------------- */ diff --git a/src/atom_vec.h b/src/atom_vec.h index a6d188d74b..8e9bb0f518 100644 --- a/src/atom_vec.h +++ b/src/atom_vec.h @@ -140,6 +140,7 @@ class AtomVec : protected Pointers { }; void grow_nmax(); + int grow_nmax_bonus(int); }; } diff --git a/src/atom_vec_body.cpp b/src/atom_vec_body.cpp index 6876e13327..d407d5e8c8 100644 --- a/src/atom_vec_body.cpp +++ b/src/atom_vec_body.cpp @@ -28,8 +28,6 @@ using namespace LAMMPS_NS; -#define DELTA_BONUS 8192 - /* ---------------------------------------------------------------------- */ AtomVecBody::AtomVecBody(LAMMPS *lmp) : AtomVec(lmp) @@ -159,7 +157,7 @@ void AtomVecBody::grow_reset() void AtomVecBody::grow_bonus() { - nmax_bonus += DELTA_BONUS; + nmax_bonus = grow_nmax_bonus(nmax_bonus); if (nmax_bonus < 0 || nmax_bonus > MAXSMALLINT) error->one(FLERR,"Per-processor system is too big"); diff --git a/src/atom_vec_ellipsoid.cpp b/src/atom_vec_ellipsoid.cpp index 317a47ed1f..81e4fbee20 100755 --- a/src/atom_vec_ellipsoid.cpp +++ b/src/atom_vec_ellipsoid.cpp @@ -31,8 +31,6 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define DELTA_BONUS 8192 - /* ---------------------------------------------------------------------- */ AtomVecEllipsoid::AtomVecEllipsoid(LAMMPS *lmp) : AtomVec(lmp) @@ -114,7 +112,7 @@ void AtomVecEllipsoid::grow_reset() void AtomVecEllipsoid::grow_bonus() { - nmax_bonus += DELTA_BONUS; + nmax_bonus = grow_nmax_bonus(nmax_bonus); if (nmax_bonus < 0 || nmax_bonus > MAXSMALLINT) error->one(FLERR,"Per-processor system is too big"); diff --git a/src/atom_vec_line.cpp b/src/atom_vec_line.cpp index d203ff8f75..6760589ecb 100644 --- a/src/atom_vec_line.cpp +++ b/src/atom_vec_line.cpp @@ -26,7 +26,6 @@ using namespace LAMMPS_NS; -#define DELTA_BONUS 10000 #define EPSILON 0.001 /* ---------------------------------------------------------------------- */ @@ -123,7 +122,7 @@ void AtomVecLine::grow_reset() void AtomVecLine::grow_bonus() { - nmax_bonus += DELTA_BONUS; + nmax_bonus = grow_nmax_bonus(nmax_bonus); if (nmax_bonus < 0 || nmax_bonus > MAXSMALLINT) error->one(FLERR,"Per-processor system is too big"); diff --git a/src/atom_vec_tri.cpp b/src/atom_vec_tri.cpp index 10d82a237f..f5f0f55f63 100644 --- a/src/atom_vec_tri.cpp +++ b/src/atom_vec_tri.cpp @@ -27,7 +27,6 @@ using namespace LAMMPS_NS; -#define DELTA_BONUS 10000 #define EPSILON 0.001 /* ---------------------------------------------------------------------- */ @@ -124,7 +123,7 @@ void AtomVecTri::grow_reset() void AtomVecTri::grow_bonus() { - nmax_bonus += DELTA_BONUS; + nmax_bonus = grow_nmax_bonus(nmax_bonus); if (nmax_bonus < 0 || nmax_bonus > MAXSMALLINT) error->one(FLERR,"Per-processor system is too big"); From 320d269f42b53283df8fe51f4b2de4b85eef53b8 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Wed, 7 May 2014 16:30:05 +0000 Subject: [PATCH 05/10] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@11939 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/atom.cpp | 2 +- src/compute_temp.cpp | 2 -- src/fix_adapt.cpp | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/atom.cpp b/src/atom.cpp index e8e15806d2..cb394e44ed 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -641,7 +641,7 @@ int Atom::count_words(const char *line) 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 + e.g. due to grow(1) in create_avec() ------------------------------------------------------------------------- */ void Atom::deallocate_topology() diff --git a/src/compute_temp.cpp b/src/compute_temp.cpp index e2d93e357b..c54a9ba9b5 100644 --- a/src/compute_temp.cpp +++ b/src/compute_temp.cpp @@ -18,8 +18,6 @@ #include "update.h" #include "force.h" #include "domain.h" -#include "modify.h" -#include "fix.h" #include "group.h" #include "error.h" diff --git a/src/fix_adapt.cpp b/src/fix_adapt.cpp index 3f04cb8254..d7bef2293b 100644 --- a/src/fix_adapt.cpp +++ b/src/fix_adapt.cpp @@ -370,7 +370,7 @@ void FixAdapt::change_settings() } /* ---------------------------------------------------------------------- - restore pair,kspace.atom parameters to original values + restore pair,kspace,atom parameters to original values ------------------------------------------------------------------------- */ void FixAdapt::restore_settings() From c3a29a758563aa1decbfbe31f8694b52b1f58677 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Wed, 7 May 2014 16:33:37 +0000 Subject: [PATCH 06/10] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@11940 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.h b/src/version.h index 61569290c2..08a2177cc9 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define LAMMPS_VERSION "8 May 2014" +#define LAMMPS_VERSION "9 May 2014" From 919d293a147f71701b353bbfdb7c1fefadf61597 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Wed, 7 May 2014 16:33:38 +0000 Subject: [PATCH 07/10] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@11941 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- doc/Manual.html | 4 ++-- doc/Manual.txt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/Manual.html b/doc/Manual.html index c069efe721..1a48d14c9f 100644 --- a/doc/Manual.html +++ b/doc/Manual.html @@ -1,7 +1,7 @@ LAMMPS Users Manual - + @@ -22,7 +22,7 @@

LAMMPS Documentation

-

8 May 2014 version +

9 May 2014 version

Version info:

diff --git a/doc/Manual.txt b/doc/Manual.txt index 8fb946bf4b..ce94961c3c 100644 --- a/doc/Manual.txt +++ b/doc/Manual.txt @@ -1,6 +1,6 @@ LAMMPS Users Manual - + @@ -18,7 +18,7 @@

LAMMPS Documentation :c,h3 -8 May 2014 version :c,h4 +9 May 2014 version :c,h4 Version info: :h4 From 8c0de891d7fd218a94f5ac901a46bab109c3e080 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Wed, 7 May 2014 18:12:12 +0000 Subject: [PATCH 08/10] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@11943 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/create_box.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/create_box.cpp b/src/create_box.cpp index d5bf0712a5..21e20aab56 100644 --- a/src/create_box.cpp +++ b/src/create_box.cpp @@ -171,7 +171,7 @@ void CreateBox::command(int narg, char **arg) atom->allocate_type_arrays(); atom->deallocate_topology(); - atom->avec->grow(atom->nmax); + atom->avec->grow(1); domain->print_box("Created "); domain->set_initial_box(); From 4d9cdc874670ea6de8b3ed50a0f4b8500d025c7b Mon Sep 17 00:00:00 2001 From: sjplimp Date: Wed, 7 May 2014 19:29:36 +0000 Subject: [PATCH 09/10] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@11944 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/fix_store_state.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fix_store_state.cpp b/src/fix_store_state.cpp index 838e1df18e..e70eada845 100644 --- a/src/fix_store_state.cpp +++ b/src/fix_store_state.cpp @@ -304,6 +304,7 @@ FixStoreState::FixStoreState(LAMMPS *lmp, int narg, char **arg) : // perform initial allocation of atom-based array // register with Atom class + values = NULL; grow_arrays(atom->nmax); atom->add_callback(0); atom->add_callback(1); From cf0cd2e912adc249f0a436640e9699b48731ac27 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Wed, 7 May 2014 20:54:35 +0000 Subject: [PATCH 10/10] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@11945 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/ASPHERE/compute_temp_asphere.h | 2 +- src/compute_temp_com.h | 1 - src/compute_temp_deform.h | 1 - src/compute_temp_partial.h | 1 - src/compute_temp_profile.h | 1 - src/compute_temp_ramp.h | 2 +- src/compute_temp_sphere.h | 2 +- 7 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/ASPHERE/compute_temp_asphere.h b/src/ASPHERE/compute_temp_asphere.h index 544d811355..4edfee325d 100755 --- a/src/ASPHERE/compute_temp_asphere.h +++ b/src/ASPHERE/compute_temp_asphere.h @@ -37,7 +37,7 @@ class ComputeTempAsphere : public Compute { void restore_bias(int, double *); private: - int fix_dof,mode; + int mode; double tfactor; char *id_bias; class Compute *tbias; // ptr to additional bias compute diff --git a/src/compute_temp_com.h b/src/compute_temp_com.h index f59a267d36..8b5b3f1e4b 100644 --- a/src/compute_temp_com.h +++ b/src/compute_temp_com.h @@ -39,7 +39,6 @@ class ComputeTempCOM : public Compute { void restore_bias_all(); private: - int fix_dof; double tfactor,masstotal; void dof_compute(); diff --git a/src/compute_temp_deform.h b/src/compute_temp_deform.h index 92052d986f..8faed4bfac 100644 --- a/src/compute_temp_deform.h +++ b/src/compute_temp_deform.h @@ -40,7 +40,6 @@ class ComputeTempDeform : public Compute { double memory_usage(); protected: - int fix_dof; double tfactor; virtual void dof_compute(); diff --git a/src/compute_temp_partial.h b/src/compute_temp_partial.h index a6178e4ae3..2fda76237d 100644 --- a/src/compute_temp_partial.h +++ b/src/compute_temp_partial.h @@ -42,7 +42,6 @@ class ComputeTempPartial : public Compute { protected: int xflag,yflag,zflag; - int fix_dof; double tfactor; void dof_compute(); diff --git a/src/compute_temp_profile.h b/src/compute_temp_profile.h index aad7a1f2c4..634090ea8d 100644 --- a/src/compute_temp_profile.h +++ b/src/compute_temp_profile.h @@ -44,7 +44,6 @@ class ComputeTempProfile : public Compute { int xflag,yflag,zflag,ncount,outflag; int nbinx,nbiny,nbinz,nbins; int ivx,ivy,ivz; - int fix_dof; double tfactor; int box_change,triclinic; diff --git a/src/compute_temp_ramp.h b/src/compute_temp_ramp.h index 4eaa21de50..3c1497e71d 100644 --- a/src/compute_temp_ramp.h +++ b/src/compute_temp_ramp.h @@ -44,7 +44,7 @@ class ComputeTempRamp : public Compute { double coord_lo,coord_hi; int v_dim; double v_lo,v_hi; - int scaleflag,fix_dof; + int scaleflag; double tfactor,xscale,yscale,zscale; void dof_compute(); diff --git a/src/compute_temp_sphere.h b/src/compute_temp_sphere.h index 7d4f34b8f4..505276f8e3 100644 --- a/src/compute_temp_sphere.h +++ b/src/compute_temp_sphere.h @@ -37,7 +37,7 @@ class ComputeTempSphere : public Compute { void restore_bias(int, double *); private: - int fix_dof,mode; + int mode; double tfactor; double *inertia; char *id_bias;