various coding style updates

This commit is contained in:
Axel Kohlmeyer
2024-01-19 13:00:29 -05:00
parent e0967af6e8
commit 39d21473a0
14 changed files with 33 additions and 53 deletions

View File

@ -100,8 +100,6 @@ FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) :
omega_mass_flag = 0; omega_mass_flag = 0;
etap_mass_flag = 0; etap_mass_flag = 0;
flipflag = 1; flipflag = 1;
dipole_flag = 0;
dlm_flag = 0;
tcomputeflag = 0; tcomputeflag = 0;
pcomputeflag = 0; pcomputeflag = 0;
@ -264,13 +262,6 @@ FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) :
if (p_flag[2] && domain->zperiodic == 0) if (p_flag[2] && domain->zperiodic == 0)
error->all(FLERR,"Cannot use fix bocs on a non-periodic dimension"); error->all(FLERR,"Cannot use fix bocs on a non-periodic dimension");
if (dipole_flag) {
if (!atom->sphere_flag)
error->all(FLERR,"Using update dipole flag requires atom style sphere");
if (!atom->mu_flag)
error->all(FLERR,"Using update dipole flag requires atom attribute mu");
}
if ((tstat_flag && t_period <= 0.0) || if ((tstat_flag && t_period <= 0.0) ||
(p_flag[0] && p_period[0] <= 0.0) || (p_flag[0] && p_period[0] <= 0.0) ||
(p_flag[1] && p_period[1] <= 0.0) || (p_flag[1] && p_period[1] <= 0.0) ||

View File

@ -129,8 +129,6 @@ class FixBocs : public Fix {
int eta_mass_flag; // 1 if eta_mass updated, 0 if not. int eta_mass_flag; // 1 if eta_mass updated, 0 if not.
int omega_mass_flag; // 1 if omega_mass updated, 0 if not. int omega_mass_flag; // 1 if omega_mass updated, 0 if not.
int etap_mass_flag; // 1 if etap_mass updated, 0 if not. int etap_mass_flag; // 1 if etap_mass updated, 0 if not.
int dipole_flag; // 1 if dipole is updated, 0 if not.
int dlm_flag; // 1 if using the DLM rotational integrator, 0 if not
int scaleyz; // 1 if yz scaled with lz int scaleyz; // 1 if yz scaled with lz
int scalexz; // 1 if xz scaled with lz int scalexz; // 1 if xz scaled with lz

View File

@ -28,7 +28,7 @@ using namespace MathExtra;
FixNVEBPMSphere::FixNVEBPMSphere(LAMMPS *_lmp, int narg, char **arg) : FixNVE(_lmp, narg, arg) FixNVEBPMSphere::FixNVEBPMSphere(LAMMPS *_lmp, int narg, char **arg) : FixNVE(_lmp, narg, arg)
{ {
if (narg < 3) error->all(FLERR, "Illegal fix nve/bpm/sphere command"); if (narg < 3) utils::missing_cmd_args(FLERR, "fix nve/bpm/sphere", error);
time_integrate = 1; time_integrate = 1;
@ -45,7 +45,7 @@ FixNVEBPMSphere::FixNVEBPMSphere(LAMMPS *_lmp, int narg, char **arg) : FixNVE(_l
error->all(FLERR, "Fix nve/bpm/sphere disc requires 2d simulation"); error->all(FLERR, "Fix nve/bpm/sphere disc requires 2d simulation");
iarg++; iarg++;
} else } else
error->all(FLERR, "Illegal fix nve/bpm/sphere command"); error->all(FLERR, "Illegal fix nve/bpm/sphere keyword {}", arg[iarg]);
} }
inv_inertia = 1.0 / inertia; inv_inertia = 1.0 / inertia;

View File

@ -204,7 +204,7 @@ FixBrownianBase::~FixBrownianBase()
delete[] gamma_r_invsqrt; delete[] gamma_r_invsqrt;
} }
if (dipole_flag) { delete[] dipole_body; } if (dipole_flag) delete[] dipole_body;
delete rng; delete rng;
} }

View File

@ -36,10 +36,10 @@ FixBrownianSphere::FixBrownianSphere(LAMMPS *lmp, int narg, char **arg) :
FixBrownianBase(lmp, narg, arg) FixBrownianBase(lmp, narg, arg)
{ {
if (gamma_t_eigen_flag || gamma_r_eigen_flag) { if (gamma_t_eigen_flag || gamma_r_eigen_flag) {
error->all(FLERR, "Illegal fix brownian command."); error->all(FLERR, "Illegal fix brownian/sphere command.");
} }
if (!gamma_t_flag || !gamma_r_flag) { error->all(FLERR, "Illegal fix brownian command."); } if (!gamma_t_flag || !gamma_r_flag) error->all(FLERR, "Illegal fix brownian/sphere command.");
if (!atom->mu_flag) error->all(FLERR, "Fix brownian/sphere requires atom attribute mu"); if (!atom->mu_flag) error->all(FLERR, "Fix brownian/sphere requires atom attribute mu");
if (!atom->sphere_flag) error->all(FLERR, "Fix brownian/sphere requires atom style sphere"); if (!atom->sphere_flag) error->all(FLERR, "Fix brownian/sphere requires atom style sphere");
} }

