apply clang-format

This commit is contained in:
Axel Kohlmeyer
2024-10-05 22:25:07 -04:00
parent 6ab0b2c249
commit 719a64d9dd
9 changed files with 93 additions and 64 deletions

View File

@ -96,8 +96,7 @@ void BondHybrid::compute(int eflag, int vflag)
bondlist[m][n][0] = bondlist_orig[i][0]; bondlist[m][n][0] = bondlist_orig[i][0];
bondlist[m][n][1] = bondlist_orig[i][1]; bondlist[m][n][1] = bondlist_orig[i][1];
bondlist[m][n][2] = bondlist_orig[i][2]; bondlist[m][n][2] = bondlist_orig[i][2];
if (partial_flag) if (partial_flag) orig_map[m][n] = i;
orig_map[m][n] = i;
nbondlist[m]++; nbondlist[m]++;
} }
} }
@ -381,8 +380,10 @@ void BondHybrid::init_style()
// bond style quartic will set broken bonds to bond type 0, so we need // 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 // to create an entry for it in the bond type to sub-style map
if (has_quartic >= 0) map[0] = has_quartic; if (has_quartic >= 0)
else map[0] = -1; map[0] = has_quartic;
else
map[0] = -1;
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -124,7 +124,8 @@ void ComputeMSDChunk::compute_array()
// first time call, allocate per-chunk arrays // first time call, allocate per-chunk arrays
// thereafter, require nchunk remain the same // thereafter, require nchunk remain the same
if (firstflag) msdnchunk = nchunk; if (firstflag)
msdnchunk = nchunk;
else if (msdnchunk != nchunk) else if (msdnchunk != nchunk)
error->all(FLERR, "Compute msd/chunk nchunk is not static"); error->all(FLERR, "Compute msd/chunk nchunk is not static");

View File

@ -34,7 +34,7 @@ ComputeReduceRegion::ComputeReduceRegion(LAMMPS *lmp, int narg, char **arg) :
ComputeReduce(lmp, narg, arg) ComputeReduce(lmp, narg, arg)
{ {
if (input_mode == LOCAL) 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]; one = fix_array[flag][aidxm1];
} }
// evaluate atom-style variable // evaluate atom-style variable
} else if (val.which == ArgInfo::VARIABLE) { } else if (val.which == ArgInfo::VARIABLE) {
if (atom->nmax > maxatom) { if (atom->nmax > maxatom) {

View File

@ -114,7 +114,7 @@ void CreateAtoms::command(int narg, char **arg)
xone[1] = utils::numeric(FLERR, arg[3], false, lmp); xone[1] = utils::numeric(FLERR, arg[3], false, lmp);
xone[2] = utils::numeric(FLERR, arg[4], false, lmp); xone[2] = utils::numeric(FLERR, arg[4], false, lmp);
if (domain->dimension == 2 && xone[2] != 0.0) 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; iarg = 5;
} else if (strcmp(arg[1], "random") == 0) { } else if (strcmp(arg[1], "random") == 0) {
style = RANDOM; style = RANDOM;
@ -184,7 +184,8 @@ void CreateAtoms::command(int narg, char **arg)
if (imol == -1) if (imol == -1)
error->all(FLERR, "Molecule template ID {} for create_atoms does not exist", arg[iarg + 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)) 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."); "Only the first set will be used.");
mode = MOLECULE; mode = MOLECULE;
onemol = atom->molecules[imol]; onemol = atom->molecules[imol];
@ -371,9 +372,9 @@ void CreateAtoms::command(int narg, char **arg)
if (scaleflag) { if (scaleflag) {
if (style == SINGLE) { if (style == SINGLE) {
xone[0] *= domain->lattice->xlattice; xone[0] *= domain->lattice->xlattice;
xone[1] *= domain->lattice->ylattice; xone[1] *= domain->lattice->ylattice;
xone[2] *= domain->lattice->zlattice; xone[2] *= domain->lattice->zlattice;
} else if (style == RANDOM) { } else if (style == RANDOM) {
if (overlapflag) overlap *= domain->lattice->xlattice; if (overlapflag) overlap *= domain->lattice->xlattice;
} else if (style == MESH) { } else if (style == MESH) {
@ -835,7 +836,7 @@ void CreateAtoms::add_random()
} }
} else { } else {
if (comm->me == 0) get_xmol(xone); 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 i = 0; i < nlocal; i++) {
for (int j = 0; j < onemol->natoms; j++) { for (int j = 0; j < onemol->natoms; j++) {
@ -1207,9 +1208,10 @@ void CreateAtoms::add_lattice()
// verify lattice was defined with triclinic/general option // verify lattice was defined with triclinic/general option
if (!domain->triclinic_general && domain->lattice->is_general_triclinic()) 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()) 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 // convert 8 corners of my subdomain from box coords to lattice coords
// for orthogonal, use corner pts of my subbox // 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, 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); 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 // 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 // new set of 8 points is no longer an orthogonal bounding box
// instead invoke lattice->bbox() on each of 8 points // instead invoke lattice->bbox() on each of 8 points
} else if (domain->triclinic_general) { } else if (domain->triclinic_general) {
double point[3]; 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->restricted_to_general_coords(point);
domain->lattice->bbox(1, point[0], point[1], point[2], xmin, ymin, zmin, xmax, ymax, zmax); 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->restricted_to_general_coords(point);
domain->lattice->bbox(1, point[0], point[1], point[2], xmin, ymin, zmin, xmax, ymax, zmax); 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->restricted_to_general_coords(point);
domain->lattice->bbox(1, point[0], point[1], point[2], xmin, ymin, zmin, xmax, ymax, zmax); 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->restricted_to_general_coords(point);
domain->lattice->bbox(1, point[0], point[1], point[2], xmin, ymin, zmin, xmax, ymax, zmax); 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->restricted_to_general_coords(point);
domain->lattice->bbox(1, point[0], point[1], point[2], xmin, ymin, zmin, xmax, ymax, zmax); 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->restricted_to_general_coords(point);
domain->lattice->bbox(1, point[0], point[1], point[2], xmin, ymin, zmin, xmax, ymax, zmax); 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->restricted_to_general_coords(point);
domain->lattice->bbox(1, point[0], point[1], point[2], xmin, ymin, zmin, xmax, ymax, zmax); 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->restricted_to_general_coords(point);
domain->lattice->bbox(1, point[0], point[1], point[2], xmin, ymin, zmin, xmax, ymax, zmax); 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); domain->general_to_restricted_coords(x);
if (dimension == 2) { if (dimension == 2) {
if (fabs(x[2]) > EPS_ZCOORD) 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; x[2] = 0.0;
} }
} }
@ -1510,8 +1528,7 @@ void CreateAtoms::get_xmol(double *center)
for (int m = 0; m < natoms; m++) { for (int m = 0; m < natoms; m++) {
MathExtra::matvec(rotmat, onemol->dx[m], xnew); MathExtra::matvec(rotmat, onemol->dx[m], xnew);
MathExtra::add3(xnew, center, xnew); MathExtra::add3(xnew, center, xnew);
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++) xmol[m][i] = xnew[i];
xmol[m][i] = xnew[i];
} }
} }

