diff --git a/src/input.cpp b/src/input.cpp index abdc3775ce..ba38112ac8 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -29,6 +29,7 @@ #include "group.h" #include "improper.h" #include "kspace.h" +#include "label_map.h" #include "memory.h" #include "min.h" #include "modify.h" @@ -738,6 +739,7 @@ int Input::execute_command() else if (!strcmp(command,"improper_style")) improper_style(); else if (!strcmp(command,"kspace_modify")) kspace_modify(); else if (!strcmp(command,"kspace_style")) kspace_style(); + else if (!strcmp(command,"labelmap")) labelmap(); else if (!strcmp(command,"lattice")) lattice(); else if (!strcmp(command,"mass")) mass(); else if (!strcmp(command,"min_modify")) min_modify(); @@ -1552,6 +1554,14 @@ void Input::kspace_style() force->create_kspace(arg[0],1); if (force->kspace) force->kspace->settings(narg-1,&arg[1]); } +/* ---------------------------------------------------------------------- */ + +void Input::labelmap() +{ + if (domain->box_exist == 0) + error->all(FLERR,"Labelmap command before simulation box is defined"); + atom->lmap->modify_lmap(narg,arg); +} /* ---------------------------------------------------------------------- */ diff --git a/src/input.h b/src/input.h index b8ffb276f9..e275981d32 100644 --- a/src/input.h +++ b/src/input.h @@ -113,6 +113,7 @@ class Input : protected Pointers { void improper_style(); void kspace_modify(); void kspace_style(); + void labelmap(); void lattice(); void mass(); void min_modify(); diff --git a/src/label_map.cpp b/src/label_map.cpp index cf7223bf0b..9c5db1af01 100755 --- a/src/label_map.cpp +++ b/src/label_map.cpp @@ -80,6 +80,42 @@ void LabelMap::allocate_type_labels() } } +/* ---------------------------------------------------------------------- + labelmap command in input script +------------------------------------------------------------------------- */ + +void LabelMap::modify_lmap(int narg, char **arg) +{ + if (narg < 3 || narg % 2 == 0) error->all(FLERR,"Illegal labelmap command"); + + int ntypes; + std::vector *labels; + if (!strcmp(arg[0],"atom")) { + ntypes = natomtypes; + labels = &typelabel; + } else if (!strcmp(arg[0],"bond")) { + ntypes = nbondtypes; + labels = &btypelabel; + } else if (!strcmp(arg[0],"angle")) { + ntypes = nangletypes; + labels = &atypelabel; + } else if (!strcmp(arg[0],"dihedral")) { + ntypes = ndihedraltypes; + labels = &dtypelabel; + } else if (!strcmp(arg[0],"improper")) { + ntypes = nimpropertypes; + labels = &itypelabel; + } else error->all(FLERR,"Illegal labelmap command"); + + int itype; + int iarg = 1; + while (iarg < narg) { + itype = utils::inumeric(FLERR,arg[iarg++],false,lmp); + if (itype > ntypes) error->all(FLERR,"Topology type exceeds system topology type"); + (*labels)[itype-1] = arg[iarg++]; + } +} + /* ---------------------------------------------------------------------- copy another map (lmap2) into this one if label already exists, leave in place diff --git a/src/label_map.h b/src/label_map.h index 4372ebaa86..a01f238fc3 100755 --- a/src/label_map.h +++ b/src/label_map.h @@ -42,6 +42,7 @@ class LabelMap : protected Pointers { ~LabelMap(); void allocate_type_labels(); + void modify_lmap(int, char **); void merge_lmap(class LabelMap *, int); // copy another lmap into this one void create_lmap2lmap(class LabelMap *, int); // index mapping between two lmaps int find_or_create(std::string, std::vector &, int); // look up type or create new type diff --git a/src/read_data.cpp b/src/read_data.cpp index eb778c5ec2..a8581668aa 100755 --- a/src/read_data.cpp +++ b/src/read_data.cpp @@ -1971,7 +1971,6 @@ void ReadData::impropercoeffs(int which) void ReadData::typelabels(std::vector &mytypelabel, int myntypes, int mode) { if (settypeflag) error->all(FLERR,"Must read Type Labels before any section involving types"); - int n; char *next; char *buf = new char[myntypes*MAXLINE];