diff --git a/src/GRANULAR/fix_pour.cpp b/src/GRANULAR/fix_pour.cpp index 55c97adb09..613dd61496 100644 --- a/src/GRANULAR/fix_pour.cpp +++ b/src/GRANULAR/fix_pour.cpp @@ -22,7 +22,6 @@ #include "comm.h" #include "modify.h" #include "fix_gravity.h" -#include "fix_shear_history.h" #include "domain.h" #include "region.h" #include "region_block.h" @@ -270,15 +269,6 @@ void FixPour::init() fabs(zgrav) > EPSILON) error->all("Gravity must point in -y to use with fix pour in 2d"); } - - // check if a shear history fix exists - - fix_history = NULL; - if (force->pair_match("gran/hooke/history",1) || - force->pair_match("gran/hertz/history",1)) - for (int i = 0; i < modify->nfix; i++) - if (strcmp(modify->fix[i]->style,"SHEAR_HISTORY") == 0) - fix_history = (FixShearHistory *) modify->fix[i]; } /* ---------------------------------------------------------------------- @@ -419,12 +409,15 @@ void FixPour::pre_exchange() // set npartner for new atom to 0 (assume not touching any others) AtomVec *avec = atom->avec; - int m,flag; + int j,m,flag; double denstmp,vxtmp,vytmp,vztmp; double g = 1.0; double *sublo = domain->sublo; double *subhi = domain->subhi; + int nfix = modify->nfix; + Fix **fix = modify->fix; + for (i = nprevious; i < nnear; i++) { coord[0] = xnear[i][0]; coord[1] = xnear[i][1]; @@ -464,7 +457,8 @@ void FixPour::pre_exchange() atom->v[m][0] = vxtmp; atom->v[m][1] = vytmp; atom->v[m][2] = vztmp; - if (fix_history) fix_history->npartner[m] = 0; + for (j = 0; j < nfix; j++) + if (fix[j]->create_attribute) fix[j]->set_arrays(m); } } diff --git a/src/GRANULAR/fix_wall_gran.cpp b/src/GRANULAR/fix_wall_gran.cpp index 27f9890c09..52b801ad1b 100644 --- a/src/GRANULAR/fix_wall_gran.cpp +++ b/src/GRANULAR/fix_wall_gran.cpp @@ -52,7 +52,8 @@ FixWallGran::FixWallGran(LAMMPS *lmp, int narg, char **arg) : error->all("Fix wall/gran requires atom attributes radius, omega, torque"); restart_peratom = 1; - + create_attribute = 1; + // wall/particle coefficients kn = atof(arg[3]); @@ -689,6 +690,15 @@ void FixWallGran::copy_arrays(int i, int j) shear[j][2] = shear[i][2]; } +/* ---------------------------------------------------------------------- + initialize one atom's array values, called when atom is created +------------------------------------------------------------------------- */ + +void FixWallGran::set_arrays(int i) +{ + shear[i][0] = shear[i][1] = shear[i][2] = 0.0; +} + /* ---------------------------------------------------------------------- pack values in local atom-based arrays for exchange with another proc ------------------------------------------------------------------------- */ diff --git a/src/GRANULAR/fix_wall_gran.h b/src/GRANULAR/fix_wall_gran.h index e843cf0022..268d433917 100644 --- a/src/GRANULAR/fix_wall_gran.h +++ b/src/GRANULAR/fix_wall_gran.h @@ -31,6 +31,7 @@ class FixWallGran : public Fix { double memory_usage(); void grow_arrays(int); void copy_arrays(int, int); + void set_arrays(int); int pack_exchange(int, double *); int unpack_exchange(int, double *); int pack_restart(int, double *); diff --git a/src/MOLECULE/atom_vec_angle.cpp b/src/MOLECULE/atom_vec_angle.cpp index ce9215aeea..31f5741461 100644 --- a/src/MOLECULE/atom_vec_angle.cpp +++ b/src/MOLECULE/atom_vec_angle.cpp @@ -569,6 +569,7 @@ void AtomVecAngle::create_atom(int itype, double *coord) molecule[nlocal] = 0; num_bond[nlocal] = 0; num_angle[nlocal] = 0; + nspecial[nlocal][0] = nspecial[nlocal][1] = nspecial[nlocal][2] = 0; atom->nlocal++; } diff --git a/src/MOLECULE/atom_vec_bond.cpp b/src/MOLECULE/atom_vec_bond.cpp index 0d9d621341..1ce170bff5 100644 --- a/src/MOLECULE/atom_vec_bond.cpp +++ b/src/MOLECULE/atom_vec_bond.cpp @@ -512,6 +512,7 @@ void AtomVecBond::create_atom(int itype, double *coord) molecule[nlocal] = 0; num_bond[nlocal] = 0; + nspecial[nlocal][0] = nspecial[nlocal][1] = nspecial[nlocal][2] = 0; atom->nlocal++; } diff --git a/src/MOLECULE/atom_vec_full.cpp b/src/MOLECULE/atom_vec_full.cpp index 5aed9d81a2..5d18c80b14 100644 --- a/src/MOLECULE/atom_vec_full.cpp +++ b/src/MOLECULE/atom_vec_full.cpp @@ -713,6 +713,7 @@ void AtomVecFull::create_atom(int itype, double *coord) num_angle[nlocal] = 0; num_dihedral[nlocal] = 0; num_improper[nlocal] = 0; + nspecial[nlocal][0] = nspecial[nlocal][1] = nspecial[nlocal][2] = 0; atom->nlocal++; } diff --git a/src/MOLECULE/atom_vec_molecular.cpp b/src/MOLECULE/atom_vec_molecular.cpp index e3d5a10f8b..f022b88f97 100644 --- a/src/MOLECULE/atom_vec_molecular.cpp +++ b/src/MOLECULE/atom_vec_molecular.cpp @@ -700,6 +700,7 @@ void AtomVecMolecular::create_atom(int itype, double *coord) num_angle[nlocal] = 0; num_dihedral[nlocal] = 0; num_improper[nlocal] = 0; + nspecial[nlocal][0] = nspecial[nlocal][1] = nspecial[nlocal][2] = 0; atom->nlocal++; } diff --git a/src/fix.cpp b/src/fix.cpp index f58077b509..6303e26563 100644 --- a/src/fix.cpp +++ b/src/fix.cpp @@ -54,6 +54,7 @@ Fix::Fix(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) no_change_box = 0; time_integrate = 0; time_depend = 0; + create_attribute = 0; restart_pbc = 0; scalar_flag = vector_flag = peratom_flag = 0; diff --git a/src/fix.h b/src/fix.h index 7bf7f144bc..31ea065fbe 100644 --- a/src/fix.h +++ b/src/fix.h @@ -35,6 +35,8 @@ class Fix : protected Pointers { int no_change_box; // 1 if cannot swap ortho <-> triclinic int time_integrate; // 1 if fix performs time integration, 0 if no int time_depend; // 1 if fix is timestep dependent, 0 if not + int create_attribute; // 1 if fix stores attributes that need + // setting when a new atom is created int restart_pbc; // 1 if fix moves atoms (except integrate) // so that write_restart must remap to PBC @@ -88,6 +90,7 @@ class Fix : protected Pointers { virtual void grow_arrays(int) {} virtual void copy_arrays(int, int) {} + virtual void set_arrays(int) {} virtual int pack_exchange(int, double *) {return 0;} virtual int unpack_exchange(int, double *) {return 0;} virtual int pack_restart(int, double *) {return 0;} diff --git a/src/fix_deposit.cpp b/src/fix_deposit.cpp index b6122fd6a6..0e0aaaf677 100644 --- a/src/fix_deposit.cpp +++ b/src/fix_deposit.cpp @@ -19,6 +19,8 @@ #include "atom_vec.h" #include "force.h" #include "update.h" +#include "modify.h" +#include "fix.h" #include "comm.h" #include "domain.h" #include "lattice.h" @@ -155,6 +157,7 @@ int FixDeposit::setmask() void FixDeposit::pre_exchange() { + int i,j; int flag,flagall; double coord[3],lamda[3],delx,dely,delz,rsq; double *newcoord; @@ -178,7 +181,10 @@ void FixDeposit::pre_exchange() } // attempt an insertion until successful - + + int nfix = modify->nfix; + Fix **fix = modify->fix; + int success = 0; int attempt = 0; while (attempt < maxattempt) { @@ -218,7 +224,7 @@ void FixDeposit::pre_exchange() double **x = atom->x; int nlocal = atom->nlocal; - for (int i = 0; i < nlocal; i++) { + for (i = 0; i < nlocal; i++) { if (localflag) { delx = coord[0] - x[i][0]; dely = coord[1] - x[i][1]; @@ -245,7 +251,7 @@ void FixDeposit::pre_exchange() int nlocal = atom->nlocal; flag = 0; - for (int i = 0; i < nlocal; i++) { + for (i = 0; i < nlocal; i++) { delx = coord[0] - x[i][0]; dely = coord[1] - x[i][1]; delz = coord[2] - x[i][2]; @@ -293,6 +299,8 @@ void FixDeposit::pre_exchange() atom->v[m][0] = vxtmp; atom->v[m][1] = vytmp; atom->v[m][2] = vztmp; + for (j = 0; j < nfix; j++) + if (fix[j]->create_attribute) fix[j]->set_arrays(m); } MPI_Allreduce(&flag,&success,1,MPI_INT,MPI_MAX,world); break; diff --git a/src/fix_rigid.cpp b/src/fix_rigid.cpp index 45dbf21b0d..adc42b88dd 100644 --- a/src/fix_rigid.cpp +++ b/src/fix_rigid.cpp @@ -49,6 +49,7 @@ FixRigid::FixRigid(LAMMPS *lmp, int narg, char **arg) : time_integrate = 1; rigid_flag = 1; virial_flag = 1; + create_attribute = 1; // perform initial allocation of atom-based arrays // register with Atom class @@ -2053,6 +2054,18 @@ void FixRigid::copy_arrays(int i, int j) } } +/* ---------------------------------------------------------------------- + initialize one atom's array values, called when atom is created +------------------------------------------------------------------------- */ + +void FixRigid::set_arrays(int i) +{ + body[i] = -1; + displace[i][0] = 0.0; + displace[i][1] = 0.0; + displace[i][2] = 0.0; +} + /* ---------------------------------------------------------------------- pack values in local atom-based arrays for exchange with another proc ------------------------------------------------------------------------- */ diff --git a/src/fix_rigid.h b/src/fix_rigid.h index 5bd3ad783f..5617ce774b 100644 --- a/src/fix_rigid.h +++ b/src/fix_rigid.h @@ -33,6 +33,7 @@ class FixRigid : public Fix { double memory_usage(); void grow_arrays(int); void copy_arrays(int, int); + void set_arrays(int); int pack_exchange(int, double *); int unpack_exchange(int, double *); diff --git a/src/fix_shake.cpp b/src/fix_shake.cpp index b823f6291d..057797b13a 100644 --- a/src/fix_shake.cpp +++ b/src/fix_shake.cpp @@ -43,12 +43,14 @@ using namespace LAMMPS_NS; FixShake::FixShake(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) { - virial_flag = 1; MPI_Comm_rank(world,&me); MPI_Comm_size(world,&nprocs); PI = 4.0*atan(1.0); + virial_flag = 1; + create_attribute = 1; + // error check if (atom->molecular == 0) @@ -2176,6 +2178,15 @@ void FixShake::copy_arrays(int i, int j) } } +/* ---------------------------------------------------------------------- + initialize one atom's array values, called when atom is created +------------------------------------------------------------------------- */ + +void FixShake::set_arrays(int i) +{ + shake_flag[i] = 0; +} + /* ---------------------------------------------------------------------- pack values in local atom-based arrays for exchange with another proc ------------------------------------------------------------------------- */ diff --git a/src/fix_shake.h b/src/fix_shake.h index 74aa51ebbb..63090b9c61 100644 --- a/src/fix_shake.h +++ b/src/fix_shake.h @@ -32,6 +32,7 @@ class FixShake : public Fix { double memory_usage(); void grow_arrays(int); void copy_arrays(int, int); + void set_arrays(int); int pack_exchange(int, double *); int unpack_exchange(int, double *); int pack_comm(int, int *, double *, int, int *); diff --git a/src/fix_shear_history.cpp b/src/fix_shear_history.cpp index 915286f850..e3f28bad75 100644 --- a/src/fix_shear_history.cpp +++ b/src/fix_shear_history.cpp @@ -34,6 +34,7 @@ FixShearHistory::FixShearHistory(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) { restart_peratom = 1; + create_attribute = 1; // perform initial allocation of atom-based arrays // register with atom class @@ -199,6 +200,15 @@ void FixShearHistory::copy_arrays(int i, int j) } } +/* ---------------------------------------------------------------------- + initialize one atom's array values, called when atom is created +------------------------------------------------------------------------- */ + +void FixShearHistory::set_arrays(int i) +{ + npartner[i] = 0; +} + /* ---------------------------------------------------------------------- pack values in local atom-based arrays for exchange with another proc ------------------------------------------------------------------------- */ diff --git a/src/fix_shear_history.h b/src/fix_shear_history.h index 407981ebc5..0bf07e259f 100644 --- a/src/fix_shear_history.h +++ b/src/fix_shear_history.h @@ -33,6 +33,7 @@ class FixShearHistory : public Fix { double memory_usage(); void grow_arrays(int); void copy_arrays(int, int); + void set_arrays(int); int pack_exchange(int, double *); int unpack_exchange(int, double *); int pack_restart(int, double *);