From e72cef0c3ad3f863dc15988ce5af05fd6b93b01a Mon Sep 17 00:00:00 2001 From: sjplimp Date: Mon, 11 Jan 2016 22:00:29 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@14421 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/MISC/fix_deposit.cpp | 28 +++++++++++++++++++--------- src/body.h | 4 +++- src/create_atoms.cpp | 35 +++++++++++++++++++++-------------- 3 files changed, 43 insertions(+), 24 deletions(-) diff --git a/src/MISC/fix_deposit.cpp b/src/MISC/fix_deposit.cpp index bfac27fa52..a7729ba839 100644 --- a/src/MISC/fix_deposit.cpp +++ b/src/MISC/fix_deposit.cpp @@ -301,6 +301,13 @@ void FixDeposit::pre_exchange() if (next_reneighbor != update->ntimestep) return; + // clear ghost count and any ghost bonus data internal to AtomVec + // same logic as beginning of Comm::exchange() + // do it now b/c inserting atoms will overwrite ghost atoms + + atom->nghost = 0; + atom->avec->clear_bonus(); + // compute current offset = bottom of insertion volume double offset = 0.0; @@ -524,8 +531,10 @@ void FixDeposit::pre_exchange() atom->v[n][0] = vnew[0]; atom->v[n][1] = vnew[1]; atom->v[n][2] = vnew[2]; - if (mode == MOLECULE) + if (mode == MOLECULE) { + onemols[imol]->quat_external = quat; atom->add_molecule_atom(onemols[imol],m,n,maxtag_all); + } modify->create_attribute(n); } } @@ -559,7 +568,8 @@ void FixDeposit::pre_exchange() // reset global natoms,nbonds,etc // increment maxtag_all and maxmol_all if necessary // if global map exists, reset it now instead of waiting for comm - // since adding atoms messes up ghosts + // since other pre-exchange fixes may use it + // invoke map_init() b/c atom count has grown if (success) { atom->natoms += natom; @@ -576,7 +586,6 @@ void FixDeposit::pre_exchange() error->all(FLERR,"New atom IDs exceed maximum allowed ID"); if (mode == MOLECULE && atom->molecule_flag) maxmol_all++; if (atom->map_style) { - atom->nghost = 0; atom->map_init(); atom->map_set(); } @@ -811,23 +820,24 @@ void *FixDeposit::extract(const char *str, int &itype) } else { - // find a molecule in template with matching type + // loop over onemols molecules + // skip a molecule with no atoms as large as itype + oneradius = 0.0; for (int i = 0; i < nmol; i++) { - if (itype-ntype > onemols[i]->ntypes) continue; + if (itype > ntype+onemols[i]->ntypes) continue; double *radius = onemols[i]->radius; int *type = onemols[i]->type; int natoms = onemols[i]->natoms; - // check radii of matching types in Molecule + // check radii of atoms in Molecule with matching types // default to 0.5, if radii not defined in Molecule // same as atom->avec->create_atom(), invoked in pre_exchange() - oneradius = 0.0; for (int i = 0; i < natoms; i++) - if (type[i] == itype-ntype) { + if (type[i]+ntype == itype) { if (radius) oneradius = MAX(oneradius,radius[i]); - else oneradius = 0.5; + else oneradius = MAX(oneradius,0.5); } } } diff --git a/src/body.h b/src/body.h index 35e2612832..59001620f8 100644 --- a/src/body.h +++ b/src/body.h @@ -41,11 +41,13 @@ class Body : protected Pointers { virtual int unpack_border_body(struct AtomVecBody::Bonus *, double *) {return 0;} - virtual void data_body(int, int, int, char **, char **) = 0; + virtual void data_body(int, int, int, int*, double *) = 0; virtual int noutrow(int) = 0; virtual int noutcol() = 0; virtual void output(int, int, double *) = 0; virtual int image(int, double, double, int *&, double **&) = 0; + + virtual double radius_body(int, int, int *, double *) {return 0.0;} }; } diff --git a/src/create_atoms.cpp b/src/create_atoms.cpp index 22d58bdc64..8b9a1ea7af 100644 --- a/src/create_atoms.cpp +++ b/src/create_atoms.cpp @@ -347,6 +347,13 @@ void CreateAtoms::command(int narg, char **arg) } } + // clear ghost count and any ghost bonus data internal to AtomVec + // same logic as beginning of Comm::exchange() + // do it now b/c creating atoms will overwrite ghost atoms + + atom->nghost = 0; + atom->avec->clear_bonus(); + // add atoms/molecules in one of 3 ways bigint natoms_previous = atom->natoms; @@ -400,11 +407,10 @@ void CreateAtoms::command(int narg, char **arg) if (atom->tag_enable) atom->tag_extend(); atom->tag_check(); - // create global mapping of atoms - // zero nghost in case are adding new atoms to existing atoms + // if global map exists, reset it + // invoke map_init() b/c atom count has grown if (atom->map_style) { - atom->nghost = 0; atom->map_init(); atom->map_set(); } @@ -595,7 +601,7 @@ void CreateAtoms::add_single() if (mode == ATOM) atom->avec->create_atom(ntype,xone); else if (quatone[0] == 0.0 && quatone[1] == 0.0 && quatone[2] == 0.0) add_molecule(xone); - else add_molecule(xone,&quatone[0]); + else add_molecule(xone,quatone); } } @@ -807,24 +813,25 @@ void CreateAtoms::add_molecule(double *center, double *quat_user) int n; double r[3],rotmat[3][3],quat[4],xnew[3]; - if (domain->dimension == 3) { - r[0] = ranmol->uniform() - 0.5; - r[1] = ranmol->uniform() - 0.5; - r[2] = ranmol->uniform() - 0.5; - } else { - r[0] = r[1] = 0.0; - r[2] = 1.0; - } - if (quat_user) { quat[0] = quat_user[0]; quat[1] = quat_user[1]; quat[2] = quat_user[2]; quat[3] = quat_user[3]; } else { - double theta = ranmol->uniform() * MY_2PI; + if (domain->dimension == 3) { + r[0] = ranmol->uniform() - 0.5; + r[1] = ranmol->uniform() - 0.5; + r[2] = ranmol->uniform() - 0.5; + } else { + r[0] = r[1] = 0.0; + r[2] = 1.0; + } MathExtra::norm3(r); + double theta = ranmol->uniform() * MY_2PI; MathExtra::axisangle_to_quat(r,theta,quat); } + MathExtra::quat_to_mat(quat,rotmat); + onemol->quat_external = quat; // create atoms in molecule with atom ID = 0 and mol ID = 0 // reset in caller after all moleclues created by all procs