From c4330298e1410f8653ec3fc1b043f8658245ffde Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Mon, 15 Nov 2021 23:24:57 -0500 Subject: [PATCH] enforce unique labels when using labelmap command --- doc/src/labelmap.rst | 18 +++++++++--------- src/label_map.cpp | 2 ++ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/doc/src/labelmap.rst b/doc/src/labelmap.rst index 4fd67798b2..e0e289979a 100644 --- a/doc/src/labelmap.rst +++ b/doc/src/labelmap.rst @@ -56,12 +56,11 @@ Type Label sections. The label map of only one type of interaction (atom, bond, etc.) may be modified by a given *labelmap* command. Any number of numeric-type/type-label pairs may follow. If a type label already -exists for a given numeric type, it will be overwritten. Assigning the -same type label to multiple numeric types is permitted; how this -ambiguity is treated may depend on the feature utilizing type labels. -There does not need to be a type label associated with every numeric -type; in this case, those types without a label must be referenced by -their numeric type. +exists for a given numeric type, it will be overwritten. Types labels +must be unique; assigning the same type label to multiple numeric +types is not permitted. There does not need to be a type label +associated with every numeric type; in this case, those types without +a label must be referenced by their numeric type. For certain features, it is necessary to be able to extract the atom types that make up a given bond, angle, dihedral or improper. The @@ -95,9 +94,10 @@ substring "::". The default label map has no prefix. Restrictions """""""""""" -This command must come after the simulation box is defined by a -:doc:`read_data `, :doc:`read_restart `, or -:doc:`create_box ` command. +Type labels cannot contain the symbols '#' or '*'. This command must +come after the simulation box is defined by a :doc:`read_data `, +:doc:`read_restart `, or :doc:`create_box ` +command. Related commands """""""""""""""" diff --git a/src/label_map.cpp b/src/label_map.cpp index e9c677bbe7..e99a43aa0b 100644 --- a/src/label_map.cpp +++ b/src/label_map.cpp @@ -101,6 +101,8 @@ void LabelMap::modify_lmap(int narg, char **arg) std::string slabel(arg[iarg++]); if (isdigit(slabel[0])) error->all(FLERR,"Type labels cannot start with a number"); + if (search(slabel,(*labels),ntypes) != -1) + error->all(FLERR,"Type label already exists: types labels must be unique"); (*labels)[itype-1] = slabel; } }