View File

@ -49,11 +49,13 @@ void CreateBox::command(int narg, char **arg)
Region *region = nullptr; Region *region = nullptr;
int triclinic_general = 0; int triclinic_general = 0;
if (strcmp(arg[1],"NULL") == 0) triclinic_general = 1; if (strcmp(arg[1], "NULL") == 0)
triclinic_general = 1;
else { else {
region = domain->get_region_by_id(arg[1]); region = domain->get_region_by_id(arg[1]);
if (!region) error->all(FLERR, "Create_box region {} does not exist", 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(); region->init();
} }
@ -77,9 +79,9 @@ void CreateBox::command(int narg, char **arg)
domain->boxlo[2] = region->extent_zlo; domain->boxlo[2] = region->extent_zlo;
domain->boxhi[2] = region->extent_zhi; domain->boxhi[2] = region->extent_zhi;
// region is prism // region is prism
// seutp restricted triclinic box // seutp restricted triclinic box
// set simulation domain from prism params // set simulation domain from prism params
} else { } else {
domain->triclinic = 1; domain->triclinic = 1;
@ -97,17 +99,17 @@ void CreateBox::command(int narg, char **arg)
if (domain->dimension == 2) { if (domain->dimension == 2) {
if (domain->boxlo[2] >= 0.0 || domain->boxhi[2] <= 0.0) 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) // setup general triclinic box (with no region)
// read next box extent arguments to create ABC edge vectors + origin // read next box extent arguments to create ABC edge vectors + origin
// define_general_triclinic() converts // define_general_triclinic() converts
// ABC edge vectors + origin to restricted triclinic // ABC edge vectors + origin to restricted triclinic
} else if (triclinic_general) { } else if (triclinic_general) {
if (!domain->lattice->is_general_triclinic()) 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); 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 (domain->dimension == 2)
if (clo != -0.5 || chi != 0.5) 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 // use lattice2box() to generate origin and ABC vectors
// origin = abc lo // origin = abc lo
// ABC vectors = hi in one dim - origin // ABC vectors = hi in one dim - origin
double avec[3],bvec[3],cvec[3],origin[3]; double avec[3], bvec[3], cvec[3], origin[3];
double px,py,pz; double px, py, pz;
px = alo; py = blo; pz = clo; px = alo;
domain->lattice->lattice2box(px,py,pz); py = blo;
pz = clo;
domain->lattice->lattice2box(px, py, pz);
origin[0] = px; origin[0] = px;
origin[1] = py; origin[1] = py;
origin[2] = pz; origin[2] = pz;
px = ahi; py = blo; pz = clo; px = ahi;
domain->lattice->lattice2box(px,py,pz); py = blo;
pz = clo;
domain->lattice->lattice2box(px, py, pz);
avec[0] = px - origin[0]; avec[0] = px - origin[0];
avec[1] = py - origin[1]; avec[1] = py - origin[1];
avec[2] = pz - origin[2]; avec[2] = pz - origin[2];
px = alo; py = bhi; pz = clo; px = alo;
domain->lattice->lattice2box(px,py,pz); py = bhi;
pz = clo;
domain->lattice->lattice2box(px, py, pz);
bvec[0] = px - origin[0]; bvec[0] = px - origin[0];
bvec[1] = py - origin[1]; bvec[1] = py - origin[1];
bvec[2] = pz - origin[2]; bvec[2] = pz - origin[2];
px = alo; py = blo; pz = chi; px = alo;
domain->lattice->lattice2box(px,py,pz); py = blo;
pz = chi;
domain->lattice->lattice2box(px, py, pz);
cvec[0] = px - origin[0]; cvec[0] = px - origin[0];
cvec[1] = py - origin[1]; cvec[1] = py - origin[1];
cvec[2] = pz - origin[2]; cvec[2] = pz - origin[2];
// define general triclinic box within Domain class // 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 // if molecular, zero out topology info

View File

@ -777,9 +777,9 @@ void DeleteAtoms::bondring(int nbuf, char *cbuf, void *ptr)
bond_type[i][m] = bond_type[i][n - 1]; bond_type[i][m] = bond_type[i][n - 1];
bond_atom[i][m] = bond_atom[i][n - 1]; bond_atom[i][m] = bond_atom[i][n - 1];
if (n_histories > 0) if (n_histories > 0)
for (auto &ihistory: histories) { for (auto &ihistory : histories) {
dynamic_cast<FixBondHistory *>(ihistory)->shift_history(i,m,n-1); dynamic_cast<FixBondHistory *>(ihistory)->shift_history(i, m, n - 1);
dynamic_cast<FixBondHistory *>(ihistory)->delete_history(i,n-1); dynamic_cast<FixBondHistory *>(ihistory)->delete_history(i, n - 1);
} }
n--; n--;
} else } else

