simplified logic from clang-tidy

This commit is contained in:
Axel Kohlmeyer
2023-03-26 21:33:37 -04:00
parent 7787734496
commit 0d8623c3f2
12 changed files with 33 additions and 33 deletions

View File

@ -778,7 +778,7 @@ double PairRESquared::resquared_analytic(const int i, const int j, const RE2Vars
// torque on j // torque on j
if (!(force->newton_pair || j < atom->nlocal)) return Ua + Ur; if (!force->newton_pair && j >= atom->nlocal) return Ua + Ur;
MathExtra::vecmat(fourw, wj.aTe, fwae); MathExtra::vecmat(fourw, wj.aTe, fwae);

View File

@ -125,7 +125,7 @@ ComputeXRD::ComputeXRD(LAMMPS *lmp, int narg, char **arg) :
if (iarg+2 > narg) error->all(FLERR,"Illegal Compute XRD Command"); if (iarg+2 > narg) error->all(FLERR,"Illegal Compute XRD Command");
LP = utils::numeric(FLERR,arg[iarg+1],false,lmp); LP = utils::numeric(FLERR,arg[iarg+1],false,lmp);
if (!(LP == 1 || LP == 0)) if (LP != 1 && LP != 0)
error->all(FLERR,"Compute XRD: LP must have value of 0 or 1"); error->all(FLERR,"Compute XRD: LP must have value of 0 or 1");
iarg += 2; iarg += 2;

View File

@ -158,7 +158,7 @@ void ElectrodeMatrix::pair_contribution(double **array)
aij *= ElectrodeMath::safe_erfc(g_ewald * r); aij *= ElectrodeMath::safe_erfc(g_ewald * r);
aij -= ElectrodeMath::safe_erfc(etaij * r) * rinv; aij -= ElectrodeMath::safe_erfc(etaij * r) * rinv;
// newton on or off? // newton on or off?
if (!(newton_pair || j < nlocal)) aij *= 0.5; if (!newton_pair && j >= nlocal) aij *= 0.5;
bigint jpos = tag_to_iele[tag[j]]; bigint jpos = tag_to_iele[tag[j]];
array[ipos][jpos] += aij; array[ipos][jpos] += aij;
array[jpos][ipos] += aij; array[jpos][ipos] += aij;

View File

@ -637,7 +637,7 @@ void remap_3d_destroy_plan(struct remap_plan_3d *plan)
{ {
// free MPI communicator // free MPI communicator
if (!((plan->usecollective) && (plan->commringlen == 0))) if (!(plan->usecollective) || (plan->commringlen != 0))
MPI_Comm_free(&plan->comm); MPI_Comm_free(&plan->comm);
if (plan->usecollective) { if (plan->usecollective) {

View File

@ -1775,7 +1775,7 @@ double PairAIREBO::bondorder(int i, int j, double rij[3], double rijmag, double
atoml = REBO_neighs_j[l]; atoml = REBO_neighs_j[l];
atom4 = atoml; atom4 = atoml;
ltype = map[type[atoml]]; ltype = map[type[atoml]];
if (!(atoml == atomi || atoml == atomk)) { if (atoml != atomi && atoml != atomk) {
r34[0] = x[atom3][0]-x[atom4][0]; r34[0] = x[atom3][0]-x[atom4][0];
r34[1] = x[atom3][1]-x[atom4][1]; r34[1] = x[atom3][1]-x[atom4][1];
r34[2] = x[atom3][2]-x[atom4][2]; r34[2] = x[atom3][2]-x[atom4][2];
@ -2284,7 +2284,7 @@ double PairAIREBO::bondorderLJ(int i, int j, double /* rij_mod */[3], double rij
atoml = REBO_neighs_j[l]; atoml = REBO_neighs_j[l];
atom4 = atoml; atom4 = atoml;
ltype = map[type[atoml]]; ltype = map[type[atoml]];
if (!(atoml == atomi || atoml == atomk)) { if (atoml != atomi && atoml != atomk) {
r34[0] = x[atom3][0]-x[atom4][0]; r34[0] = x[atom3][0]-x[atom4][0];
r34[1] = x[atom3][1]-x[atom4][1]; r34[1] = x[atom3][1]-x[atom4][1];
r34[2] = x[atom3][2]-x[atom4][2]; r34[2] = x[atom3][2]-x[atom4][2];
@ -2732,7 +2732,7 @@ double PairAIREBO::bondorderLJ(int i, int j, double /* rij_mod */[3], double rij
atoml = REBO_neighs_j[l]; atoml = REBO_neighs_j[l];
atom4 = atoml; atom4 = atoml;
ltype = map[type[atoml]]; ltype = map[type[atoml]];
if (!(atoml == atomi || atoml == atomk)) { if (atoml != atomi && atoml != atomk) {
r34[0] = x[atom3][0]-x[atom4][0]; r34[0] = x[atom3][0]-x[atom4][0];
r34[1] = x[atom3][1]-x[atom4][1]; r34[1] = x[atom3][1]-x[atom4][1];
r34[2] = x[atom3][2]-x[atom4][2]; r34[2] = x[atom3][2]-x[atom4][2];

View File

@ -481,7 +481,7 @@ void PairMesoCNT::compute(int eflag, int vflag)
geometry(r1, r2, p1, p2, nullptr, p, m, param, basis); geometry(r1, r2, p1, p2, nullptr, p, m, param, basis);
if (param[0] > cutoff) continue; if (param[0] > cutoff) continue;
if (!(param[2] < 0 && param[3] > 0)) { if (param[2] >= 0 || param[3] <= 0) {
double salpha = sin(param[1]); double salpha = sin(param[1]);
double sxi1 = salpha * param[2]; double sxi1 = salpha * param[2];
double sxi2 = salpha * param[3]; double sxi2 = salpha * param[3];
@ -503,7 +503,7 @@ void PairMesoCNT::compute(int eflag, int vflag)
geometry(r1, r2, p2, p1, qe, p, m, param, basis); geometry(r1, r2, p2, p1, qe, p, m, param, basis);
if (param[0] > cutoff) continue; if (param[0] > cutoff) continue;
if (!(param[2] < 0 && param[3] > 0)) { if (param[2] >= 0 || param[3] <= 0) {
double hsq = param[0] * param[0]; double hsq = param[0] * param[0];
double calpha = cos(param[1]); double calpha = cos(param[1]);
double etamin = calpha * param[2]; double etamin = calpha * param[2];

View File

@ -485,7 +485,7 @@ void PairMesoCNTViscous::compute(int eflag, int vflag)
geometry(r1, r2, p1, p2, nullptr, p, m, param, basis); geometry(r1, r2, p1, p2, nullptr, p, m, param, basis);
if (param[0] > cutoff) continue; if (param[0] > cutoff) continue;
if (!(param[2] < 0 && param[3] > 0)) { if (param[2] >= 0 || param[3] <= 0) {
double salpha = sin(param[1]); double salpha = sin(param[1]);
double sxi1 = salpha * param[2]; double sxi1 = salpha * param[2];
double sxi2 = salpha * param[3]; double sxi2 = salpha * param[3];
@ -508,7 +508,7 @@ void PairMesoCNTViscous::compute(int eflag, int vflag)
geometry(r1, r2, p2, p1, qe, p, m, param, basis); geometry(r1, r2, p2, p1, qe, p, m, param, basis);
if (param[0] > cutoff) continue; if (param[0] > cutoff) continue;
if (!(param[2] < 0 && param[3] > 0)) { if (param[2] >= 0 || param[3] <= 0) {
double hsq = param[0] * param[0]; double hsq = param[0] * param[0];
double calpha = cos(param[1]); double calpha = cos(param[1]);
double etamin = calpha * param[2]; double etamin = calpha * param[2];

View File

@ -1546,7 +1546,7 @@ double PairAIREBOOMP::bondorder_thr(int i, int j, double rij[3], double rijmag,
atoml = REBO_neighs_j[l]; atoml = REBO_neighs_j[l];
atom4 = atoml; atom4 = atoml;
ltype = map[type[atoml]]; ltype = map[type[atoml]];
if (!(atoml == atomi || atoml == atomk)) { if (atoml != atomi && atoml != atomk) {
r34[0] = x[atom3][0]-x[atom4][0]; r34[0] = x[atom3][0]-x[atom4][0];
r34[1] = x[atom3][1]-x[atom4][1]; r34[1] = x[atom3][1]-x[atom4][1];
r34[2] = x[atom3][2]-x[atom4][2]; r34[2] = x[atom3][2]-x[atom4][2];
@ -2048,7 +2048,7 @@ double PairAIREBOOMP::bondorderLJ_thr(int i, int j, double /* rij_mod */[3], dou
atoml = REBO_neighs_j[l]; atoml = REBO_neighs_j[l];
atom4 = atoml; atom4 = atoml;
ltype = map[type[atoml]]; ltype = map[type[atoml]];
if (!(atoml == atomi || atoml == atomk)) { if (atoml != atomi && atoml != atomk) {
r34[0] = x[atom3][0]-x[atom4][0]; r34[0] = x[atom3][0]-x[atom4][0];
r34[1] = x[atom3][1]-x[atom4][1]; r34[1] = x[atom3][1]-x[atom4][1];
r34[2] = x[atom3][2]-x[atom4][2]; r34[2] = x[atom3][2]-x[atom4][2];
@ -2496,7 +2496,7 @@ double PairAIREBOOMP::bondorderLJ_thr(int i, int j, double /* rij_mod */[3], dou
atoml = REBO_neighs_j[l]; atoml = REBO_neighs_j[l];
atom4 = atoml; atom4 = atoml;
ltype = map[type[atoml]]; ltype = map[type[atoml]];
if (!(atoml == atomi || atoml == atomk)) { if (atoml != atomi && atoml != atomk) {
r34[0] = x[atom3][0]-x[atom4][0]; r34[0] = x[atom3][0]-x[atom4][0];
r34[1] = x[atom3][1]-x[atom4][1]; r34[1] = x[atom3][1]-x[atom4][1];
r34[2] = x[atom3][2]-x[atom4][2]; r34[2] = x[atom3][2]-x[atom4][2];

View File

@ -1358,7 +1358,7 @@ void FixBondReact::superimpose_algorithm()
int hang_catch = 0; int hang_catch = 0;
while (!(status == ACCEPT || status == REJECT)) { while (status != ACCEPT && status != REJECT) {
for (int i = 0; i < max_natoms; i++) { for (int i = 0; i < max_natoms; i++) {
pioneers[i] = 0; pioneers[i] = 0;
@ -4176,7 +4176,7 @@ void FixBondReact::ReadConstraints(char *line, int myrxn)
tmp[3] = 182.0; tmp[3] = 182.0;
rv = sscanf(line,"%*s %s %s %s %s %lg %lg %lg %lg",strargs[0],strargs[1], rv = sscanf(line,"%*s %s %s %s %s %lg %lg %lg %lg",strargs[0],strargs[1],
strargs[2],strargs[3],&tmp[0],&tmp[1],&tmp[2],&tmp[3]); strargs[2],strargs[3],&tmp[0],&tmp[1],&tmp[2],&tmp[3]);
if (!(rv == 6 || rv == 8)) error->one(FLERR, "Dihedral constraint is incorrectly formatted"); if (rv != 6 && rv != 8) error->one(FLERR, "Dihedral constraint is incorrectly formatted");
readID(strargs[0], i, myrxn, 0); readID(strargs[0], i, myrxn, 0);
readID(strargs[1], i, myrxn, 1); readID(strargs[1], i, myrxn, 1);
readID(strargs[2], i, myrxn, 2); readID(strargs[2], i, myrxn, 2);
@ -4198,7 +4198,7 @@ void FixBondReact::ReadConstraints(char *line, int myrxn)
constraints[i][myrxn].type = RMSD; constraints[i][myrxn].type = RMSD;
strcpy(strargs[0],"0"); strcpy(strargs[0],"0");
rv = sscanf(line,"%*s %lg %s",&tmp[0],strargs[0]); rv = sscanf(line,"%*s %lg %s",&tmp[0],strargs[0]);
if (!(rv == 1 || rv == 2)) error->one(FLERR, "RMSD constraint is incorrectly formatted"); if (rv != 1 && rv != 2) error->one(FLERR, "RMSD constraint is incorrectly formatted");
constraints[i][myrxn].par[0] = tmp[0]; // RMSDmax constraints[i][myrxn].par[0] = tmp[0]; // RMSDmax
constraints[i][myrxn].id[0] = -1; // optional molecule fragment constraints[i][myrxn].id[0] = -1; // optional molecule fragment
if (isalpha(strargs[0][0])) { if (isalpha(strargs[0][0])) {

View File

@ -804,7 +804,7 @@ Calculate ideal positions for parallel "ideal" or "equal"
void FixNEB::calculate_ideal_positions() void FixNEB::calculate_ideal_positions()
{ {
// Skip unless "ideal" or "equal" // Skip unless "ideal" or "equal"
if (!((neb_mode == IDEAL) || (neb_mode == EQUAL))) return; if ((neb_mode != IDEAL) && (neb_mode != EQUAL)) return;
double lentot, lenuntilClimber; double lentot, lenuntilClimber;
double meanDist, meanDistBeforeClimber, meanDistAfterClimber; double meanDist, meanDistBeforeClimber, meanDistAfterClimber;

View File

@ -831,10 +831,10 @@ bool FixRattle::check2(double **v, int m, bool checkr, bool checkv)
domain->minimum_image(r01); domain->minimum_image(r01);
MathExtra::sub3(v[i1],v[i0],v01); MathExtra::sub3(v[i1],v[i0],v01);
stat = !(checkr && (fabs(sqrt(MathExtra::dot3(r01,r01)) - bond1) > tol)); stat = !checkr || (fabs(sqrt(MathExtra::dot3(r01,r01)) - bond1) <= tol);
if (!stat) error->one(FLERR,"Coordinate constraints are not satisfied up to desired tolerance "); if (!stat) error->one(FLERR,"Coordinate constraints are not satisfied up to desired tolerance ");
stat = !(checkv && (fabs(MathExtra::dot3(r01,v01)) > tol)); stat = !checkv || (fabs(MathExtra::dot3(r01,v01)) <= tol);
if (!stat) error->one(FLERR,"Velocity constraints are not satisfied up to desired tolerance "); if (!stat) error->one(FLERR,"Velocity constraints are not satisfied up to desired tolerance ");
return stat; return stat;
} }
@ -863,12 +863,12 @@ bool FixRattle::check3(double **v, int m, bool checkr, bool checkv)
MathExtra::sub3(v[i1],v[i0],v01); MathExtra::sub3(v[i1],v[i0],v01);
MathExtra::sub3(v[i2],v[i0],v02); MathExtra::sub3(v[i2],v[i0],v02);
stat = !(checkr && (fabs(sqrt(MathExtra::dot3(r01,r01)) - bond1) > tol || stat = !checkr || (fabs(sqrt(MathExtra::dot3(r01,r01)) - bond1) <= tol &&
fabs(sqrt(MathExtra::dot3(r02,r02))-bond2) > tol)); fabs(sqrt(MathExtra::dot3(r02,r02))-bond2) <= tol);
if (!stat) error->one(FLERR,"Coordinate constraints are not satisfied up to desired tolerance "); if (!stat) error->one(FLERR,"Coordinate constraints are not satisfied up to desired tolerance ");
stat = !(checkv && (fabs(MathExtra::dot3(r01,v01)) > tol || stat = !checkv || (fabs(MathExtra::dot3(r01,v01)) <= tol &&
fabs(MathExtra::dot3(r02,v02)) > tol)); fabs(MathExtra::dot3(r02,v02)) <= tol);
if (!stat) error->one(FLERR,"Velocity constraints are not satisfied up to desired tolerance "); if (!stat) error->one(FLERR,"Velocity constraints are not satisfied up to desired tolerance ");
return stat; return stat;
} }
@ -901,14 +901,14 @@ bool FixRattle::check4(double **v, int m, bool checkr, bool checkv)
MathExtra::sub3(v[i2],v[i0],v02); MathExtra::sub3(v[i2],v[i0],v02);
MathExtra::sub3(v[i3],v[i0],v03); MathExtra::sub3(v[i3],v[i0],v03);
stat = !(checkr && (fabs(sqrt(MathExtra::dot3(r01,r01)) - bond1) > tol || stat = !checkr || (fabs(sqrt(MathExtra::dot3(r01,r01)) - bond1) <= tol &&
fabs(sqrt(MathExtra::dot3(r02,r02))-bond2) > tol || fabs(sqrt(MathExtra::dot3(r02,r02))-bond2) <= tol &&
fabs(sqrt(MathExtra::dot3(r03,r03))-bond3) > tol)); fabs(sqrt(MathExtra::dot3(r03,r03))-bond3) <= tol);
if (!stat) error->one(FLERR,"Coordinate constraints are not satisfied up to desired tolerance "); if (!stat) error->one(FLERR,"Coordinate constraints are not satisfied up to desired tolerance ");
stat = !(checkv && (fabs(MathExtra::dot3(r01,v01)) > tol || stat = !checkv || (fabs(MathExtra::dot3(r01,v01)) <= tol &&
fabs(MathExtra::dot3(r02,v02)) > tol || fabs(MathExtra::dot3(r02,v02)) <= tol &&
fabs(MathExtra::dot3(r03,v03)) > tol)); fabs(MathExtra::dot3(r03,v03)) <= tol);
if (!stat) error->one(FLERR,"Velocity constraints are not satisfied up to desired tolerance "); if (!stat) error->one(FLERR,"Velocity constraints are not satisfied up to desired tolerance ");
return stat; return stat;
} }
@ -944,7 +944,7 @@ bool FixRattle::check3angle(double **v, int m, bool checkr, bool checkv)
double db2 = fabs(sqrt(MathExtra::dot3(r02,r02))-bond2); double db2 = fabs(sqrt(MathExtra::dot3(r02,r02))-bond2);
double db12 = fabs(sqrt(MathExtra::dot3(r12,r12))-bond12); double db12 = fabs(sqrt(MathExtra::dot3(r12,r12))-bond12);
stat = !(checkr && (db1 > tol || db2 > tol || db12 > tol)); stat = !checkr || (db1 <= tol && db2 <= tol && db12 <= tol);
if (derr_max < db1/bond1) derr_max = db1/bond1; if (derr_max < db1/bond1) derr_max = db1/bond1;
if (derr_max < db2/bond2) derr_max = db2/bond2; if (derr_max < db2/bond2) derr_max = db2/bond2;
@ -962,7 +962,7 @@ bool FixRattle::check3angle(double **v, int m, bool checkr, bool checkv)
if (verr_max < dv2) verr_max = dv2; if (verr_max < dv2) verr_max = dv2;
if (verr_max < dv12) verr_max = dv12; if (verr_max < dv12) verr_max = dv12;
stat = !(checkv && (dv1 > tol || dv2 > tol || dv12> tol)); stat = !checkv || (dv1 <= tol && dv2 <= tol && dv12<= tol);
#if RATTLE_RAISE_ERROR #if RATTLE_RAISE_ERROR
if (!stat) error->one(FLERR,"Velocity constraints are not satisfied up to desired tolerance!"); if (!stat) error->one(FLERR,"Velocity constraints are not satisfied up to desired tolerance!");

View File

@ -607,7 +607,7 @@ void Input::substitute(char *&str, char *&str2, int &max, int &max2, int flag)
paren_count = 0; paren_count = 0;
i = 0; i = 0;
while (var[i] != '\0' && !(var[i] == ')' && paren_count == 0)) { while (var[i] != '\0' && (var[i] != ')' || paren_count != 0)) {
switch (var[i]) { switch (var[i]) {
case '(': paren_count++; break; case '(': paren_count++; break;
case ')': paren_count--; break; case ')': paren_count--; break;