diff --git a/doc/src/dump.rst b/doc/src/dump.rst index 9f2be8c129..a8175fa612 100644 --- a/doc/src/dump.rst +++ b/doc/src/dump.rst @@ -114,6 +114,7 @@ Syntax proc = ID of processor that owns atom procp1 = ID+1 of processor that owns atom type = atom type + typelabel = atom :doc:`type label ` element = name of atom element, as defined by :doc:`dump_modify ` command mass = atom mass x,y,z = unscaled atom coordinates @@ -775,21 +776,21 @@ command creates a per-atom array with six columns: Per-atom attributes used as arguments to the *custom* and *cfg* styles: -The *id*, *mol*, *proc*, *procp1*, *type*, *element*, *mass*, *vx*, -*vy*, *vz*, *fx*, *fy*, *fz*, *q* attributes are self-explanatory. +The *id*, *mol*, *proc*, *procp1*, *type*, *typelabel*, *element*, *mass*, +*vx*, *vy*, *vz*, *fx*, *fy*, *fz*, *q* attributes are self-explanatory. -*Id* is the atom ID. *Mol* is the molecule ID, included in the data -file for molecular systems. *Proc* is the ID of the processor (0 to +*Id* is the atom ID. *Mol* is the molecule ID, included in the data file +for molecular systems. *Proc* is the ID of the processor (0 to :math:`N_\text{procs}-1`) that currently owns the atom. *Procp1* is the proc ID+1, which can be convenient in place of a *type* attribute (1 to :math:`N_\text{types}`) for coloring atoms in a visualization program. -*Type* is the atom type (1 to :math:`N_\text{types}`). *Element* is -typically the chemical name of an element, which you must assign to each -type via the :doc:`dump_modify element ` command. More -generally, it can be any string you wish to associated with an atom -type. *Mass* is the atom mass. The quantities *vx*, *vy*, *vz*, *fx*, -*fy*, *fz*, and *q* are components of atom velocity and force and atomic -charge. +*Type* is the atom type (1 to :math:`N_\text{types}`). *Typelabel* is the +atom :doc:`type label `. *Element* is typically the +chemical name of an element, which you must assign to each type via the +:doc:`dump_modify element ` command. More generally, it can +be any string you wish to associated with an atom type. *Mass* is the atom +mass. The quantities *vx*, *vy*, *vz*, *fx*, *fy*, *fz*, and *q* are +components of atom velocity and force and atomic charge. There are several options for outputting atom coordinates. The *x*, *y*, and *z* attributes write atom coordinates "unscaled", in the diff --git a/src/dump.h b/src/dump.h index 43baf96ccf..e5711af7a7 100644 --- a/src/dump.h +++ b/src/dump.h @@ -107,7 +107,7 @@ class Dump : protected Pointers { char *format_int_user; char *format_bigint_user; char **format_column_user; - enum { INT, DOUBLE, STRING, BIGINT }; + enum { INT, DOUBLE, STRING, STRING2, BIGINT }; std::map key2col; std::vector keyword_user; diff --git a/src/dump_custom.cpp b/src/dump_custom.cpp index fb07efd561..1676388de0 100644 --- a/src/dump_custom.cpp +++ b/src/dump_custom.cpp @@ -23,6 +23,7 @@ #include "fix_store_atom.h" #include "group.h" #include "input.h" +#include "label_map.h" #include "memory.h" #include "modify.h" #include "region.h" @@ -36,7 +37,7 @@ using namespace LAMMPS_NS; // customize by adding keyword // also customize compute_property_atom.cpp -enum{ID,MOL,PROC,PROCP1,TYPE,ELEMENT,MASS, +enum{ID,MOL,PROC,PROCP1,TYPE,TYPELABEL,ELEMENT,MASS, X,Y,Z,XS,YS,ZS,XSTRI,YSTRI,ZSTRI,XU,YU,ZU,XUTRI,YUTRI,ZUTRI, XSU,YSU,ZSU,XSUTRI,YSUTRI,ZSUTRI, IX,IY,IZ, @@ -140,6 +141,7 @@ DumpCustom::DumpCustom(LAMMPS *lmp, int narg, char **arg) : if (vtype[i] == Dump::INT) cols += "%d "; else if (vtype[i] == Dump::DOUBLE) cols += "%g "; else if (vtype[i] == Dump::STRING) cols += "%s "; + else if (vtype[i] == Dump::STRING2) cols += "%s "; else if (vtype[i] == Dump::BIGINT) cols += BIGINT_FORMAT " "; vformat[i] = nullptr; } @@ -695,7 +697,12 @@ int DumpCustom::count() for (i = 0; i < nlocal; i++) dchoose[i] = type[i]; ptr = dchoose; nstride = 1; - } else if (thresh_array[ithresh] == ELEMENT) { + } else if (thresh_array[ithresh] == TYPELABEL) { // dead code? + int *type = atom->type; + for (i = 0; i < nlocal; i++) dchoose[i] = type[i]; + ptr = dchoose; + nstride = 1; + } else if (thresh_array[ithresh] == ELEMENT) { // dead code? int *type = atom->type; for (i = 0; i < nlocal; i++) dchoose[i] = type[i]; ptr = dchoose; @@ -1235,6 +1242,8 @@ int DumpCustom::convert_string(int n, double *mybuf) offset += sprintf(&sbuf[offset],vformat[j],mybuf[m]); else if (vtype[j] == Dump::STRING) offset += sprintf(&sbuf[offset],vformat[j],typenames[(int) mybuf[m]]); + else if (vtype[j] == Dump::STRING2) + offset += sprintf(&sbuf[offset],vformat[j],atom->lmap->typelabel[(int) mybuf[m]-1].c_str()); else if (vtype[j] == Dump::BIGINT) offset += sprintf(&sbuf[offset],vformat[j], static_cast (mybuf[m])); @@ -1283,6 +1292,8 @@ void DumpCustom::write_lines(int n, double *mybuf) else if (vtype[j] == Dump::DOUBLE) fprintf(fp,vformat[j],mybuf[m]); else if (vtype[j] == Dump::STRING) fprintf(fp,vformat[j],typenames[(int) mybuf[m]]); + else if (vtype[j] == Dump::STRING2) + fprintf(fp,vformat[j],atom->lmap->typelabel[(int) mybuf[m]-1].c_str()); else if (vtype[j] == Dump::BIGINT) fprintf(fp,vformat[j],static_cast (mybuf[m])); m++; @@ -1323,6 +1334,9 @@ int DumpCustom::parse_fields(int narg, char **arg) } else if (strcmp(arg[iarg],"element") == 0) { pack_choice[iarg] = &DumpCustom::pack_type; vtype[iarg] = Dump::STRING; + } else if (strcmp(arg[iarg],"typelabel") == 0) { + pack_choice[iarg] = &DumpCustom::pack_type; + vtype[iarg] = Dump::STRING2; } else if (strcmp(arg[iarg],"mass") == 0) { pack_choice[iarg] = &DumpCustom::pack_mass; vtype[iarg] = Dump::DOUBLE; diff --git a/src/label_map.h b/src/label_map.h index 0dfc42c9b5..eeab3aeae8 100644 --- a/src/label_map.h +++ b/src/label_map.h @@ -22,6 +22,7 @@ namespace LAMMPS_NS { class LabelMap : protected Pointers { friend class AtomVec; + friend class DumpCustom; friend class DumpXYZ; friend class ReadData;