enforce unique labels when using labelmap command
This commit is contained in:
@ -56,12 +56,11 @@ Type Label sections.
|
|||||||
The label map of only one type of interaction (atom, bond, etc.) may
|
The label map of only one type of interaction (atom, bond, etc.) may
|
||||||
be modified by a given *labelmap* command. Any number of
|
be modified by a given *labelmap* command. Any number of
|
||||||
numeric-type/type-label pairs may follow. If a type label already
|
numeric-type/type-label pairs may follow. If a type label already
|
||||||
exists for a given numeric type, it will be overwritten. Assigning the
|
exists for a given numeric type, it will be overwritten. Types labels
|
||||||
same type label to multiple numeric types is permitted; how this
|
must be unique; assigning the same type label to multiple numeric
|
||||||
ambiguity is treated may depend on the feature utilizing type labels.
|
types is not permitted. There does not need to be a type label
|
||||||
There does not need to be a type label associated with every numeric
|
associated with every numeric type; in this case, those types without
|
||||||
type; in this case, those types without a label must be referenced by
|
a label must be referenced by their numeric type.
|
||||||
their numeric type.
|
|
||||||
|
|
||||||
For certain features, it is necessary to be able to extract the
|
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
|
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
|
Restrictions
|
||||||
""""""""""""
|
""""""""""""
|
||||||
|
|
||||||
This command must come after the simulation box is defined by a
|
Type labels cannot contain the symbols '#' or '*'. This command must
|
||||||
:doc:`read_data <read_data>`, :doc:`read_restart <read_restart>`, or
|
come after the simulation box is defined by a :doc:`read_data <read_data>`,
|
||||||
:doc:`create_box <create_box>` command.
|
:doc:`read_restart <read_restart>`, or :doc:`create_box <create_box>`
|
||||||
|
command.
|
||||||
|
|
||||||
Related commands
|
Related commands
|
||||||
""""""""""""""""
|
""""""""""""""""
|
||||||
|
|||||||
@ -101,6 +101,8 @@ void LabelMap::modify_lmap(int narg, char **arg)
|
|||||||
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,"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;
|
(*labels)[itype-1] = slabel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user