From 719a64d9dd8d67fc9d5c286761cc844fa87bc7b5 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 5 Oct 2024 22:25:07 -0400 Subject: [PATCH] apply clang-format --- src/bond_hybrid.cpp | 9 +++--- src/compute_msd_chunk.cpp | 3 +- src/compute_reduce_region.cpp | 4 +-- src/create_atoms.cpp | 61 ++++++++++++++++++++++------------- src/create_box.cpp | 56 +++++++++++++++++++------------- src/delete_atoms.cpp | 6 ++-- src/dihedral_write.cpp | 3 +- src/fix_property_atom.cpp | 10 +++--- src/region_plane.cpp | 5 ++- 9 files changed, 93 insertions(+), 64 deletions(-) diff --git a/src/bond_hybrid.cpp b/src/bond_hybrid.cpp index bd5badb54c..d39af40904 100644 --- a/src/bond_hybrid.cpp +++ b/src/bond_hybrid.cpp @@ -96,8 +96,7 @@ void BondHybrid::compute(int eflag, int vflag) bondlist[m][n][0] = bondlist_orig[i][0]; bondlist[m][n][1] = bondlist_orig[i][1]; bondlist[m][n][2] = bondlist_orig[i][2]; - if (partial_flag) - orig_map[m][n] = i; + if (partial_flag) orig_map[m][n] = i; nbondlist[m]++; } } @@ -381,8 +380,10 @@ void BondHybrid::init_style() // bond style quartic will set broken bonds to bond type 0, so we need // to create an entry for it in the bond type to sub-style map - if (has_quartic >= 0) map[0] = has_quartic; - else map[0] = -1; + if (has_quartic >= 0) + map[0] = has_quartic; + else + map[0] = -1; } /* ---------------------------------------------------------------------- */ diff --git a/src/compute_msd_chunk.cpp b/src/compute_msd_chunk.cpp index 59aff980f1..d738b835fa 100644 --- a/src/compute_msd_chunk.cpp +++ b/src/compute_msd_chunk.cpp @@ -124,7 +124,8 @@ void ComputeMSDChunk::compute_array() // first time call, allocate per-chunk arrays // thereafter, require nchunk remain the same - if (firstflag) msdnchunk = nchunk; + if (firstflag) + msdnchunk = nchunk; else if (msdnchunk != nchunk) error->all(FLERR, "Compute msd/chunk nchunk is not static"); diff --git a/src/compute_reduce_region.cpp b/src/compute_reduce_region.cpp index bd850e902c..6347bfe4c9 100644 --- a/src/compute_reduce_region.cpp +++ b/src/compute_reduce_region.cpp @@ -34,7 +34,7 @@ ComputeReduceRegion::ComputeReduceRegion(LAMMPS *lmp, int narg, char **arg) : ComputeReduce(lmp, narg, arg) { if (input_mode == LOCAL) - error->all(FLERR,"Compute reduce/region cannot use local data as input"); + error->all(FLERR, "Compute reduce/region cannot use local data as input"); } /* ---------------------------------------------------------------------- @@ -150,7 +150,7 @@ double ComputeReduceRegion::compute_one(int m, int flag) one = fix_array[flag][aidxm1]; } - // evaluate atom-style variable + // evaluate atom-style variable } else if (val.which == ArgInfo::VARIABLE) { if (atom->nmax > maxatom) { diff --git a/src/create_atoms.cpp b/src/create_atoms.cpp index d6c402f721..ade6bdc3c1 100644 --- a/src/create_atoms.cpp +++ b/src/create_atoms.cpp @@ -114,7 +114,7 @@ void CreateAtoms::command(int narg, char **arg) xone[1] = utils::numeric(FLERR, arg[3], false, lmp); xone[2] = utils::numeric(FLERR, arg[4], false, lmp); if (domain->dimension == 2 && xone[2] != 0.0) - error->all(FLERR,"Create_atoms single for 2d simulation requires z coord = 0.0"); + error->all(FLERR, "Create_atoms single for 2d simulation requires z coord = 0.0"); iarg = 5; } else if (strcmp(arg[1], "random") == 0) { style = RANDOM; @@ -184,7 +184,8 @@ void CreateAtoms::command(int narg, char **arg) if (imol == -1) error->all(FLERR, "Molecule template ID {} for create_atoms does not exist", arg[iarg + 1]); if ((atom->molecules[imol]->nset > 1) && (comm->me == 0)) - error->warning(FLERR, "Molecule template for create_atoms has multiple molecule sets. " + error->warning(FLERR, + "Molecule template for create_atoms has multiple molecule sets. " "Only the first set will be used."); mode = MOLECULE; onemol = atom->molecules[imol]; @@ -371,9 +372,9 @@ void CreateAtoms::command(int narg, char **arg) if (scaleflag) { if (style == SINGLE) { - xone[0] *= domain->lattice->xlattice; - xone[1] *= domain->lattice->ylattice; - xone[2] *= domain->lattice->zlattice; + xone[0] *= domain->lattice->xlattice; + xone[1] *= domain->lattice->ylattice; + xone[2] *= domain->lattice->zlattice; } else if (style == RANDOM) { if (overlapflag) overlap *= domain->lattice->xlattice; } else if (style == MESH) { @@ -835,7 +836,7 @@ void CreateAtoms::add_random() } } else { if (comm->me == 0) get_xmol(xone); - MPI_Bcast(&xmol[0][0], onemol->natoms*3, MPI_DOUBLE, 0, world); + MPI_Bcast(&xmol[0][0], onemol->natoms * 3, MPI_DOUBLE, 0, world); for (int i = 0; i < nlocal; i++) { for (int j = 0; j < onemol->natoms; j++) { @@ -1207,9 +1208,10 @@ void CreateAtoms::add_lattice() // verify lattice was defined with triclinic/general option if (!domain->triclinic_general && domain->lattice->is_general_triclinic()) - error->all(FLERR,"Create_atoms for non general triclinic box cannot use triclinic/general lattice"); + error->all(FLERR, + "Create_atoms for non general triclinic box cannot use triclinic/general lattice"); if (domain->triclinic_general && !domain->lattice->is_general_triclinic()) - error->all(FLERR,"Create_atoms for general triclinic box requires triclinic/general lattice"); + error->all(FLERR, "Create_atoms for general triclinic box requires triclinic/general lattice"); // convert 8 corners of my subdomain from box coords to lattice coords // for orthogonal, use corner pts of my subbox @@ -1266,38 +1268,54 @@ void CreateAtoms::add_lattice() domain->lattice->bbox(1, bboxlo[0], bboxhi[1], bboxhi[2], xmin, ymin, zmin, xmax, ymax, zmax); domain->lattice->bbox(1, bboxhi[0], bboxhi[1], bboxhi[2], xmin, ymin, zmin, xmax, ymax, zmax); - // for general triclinic, convert 8 corner points of bbox to general triclinic coords - // new set of 8 points is no longer an orthogonal bounding box - // instead invoke lattice->bbox() on each of 8 points + // for general triclinic, convert 8 corner points of bbox to general triclinic coords + // new set of 8 points is no longer an orthogonal bounding box + // instead invoke lattice->bbox() on each of 8 points } else if (domain->triclinic_general) { double point[3]; - point[0] = bboxlo[0]; point[1] = bboxlo[1]; point[2] = bboxlo[2]; + point[0] = bboxlo[0]; + point[1] = bboxlo[1]; + point[2] = bboxlo[2]; domain->restricted_to_general_coords(point); domain->lattice->bbox(1, point[0], point[1], point[2], xmin, ymin, zmin, xmax, ymax, zmax); - point[0] = bboxhi[0]; point[1] = bboxlo[1]; point[2] = bboxlo[2]; + point[0] = bboxhi[0]; + point[1] = bboxlo[1]; + point[2] = bboxlo[2]; domain->restricted_to_general_coords(point); domain->lattice->bbox(1, point[0], point[1], point[2], xmin, ymin, zmin, xmax, ymax, zmax); - point[0] = bboxlo[0]; point[1] = bboxhi[1]; point[2] = bboxlo[2]; + point[0] = bboxlo[0]; + point[1] = bboxhi[1]; + point[2] = bboxlo[2]; domain->restricted_to_general_coords(point); domain->lattice->bbox(1, point[0], point[1], point[2], xmin, ymin, zmin, xmax, ymax, zmax); - point[0] = bboxhi[0]; point[1] = bboxhi[1]; point[2] = bboxlo[2]; + point[0] = bboxhi[0]; + point[1] = bboxhi[1]; + point[2] = bboxlo[2]; domain->restricted_to_general_coords(point); domain->lattice->bbox(1, point[0], point[1], point[2], xmin, ymin, zmin, xmax, ymax, zmax); - point[0] = bboxlo[0]; point[1] = bboxlo[1]; point[2] = bboxhi[2]; + point[0] = bboxlo[0]; + point[1] = bboxlo[1]; + point[2] = bboxhi[2]; domain->restricted_to_general_coords(point); domain->lattice->bbox(1, point[0], point[1], point[2], xmin, ymin, zmin, xmax, ymax, zmax); - point[0] = bboxhi[0]; point[1] = bboxlo[1]; point[2] = bboxhi[2]; + point[0] = bboxhi[0]; + point[1] = bboxlo[1]; + point[2] = bboxhi[2]; domain->restricted_to_general_coords(point); domain->lattice->bbox(1, point[0], point[1], point[2], xmin, ymin, zmin, xmax, ymax, zmax); - point[0] = bboxlo[0]; point[1] = bboxhi[1]; point[2] = bboxhi[2]; + point[0] = bboxlo[0]; + point[1] = bboxhi[1]; + point[2] = bboxhi[2]; domain->restricted_to_general_coords(point); domain->lattice->bbox(1, point[0], point[1], point[2], xmin, ymin, zmin, xmax, ymax, zmax); - point[0] = bboxhi[0]; point[1] = bboxhi[1]; point[2] = bboxhi[2]; + point[0] = bboxhi[0]; + point[1] = bboxhi[1]; + point[2] = bboxhi[2]; domain->restricted_to_general_coords(point); domain->lattice->bbox(1, point[0], point[1], point[2], xmin, ymin, zmin, xmax, ymax, zmax); } @@ -1419,7 +1437,7 @@ void CreateAtoms::loop_lattice(int action) domain->general_to_restricted_coords(x); if (dimension == 2) { if (fabs(x[2]) > EPS_ZCOORD) - error->all(FLERR,"Create_atoms atom z coord is non-zero for 2d simulation"); + error->all(FLERR, "Create_atoms atom z coord is non-zero for 2d simulation"); x[2] = 0.0; } } @@ -1510,8 +1528,7 @@ void CreateAtoms::get_xmol(double *center) for (int m = 0; m < natoms; m++) { MathExtra::matvec(rotmat, onemol->dx[m], xnew); MathExtra::add3(xnew, center, xnew); - for (int i = 0; i < 3; i++) - xmol[m][i] = xnew[i]; + for (int i = 0; i < 3; i++) xmol[m][i] = xnew[i]; } } diff --git a/src/create_box.cpp b/src/create_box.cpp index 8a74ffd7bd..93e699e06b 100644 --- a/src/create_box.cpp +++ b/src/create_box.cpp @@ -49,11 +49,13 @@ void CreateBox::command(int narg, char **arg) Region *region = nullptr; int triclinic_general = 0; - if (strcmp(arg[1],"NULL") == 0) triclinic_general = 1; + if (strcmp(arg[1], "NULL") == 0) + triclinic_general = 1; else { region = domain->get_region_by_id(arg[1]); if (!region) error->all(FLERR, "Create_box region {} does not exist", arg[1]); - if (region->bboxflag == 0) error->all(FLERR, "Create_box region does not support a bounding box"); + if (region->bboxflag == 0) + error->all(FLERR, "Create_box region does not support a bounding box"); region->init(); } @@ -77,9 +79,9 @@ void CreateBox::command(int narg, char **arg) domain->boxlo[2] = region->extent_zlo; domain->boxhi[2] = region->extent_zhi; - // region is prism - // seutp restricted triclinic box - // set simulation domain from prism params + // region is prism + // seutp restricted triclinic box + // set simulation domain from prism params } else { domain->triclinic = 1; @@ -97,17 +99,17 @@ void CreateBox::command(int narg, char **arg) if (domain->dimension == 2) { if (domain->boxlo[2] >= 0.0 || domain->boxhi[2] <= 0.0) - error->all(FLERR,"Create_box region zlo/zhi for 2d simulation must straddle 0.0"); + error->all(FLERR, "Create_box region zlo/zhi for 2d simulation must straddle 0.0"); } - // setup general triclinic box (with no region) - // read next box extent arguments to create ABC edge vectors + origin - // define_general_triclinic() converts - // ABC edge vectors + origin to restricted triclinic + // setup general triclinic box (with no region) + // read next box extent arguments to create ABC edge vectors + origin + // define_general_triclinic() converts + // ABC edge vectors + origin to restricted triclinic } else if (triclinic_general) { if (!domain->lattice->is_general_triclinic()) - error->all(FLERR,"Create_box for general triclinic requires triclnic/general lattice"); + error->all(FLERR, "Create_box for general triclinic requires triclnic/general lattice"); if (iarg + 6 > narg) utils::missing_cmd_args(FLERR, "create_box general triclinic", error); @@ -121,42 +123,50 @@ void CreateBox::command(int narg, char **arg) if (domain->dimension == 2) if (clo != -0.5 || chi != 0.5) - error->all(FLERR,"Create_box for general triclinic requires clo = -0.5 and chi = 0.5"); + error->all(FLERR, "Create_box for general triclinic requires clo = -0.5 and chi = 0.5"); // use lattice2box() to generate origin and ABC vectors // origin = abc lo // ABC vectors = hi in one dim - origin - double avec[3],bvec[3],cvec[3],origin[3]; - double px,py,pz; + double avec[3], bvec[3], cvec[3], origin[3]; + double px, py, pz; - px = alo; py = blo; pz = clo; - domain->lattice->lattice2box(px,py,pz); + px = alo; + py = blo; + pz = clo; + domain->lattice->lattice2box(px, py, pz); origin[0] = px; origin[1] = py; origin[2] = pz; - px = ahi; py = blo; pz = clo; - domain->lattice->lattice2box(px,py,pz); + px = ahi; + py = blo; + pz = clo; + domain->lattice->lattice2box(px, py, pz); avec[0] = px - origin[0]; avec[1] = py - origin[1]; avec[2] = pz - origin[2]; - px = alo; py = bhi; pz = clo; - domain->lattice->lattice2box(px,py,pz); + px = alo; + py = bhi; + pz = clo; + domain->lattice->lattice2box(px, py, pz); bvec[0] = px - origin[0]; bvec[1] = py - origin[1]; bvec[2] = pz - origin[2]; - px = alo; py = blo; pz = chi; - domain->lattice->lattice2box(px,py,pz); + px = alo; + py = blo; + pz = chi; + domain->lattice->lattice2box(px, py, pz); cvec[0] = px - origin[0]; cvec[1] = py - origin[1]; cvec[2] = pz - origin[2]; // define general triclinic box within Domain class - domain->define_general_triclinic(avec,bvec,cvec,origin); + domain->define_general_triclinic(avec, bvec, cvec, origin); } // if molecular, zero out topology info diff --git a/src/delete_atoms.cpp b/src/delete_atoms.cpp index 6f887a33e6..35f608461b 100644 --- a/src/delete_atoms.cpp +++ b/src/delete_atoms.cpp @@ -777,9 +777,9 @@ void DeleteAtoms::bondring(int nbuf, char *cbuf, void *ptr) bond_type[i][m] = bond_type[i][n - 1]; bond_atom[i][m] = bond_atom[i][n - 1]; if (n_histories > 0) - for (auto &ihistory: histories) { - dynamic_cast(ihistory)->shift_history(i,m,n-1); - dynamic_cast(ihistory)->delete_history(i,n-1); + for (auto &ihistory : histories) { + dynamic_cast(ihistory)->shift_history(i, m, n - 1); + dynamic_cast(ihistory)->delete_history(i, n - 1); } n--; } else diff --git a/src/dihedral_write.cpp b/src/dihedral_write.cpp index 1d0f908e2c..51041c46fc 100644 --- a/src/dihedral_write.cpp +++ b/src/dihedral_write.cpp @@ -149,8 +149,7 @@ void DihedralWrite::command(int narg, char **arg) FILE *coeffs; char line[MAXLINE] = {'\0'}; coeffs = fopen(coeffs_file.c_str(), "r"); - if (!coeffs) - error->one(FLERR, "Unable to open temporary file {}: {}", utils::getsyserror()); + if (!coeffs) error->one(FLERR, "Unable to open temporary file {}: {}", utils::getsyserror()); for (int i = 0; i < atom->ndihedraltypes; ++i) { utils::sfgets(FLERR, line, MAXLINE, coeffs, coeffs_file.c_str(), error); writer->input->one(fmt::format("dihedral_coeff {}", line)); diff --git a/src/fix_property_atom.cpp b/src/fix_property_atom.cpp index 2cbdb44ab0..f88d6551b4 100644 --- a/src/fix_property_atom.cpp +++ b/src/fix_property_atom.cpp @@ -182,7 +182,7 @@ FixPropertyAtom::FixPropertyAtom(LAMMPS *lmp, int narg, char **arg) : // optional args while (iarg < narg) { - if (strcmp(arg[iarg], "ghost") == 0) { // skip here, since handled earlier + if (strcmp(arg[iarg], "ghost") == 0) { // skip here, since handled earlier iarg += 2; } else if (strcmp(arg[iarg], "writedata") == 0) { if (iarg + 2 > narg) error->all(FLERR, "Illegal fix property/atom command"); @@ -200,9 +200,12 @@ FixPropertyAtom::FixPropertyAtom(LAMMPS *lmp, int narg, char **arg) : int flag = 0; for (int i = 0; i < nvalue; i++) if (styles[i] == MOLECULE || styles[i] == CHARGE || styles[i] == RMASS || - styles[i] == TEMPERATURE || styles[i] == HEATFLOW) flag = 1; + styles[i] == TEMPERATURE || styles[i] == HEATFLOW) + flag = 1; if (flag && comm->me == 0) - error->warning(FLERR, "Fix property/atom mol, charge, rmass, temperature, or heatflow w/out ghost communication"); + error->warning(FLERR, + "Fix property/atom mol, charge, rmass, temperature, or heatflow w/out ghost " + "communication"); } // store current atom style @@ -216,7 +219,6 @@ FixPropertyAtom::FixPropertyAtom(LAMMPS *lmp, int narg, char **arg) : if (border) atom->add_callback(Atom::BORDER); } - /* ---------------------------------------------------------------------- */ void FixPropertyAtom::post_constructor() diff --git a/src/region_plane.cpp b/src/region_plane.cpp index 6dc162eead..11d96b8266 100644 --- a/src/region_plane.cpp +++ b/src/region_plane.cpp @@ -24,8 +24,8 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -RegPlane::RegPlane(LAMMPS *lmp, int narg, char **arg) : Region(lmp, narg, arg), - xstr(nullptr), ystr(nullptr), zstr(nullptr) +RegPlane::RegPlane(LAMMPS *lmp, int narg, char **arg) : + Region(lmp, narg, arg), xstr(nullptr), ystr(nullptr), zstr(nullptr) { xvar = yvar = zvar = 0.0; @@ -203,4 +203,3 @@ void RegPlane::variable_check() error->all(FLERR, "Variable {} for region plane is invalid style", zstr); } } -