diff --git a/src/SHOCK/fix_append_atoms.cpp b/src/SHOCK/fix_append_atoms.cpp index 66580c6bfa..9b2f92b9f6 100644 --- a/src/SHOCK/fix_append_atoms.cpp +++ b/src/SHOCK/fix_append_atoms.cpp @@ -60,6 +60,13 @@ FixAppendAtoms::FixAppendAtoms(LAMMPS *lmp, int narg, char **arg) : randomx = NULL; randomt = NULL; + if (!domain->lattice) + error->all(FLERR,"Fix append/atoms requires a lattice be defined"); + + nbasis = domain->lattice->nbasis; + basistype = new int[nbasis]; + for (int i = 0; i < nbasis; i++) basistype[i] = 1; + int iarg = 0; iarg = 3; while (iarg < narg) { @@ -117,6 +124,16 @@ FixAppendAtoms::FixAppendAtoms(LAMMPS *lmp, int narg, char **arg) : strcpy(spatialid,suffix); delete [] suffix; iarg += 3; + } else if (strcmp(arg[iarg],"basis") == 0) { + if (iarg+3 > narg) error->all(FLERR,"Illegal fix append/atoms command"); + if (domain->lattice == NULL) + error->all(FLERR,"Must define lattice to append/atoms"); + int ibasis = atoi(arg[iarg+1]); + int itype = atoi(arg[iarg+2]); + if (ibasis <= 0 || ibasis > nbasis || itype <= 0 || itype > atom->ntypes) + error->all(FLERR,"Illegal fix append/atoms command"); + basistype[ibasis-1] = itype; + iarg += 3; } else if (strcmp(arg[iarg],"size") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix append/atoms command"); size = atof(arg[iarg+1]); @@ -193,6 +210,8 @@ FixAppendAtoms::FixAppendAtoms(LAMMPS *lmp, int narg, char **arg) : FixAppendAtoms::~FixAppendAtoms() { + delete [] basistype; + if (ranflag) delete randomx; if (tempflag) { delete randomt; @@ -396,12 +415,6 @@ void FixAppendAtoms::pre_exchange() if (ntimestep % freq == 0) { if (spatflag==1) if (get_spatial()==0) return; if (comm->myloc[2] == comm->procgrid[2]-1) { - if (domain->lattice) { - nbasis = domain->lattice->nbasis; - basistype = new int[nbasis]; - for (int i = 0; i < nbasis; i++) basistype[i] = 1; - } else error->all(FLERR,"Must define lattice to append/atoms"); - double bboxlo[3],bboxhi[3]; bboxlo[0] = domain->sublo[0]; bboxhi[0] = domain->subhi[0]; diff --git a/src/SHOCK/fix_append_atoms.h b/src/SHOCK/fix_append_atoms.h index dca43d5ec2..5b374c9c87 100644 --- a/src/SHOCK/fix_append_atoms.h +++ b/src/SHOCK/fix_append_atoms.h @@ -42,9 +42,10 @@ class FixAppendAtoms : public Fix { class RanMars *randomx; class RanMars *randomt; int scaleflag, freq; - int *basistype, nbasis; - int advance, advance_sum; - double size, spatlead; + int nbasis; + int *basistype; + int advance,advance_sum; + double size,spatlead; char *spatialid; double tfactor; double *gfactor1,*gfactor2;