From 3e053adfbe8ebc441f4c7ff08cbe413bb8563573 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 4 Jan 2023 08:42:43 -0500 Subject: [PATCH] Print warning about unsorted custom dumps without atom IDs. Explain in manual. --- doc/src/dump.rst | 8 ++++++++ src/dump.cpp | 11 +++++++++-- src/dump.h | 1 + src/dump_custom.cpp | 3 +++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/doc/src/dump.rst b/doc/src/dump.rst index 800542475d..40eafbb427 100644 --- a/doc/src/dump.rst +++ b/doc/src/dump.rst @@ -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 + ` 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 diff --git a/src/dump.cpp b/src/dump.cpp index 82a25c31f2..7c65536df2 100644 --- a/src/dump.cpp +++ b/src/dump.cpp @@ -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); diff --git a/src/dump.h b/src/dump.h index 4f0019ca2c..bae7dbd8c8 100644 --- a/src/dump.h +++ b/src/dump.h @@ -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; diff --git a/src/dump_custom.cpp b/src/dump_custom.cpp index d2b091eb6d..8d64e532a4 100644 --- a/src/dump_custom.cpp +++ b/src/dump_custom.cpp @@ -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");