make double to bool/int/tagint conversions explicit

This commit is contained in:
Axel Kohlmeyer
2025-06-29 19:10:29 -04:00
parent b279ba9a40
commit fee96bc777
11 changed files with 24 additions and 24 deletions

View File

@ -95,7 +95,7 @@ void Group2Ndx::write_group(FILE *fp, int gid)
} else { } else {
utils::print(fp, "[ {} ]\n", group->names[gid]); utils::print(fp, "[ {} ]\n", group->names[gid]);
} }
width = log10((double) atom->natoms) + 2; width = (int) log10((double) atom->natoms) + 2;
cols = 80 / width; cols = 80 / width;
} }

View File

@ -72,7 +72,7 @@ void EwaldDipole::init()
dipoleflag = atom->mu?1:0; dipoleflag = atom->mu?1:0;
qsum_qsq(0); // q[i] might not be declared ? qsum_qsq(0); // q[i] might not be declared ?
if (dipoleflag && q2) if (dipoleflag && (q2 != 0.0))
error->all(FLERR,"Cannot (yet) use charges with Kspace style EwaldDipole"); error->all(FLERR,"Cannot (yet) use charges with Kspace style EwaldDipole");
// no triclinic ewald dipole (yet) // no triclinic ewald dipole (yet)

View File

@ -95,7 +95,7 @@ void PPPMDipole::init()
dipoleflag = atom->mu?1:0; dipoleflag = atom->mu?1:0;
qsum_qsq(0); // q[i] might not be declared ? qsum_qsq(0); // q[i] might not be declared ?
if (dipoleflag && q2) if (dipoleflag && (q2 != 0.0))
error->all(FLERR,"Cannot (yet) use charges with Kspace style PPPMDipole"); error->all(FLERR,"Cannot (yet) use charges with Kspace style PPPMDipole");
triclinic_check(); triclinic_check();

View File