View File

@ -149,8 +149,7 @@ void DihedralWrite::command(int narg, char **arg)
FILE *coeffs; FILE *coeffs;
char line[MAXLINE] = {'\0'}; char line[MAXLINE] = {'\0'};
coeffs = fopen(coeffs_file.c_str(), "r"); coeffs = fopen(coeffs_file.c_str(), "r");
if (!coeffs) if (!coeffs) error->one(FLERR, "Unable to open temporary file {}: {}", utils::getsyserror());
error->one(FLERR, "Unable to open temporary file {}: {}", utils::getsyserror());
for (int i = 0; i < atom->ndihedraltypes; ++i) { for (int i = 0; i < atom->ndihedraltypes; ++i) {
utils::sfgets(FLERR, line, MAXLINE, coeffs, coeffs_file.c_str(), error); utils::sfgets(FLERR, line, MAXLINE, coeffs, coeffs_file.c_str(), error);
writer->input->one(fmt::format("dihedral_coeff {}", line)); writer->input->one(fmt::format("dihedral_coeff {}", line));

View File

@ -182,7 +182,7 @@ FixPropertyAtom::FixPropertyAtom(LAMMPS *lmp, int narg, char **arg) :
// optional args // optional args
while (iarg < narg) { 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; iarg += 2;
} else if (strcmp(arg[iarg], "writedata") == 0) { } else if (strcmp(arg[iarg], "writedata") == 0) {
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix property/atom command"); 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; int flag = 0;
for (int i = 0; i < nvalue; i++) for (int i = 0; i < nvalue; i++)
if (styles[i] == MOLECULE || styles[i] == CHARGE || styles[i] == RMASS || 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) 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 // store current atom style
@ -216,7 +219,6 @@ FixPropertyAtom::FixPropertyAtom(LAMMPS *lmp, int narg, char **arg) :
if (border) atom->add_callback(Atom::BORDER); if (border) atom->add_callback(Atom::BORDER);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void FixPropertyAtom::post_constructor() void FixPropertyAtom::post_constructor()

View File

@ -24,8 +24,8 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
RegPlane::RegPlane(LAMMPS *lmp, int narg, char **arg) : Region(lmp, narg, arg), RegPlane::RegPlane(LAMMPS *lmp, int narg, char **arg) :
xstr(nullptr), ystr(nullptr), zstr(nullptr) Region(lmp, narg, arg), xstr(nullptr), ystr(nullptr), zstr(nullptr)
{ {
xvar = yvar = zvar = 0.0; xvar = yvar = zvar = 0.0;
@ -203,4 +203,3 @@ void RegPlane::variable_check()
error->all(FLERR, "Variable {} for region plane is invalid style", zstr); error->all(FLERR, "Variable {} for region plane is invalid style", zstr);
} }
} }