initialize LabelMap class through constructor, properly wipe out old data
This commit is contained in:
17
src/atom.cpp
17
src/atom.cpp
@ -55,9 +55,9 @@ using namespace MathConst;
|
|||||||
one instance per AtomVec style in style_atom.h
|
one instance per AtomVec style in style_atom.h
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
template <typename T> static AtomVec *avec_creator(LAMMPS *lmp)
|
template <typename T> static AtomVec *avec_creator(LAMMPS *_lmp)
|
||||||
{
|
{
|
||||||
return new T(lmp);
|
return new T(_lmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
@ -89,7 +89,7 @@ are updated by the AtomVec class as needed.
|
|||||||
*
|
*
|
||||||
* \param lmp pointer to the base LAMMPS class */
|
* \param lmp pointer to the base LAMMPS class */
|
||||||
|
|
||||||
Atom::Atom(LAMMPS *lmp) : Pointers(lmp)
|
Atom::Atom(LAMMPS *_lmp) : Pointers(_lmp)
|
||||||
{
|
{
|
||||||
natoms = 0;
|
natoms = 0;
|
||||||
nlocal = nghost = nmax = 0;
|
nlocal = nghost = nmax = 0;
|
||||||
@ -2086,16 +2086,7 @@ void Atom::add_molecule_atom(Molecule *onemol, int iatom, int ilocal, tagint off
|
|||||||
void Atom::add_label_map()
|
void Atom::add_label_map()
|
||||||
{
|
{
|
||||||
labelmapflag = 1;
|
labelmapflag = 1;
|
||||||
lmap = (LabelMap *)
|
lmap = new LabelMap(lmp,ntypes,nbondtypes,nangletypes,ndihedraltypes,nimpropertypes);
|
||||||
memory->srealloc(lmap,sizeof(LabelMap *),
|
|
||||||
"atom::lmap");
|
|
||||||
lmap = new LabelMap(lmp);
|
|
||||||
lmap->natomtypes = ntypes;
|
|
||||||
lmap->nbondtypes = nbondtypes;
|
|
||||||
lmap->nangletypes = nangletypes;
|
|
||||||
lmap->ndihedraltypes = ndihedraltypes;
|
|
||||||
lmap->nimpropertypes = nimpropertypes;
|
|
||||||
lmap->allocate_type_labels();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
|
|||||||
@ -25,10 +25,15 @@ using namespace LAMMPS_NS;
|
|||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
LabelMap::LabelMap(LAMMPS *lmp) : Pointers(lmp)
|
LabelMap::LabelMap(LAMMPS *_lmp, int _natomtypes, int _nbondtypes, int _nangletypes,
|
||||||
|
int _ndihedraltypes, int _nimpropertypes) :
|
||||||
|
Pointers(_lmp),
|
||||||
|
natomtypes(_natomtypes), nbondtypes(_nbondtypes), nangletypes(_nangletypes),
|
||||||
|
ndihedraltypes(_ndihedraltypes), nimpropertypes(_nimpropertypes)
|
||||||
{
|
{
|
||||||
natomtypes = nbondtypes = nangletypes = 0;
|
lmap2lmap.atom = lmap2lmap.bond = lmap2lmap.angle = lmap2lmap.dihedral = lmap2lmap.improper =
|
||||||
ndihedraltypes = nimpropertypes = 0;
|
nullptr;
|
||||||
|
allocate_type_labels();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
@ -49,19 +54,34 @@ LabelMap::~LabelMap()
|
|||||||
void LabelMap::allocate_type_labels()
|
void LabelMap::allocate_type_labels()
|
||||||
{
|
{
|
||||||
typelabel.resize(natomtypes);
|
typelabel.resize(natomtypes);
|
||||||
|
delete[] lmap2lmap.atom;
|
||||||
lmap2lmap.atom = new int[natomtypes];
|
lmap2lmap.atom = new int[natomtypes];
|
||||||
|
for (auto &i : typelabel) i.clear();
|
||||||
|
memset(lmap2lmap.atom, 0, natomtypes * sizeof(int));
|
||||||
|
|
||||||
btypelabel.resize(nbondtypes);
|
btypelabel.resize(nbondtypes);
|
||||||
|
delete[] lmap2lmap.bond;
|
||||||
|
for (auto &i : btypelabel) i.clear();
|
||||||
lmap2lmap.bond = new int[nbondtypes];
|
lmap2lmap.bond = new int[nbondtypes];
|
||||||
|
memset(lmap2lmap.bond, 0, nbondtypes * sizeof(int));
|
||||||
|
|
||||||
atypelabel.resize(nangletypes);
|
atypelabel.resize(nangletypes);
|
||||||
|
delete[] lmap2lmap.angle;
|
||||||
|
for (auto &i : atypelabel) i.clear();
|
||||||
lmap2lmap.angle = new int[nangletypes];
|
lmap2lmap.angle = new int[nangletypes];
|
||||||
|
memset(lmap2lmap.angle, 0, nangletypes * sizeof(int));
|
||||||
|
|
||||||
dtypelabel.resize(ndihedraltypes);
|
dtypelabel.resize(ndihedraltypes);
|
||||||
|
delete[] lmap2lmap.dihedral;
|
||||||
|
for (auto &i : dtypelabel) i.clear();
|
||||||
lmap2lmap.dihedral = new int[ndihedraltypes];
|
lmap2lmap.dihedral = new int[ndihedraltypes];
|
||||||
|
memset(lmap2lmap.dihedral, 0, ndihedraltypes * sizeof(int));
|
||||||
|
|
||||||
itypelabel.resize(nimpropertypes);
|
itypelabel.resize(nimpropertypes);
|
||||||
|
delete[] lmap2lmap.improper;
|
||||||
|
for (auto &i : itypelabel) i.clear();
|
||||||
lmap2lmap.improper = new int[nimpropertypes];
|
lmap2lmap.improper = new int[nimpropertypes];
|
||||||
|
memset(lmap2lmap.dihedral, 0, nimpropertypes * sizeof(int));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
@ -70,7 +90,8 @@ void LabelMap::allocate_type_labels()
|
|||||||
|
|
||||||
void LabelMap::modify_lmap(int narg, char **arg)
|
void LabelMap::modify_lmap(int narg, char **arg)
|
||||||
{
|
{
|
||||||
if (narg < 3 || narg % 2 == 0) error->all(FLERR,"Illegal labelmap command");
|
if (narg < 3 || narg % 2 == 0)
|
||||||
|
error->all(FLERR, "Incorrect number of arguments for labelmap command");
|
||||||
|
|
||||||
int ntypes;
|
int ntypes;
|
||||||
std::vector<std::string> *labels;
|
std::vector<std::string> *labels;
|
||||||
@ -96,18 +117,20 @@ void LabelMap::modify_lmap(int narg, char **arg)
|
|||||||
ntypes = nimpropertypes;
|
ntypes = nimpropertypes;
|
||||||
labels = &itypelabel;
|
labels = &itypelabel;
|
||||||
labels_map = &itypelabel_map;
|
labels_map = &itypelabel_map;
|
||||||
} else error->all(FLERR,"Illegal labelmap command");
|
} else
|
||||||
|
error->all(FLERR, "Unknown labelmap type {}", tlabel);
|
||||||
|
|
||||||
int iarg = 1;
|
int iarg = 1;
|
||||||
while (iarg < narg) {
|
while (iarg < narg) {
|
||||||
int itype = utils::inumeric(FLERR, arg[iarg++], false, lmp);
|
int itype = utils::inumeric(FLERR, arg[iarg++], false, lmp);
|
||||||
if (itype > ntypes)
|
if (itype > ntypes)
|
||||||
error->all(FLERR,"Topology type exceeds system topology type");
|
error->all(FLERR, "Assigned {} type {} is larger than allowed maximum of {}", tlabel, itype,
|
||||||
|
ntypes);
|
||||||
std::string slabel(arg[iarg++]);
|
std::string slabel(arg[iarg++]);
|
||||||
if (isdigit(slabel[0]))
|
if (isdigit(slabel[0]))
|
||||||
error->all(FLERR,"Type labels cannot start with a number");
|
error->all(FLERR, "Label {} for {} type must not start with a number", slabel, tlabel);
|
||||||
if (search(slabel, (*labels_map)) != -1)
|
if (search(slabel, (*labels_map)) != -1)
|
||||||
error->all(FLERR,"Type label already exists: type labels must be unique");
|
error->all(FLERR, "The {} type label {} already exists: type labels must be unique");
|
||||||
std::string &str = (*labels)[itype - 1];
|
std::string &str = (*labels)[itype - 1];
|
||||||
if (!str.empty()) (*labels_map).erase(str);
|
if (!str.empty()) (*labels_map).erase(str);
|
||||||
str = slabel;
|
str = slabel;
|
||||||
@ -123,27 +146,21 @@ void LabelMap::modify_lmap(int narg, char **arg)
|
|||||||
|
|
||||||
void LabelMap::merge_lmap(LabelMap *lmap2, int mode)
|
void LabelMap::merge_lmap(LabelMap *lmap2, int mode)
|
||||||
{
|
{
|
||||||
switch (mode)
|
switch (mode) {
|
||||||
{
|
|
||||||
case Atom::ATOM:
|
case Atom::ATOM:
|
||||||
for (auto &it : lmap2->typelabel)
|
for (auto &it : lmap2->typelabel) find_or_create(it, typelabel, typelabel_map);
|
||||||
find_or_create(it,typelabel,typelabel_map);
|
|
||||||
break;
|
break;
|
||||||
case Atom::BOND:
|
case Atom::BOND:
|
||||||
for (auto &it : lmap2->btypelabel)
|
for (auto &it : lmap2->btypelabel) find_or_create(it, btypelabel, btypelabel_map);
|
||||||
find_or_create(it,btypelabel,btypelabel_map);
|
|
||||||
break;
|
break;
|
||||||
case Atom::ANGLE:
|
case Atom::ANGLE:
|
||||||
for (auto &it : lmap2->atypelabel)
|
for (auto &it : lmap2->atypelabel) find_or_create(it, atypelabel, atypelabel_map);
|
||||||
find_or_create(it,atypelabel,atypelabel_map);
|
|
||||||
break;
|
break;
|
||||||
case Atom::DIHEDRAL:
|
case Atom::DIHEDRAL:
|
||||||
for (auto &it : lmap2->dtypelabel)
|
for (auto &it : lmap2->dtypelabel) find_or_create(it, dtypelabel, dtypelabel_map);
|
||||||
find_or_create(it,dtypelabel,dtypelabel_map);
|
|
||||||
break;
|
break;
|
||||||
case Atom::IMPROPER:
|
case Atom::IMPROPER:
|
||||||
for (auto &it : lmap2->itypelabel)
|
for (auto &it : lmap2->itypelabel) find_or_create(it, itypelabel, itypelabel_map);
|
||||||
find_or_create(it,itypelabel,itypelabel_map);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -155,8 +172,7 @@ void LabelMap::merge_lmap(LabelMap *lmap2, int mode)
|
|||||||
|
|
||||||
void LabelMap::create_lmap2lmap(LabelMap *lmap2, int mode)
|
void LabelMap::create_lmap2lmap(LabelMap *lmap2, int mode)
|
||||||
{
|
{
|
||||||
switch (mode)
|
switch (mode) {
|
||||||
{
|
|
||||||
case Atom::ATOM:
|
case Atom::ATOM:
|
||||||
for (int i = 0; i < natomtypes; ++i)
|
for (int i = 0; i < natomtypes; ++i)
|
||||||
lmap2lmap.atom[i] = search(typelabel[i], lmap2->typelabel_map);
|
lmap2lmap.atom[i] = search(typelabel[i], lmap2->typelabel_map);
|
||||||
@ -185,8 +201,7 @@ void LabelMap::create_lmap2lmap(LabelMap *lmap2, int mode)
|
|||||||
return numeric type
|
return numeric type
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int LabelMap::find_or_create(const std::string &mylabel,
|
int LabelMap::find_or_create(const std::string &mylabel, std::vector<std::string> &labels,
|
||||||
std::vector<std::string> &labels,
|
|
||||||
std::unordered_map<std::string, int> &labels_map)
|
std::unordered_map<std::string, int> &labels_map)
|
||||||
{
|
{
|
||||||
auto search = labels_map.find(mylabel);
|
auto search = labels_map.find(mylabel);
|
||||||
@ -213,16 +228,14 @@ int LabelMap::find_or_create(const std::string &mylabel,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
return numeric type given a type label
|
return numeric type given a type label
|
||||||
return -1 if type not yet defined
|
return -1 if type not yet defined
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int LabelMap::find(const std::string &mylabel, int mode)
|
int LabelMap::find(const std::string &mylabel, int mode) const
|
||||||
{
|
|
||||||
switch (mode)
|
|
||||||
{
|
{
|
||||||
|
switch (mode) {
|
||||||
case Atom::ATOM:
|
case Atom::ATOM:
|
||||||
return search(mylabel, typelabel_map);
|
return search(mylabel, typelabel_map);
|
||||||
break;
|
break;
|
||||||
@ -249,43 +262,37 @@ int LabelMap::find(const std::string &mylabel, int mode)
|
|||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int LabelMap::search(const std::string &mylabel,
|
int LabelMap::search(const std::string &mylabel,
|
||||||
const std::unordered_map<std::string, int> &labels_map)
|
const std::unordered_map<std::string, int> &labels_map) const
|
||||||
{
|
{
|
||||||
auto search = labels_map.find(mylabel);
|
auto search = labels_map.find(mylabel);
|
||||||
if (search == labels_map.end()) return -1;
|
if (search == labels_map.end()) return -1;
|
||||||
return search->second;
|
return search->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
check that all types have been assigned a unique type label
|
check that all types have been assigned a unique type label
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int LabelMap::is_complete(int mode)
|
bool LabelMap::is_complete(int mode) const
|
||||||
{
|
|
||||||
switch (mode)
|
|
||||||
{
|
{
|
||||||
|
switch (mode) {
|
||||||
case Atom::ATOM:
|
case Atom::ATOM:
|
||||||
return static_cast<int>(typelabel_map.size()) == natomtypes;
|
return static_cast<int>(typelabel_map.size()) == natomtypes;
|
||||||
break;
|
break;
|
||||||
case Atom::BOND:
|
case Atom::BOND:
|
||||||
if (force->bond)
|
if (force->bond) return static_cast<int>(btypelabel_map.size()) == nbondtypes;
|
||||||
return static_cast<int>(btypelabel_map.size()) == nbondtypes;
|
|
||||||
break;
|
break;
|
||||||
case Atom::ANGLE:
|
case Atom::ANGLE:
|
||||||
if (force->angle)
|
if (force->angle) return static_cast<int>(atypelabel_map.size()) == nangletypes;
|
||||||
return static_cast<int>(atypelabel_map.size()) == nangletypes;
|
|
||||||
break;
|
break;
|
||||||
case Atom::DIHEDRAL:
|
case Atom::DIHEDRAL:
|
||||||
if (force->dihedral)
|
if (force->dihedral) return static_cast<int>(dtypelabel_map.size()) == ndihedraltypes;
|
||||||
return static_cast<int>(dtypelabel_map.size()) == ndihedraltypes;
|
|
||||||
break;
|
break;
|
||||||
case Atom::IMPROPER:
|
case Atom::IMPROPER:
|
||||||
if (force->improper)
|
if (force->improper) return static_cast<int>(itypelabel_map.size()) == nimpropertypes;
|
||||||
return static_cast<int>(itypelabel_map.size()) == nimpropertypes;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
@ -296,32 +303,27 @@ void LabelMap::write_data(FILE *fp)
|
|||||||
{
|
{
|
||||||
if (is_complete(Atom::ATOM)) {
|
if (is_complete(Atom::ATOM)) {
|
||||||
fmt::print(fp, "\nAtom Type Labels\n\n");
|
fmt::print(fp, "\nAtom Type Labels\n\n");
|
||||||
for (int i = 0; i < natomtypes; i++)
|
for (int i = 0; i < natomtypes; i++) fmt::print(fp, "{} {}\n", i + 1, typelabel[i]);
|
||||||
fmt::print(fp,"{} {}\n",i+1,typelabel[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (force->bond && is_complete(Atom::BOND)) {
|
if (force->bond && is_complete(Atom::BOND)) {
|
||||||
fmt::print(fp, "\nBond Type Labels\n\n");
|
fmt::print(fp, "\nBond Type Labels\n\n");
|
||||||
for (int i = 0; i < nbondtypes; i++)
|
for (int i = 0; i < nbondtypes; i++) fmt::print(fp, "{} {}\n", i + 1, btypelabel[i]);
|
||||||
fmt::print(fp,"{} {}\n",i+1,btypelabel[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (force->angle && is_complete(Atom::ANGLE)) {
|
if (force->angle && is_complete(Atom::ANGLE)) {
|
||||||
fmt::print(fp, "\nAngle Type Labels\n\n");
|
fmt::print(fp, "\nAngle Type Labels\n\n");
|
||||||
for (int i = 0; i < nangletypes; i++)
|
for (int i = 0; i < nangletypes; i++) fmt::print(fp, "{} {}\n", i + 1, atypelabel[i]);
|
||||||
fmt::print(fp,"{} {}\n",i+1,atypelabel[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (force->dihedral && is_complete(Atom::DIHEDRAL)) {
|
if (force->dihedral && is_complete(Atom::DIHEDRAL)) {
|
||||||
fmt::print(fp, "\nDihedral Type Labels\n\n");
|
fmt::print(fp, "\nDihedral Type Labels\n\n");
|
||||||
for (int i = 0; i < ndihedraltypes; i++)
|
for (int i = 0; i < ndihedraltypes; i++) fmt::print(fp, "{} {}\n", i + 1, dtypelabel[i]);
|
||||||
fmt::print(fp,"{} {}\n",i+1,dtypelabel[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (force->improper && is_complete(Atom::IMPROPER)) {
|
if (force->improper && is_complete(Atom::IMPROPER)) {
|
||||||
fmt::print(fp, "\nImproper Type Labels\n\n");
|
fmt::print(fp, "\nImproper Type Labels\n\n");
|
||||||
for (int i = 0; i < nimpropertypes; i++)
|
for (int i = 0; i < nimpropertypes; i++) fmt::print(fp, "{} {}\n", i + 1, itypelabel[i]);
|
||||||
fmt::print(fp,"{} {}\n",i+1,itypelabel[i]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -375,20 +377,15 @@ void LabelMap::read_restart(FILE *fp)
|
|||||||
|
|
||||||
void LabelMap::write_restart(FILE *fp)
|
void LabelMap::write_restart(FILE *fp)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < natomtypes; i++)
|
for (int i = 0; i < natomtypes; i++) write_string(typelabel[i], fp);
|
||||||
write_string(typelabel[i],fp);
|
|
||||||
|
|
||||||
for (int i = 0; i < nbondtypes; i++)
|
for (int i = 0; i < nbondtypes; i++) write_string(btypelabel[i], fp);
|
||||||
write_string(btypelabel[i],fp);
|
|
||||||
|
|
||||||
for (int i = 0; i < nangletypes; i++)
|
for (int i = 0; i < nangletypes; i++) write_string(atypelabel[i], fp);
|
||||||
write_string(atypelabel[i],fp);
|
|
||||||
|
|
||||||
for (int i = 0; i < ndihedraltypes; i++)
|
for (int i = 0; i < ndihedraltypes; i++) write_string(dtypelabel[i], fp);
|
||||||
write_string(dtypelabel[i],fp);
|
|
||||||
|
|
||||||
for (int i = 0; i < nimpropertypes; i++)
|
for (int i = 0; i < nimpropertypes; i++) write_string(itypelabel[i], fp);
|
||||||
write_string(itypelabel[i],fp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
@ -401,8 +398,7 @@ char *LabelMap::read_string(FILE *fp)
|
|||||||
int n = read_int(fp);
|
int n = read_int(fp);
|
||||||
if (n < 0) error->all(FLERR, "Illegal size string or corrupt restart");
|
if (n < 0) error->all(FLERR, "Illegal size string or corrupt restart");
|
||||||
char *value = new char[n];
|
char *value = new char[n];
|
||||||
if (comm->me == 0)
|
if (comm->me == 0) utils::sfread(FLERR, value, sizeof(char), n, fp, nullptr, error);
|
||||||
utils::sfread(FLERR,value,sizeof(char),n,fp,nullptr,error);
|
|
||||||
MPI_Bcast(value, n, MPI_CHAR, 0, world);
|
MPI_Bcast(value, n, MPI_CHAR, 0, world);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,25 @@
|
|||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class LabelMap : protected Pointers {
|
class LabelMap : protected Pointers {
|
||||||
|
friend class AtomVec;
|
||||||
|
friend class ReadData;
|
||||||
public:
|
public:
|
||||||
|
LabelMap(LAMMPS *lmp, int, int, int, int, int);
|
||||||
|
~LabelMap();
|
||||||
|
|
||||||
|
void modify_lmap(int, char **); // labelmap command in the input script
|
||||||
|
void merge_lmap(LabelMap *, int); // copy another lmap into this one
|
||||||
|
void create_lmap2lmap(LabelMap *, int); // index mapping between two lmaps
|
||||||
|
int find(const std::string &, int) const; // find numeric type of type label
|
||||||
|
bool is_complete(int) const; // check if all types are assigned
|
||||||
|
|
||||||
|
// input/output for atom class label map
|
||||||
|
|
||||||
|
void write_data(FILE *);
|
||||||
|
void read_restart(FILE *fp);
|
||||||
|
void write_restart(FILE *);
|
||||||
|
|
||||||
|
protected:
|
||||||
int natomtypes, nbondtypes, nangletypes, ndihedraltypes, nimpropertypes;
|
int natomtypes, nbondtypes, nangletypes, ndihedraltypes, nimpropertypes;
|
||||||
std::vector<std::string> typelabel, btypelabel, atypelabel;
|
std::vector<std::string> typelabel, btypelabel, atypelabel;
|
||||||
std::vector<std::string> dtypelabel, itypelabel;
|
std::vector<std::string> dtypelabel, itypelabel;
|
||||||
@ -43,30 +61,16 @@ class LabelMap : protected Pointers {
|
|||||||
|
|
||||||
Lmap2Lmap lmap2lmap;
|
Lmap2Lmap lmap2lmap;
|
||||||
|
|
||||||
LabelMap(LAMMPS *lmp);
|
|
||||||
~LabelMap();
|
|
||||||
|
|
||||||
void allocate_type_labels();
|
void allocate_type_labels();
|
||||||
void modify_lmap(int, char **); // labelmap command in the input script
|
int find_or_create(const std::string &, std::vector<std::string> &,
|
||||||
void merge_lmap(class LabelMap *, int); // copy another lmap into this one
|
std::unordered_map<std::string, int> &); // look up type or create new type
|
||||||
void create_lmap2lmap(class LabelMap *, int); // index mapping between two lmaps
|
int search(const std::string &,
|
||||||
int find(const std::string &, int); // find numeric type of type label
|
const std::unordered_map<std::string, int> &) const; // look up type index
|
||||||
int is_complete(int); // check if all types are assigned
|
|
||||||
|
|
||||||
// input/output for atom class label map
|
|
||||||
|
|
||||||
void write_data(FILE *);
|
|
||||||
void read_restart(FILE *fp);
|
|
||||||
void write_restart(FILE *);
|
|
||||||
|
|
||||||
private:
|
|
||||||
int find_or_create(const std::string &, std::vector<std::string> &, std::unordered_map<std::string, int> &); // look up type or create new type
|
|
||||||
int search(const std::string &, const std::unordered_map<std::string, int> &); // look up type index
|
|
||||||
char *read_string(FILE *);
|
char *read_string(FILE *);
|
||||||
void write_string(const std::string &, FILE *);
|
void write_string(const std::string &, FILE *);
|
||||||
int read_int(FILE *);
|
int read_int(FILE *);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace LAMMPS_NS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -533,13 +533,8 @@ void ReadData::command(int narg, char **arg)
|
|||||||
// allocate space for type label map
|
// allocate space for type label map
|
||||||
|
|
||||||
if (firstpass) {
|
if (firstpass) {
|
||||||
lmap = new LabelMap(lmp);
|
delete lmap;
|
||||||
lmap->natomtypes = ntypes;
|
lmap = new LabelMap(lmp,ntypes,nbondtypes,nangletypes,ndihedraltypes,nimpropertypes);
|
||||||
lmap->nbondtypes = nbondtypes;
|
|
||||||
lmap->nangletypes = nangletypes;
|
|
||||||
lmap->ndihedraltypes = ndihedraltypes;
|
|
||||||
lmap->nimpropertypes = nimpropertypes;
|
|
||||||
lmap->allocate_type_labels();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// customize for new sections
|
// customize for new sections
|
||||||
|
|||||||
Reference in New Issue
Block a user