Print warning about unsorted custom dumps without atom IDs. Explain in manual.

This commit is contained in:
Axel Kohlmeyer
2023-01-04 08:42:43 -05:00
parent 56cb967991
commit 3e053adfbe
4 changed files with 21 additions and 2 deletions

View File

@ -242,6 +242,14 @@ all the processors or multiple smaller files.
data for a single snapshot is collected from multiple processors,
each of which owns a subset of the atoms.
.. warning::
Without either including atom IDs or using the :doc:`dump_modify sort
<dump_modify>` option, it is impossible for visualization programs
(e.g. OVITO or VMD) or analysis tools to assign data in different
frames consistently to the same atom. This can lead to incorrect
visualizations or results. LAMMPS will print a warning in such cases.
For the *atom*, *custom*, *cfg*, *grid*, and *local* styles, sorting
is off by default. For the *dcd*, *grid/vtk*, *xtc*, *xyz*, and
*molfile* styles, sorting by atom ID or grid ID is on by default. See

View File

@ -89,6 +89,7 @@ Dump::Dump(LAMMPS *lmp, int /*narg*/, char **arg) : Pointers(lmp)
unit_count = 0;
delay_flag = 0;
write_header_flag = 1;
has_id = 1;
skipflag = 0;
skipvar = nullptr;
@ -231,16 +232,22 @@ void Dump::init()
ids = idsort = nullptr;
index = proclist = nullptr;
irregular = nullptr;
if ((has_id == 0) && (me == 0))
error->warning(FLERR,"Dump {} is without Atom-IDs and not sorted by id. This may lead to data "
"changing order and prevent tracking individual atoms", id);
}
if (sort_flag) {
if (multiproc > 1)
error->all(FLERR,
"Cannot dump sort when 'nfile' or 'fileper' keywords are set to non-default values");
"Cannot sort dump when 'nfile' or 'fileper' keywords are set to non-default values");
if (sortcol == 0 && atom->tag_enable == 0)
error->all(FLERR,"Cannot dump sort on atom IDs with no atom IDs defined");
error->all(FLERR,"Cannot sort dump on atom IDs with no atom IDs defined");
if (sortcol && sortcol > size_one)
error->all(FLERR,"Dump sort column is invalid");
if ((sortcol != 0) && (has_id == 0) && (me == 0))
error->warning(FLERR,"Dump {} is without Atom-IDs and not sorted by id. This may lead to data "
"changing order and prevent tracking individual atoms", id);
if (nprocs > 1 && irregular == nullptr)
irregular = new Irregular(lmp);

View File

@ -90,6 +90,7 @@ class Dump : protected Pointers {
int unit_count; // # of times the unit information was written
int delay_flag; // 1 if delay output until delaystep
int write_header_flag; // 1 if write header, 0 if not
int has_id; // 1 if output contains Atom-IDs
bigint delaystep;

View File

@ -1245,11 +1245,14 @@ int DumpCustom::parse_fields(int narg, char **arg)
{
// customize by adding to if statement
has_id = 0;
for (int iarg = 0; iarg < narg; iarg++) {
if (strcmp(arg[iarg],"id") == 0) {
pack_choice[iarg] = &DumpCustom::pack_id;
if (sizeof(tagint) == sizeof(smallint)) vtype[iarg] = Dump::INT;
else vtype[iarg] = Dump::BIGINT;
has_id = 1;
} else if (strcmp(arg[iarg],"mol") == 0) {
if (!atom->molecule_flag)
error->all(FLERR,"Dumping an atom property that isn't allocated");