write_data: directly replace types w labels
allow direct replacement of numeric atom types in Atoms sections with type labels, using new keyword
This commit is contained in:
@ -19,6 +19,7 @@ Syntax
|
||||
*nocoeff* = do not write out force field info
|
||||
*nofix* = do not write out extra sections read by fixes
|
||||
*nolabelmap* = do not write out the default label map
|
||||
*types_style* value = *numeric* or *labels*
|
||||
*pair* value = *ii* or *ij*
|
||||
*ii* = write one line of pair coefficient info per atom type
|
||||
*ij* = write one line of pair coefficient info per IJ atom type pair
|
||||
@ -112,7 +113,12 @@ not be written to the data file (see the Type Label sections of
|
||||
default label map is fully defined for a given interaction, i.e. every
|
||||
atom, bond, angle, dihedral or improper type has an associated type
|
||||
label, then a type label section for that interaction is written to
|
||||
the data file.
|
||||
the data file. The *types_style* keyword indicates how atom, bond,
|
||||
etc. types are written in the Atoms, Bonds, etc. sections. If the
|
||||
value is specified as *numeric*, then numeric types are used. If the
|
||||
value is specified as *labels*, then interaction types are written as
|
||||
type labels using the default label map. When using type labels, the
|
||||
default label map must be written to the data file.
|
||||
|
||||
The *pair* keyword lets you specify in what format the pair
|
||||
coefficient information is written into the data file. If the value
|
||||
@ -153,4 +159,4 @@ Related commands
|
||||
Default
|
||||
"""""""
|
||||
|
||||
The option defaults are pair = ii.
|
||||
The option defaults are pair = ii and types_style = numeric.
|
||||
|
||||
@ -33,6 +33,7 @@ class Atom : protected Pointers {
|
||||
enum { GROW = 0, RESTART = 1, BORDER = 2 };
|
||||
enum { ATOMIC = 0, MOLECULAR = 1, TEMPLATE = 2 };
|
||||
enum { ATOM = 0, BOND = 1, ANGLE = 2, DIHEDRAL = 3, IMPROPER = 4 };
|
||||
enum { NUMERIC = 0, LABELS = 1};
|
||||
enum { MAP_NONE = 0, MAP_ARRAY = 1, MAP_HASH = 2, MAP_YES = 3 };
|
||||
|
||||
// atom counts
|
||||
@ -175,7 +176,7 @@ class Atom : protected Pointers {
|
||||
// most are existence flags for per-atom vectors and arrays
|
||||
// 1 if variable is used, 0 if not
|
||||
|
||||
int labelmapflag;
|
||||
int labelmapflag, types_style;
|
||||
int sphere_flag, ellipsoid_flag, line_flag, tri_flag, body_flag;
|
||||
int peri_flag, electron_flag;
|
||||
int wavepacket_flag, sph_flag;
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
#include "error.h"
|
||||
#include "fix.h"
|
||||
#include "force.h"
|
||||
#include "label_map.h"
|
||||
#include "math_const.h"
|
||||
#include "memory.h"
|
||||
#include "modify.h"
|
||||
@ -1866,6 +1867,11 @@ void AtomVec::write_data(FILE *fp, int n, double **buf)
|
||||
}
|
||||
} else if (datatype == Atom::INT) {
|
||||
if (cols == 0) {
|
||||
if (atom->types_style == Atom::LABELS &&
|
||||
strcmp(atom->peratom[mdata_atom.index[nn]].name,"type") == 0) {
|
||||
fmt::print(fp," {}",atom->lmaps[0]->typelabel[ubuf(buf[i][j++]).i-1]);
|
||||
continue;
|
||||
}
|
||||
fmt::print(fp," {}",ubuf(buf[i][j++]).i);
|
||||
} else {
|
||||
for (m = 0; m < cols; m++)
|
||||
|
||||
@ -73,6 +73,7 @@ void WriteData::command(int narg, char **arg)
|
||||
coeffflag = 1;
|
||||
fixflag = 1;
|
||||
lmapflag = 1;
|
||||
atom->types_style = Atom::NUMERIC;
|
||||
int noinit = 0;
|
||||
|
||||
int iarg = 1;
|
||||
@ -95,6 +96,12 @@ void WriteData::command(int narg, char **arg)
|
||||
} else if (strcmp(arg[iarg],"nolabelmap") == 0) {
|
||||
lmapflag = 0;
|
||||
iarg++;
|
||||
} else if (strcmp(arg[iarg],"types_style") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal write_data command");
|
||||
if (strcmp(arg[iarg+1],"numeric") == 0) atom->types_style = Atom::NUMERIC;
|
||||
else if (strcmp(arg[iarg+1],"labels") == 0) atom->types_style = Atom::LABELS;
|
||||
else error->all(FLERR,"Illegal write_data command");
|
||||
iarg += 2;
|
||||
} else error->all(FLERR,"Illegal write_data command");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user