type offsets are only applied to numeric types
This commit is contained in:
@ -89,6 +89,12 @@ molecule file. E.g. if *toff* = 2, and the file uses atom types
|
||||
individual values will be ignored if the molecule template does not
|
||||
use that attribute (e.g. no bonds).
|
||||
|
||||
.. note::
|
||||
|
||||
Offsets are **ignored** if the molecule file lines using type labels,
|
||||
as the type labels will determine the actual types depending on the
|
||||
current :doc:`labelmap <labelmap>` settings.
|
||||
|
||||
The *scale* keyword scales the size of the molecule. This can be
|
||||
useful for modeling polydisperse granular rigid bodies. The scale
|
||||
factor is applied to each of these properties in the molecule file, if
|
||||
@ -183,6 +189,7 @@ type labels have been defined, either by the :doc:`labelmap
|
||||
Type Labels, Angle Type Labels, etc. See the :doc:`Howto type labels
|
||||
<Howto_type_labels>` doc page for the allowed syntax of type labels
|
||||
and a general discussion of how type labels can be used.
|
||||
When using type labels, any values specified as *offset* are ignored.
|
||||
|
||||
If a Bonds section is specified then the Special Bond Counts and
|
||||
Special Bonds sections can also be used, if desired, to explicitly
|
||||
|
||||
@ -164,6 +164,12 @@ other types already exist. All five offset values must be specified,
|
||||
but individual values will be ignored if the data file does not use
|
||||
that attribute (e.g. no bonds).
|
||||
|
||||
.. note::
|
||||
|
||||
Offsets are **ignored** for any data file lines using type labels, as
|
||||
the type labels will determine the actual types depending on the
|
||||
current :doc:`labelmap <labelmap>` settings.
|
||||
|
||||
The *shift* keyword can be used to specify an (Sx, Sy, Sz)
|
||||
displacement applied to the coordinates of each atom. Sz must be 0.0
|
||||
for a 2d simulation. This is a mechanism for adding structured
|
||||
|
||||
42
src/atom.cpp
42
src/atom.cpp
@ -1188,11 +1188,10 @@ void Atom::data_atoms(int n, char *buf, tagint id_offset, tagint mol_offset,
|
||||
typestr = utils::utf8_subst(typestr);
|
||||
if (id_offset) tag[nlocal-1] += id_offset;
|
||||
if (mol_offset) molecule[nlocal-1] += mol_offset;
|
||||
// clang-format on
|
||||
switch (utils::is_type(typestr)) {
|
||||
|
||||
switch (utils::is_type(typestr)) {
|
||||
case 0: { // numeric
|
||||
int itype = utils::inumeric(FLERR, typestr, true, lmp);
|
||||
int itype = utils::inumeric(FLERR, typestr, true, lmp) + type_offset;
|
||||
if ((itype < 1) || (itype > ntypes))
|
||||
error->one(FLERR, "Invalid atom type {} in {}: {}", itype, location,
|
||||
utils::trim(buf));
|
||||
@ -1200,7 +1199,6 @@ void Atom::data_atoms(int n, char *buf, tagint id_offset, tagint mol_offset,
|
||||
if (labelflag) type[nlocal - 1] = ilabel[itype - 1];
|
||||
break;
|
||||
}
|
||||
|
||||
case 1: { // type label
|
||||
if (!atom->labelmapflag)
|
||||
error->one(FLERR, "Invalid line in {}: {}", location, utils::trim(buf));
|
||||
@ -1209,13 +1207,11 @@ void Atom::data_atoms(int n, char *buf, tagint id_offset, tagint mol_offset,
|
||||
error->one(FLERR, "Invalid line in {}: {}", location, utils::trim(buf));
|
||||
break;
|
||||
}
|
||||
|
||||
default: // invalid
|
||||
error->one(FLERR, "Invalid line in {}: {}", location, utils::trim(buf));
|
||||
break;
|
||||
}
|
||||
// clang-format off
|
||||
if (type_offset) type[nlocal-1] += type_offset;
|
||||
|
||||
if (type[nlocal-1] <= 0 || type[nlocal-1] > ntypes)
|
||||
error->one(FLERR,"Invalid atom type {} in {}", location, typestr);
|
||||
}
|
||||
@ -1300,30 +1296,24 @@ void Atom::data_bonds(int n, char *buf, int *count, tagint id_offset,
|
||||
atom2 += id_offset;
|
||||
}
|
||||
|
||||
// clang-format on
|
||||
switch (utils::is_type(typestr)) {
|
||||
|
||||
case 0: { // numeric
|
||||
itype = utils::inumeric(FLERR, typestr, false, lmp);
|
||||
itype = utils::inumeric(FLERR, typestr, false, lmp) + type_offset;
|
||||
if ((itype < 1) || (itype > nbondtypes))
|
||||
error->all(FLERR, "Invalid bond type {} in {}: {}", itype, location, utils::trim(buf));
|
||||
if (labelflag) itype = ilabel[itype - 1];
|
||||
break;
|
||||
}
|
||||
|
||||
case 1: { // type label
|
||||
if (!atom->labelmapflag) error->all(FLERR, "Invalid {}: {}", location, utils::trim(buf));
|
||||
itype = lmap->find(typestr, Atom::BOND);
|
||||
if (itype == -1) error->all(FLERR, "Invalid {}: {}", location, utils::trim(buf));
|
||||
break;
|
||||
}
|
||||
|
||||
default: // invalid
|
||||
error->one(FLERR, "Invalid {}: {}", location, utils::trim(buf));
|
||||
break;
|
||||
}
|
||||
itype += type_offset;
|
||||
// clang-format off
|
||||
|
||||
if ((atom1 <= 0) || (atom1 > map_tag_max) ||
|
||||
(atom2 <= 0) || (atom2 > map_tag_max) || (atom1 == atom2))
|
||||
@ -1399,30 +1389,24 @@ void Atom::data_angles(int n, char *buf, int *count, tagint id_offset,
|
||||
atom3 += id_offset;
|
||||
}
|
||||
|
||||
// clang-format on
|
||||
switch (utils::is_type(typestr)) {
|
||||
|
||||
case 0: { // numeric
|
||||
itype = utils::inumeric(FLERR, typestr, false, lmp);
|
||||
itype = utils::inumeric(FLERR, typestr, false, lmp) + type_offset;
|
||||
if ((itype < 1) || (itype > nangletypes))
|
||||
error->all(FLERR, "Invalid angle type {} in {}: {}", itype, location, utils::trim(buf));
|
||||
if (labelflag) itype = ilabel[itype - 1];
|
||||
break;
|
||||
}
|
||||
|
||||
case 1: { // type label
|
||||
if (!atom->labelmapflag) error->all(FLERR, "Invalid {}: {}", location, utils::trim(buf));
|
||||
itype = lmap->find(typestr, Atom::ANGLE);
|
||||
if (itype == -1) error->all(FLERR, "Invalid {}: {}", location, utils::trim(buf));
|
||||
break;
|
||||
}
|
||||
|
||||
default: // invalid
|
||||
error->one(FLERR, "Invalid {}: {}", location, utils::trim(buf));
|
||||
break;
|
||||
}
|
||||
itype += type_offset;
|
||||
// clang-format off
|
||||
|
||||
if ((atom1 <= 0) || (atom1 > map_tag_max) ||
|
||||
(atom2 <= 0) || (atom2 > map_tag_max) ||
|
||||
@ -1514,31 +1498,25 @@ void Atom::data_dihedrals(int n, char *buf, int *count, tagint id_offset,
|
||||
atom4 += id_offset;
|
||||
}
|
||||
|
||||
// clang-format on
|
||||
switch (utils::is_type(typestr)) {
|
||||
|
||||
case 0: { // numeric
|
||||
itype = utils::inumeric(FLERR, typestr, false, lmp);
|
||||
itype = utils::inumeric(FLERR, typestr, false, lmp) + type_offset;
|
||||
if ((itype < 1) || (itype > ndihedraltypes))
|
||||
error->all(FLERR, "Invalid dihedral type {} in {}: {}", itype, location,
|
||||
utils::trim(buf));
|
||||
if (labelflag) itype = ilabel[itype - 1];
|
||||
break;
|
||||
}
|
||||
|
||||
case 1: { // type label
|
||||
if (!atom->labelmapflag) error->all(FLERR, "Invalid {}: {}", location, utils::trim(buf));
|
||||
itype = lmap->find(typestr, Atom::DIHEDRAL);
|
||||
if (itype == -1) error->all(FLERR, "Invalid {}: {}", location, utils::trim(buf));
|
||||
break;
|
||||
}
|
||||
|
||||
default: // invalid
|
||||
error->one(FLERR, "Invalid {}: {}", location, utils::trim(buf));
|
||||
break;
|
||||
}
|
||||
itype += type_offset;
|
||||
// clang-format off
|
||||
|
||||
if ((atom1 <= 0) || (atom1 > map_tag_max) ||
|
||||
(atom2 <= 0) || (atom2 > map_tag_max) ||
|
||||
@ -1646,31 +1624,25 @@ void Atom::data_impropers(int n, char *buf, int *count, tagint id_offset,
|
||||
atom4 += id_offset;
|
||||
}
|
||||
|
||||
// clang-format on
|
||||
switch (utils::is_type(typestr)) {
|
||||
|
||||
case 0: { // numeric
|
||||
itype = utils::inumeric(FLERR, typestr, false, lmp);
|
||||
itype = utils::inumeric(FLERR, typestr, false, lmp) + type_offset;
|
||||
if ((itype < 1) || (itype > nimpropertypes))
|
||||
error->all(FLERR, "Invalid improper type {} in {}: {}", itype, location,
|
||||
utils::trim(buf));
|
||||
if (labelflag) itype = ilabel[itype - 1];
|
||||
break;
|
||||
}
|
||||
|
||||
case 1: { // type label
|
||||
if (!atom->labelmapflag) error->all(FLERR, "Invalid {}: {}", location, utils::trim(buf));
|
||||
itype = lmap->find(typestr, Atom::IMPROPER);
|
||||
if (itype == -1) error->all(FLERR, "Invalid {}: {}", location, utils::trim(buf));
|
||||
break;
|
||||
}
|
||||
|
||||
default: // invalid
|
||||
error->one(FLERR, "Invalid {}: {}", location, utils::trim(buf));
|
||||
break;
|
||||
}
|
||||
itype += type_offset;
|
||||
// clang-format off
|
||||
|
||||
if ((atom1 <= 0) || (atom1 > map_tag_max) ||
|
||||
(atom2 <= 0) || (atom2 > map_tag_max) ||
|
||||
|
||||
Reference in New Issue
Block a user