From 91582f6d69d6483f0c2e0e60c6561dfd7dbfe396 Mon Sep 17 00:00:00 2001 From: Jean-Luc Fattebert Date: Mon, 4 Mar 2024 10:35:14 -0500 Subject: [PATCH] Fix a bunch of compiler warnings (#59) --- drivers/computeKKS3Ph2Sl.cc | 1 - src/CALPHADFreeEnergyFunctionsBinary3Ph2Sl.cc | 4 --- ...PHADFreeEnergyFunctionsBinaryThreePhase.cc | 4 --- src/CALPHADSpeciesPhaseGibbsEnergy.cc | 4 +-- src/LinearSolver.cc | 18 +++++----- src/NewtonSolver.cc | 36 +++++++++---------- src/QuadraticFreeEnergyFunctionsBinary.h | 13 ++++--- ...raticFreeEnergyFunctionsBinaryThreePhase.h | 17 ++++----- ...ticFreeEnergyFunctionsTernaryThreePhase.cc | 5 ++- ...aticFreeEnergyFunctionsTernaryThreePhase.h | 7 ++-- 10 files changed, 49 insertions(+), 60 deletions(-) diff --git a/drivers/computeKKS3Ph2Sl.cc b/drivers/computeKKS3Ph2Sl.cc index a34338f..67b5542 100644 --- a/drivers/computeKKS3Ph2Sl.cc +++ b/drivers/computeKKS3Ph2Sl.cc @@ -29,7 +29,6 @@ int main(int argc, char* argv[]) = Thermo4PFM::ConcInterpolationType::LINEAR; std::cout << "Temperature: " << temperature << std::endl; - double nominalc[2] = { 0.6, 0.035 }; std::cout << "Read CALPHAD database..." << std::endl; pt::ptree calphad_db; diff --git a/src/CALPHADFreeEnergyFunctionsBinary3Ph2Sl.cc b/src/CALPHADFreeEnergyFunctionsBinary3Ph2Sl.cc index 1482228..ca9554f 100644 --- a/src/CALPHADFreeEnergyFunctionsBinary3Ph2Sl.cc +++ b/src/CALPHADFreeEnergyFunctionsBinary3Ph2Sl.cc @@ -551,10 +551,6 @@ double CALPHADFreeEnergyFunctionsBinary3Ph2Sl::fchem( double fa = 0.; double fb = 0.; - bool pure_phase_0 = phi[0] > tol; - bool pure_phase_1 = phi[1] > tol; - bool pure_phase_2 = phi[2] > tol; - if ((1.0 - phi[0] > tol) && (1.0 - phi[1] > tol) && (1.0 - phi[2] > tol)) { computePhasesFreeEnergies(temperature, hcphi, conc[0], fl, fa, fb); diff --git a/src/CALPHADFreeEnergyFunctionsBinaryThreePhase.cc b/src/CALPHADFreeEnergyFunctionsBinaryThreePhase.cc index 3cc9590..c4e7c65 100644 --- a/src/CALPHADFreeEnergyFunctionsBinaryThreePhase.cc +++ b/src/CALPHADFreeEnergyFunctionsBinaryThreePhase.cc @@ -377,10 +377,6 @@ double CALPHADFreeEnergyFunctionsBinaryThreePhase::fchem( double fa = 0.; double fb = 0.; - bool pure_phase_0 = phi[0] > tol; - bool pure_phase_1 = phi[1] > tol; - bool pure_phase_2 = phi[2] > tol; - if ((1.0 - phi[0] > tol) && (1.0 - phi[1] > tol) && (1.0 - phi[2] > tol)) { computePhasesFreeEnergies(temperature, hcphi, conc[0], fl, fa, fb); diff --git a/src/CALPHADSpeciesPhaseGibbsEnergy.cc b/src/CALPHADSpeciesPhaseGibbsEnergy.cc index 9b6f6ff..1df3eef 100644 --- a/src/CALPHADSpeciesPhaseGibbsEnergy.cc +++ b/src/CALPHADSpeciesPhaseGibbsEnergy.cc @@ -24,7 +24,7 @@ namespace Thermo4PFM { void read_optional(pt::ptree& db, const std::string key, - std::vector& coeffs, const int nintervals) + std::vector& coeffs, const unsigned int nintervals) { if (db.get_child_optional(key)) { @@ -57,7 +57,7 @@ void CALPHADSpeciesPhaseGibbsEnergy::initialize( assert(ntc > 1); assert(ntc < MAXNINTERVALS + 2); - for (int i = 0; i < ntc; i++) + for (size_t i = 0; i < ntc; i++) tc_[i] = tmp[i]; nintervals_ = ntc - 1; diff --git a/src/LinearSolver.cc b/src/LinearSolver.cc index 681c9ab..fcb4b3e 100644 --- a/src/LinearSolver.cc +++ b/src/LinearSolver.cc @@ -27,9 +27,9 @@ void LinearSolver::CopyMatrix( assert(dst != nullptr); #endif - for (int jj = 0; jj < Dimension; jj++) + for (unsigned int jj = 0; jj < Dimension; jj++) { - for (int ii = 0; ii < Dimension; ii++) + for (unsigned int ii = 0; ii < Dimension; ii++) { dst[jj][ii] = src[jj][ii]; } @@ -47,7 +47,7 @@ void LinearSolver::UpdateSolution( JacobianDataType memf[Dimension * Dimension]; JacobianDataType* mwork[Dimension]; - for (int ii = 0; ii < Dimension; ii++) + for (unsigned int ii = 0; ii < Dimension; ii++) { mwork[ii] = &memf[ii * Dimension]; } @@ -56,10 +56,10 @@ void LinearSolver::UpdateSolution( const double D_inv = 1.0 / D; // use Cramer's rule to solve linear system - for (int jj = 0; jj < Dimension; jj++) + for (unsigned int jj = 0; jj < Dimension; jj++) { CopyMatrix(mwork, fjac); - for (int ii = 0; ii < Dimension; ii++) + for (unsigned int ii = 0; ii < Dimension; ii++) { mwork[ii][jj] = fvec[ii]; } @@ -67,7 +67,7 @@ void LinearSolver::UpdateSolution( del_c[jj] = D_inv * evalDeterminant(mwork); } - for (int ii = 0; ii < Dimension; ii++) + for (unsigned int ii = 0; ii < Dimension; ii++) { c[ii] = c[ii] - del_c[ii]; } @@ -88,18 +88,18 @@ int LinearSolver::CheckTolerance( const double* const fvec, const double tol) { bool ret = true; - for (int ii = 0; ii < Dimension; ii++) + for (unsigned int ii = 0; ii < Dimension; ii++) { ret = (ret && (fabs(fvec[ii]) < tol)); } @@ -56,9 +56,9 @@ void NewtonSolver::CopyMatrix( assert(dst != nullptr); #endif - for (int jj = 0; jj < Dimension; jj++) + for (unsigned int jj = 0; jj < Dimension; jj++) { - for (int ii = 0; ii < Dimension; ii++) + for (unsigned int ii = 0; ii < Dimension; ii++) { dst[jj][ii] = src[jj][ii]; } @@ -77,7 +77,7 @@ void NewtonSolver::UpdateSolution( JacobianDataType memf[Dimension * Dimension]; JacobianDataType* mwork[Dimension]; - for (int ii = 0; ii < Dimension; ii++) + for (unsigned int ii = 0; ii < Dimension; ii++) { mwork[ii] = &memf[ii * Dimension]; } @@ -86,10 +86,10 @@ void NewtonSolver::UpdateSolution( const double D_inv = 1.0 / D; // use Cramer's rule to solve linear system - for (int jj = 0; jj < Dimension; jj++) + for (unsigned int jj = 0; jj < Dimension; jj++) { CopyMatrix(mwork, fjac); - for (int ii = 0; ii < Dimension; ii++) + for (unsigned int ii = 0; ii < Dimension; ii++) { mwork[ii][jj] = fvec[ii]; } @@ -103,7 +103,7 @@ void NewtonSolver::UpdateSolution( // std::cout << "del_c[" << jj << "] = " << del_c[jj] << std::endl; } - for (int ii = 0; ii < Dimension; ii++) + for (unsigned int ii = 0; ii < Dimension; ii++) { c[ii] = c[ii] - alpha * del_c[ii]; } @@ -120,7 +120,7 @@ int NewtonSolver 1); - // for (int ii = 0; ii < Dimension; ii++) + // for (unsigned int ii = 0; ii < Dimension; ii++) // assert(conc[ii] == conc[ii]); #ifdef WITH_CONVERGENCE_HISTORY @@ -136,7 +136,7 @@ int NewtonSolver