View File

@ -91,7 +91,6 @@ FixNPTCauchy::FixNPTCauchy(LAMMPS *lmp, int narg, char **arg) :
omega_mass_flag = 0; omega_mass_flag = 0;
etap_mass_flag = 0; etap_mass_flag = 0;
flipflag = 1; flipflag = 1;
dlm_flag = 0;
tcomputeflag = 0; tcomputeflag = 0;
pcomputeflag = 0; pcomputeflag = 0;

View File

@ -117,8 +117,6 @@ class FixNPTCauchy : public Fix {
int eta_mass_flag; // 1 if eta_mass updated, 0 if not. int eta_mass_flag; // 1 if eta_mass updated, 0 if not.
int omega_mass_flag; // 1 if omega_mass updated, 0 if not. int omega_mass_flag; // 1 if omega_mass updated, 0 if not.
int etap_mass_flag; // 1 if etap_mass updated, 0 if not. int etap_mass_flag; // 1 if etap_mass updated, 0 if not.
int dipole_flag; // 1 if dipole is updated, 0 if not.
int dlm_flag; // 1 if using the DLM rotational integrator, 0 if not
int scaleyz; // 1 if yz scaled with lz int scaleyz; // 1 if yz scaled with lz
int scalexz; // 1 if xz scaled with lz int scalexz; // 1 if xz scaled with lz

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
@ -67,10 +66,10 @@ ComputeContactAtom::~ComputeContactAtom()
void ComputeContactAtom::init() void ComputeContactAtom::init()
{ {
if (force->pair == nullptr) if (force->pair == nullptr)
error->all(FLERR,"Compute contact/atom requires a pair style be defined"); error->all(FLERR, "Compute contact/atom requires a pair style be defined");
if (modify->get_compute_by_style("contact/atom").size() > 1 && comm->me == 0) if (modify->get_compute_by_style("contact/atom").size() > 1 && comm->me == 0)
error->warning(FLERR,"More than one compute contact/atom"); error->warning(FLERR, "More than one compute contact/atom");
// need an occasional neighbor list // need an occasional neighbor list
@ -88,10 +87,10 @@ void ComputeContactAtom::init_list(int /*id*/, NeighList *ptr)
void ComputeContactAtom::compute_peratom() void ComputeContactAtom::compute_peratom()
{ {
int i,j,ii,jj,inum,jnum; int i, j, ii, jj, inum, jnum;
double xtmp,ytmp,ztmp,delx,dely,delz,rsq; double xtmp, ytmp, ztmp, delx, dely, delz, rsq;
double radi,radsum,radsumsq; double radi, radsum, radsumsq;
int *ilist,*jlist,*numneigh,**firstneigh; int *ilist, *jlist, *numneigh, **firstneigh;
invoked_peratom = update->ntimestep; invoked_peratom = update->ntimestep;
@ -100,7 +99,7 @@ void ComputeContactAtom::compute_peratom()
if (atom->nmax > nmax) { if (atom->nmax > nmax) {
memory->destroy(contact); memory->destroy(contact);
nmax = atom->nmax; nmax = atom->nmax;
memory->create(contact,nmax,"contact/atom:contact"); memory->create(contact, nmax, "contact/atom:contact");
vector_atom = contact; vector_atom = contact;
} }
@ -130,7 +129,7 @@ void ComputeContactAtom::compute_peratom()
i = ilist[ii]; i = ilist[ii];
// Only proceed if i is either part of the compute group or will contribute to contacts // Only proceed if i is either part of the compute group or will contribute to contacts
if (! (mask[i] & groupbit) && ! (mask[i] & jgroupbit)) continue; if (!(mask[i] & groupbit) && !(mask[i] & jgroupbit)) continue;
xtmp = x[i][0]; xtmp = x[i][0];
ytmp = x[i][1]; ytmp = x[i][1];
@ -146,7 +145,7 @@ void ComputeContactAtom::compute_peratom()
// Only tally for atoms in compute group (groupbit) if neighbor is in group2 (jgroupbit) // Only tally for atoms in compute group (groupbit) if neighbor is in group2 (jgroupbit)
update_i_flag = (mask[i] & groupbit) && (mask[j] & jgroupbit); update_i_flag = (mask[i] & groupbit) && (mask[j] & jgroupbit);
update_j_flag = (mask[j] & groupbit) && (mask[i] & jgroupbit); update_j_flag = (mask[j] & groupbit) && (mask[i] & jgroupbit);
if (! update_i_flag && ! update_j_flag) continue; if (!update_i_flag && !update_j_flag) continue;
delx = xtmp - x[j][0]; delx = xtmp - x[j][0];
dely = ytmp - x[j][1]; dely = ytmp - x[j][1];
@ -170,12 +169,11 @@ void ComputeContactAtom::compute_peratom()
int ComputeContactAtom::pack_reverse_comm(int n, int first, double *buf) int ComputeContactAtom::pack_reverse_comm(int n, int first, double *buf)
{ {
int i,m,last; int i, m, last;
m = 0; m = 0;
last = first + n; last = first + n;
for (i = first; i < last; i++) for (i = first; i < last; i++) buf[m++] = contact[i];
buf[m++] = contact[i];
return m; return m;
} }
@ -183,7 +181,7 @@ int ComputeContactAtom::pack_reverse_comm(int n, int first, double *buf)
void ComputeContactAtom::unpack_reverse_comm(int n, int *list, double *buf) void ComputeContactAtom::unpack_reverse_comm(int n, int *list, double *buf)
{ {
int i,j,m; int i, j, m;
m = 0; m = 0;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
@ -198,6 +196,6 @@ void ComputeContactAtom::unpack_reverse_comm(int n, int *list, double *buf)
double ComputeContactAtom::memory_usage() double ComputeContactAtom::memory_usage()
{ {
double bytes = (double)nmax * sizeof(double); double bytes = (double) nmax * sizeof(double);
return bytes; return bytes;
} }

View File

@ -42,7 +42,7 @@ FixDampingCundall::FixDampingCundall(LAMMPS *_lmp, int narg, char **arg) :
if (!atom->sphere_flag) error->all(FLERR, "Fix damping/cundall requires atom style sphere"); if (!atom->sphere_flag) error->all(FLERR, "Fix damping/cundall requires atom style sphere");
if (narg < 5) error->all(FLERR, "Illegal fix damping/cundall command"); if (narg < 5) utils::missing_cmd_args(FLERR, "fix damping/cundall", error);
gamma_lin = utils::numeric(FLERR, arg[3], false, lmp); gamma_lin = utils::numeric(FLERR, arg[3], false, lmp);
gamma_ang = utils::numeric(FLERR, arg[4], false, lmp); gamma_ang = utils::numeric(FLERR, arg[4], false, lmp);

View File

@ -55,7 +55,7 @@ FixWallGran::FixWallGran(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg), idregion(nullptr), tstr(nullptr), history_one(nullptr), Fix(lmp, narg, arg), idregion(nullptr), tstr(nullptr), history_one(nullptr),
fix_rigid(nullptr), mass_rigid(nullptr) fix_rigid(nullptr), mass_rigid(nullptr)
{ {
if (narg < 4) error->all(FLERR,"Illegal fix wall/gran command"); if (narg < 4) utils::missing_cmd_args(FLERR,"fix wall/gran", error);
if (!atom->sphere_flag) if (!atom->sphere_flag)
error->all(FLERR,"Fix wall/gran requires atom style sphere"); error->all(FLERR,"Fix wall/gran requires atom style sphere");
@ -110,7 +110,7 @@ FixWallGran::FixWallGran(LAMMPS *lmp, int narg, char **arg) :
model->limit_damping = 1; model->limit_damping = 1;
iarg += 1; iarg += 1;
} else { } else {
error->all(FLERR, "Illegal fix wall/gran command"); error->all(FLERR, "Unknown fix wall/gran keyword {}", arg[iarg]);
} }
} }
} }
@ -281,8 +281,8 @@ FixWallGran::~FixWallGran()
// delete local storage // delete local storage
delete model; delete model;
delete [] tstr; delete[] tstr;
delete [] idregion; delete[] idregion;
memory->destroy(history_one); memory->destroy(history_one);
memory->destroy(mass_rigid); memory->destroy(mass_rigid);
} }

View File

@ -81,7 +81,7 @@ FixWallGranOld::FixWallGranOld(LAMMPS *lmp, int narg, char **arg) :
else if (strcmp(arg[3],"hooke/history") == 0) pairstyle = HOOKE_HISTORY; else if (strcmp(arg[3],"hooke/history") == 0) pairstyle = HOOKE_HISTORY;
else if (strcmp(arg[3],"hertz/history") == 0) pairstyle = HERTZ_HISTORY; else if (strcmp(arg[3],"hertz/history") == 0) pairstyle = HERTZ_HISTORY;
else if (strcmp(arg[3],"granular") == 0) pairstyle = GRANULAR; else if (strcmp(arg[3],"granular") == 0) pairstyle = GRANULAR;
else error->all(FLERR,"Invalid fix wall/gran interaction style"); else error->all(FLERR,"Invalid fix {} interaction style: {}", style, arg[3]);
use_history = restart_peratom = 1; use_history = restart_peratom = 1;
if (pairstyle == HOOKE) use_history = restart_peratom = 0; if (pairstyle == HOOKE) use_history = restart_peratom = 0;

View File

@ -60,13 +60,10 @@ AtomVecSphere::AtomVecSphere(LAMMPS *lmp) : AtomVec(lmp)
void AtomVecSphere::process_args(int narg, char **arg) void AtomVecSphere::process_args(int narg, char **arg)
{ {
if (narg != 0 && narg != 1) error->all(FLERR, "Illegal atom_style sphere command"); if (narg > 1) error->all(FLERR, "Illegal atom_style sphere command");
radvary = 0; radvary = 0;
if (narg == 1) { if (narg == 1) radvary = utils::logical(FLERR, arg[0], true, lmp);
radvary = utils::numeric(FLERR, arg[0], true, lmp);
if (radvary < 0 || radvary > 1) error->all(FLERR, "Illegal atom_style sphere command");
}
// dynamic particle radius and mass must be communicated every step // dynamic particle radius and mass must be communicated every step

View File

@ -46,8 +46,8 @@ using namespace FixConst;
enum { NOBIAS, BIAS }; enum { NOBIAS, BIAS };
enum { CONSTANT, EQUAL, ATOM }; enum { CONSTANT, EQUAL, ATOM };
#define SINERTIA 0.4 // moment of inertia prefactor for sphere static constexpr double SINERTIA = 0.4; // moment of inertia prefactor for sphere
#define EINERTIA 0.2 // moment of inertia prefactor for ellipsoid static constexpr double EINERTIA = 0.2; // moment of inertia prefactor for ellipsoid
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -789,7 +789,7 @@ void FixLangevin::compute_target()
if (tstyle == EQUAL) { if (tstyle == EQUAL) {
t_target = input->variable->compute_equal(tvar); t_target = input->variable->compute_equal(tvar);
if (t_target < 0.0) if (t_target < 0.0)
error->one(FLERR,"Fix langevin variable returned negative temperature"); error->one(FLERR, "Fix langevin variable returned negative temperature");
tsqrt = sqrt(t_target); tsqrt = sqrt(t_target);
} else { } else {
if (atom->nmax > maxatom2) { if (atom->nmax > maxatom2) {
@ -801,8 +801,7 @@ void FixLangevin::compute_target()
for (int i = 0; i < nlocal; i++) for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) if (mask[i] & groupbit)
if (tforce[i] < 0.0) if (tforce[i] < 0.0)
error->one(FLERR, error->one(FLERR, "Fix langevin variable returned negative temperature");
"Fix langevin variable returned negative temperature");
} }
modify->addstep_compute(update->ntimestep + 1); modify->addstep_compute(update->ntimestep + 1);
} }

View File

@ -38,7 +38,7 @@ enum { LJ93, LJ126, LJ1043, COLLOID, HARMONIC, MORSE };
FixWallRegion::FixWallRegion(LAMMPS *lmp, int narg, char **arg) : FixWallRegion::FixWallRegion(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg), idregion(nullptr), region(nullptr) Fix(lmp, narg, arg), idregion(nullptr), region(nullptr)
{ {
if (narg < 8) error->all(FLERR, "Illegal fix wall/region command"); if (narg < 8) utils::missing_cmd_args(FLERR, "fix wall/region", error);
scalar_flag = 1; scalar_flag = 1;
vector_flag = 1; vector_flag = 1;
@ -70,12 +70,12 @@ FixWallRegion::FixWallRegion(LAMMPS *lmp, int narg, char **arg) :
else if (strcmp(arg[4], "morse") == 0) else if (strcmp(arg[4], "morse") == 0)
style = MORSE; style = MORSE;
else else
error->all(FLERR, "Illegal fix wall/region command"); error->all(FLERR, "Unknown fix wall/region style {}", arg[4]);
if (style != COLLOID) dynamic_group_allow = 1; if (style != COLLOID) dynamic_group_allow = 1;
if (style == MORSE) { if (style == MORSE) {
if (narg != 9) error->all(FLERR, "Illegal fix wall/region command"); if (narg != 9) error->all(FLERR, "Illegal fix wall/region morse command");
epsilon = utils::numeric(FLERR, arg[5], false, lmp); epsilon = utils::numeric(FLERR, arg[5], false, lmp);
alpha = utils::numeric(FLERR, arg[6], false, lmp); alpha = utils::numeric(FLERR, arg[6], false, lmp);