diff --git a/doc/src/delete_atoms.rst b/doc/src/delete_atoms.rst index d47743071b..e25e314310 100644 --- a/doc/src/delete_atoms.rst +++ b/doc/src/delete_atoms.rst @@ -20,8 +20,10 @@ Syntax cutoff = delete one atom from pairs of atoms within the cutoff (distance units) group1-ID = one atom in pair must be in this group group2-ID = other atom in pair must be in this group - *porosity* args = region-ID fraction seed + *porosity* args = group-ID region-ID fraction seed + group-ID = group within which to perform deletions region-ID = region within which to perform deletions + or NULL to only impose the group criterion fraction = delete this fraction of atoms seed = random number seed (positive integer) @@ -43,7 +45,8 @@ Examples delete_atoms region sphere compress no delete_atoms overlap 0.3 all all delete_atoms overlap 0.5 solvent colloid - delete_atoms porosity cube 0.1 482793 bond yes + delete_atoms porosity all cube 0.1 482793 bond yes + delete_atoms porosity polymer cube 0.1 482793 bond yes Description """"""""""" @@ -76,12 +79,17 @@ have occurred that no atom pairs within the cutoff will remain minimum number of atoms will be deleted, or that the same atoms will be deleted when running on different numbers of processors. -For style *porosity* a specified *fraction* of atoms are deleted -within the specified region. For example, if fraction is 0.1, then -10% of the atoms will be deleted. The atoms to delete are chosen -randomly. There is no guarantee that the exact fraction of atoms will -be deleted, or that the same atoms will be deleted when running on -different numbers of processors. +For style *porosity* a specified *fraction* of atoms are deleted which +are both in the specified group and within the specified region. The +region-ID can be specified as NULL to only impose the group +criterion. Likewise, specifying the group-ID as *all* will only impose +the region criterion. + +For example, if fraction is 0.1, then 10% of the eligible atoms will +be deleted. The atoms to delete are chosen randomly. There is no +guarantee that the exact fraction of atoms will be deleted, or that +the same atoms will be deleted when running on different numbers of +processors. If the *compress* keyword is set to *yes*, then after atoms are deleted, then atom IDs are re-assigned so that they run from 1 to the diff --git a/src/delete_atoms.cpp b/src/delete_atoms.cpp index 55b05e3d98..ad6efa13f0 100644 --- a/src/delete_atoms.cpp +++ b/src/delete_atoms.cpp @@ -422,15 +422,23 @@ void DeleteAtoms::delete_overlap(int narg, char **arg) void DeleteAtoms::delete_porosity(int narg, char **arg) { - if (narg < 4) error->all(FLERR,"Illegal delete_atoms command"); + if (narg < 5) error->all(FLERR,"Illegal delete_atoms command"); - int iregion = domain->find_region(arg[1]); - if (iregion == -1) error->all(FLERR,"Could not find delete_atoms region ID"); - domain->regions[iregion]->prematch(); + int igroup = group->find(arg[1]); + if (igroup == -1) error->all(FLERR,"Could not find delete_atoms group ID"); - double porosity_fraction = utils::numeric(FLERR,arg[2],false,lmp); - int seed = utils::inumeric(FLERR,arg[3],false,lmp); - options(narg-4,&arg[4]); + int iregion,regionflag; + if (strcmp(arg[2],"NULL") == 0) regionflag = 0; + else { + regionflag = 1; + int iregion = domain->find_region(arg[2]); + if (iregion == -1) error->all(FLERR,"Could not find delete_atoms region ID"); + domain->regions[iregion]->prematch(); + } + + double porosity_fraction = utils::numeric(FLERR,arg[3],false,lmp); + int seed = utils::inumeric(FLERR,arg[4],false,lmp); + options(narg-5,&arg[5]); RanMars *random = new RanMars(lmp,seed + comm->me); @@ -440,11 +448,18 @@ void DeleteAtoms::delete_porosity(int narg, char **arg) memory->create(dlist,nlocal,"delete_atoms:dlist"); for (int i = 0; i < nlocal; i++) dlist[i] = 0; - double **x = atom->x; + // delete fraction of atoms in both group and region - for (int i = 0; i < nlocal; i++) - if (domain->regions[iregion]->match(x[i][0],x[i][1],x[i][2])) + double **x = atom->x; + int *mask = atom->mask; + + int groupbit = group->bitmask[igroup]; + + for (int i = 0; i < nlocal; i++) { + if (!(mask[i] & groupbit)) continue; + if (regionflag && domain->regions[iregion]->match(x[i][0],x[i][1],x[i][2])) if (random->uniform() <= porosity_fraction) dlist[i] = 1; + } delete random; }