enable and apply clang-format
This commit is contained in:
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -25,7 +24,7 @@
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
static constexpr int MAXLINE = 1024; // max line length in dump file
|
||||
static constexpr int MAXLINE = 1024; // max line length in dump file
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -52,22 +51,21 @@ ReaderXYZ::~ReaderXYZ()
|
||||
|
||||
int ReaderXYZ::read_time(bigint &ntimestep)
|
||||
{
|
||||
char *eof = fgets(line,MAXLINE,fp);
|
||||
char *eof = fgets(line, MAXLINE, fp);
|
||||
if (eof == nullptr) return 1;
|
||||
|
||||
// first line has to have the number of atoms
|
||||
// truncate the string to the first whitespace,
|
||||
// so force->bnumeric() does not hiccup
|
||||
|
||||
for (int i=0; (i < MAXLINE) && (eof[i] != '\0'); ++i) {
|
||||
for (int i = 0; (i < MAXLINE) && (eof[i] != '\0'); ++i) {
|
||||
if (eof[i] == '\n' || eof[i] == '\r' || eof[i] == ' ' || eof[i] == '\t') {
|
||||
eof[i] = '\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
natoms = utils::bnumeric(FLERR,line,false,lmp);
|
||||
if (natoms < 1)
|
||||
error->one(FLERR,"Dump file is incorrectly formatted");
|
||||
natoms = utils::bnumeric(FLERR, line, false, lmp);
|
||||
if (natoms < 1) error->one(FLERR, "Dump file is incorrectly formatted");
|
||||
|
||||
// skip over comment/title line
|
||||
|
||||
@ -95,8 +93,8 @@ void ReaderXYZ::skip()
|
||||
bigint nchunk;
|
||||
bigint nremain = natoms;
|
||||
while (nremain) {
|
||||
nchunk = MIN(nremain,MAXSMALLINT);
|
||||
read_lines((int)nchunk);
|
||||
nchunk = MIN(nremain, MAXSMALLINT);
|
||||
read_lines((int) nchunk);
|
||||
nremain -= nchunk;
|
||||
}
|
||||
}
|
||||
@ -115,11 +113,10 @@ void ReaderXYZ::skip()
|
||||
only called by proc 0
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
bigint ReaderXYZ::read_header(double /*box*/[3][3], int &boxinfo, int &/*triclinic*/,
|
||||
int fieldinfo, int nfield,
|
||||
int *fieldtype, char **/*fieldlabel*/,
|
||||
int scaleflag, int wrapflag, int &fieldflag,
|
||||
int &xflag, int &yflag, int &zflag)
|
||||
bigint ReaderXYZ::read_header(double /*box*/[3][3], int &boxinfo, int & /*triclinic*/,
|
||||
int fieldinfo, int nfield, int *fieldtype, char ** /*fieldlabel*/,
|
||||
int scaleflag, int wrapflag, int &fieldflag, int &xflag, int &yflag,
|
||||
int &zflag)
|
||||
{
|
||||
|
||||
nid = 0;
|
||||
@ -132,24 +129,21 @@ bigint ReaderXYZ::read_header(double /*box*/[3][3], int &boxinfo, int &/*triclin
|
||||
|
||||
if (!fieldinfo) return natoms;
|
||||
|
||||
memory->create(fieldindex,nfield,"read_dump:fieldindex");
|
||||
memory->create(fieldindex, nfield, "read_dump:fieldindex");
|
||||
|
||||
// for xyz we know nothing about the style of coordinates,
|
||||
// so caller has to set the proper flags
|
||||
|
||||
xflag = 2*scaleflag + wrapflag + 1;
|
||||
yflag = 2*scaleflag + wrapflag + 1;
|
||||
zflag = 2*scaleflag + wrapflag + 1;
|
||||
xflag = 2 * scaleflag + wrapflag + 1;
|
||||
yflag = 2 * scaleflag + wrapflag + 1;
|
||||
zflag = 2 * scaleflag + wrapflag + 1;
|
||||
|
||||
// copy fieldtype list for supported fields
|
||||
|
||||
fieldflag = 0;
|
||||
for (int i = 0; i < nfield; i++) {
|
||||
if ( (fieldtype[i] == X) ||
|
||||
(fieldtype[i] == Y) ||
|
||||
(fieldtype[i] == Z) ||
|
||||
(fieldtype[i] == ID) ||
|
||||
(fieldtype[i] == TYPE)) {
|
||||
if ((fieldtype[i] == X) || (fieldtype[i] == Y) || (fieldtype[i] == Z) || (fieldtype[i] == ID) ||
|
||||
(fieldtype[i] == TYPE)) {
|
||||
fieldindex[i] = fieldtype[i];
|
||||
} else {
|
||||
fieldflag = 1;
|
||||
@ -168,15 +162,15 @@ bigint ReaderXYZ::read_header(double /*box*/[3][3], int &boxinfo, int &/*triclin
|
||||
|
||||
void ReaderXYZ::read_atoms(int n, int nfield, double **fields)
|
||||
{
|
||||
int i,m;
|
||||
int i, m;
|
||||
char *eof;
|
||||
int mytype;
|
||||
double myx, myy, myz;
|
||||
|
||||
try {
|
||||
for (i = 0; i < n; i++) {
|
||||
eof = fgets(line,MAXLINE,fp);
|
||||
if (eof == nullptr) error->one(FLERR,"Unexpected end of dump file");
|
||||
eof = fgets(line, MAXLINE, fp);
|
||||
if (eof == nullptr) error->one(FLERR, "Unexpected end of dump file");
|
||||
|
||||
++nid;
|
||||
|
||||
@ -188,21 +182,21 @@ void ReaderXYZ::read_atoms(int n, int nfield, double **fields)
|
||||
|
||||
for (m = 0; m < nfield; m++) {
|
||||
switch (fieldindex[m]) {
|
||||
case X:
|
||||
fields[i][m] = myx;
|
||||
break;
|
||||
case Y:
|
||||
fields[i][m] = myy;
|
||||
break;
|
||||
case Z:
|
||||
fields[i][m] = myz;
|
||||
break;
|
||||
case ID:
|
||||
fields[i][m] = nid;
|
||||
break;
|
||||
case TYPE:
|
||||
fields[i][m] = mytype;
|
||||
break;
|
||||
case X:
|
||||
fields[i][m] = myx;
|
||||
break;
|
||||
case Y:
|
||||
fields[i][m] = myy;
|
||||
break;
|
||||
case Z:
|
||||
fields[i][m] = myz;
|
||||
break;
|
||||
case ID:
|
||||
fields[i][m] = nid;
|
||||
break;
|
||||
case TYPE:
|
||||
fields[i][m] = mytype;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -221,6 +215,6 @@ void ReaderXYZ::read_lines(int n)
|
||||
{
|
||||
char *eof = nullptr;
|
||||
if (n <= 0) return;
|
||||
for (int i = 0; i < n; i++) eof = fgets(line,MAXLINE,fp);
|
||||
if (eof == nullptr) error->one(FLERR,"Unexpected end of dump file");
|
||||
for (int i = 0; i < n; i++) eof = fgets(line, MAXLINE, fp);
|
||||
if (eof == nullptr) error->one(FLERR, "Unexpected end of dump file");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user