enable and apply clang-format

This commit is contained in:
Axel Kohlmeyer
2024-09-21 12:12:27 -04:00
parent 29fce19c19
commit d16d744550

View File

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