git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@12157 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -403,6 +403,7 @@ void DeleteAtoms::delete_porosity(int narg, char **arg)
|
|||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
delete atoms in molecules with any deletions
|
delete atoms in molecules with any deletions
|
||||||
use dlist marked with atom deletions, and mark additional atoms
|
use dlist marked with atom deletions, and mark additional atoms
|
||||||
|
do not include molID = 0
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void DeleteAtoms::delete_molecule()
|
void DeleteAtoms::delete_molecule()
|
||||||
@ -414,9 +415,11 @@ void DeleteAtoms::delete_molecule()
|
|||||||
tagint *molecule = atom->molecule;
|
tagint *molecule = atom->molecule;
|
||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
|
|
||||||
for (int i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++) {
|
||||||
|
if (molecule[i] == 0) continue;
|
||||||
if (dlist[i] && hash->find(molecule[i]) == hash->end())
|
if (dlist[i] && hash->find(molecule[i]) == hash->end())
|
||||||
(*hash)[molecule[i]] = 1;
|
(*hash)[molecule[i]] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
// list = set of unique molecule IDs from which I deleted atoms
|
// list = set of unique molecule IDs from which I deleted atoms
|
||||||
// pass list to all other procs via comm->ring()
|
// pass list to all other procs via comm->ring()
|
||||||
|
|||||||
@ -20,6 +20,7 @@
|
|||||||
#include "domain.h"
|
#include "domain.h"
|
||||||
#include "atom.h"
|
#include "atom.h"
|
||||||
#include "force.h"
|
#include "force.h"
|
||||||
|
#include "comm.h"
|
||||||
#include "region.h"
|
#include "region.h"
|
||||||
#include "modify.h"
|
#include "modify.h"
|
||||||
#include "fix.h"
|
#include "fix.h"
|
||||||
@ -31,6 +32,8 @@
|
|||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
#define MAX_GROUP 32
|
#define MAX_GROUP 32
|
||||||
@ -40,6 +43,10 @@ enum{LT,LE,GT,GE,EQ,NEQ,BETWEEN};
|
|||||||
|
|
||||||
#define BIG 1.0e20
|
#define BIG 1.0e20
|
||||||
|
|
||||||
|
// allocate space for static class variable
|
||||||
|
|
||||||
|
Group *Group::cptr;
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
initialize group memory
|
initialize group memory
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
@ -133,6 +140,21 @@ void Group::assign(int narg, char **arg)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clear the group
|
||||||
|
|
||||||
|
if (strcmp(arg[1],"clear") == 0) {
|
||||||
|
int igroup = find(arg[0]);
|
||||||
|
if (igroup == -1) error->all (FLERR,"Could not find group clear group ID");
|
||||||
|
if (igroup == 0) error->all (FLERR,"Cannot clear group all");
|
||||||
|
|
||||||
|
int *mask = atom->mask;
|
||||||
|
int nlocal = atom->nlocal;
|
||||||
|
int bits = inversemask[igroup];
|
||||||
|
for (i = 0; i < nlocal; i++) mask[i] &= bits;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// find group in existing list
|
// find group in existing list
|
||||||
// add a new group if igroup = -1
|
// add a new group if igroup = -1
|
||||||
|
|
||||||
@ -330,6 +352,16 @@ void Group::assign(int narg, char **arg)
|
|||||||
|
|
||||||
memory->destroy(aflag);
|
memory->destroy(aflag);
|
||||||
|
|
||||||
|
// style = include
|
||||||
|
|
||||||
|
} else if (strcmp(arg[1],"include") == 0) {
|
||||||
|
|
||||||
|
if (narg != 3) error->all(FLERR,"Illegal group command");
|
||||||
|
if (strcmp(arg[2],"molecule") != 0)
|
||||||
|
error->all(FLERR,"Illegal group command");
|
||||||
|
|
||||||
|
add_molecules(igroup,bit);
|
||||||
|
|
||||||
// style = subtract
|
// style = subtract
|
||||||
|
|
||||||
} else if (strcmp(arg[1],"subtract") == 0) {
|
} else if (strcmp(arg[1],"subtract") == 0) {
|
||||||
@ -567,6 +599,69 @@ int Group::find_unused()
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
add atoms to group that are in same molecules as atoms already in group
|
||||||
|
do not include molID = 0
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void Group::add_molecules(int igroup, int bit)
|
||||||
|
{
|
||||||
|
// hash = unique molecule IDs of atoms already in group
|
||||||
|
|
||||||
|
hash = new std::map<tagint,int>();
|
||||||
|
|
||||||
|
tagint *molecule = atom->molecule;
|
||||||
|
int *mask = atom->mask;
|
||||||
|
int nlocal = atom->nlocal;
|
||||||
|
|
||||||
|
for (int i = 0; i < nlocal; i++)
|
||||||
|
if (mask[i] & bit) {
|
||||||
|
if (molecule[i] == 0) continue;
|
||||||
|
if (hash->find(molecule[i]) == hash->end()) (*hash)[molecule[i]] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// list = set of unique molecule IDs for atoms to add
|
||||||
|
// pass list to all other procs via comm->ring()
|
||||||
|
|
||||||
|
int n = hash->size();
|
||||||
|
tagint *list;
|
||||||
|
memory->create(list,n,"group:list");
|
||||||
|
|
||||||
|
n = 0;
|
||||||
|
std::map<tagint,int>::iterator pos;
|
||||||
|
for (pos = hash->begin(); pos != hash->end(); ++pos) list[n++] = pos->first;
|
||||||
|
|
||||||
|
cptr = this;
|
||||||
|
molbit = bit;
|
||||||
|
comm->ring(n,sizeof(tagint),list,1,molring,NULL);
|
||||||
|
|
||||||
|
delete hash;
|
||||||
|
memory->destroy(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
callback from comm->ring()
|
||||||
|
cbuf = list of N molecule IDs, put them in hash
|
||||||
|
loop over my atoms, if matches molecule ID in hash,
|
||||||
|
add atom to group flagged by molbit
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void Group::molring(int n, char *cbuf)
|
||||||
|
{
|
||||||
|
tagint *list = (tagint *) cbuf;
|
||||||
|
std::map<tagint,int> *hash = cptr->hash;
|
||||||
|
int nlocal = cptr->atom->nlocal;
|
||||||
|
tagint *molecule = cptr->atom->molecule;
|
||||||
|
int *mask = cptr->atom->mask;
|
||||||
|
int molbit = cptr->molbit;
|
||||||
|
|
||||||
|
hash->clear();
|
||||||
|
for (int i = 0; i < n; i++) (*hash)[list[i]] = 1;
|
||||||
|
|
||||||
|
for (int i = 0; i < nlocal; i++)
|
||||||
|
if (hash->find(molecule[i]) != hash->end()) mask[i] |= molbit;
|
||||||
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
write group info to a restart file
|
write group info to a restart file
|
||||||
only called by proc 0
|
only called by proc 0
|
||||||
|
|||||||
10
src/group.h
10
src/group.h
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
#include "pointers.h"
|
#include "pointers.h"
|
||||||
|
#include <map>
|
||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
@ -63,8 +64,17 @@ class Group : protected Pointers {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
int me;
|
int me;
|
||||||
|
std::map<tagint,int> *hash;
|
||||||
|
|
||||||
int find_unused();
|
int find_unused();
|
||||||
|
void add_molecules(int, int);
|
||||||
|
|
||||||
|
// static variable for ring communication callback to access class data
|
||||||
|
// callback functions for ring communication
|
||||||
|
|
||||||
|
static Group *cptr;
|
||||||
|
static void molring(int, char *);
|
||||||
|
int molbit;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user