@ -399,7 +399,7 @@ void PairSNAP::coeff(int narg, char **arg)
// ncoeffall should be (ncoeff+2)*(ncoeff+1)/2 // ncoeffall should be (ncoeff+2)*(ncoeff+1)/2
// so, ncoeff = floor(sqrt(2*ncoeffall))-1 // so, ncoeff = floor(sqrt(2*ncoeffall))-1
ncoeff = sqrt(2.0*ncoeffall)-1; ncoeff = (int) sqrt(2.0*ncoeffall) - 1;
ncoeffq = (ncoeff*(ncoeff+1))/2; ncoeffq = (ncoeff*(ncoeff+1))/2;
int ntmp = 1+ncoeff+ncoeffq; int ntmp = 1+ncoeff+ncoeffq;
if (ntmp != ncoeffall) { if (ntmp != ncoeffall) {

View File

@ -248,8 +248,8 @@ FixReaxFFSpecies::FixReaxFFSpecies(LAMMPS *lmp, int narg, char **arg) :
error->all(FLERR, iarg + 1, "Fix reaxff/species: Variable {} is not equal-style", error->all(FLERR, iarg + 1, "Fix reaxff/species: Variable {} is not equal-style",
delete_Nlimit_varname); delete_Nlimit_varname);
} else } else
delete_Nlimit = utils::numeric(FLERR, arg[iarg + 1], false, lmp); delete_Nlimit = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
delete_Nsteps = utils::numeric(FLERR, arg[iarg + 2], false, lmp); delete_Nsteps = utils::inumeric(FLERR, arg[iarg + 2], false, lmp);
iarg += 3; iarg += 3;
// position of molecules // position of molecules
} else if (strcmp(arg[iarg], "position") == 0) { } else if (strcmp(arg[iarg], "position") == 0) {
@ -956,7 +956,7 @@ void FixReaxFFSpecies::DeleteSpecies(int Nmole, int Nspec)
} }
ndeletions = delete_Tcount[0] - delete_Tcount[delete_Nsteps - 1]; ndeletions = delete_Tcount[0] - delete_Tcount[delete_Nsteps - 1];
if (delete_Nlimit_varid > -1) if (delete_Nlimit_varid > -1)
delete_Nlimit = input->variable->compute_equal(delete_Nlimit_varid); delete_Nlimit = (int) input->variable->compute_equal(delete_Nlimit_varid);
headroom = MAX(0, delete_Nlimit - ndeletions); headroom = MAX(0, delete_Nlimit - ndeletions);
if (headroom == 0) { if (headroom == 0) {
for (i = delete_Nsteps - 1; i > 0; i--) delete_Tcount[i] = delete_Tcount[i - 1]; for (i = delete_Nsteps - 1; i > 0; i--) delete_Tcount[i] = delete_Tcount[i - 1];
@ -1117,11 +1117,11 @@ void FixReaxFFSpecies::DeleteSpecies(int Nmole, int Nspec)
} else { } else {
int writeflag = 0; int writeflag = 0;
for (i = 0; i < ndelspec; i++) for (i = 0; i < ndelspec; i++)
if (deletecount[i]) writeflag = 1; if (deletecount[i] != 0.0) writeflag = 1;
if (writeflag) { if (writeflag) {
utils::print(fdel, "{}", update->ntimestep); utils::print(fdel, "{}", update->ntimestep);
for (i = 0; i < ndelspec; i++) { fprintf(fdel, "\t%g", deletecount[i]); } for (i = 0; i < ndelspec; i++) fprintf(fdel, "\t%g", deletecount[i]);
fprintf(fdel, "\n"); fprintf(fdel, "\n");
fflush(fdel); fflush(fdel);
} }

View File

@ -254,8 +254,8 @@ void Hyper::command(int narg, char **arg)
if (hyperenable) { if (hyperenable) {
t_hyper = fix_hyper->query(1); t_hyper = fix_hyper->query(1);
nevent_running = fix_hyper->query(2); nevent_running = (int) fix_hyper->query(2);
nevent_atoms_running = fix_hyper->query(3); nevent_atoms_running = (int) fix_hyper->query(3);
avebonds = fix_hyper->query(4); avebonds = fix_hyper->query(4);
maxdrift = fix_hyper->query(5); maxdrift = fix_hyper->query(5);
maxbondlen = fix_hyper->query(6); maxbondlen = fix_hyper->query(6);

View File

@ -2729,7 +2729,7 @@ void FixShake::stats()
// print stats only for non-zero counts // print stats only for non-zero counts
if (comm->me == 0) { if (comm->me == 0) {
const int width = log10((double)(MAX(MAX(1,nb),na)))+2; const int width = (int) log10((double)(MAX(MAX(1,nb),na))) + 2;
auto mesg = fmt::format("{} stats (type/ave/delta/count) on step {}\n", auto mesg = fmt::format("{} stats (type/ave/delta/count) on step {}\n",
utils::uppercase(style), update->ntimestep); utils::uppercase(style), update->ntimestep);
for (int i = 1; i < nb; i++) { for (int i = 1; i < nb; i++) {

View File

@ -91,10 +91,10 @@ UEFBox::UEFBox()
mul_m2(l0t,t2i); mul_m2(l0t,t2i);
for (int k=0; k<3; ++k) for (int k=0; k<3; ++k)
for (int j=0; j<3; ++j) { for (int j=0; j<3; ++j) {
a1[k][j] = round(t1[k][j]); a1[k][j] = (int)round(t1[k][j]);
a1i[k][j] = round(t1i[k][j]); a1i[k][j] = (int)round(t1i[k][j]);
a2[k][j] = round(t2[k][j]); a2[k][j] = (int)round(t2[k][j]);
a2i[k][j] = round(t2i[k][j]); a2i[k][j] = (int)round(t2i[k][j]);
} }
// winv used to transform between // winv used to transform between
@ -173,8 +173,8 @@ bool UEFBox::reduce()
// determine how many times to apply the automorphisms and find new theta // determine how many times to apply the automorphisms and find new theta
// values // values
int f1 = round(theta[0]); int f1 = (int)round(theta[0]);
int f2 = round(theta[1]); int f2 = (int)round(theta[1]);
theta[0] -= f1; theta[0] -= f1;
theta[1] -= f2; theta[1] -= f2;
@ -351,8 +351,8 @@ void red3(double b[3][3], int r[3][3], int ri[3][3])
double min = col_prod(b,2,2); double min = col_prod(b,2,2);
int x1v[2]; int x1v[2];
int x2v[2]; int x2v[2];
x1v[0] = floor(y1); x1v[1] = x1v[0]+1; x1v[0] = (int) floor(y1); x1v[1] = x1v[0]+1;
x2v[0] = floor(y2); x2v[1] = x2v[0]+1; x2v[0] = (int) floor(y2); x2v[1] = x2v[0]+1;
for (int k=0;k<2;k++) for (int k=0;k<2;k++)
for (int j=0;j<2;j++) { for (int j=0;j<2;j++) {
double a[3]; double a[3];

View File

@ -371,7 +371,7 @@ void FixBoxRelax::init()
// detect if any rigid fixes exist so rigid bodies move when box is remapped // detect if any rigid fixes exist so rigid bodies move when box is remapped
rfix.clear(); rfix.clear();
for (auto &ifix : modify->get_fix_list()) for (const auto &ifix : modify->get_fix_list())
if (ifix->rigid_flag) rfix.push_back(ifix); if (ifix->rigid_flag) rfix.push_back(ifix);
// initial box dimensions // initial box dimensions
@ -911,7 +911,7 @@ void FixBoxRelax::compute_press_target()
p_hydro = 0.0; p_hydro = 0.0;
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
if (p_flag[i]) p_hydro += p_target[i]; if (p_flag[i]) p_hydro += p_target[i];
if (pflagsum) p_hydro /= pflagsum; if (pflagsum != 0.0) p_hydro /= pflagsum;
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
if (p_flag[i] && fabs(p_hydro - p_target[i]) > 1.0e-6) deviatoric_flag = 1; if (p_flag[i] && fabs(p_hydro - p_target[i]) > 1.0e-6) deviatoric_flag = 1;

View File

@ -181,7 +181,7 @@ void FixSpringChunk::post_force(int /*vflag*/)
r = sqrt(dx*dx + dy*dy + dz*dz); r = sqrt(dx*dx + dy*dy + dz*dz);
r = MAX(r,SMALL); r = MAX(r,SMALL);
if (masstotal[m]) { if (masstotal[m] != 0.0) {
fcom[m][0] = k_spring*dx/r / masstotal[m]; fcom[m][0] = k_spring*dx/r / masstotal[m];
fcom[m][1] = k_spring*dy/r / masstotal[m]; fcom[m][1] = k_spring*dy/r / masstotal[m];
fcom[m][2] = k_spring*dz/r / masstotal[m]; fcom[m][2] = k_spring*dz/r / masstotal[m];

View File

@ -1837,7 +1837,7 @@ void Set::invoke_mol(Action *action)
if (!select[i]) continue; if (!select[i]) continue;
if (varflag) { if (varflag) {
molID = vec1[i]; molID = (tagint)vec1[i];
if (molID < 0) error->one(FLERR,"Invalid molecule ID in set command"); if (molID < 0) error->one(FLERR,"Invalid molecule ID in set command");
} }