basic support for auxiliary label maps
can be created with labelmap via mapID keyword referenced like mymapID::C where C is an atom type, for example
This commit is contained in:
30
src/atom.cpp
30
src/atom.cpp
@ -204,6 +204,7 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp)
|
||||
|
||||
// type labels
|
||||
|
||||
nlmap = 0;
|
||||
lmaps = nullptr;
|
||||
|
||||
// custom atom arrays
|
||||
@ -1990,7 +1991,7 @@ void Atom::add_molecule_atom(Molecule *onemol, int iatom,
|
||||
allocate space for type label map
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Atom::add_label_map(std::string mapID)
|
||||
int Atom::add_label_map(std::string mapID)
|
||||
{
|
||||
labelmapflag = 1;
|
||||
lmaps = (LabelMap **)
|
||||
@ -2005,6 +2006,7 @@ void Atom::add_label_map(std::string mapID)
|
||||
lmaps[nlmap]->nimpropertypes = nimpropertypes;
|
||||
lmaps[nlmap]->allocate_type_labels();
|
||||
nlmap++;
|
||||
return nlmap - 1;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -2014,13 +2016,33 @@ void Atom::add_label_map(std::string mapID)
|
||||
|
||||
int Atom::find_label(std::string label, int mode)
|
||||
{
|
||||
// find label map ... in progress
|
||||
int ilmap;
|
||||
ilmap = 0;
|
||||
int ilmap = 0;
|
||||
|
||||
// check for auxiliary map prefix
|
||||
|
||||
int pos = label.find("::");
|
||||
if (pos != std::string::npos) {
|
||||
ilmap = find_labelmap(label.substr(0,pos));
|
||||
if (ilmap == -1) return -1;
|
||||
label = label.substr(pos+2);
|
||||
}
|
||||
|
||||
return lmaps[ilmap]->find(label,mode);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
find first label map in set with ID
|
||||
return -1 if does not exist
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int Atom::find_labelmap(std::string id)
|
||||
{
|
||||
int ilmap;
|
||||
for (ilmap = 0; ilmap < nlmap; ilmap++)
|
||||
if (id == lmaps[ilmap]->id) return ilmap;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
reorder owned atoms so those in firstgroup appear first
|
||||
called by comm->exchange() if atom_modify first group is set
|
||||
|
||||
@ -329,8 +329,9 @@ class Atom : protected Pointers {
|
||||
int find_molecule(char *);
|
||||
void add_molecule_atom(class Molecule *, int, int, tagint);
|
||||
|
||||
void add_label_map(std::string mapID = "");
|
||||
int add_label_map(std::string mapID = "");
|
||||
int find_label(std::string, int);
|
||||
int find_labelmap(std::string);
|
||||
|
||||
void first_reorder();
|
||||
virtual void sort();
|
||||
|
||||
@ -1592,10 +1592,26 @@ void Input::kspace_style()
|
||||
|
||||
void Input::labelmap()
|
||||
{
|
||||
if (narg < 2 || (narg % 2 == 0)) error->all(FLERR,"Illegal labelmap command");
|
||||
if (domain->box_exist == 0)
|
||||
error->all(FLERR,"Labelmap command before simulation box is defined");
|
||||
|
||||
if (!atom->labelmapflag) atom->add_label_map();
|
||||
atom->lmaps[0]->modify_lmap(narg,arg);
|
||||
|
||||
int ilmap = 0;
|
||||
std::string mapid;
|
||||
for (int i = 1; i < narg; i++) {
|
||||
if (strcmp(arg[i],"mapID") == 0) {
|
||||
mapid = arg[i+1];
|
||||
ilmap = atom->find_labelmap(mapid);
|
||||
if (ilmap == -1) ilmap = atom->add_label_map(mapid);
|
||||
if (narg > i+2) error->all(FLERR,"Illegal labelmap command");
|
||||
narg = i - 2;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
atom->lmaps[ilmap]->modify_lmap(narg,arg);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
Reference in New Issue
Block a user