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:
@ -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