Skip to content

Commit

Permalink
Fix a bunch of compiler warnings (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanlucf22 authored Mar 4, 2024
1 parent 268cf0a commit 91582f6
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 60 deletions.
1 change: 0 additions & 1 deletion drivers/computeKKS3Ph2Sl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 0 additions & 4 deletions src/CALPHADFreeEnergyFunctionsBinary3Ph2Sl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 0 additions & 4 deletions src/CALPHADFreeEnergyFunctionsBinaryThreePhase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/CALPHADSpeciesPhaseGibbsEnergy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace Thermo4PFM
{

void read_optional(pt::ptree& db, const std::string key,
std::vector<double>& coeffs, const int nintervals)
std::vector<double>& coeffs, const unsigned int nintervals)
{
if (db.get_child_optional(key))
{
Expand Down Expand Up @@ -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;

Expand Down
18 changes: 9 additions & 9 deletions src/LinearSolver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ void LinearSolver<Dimension, SolverType, JacobianDataType>::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];
}
Expand All @@ -47,7 +47,7 @@ void LinearSolver<Dimension, SolverType, JacobianDataType>::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];
}
Expand All @@ -56,18 +56,18 @@ void LinearSolver<Dimension, SolverType, JacobianDataType>::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];
}

del_c[jj] = D_inv * evalDeterminant<Dimension, JacobianDataType>(mwork);
}

for (int ii = 0; ii < Dimension; ii++)
for (unsigned int ii = 0; ii < Dimension; ii++)
{
c[ii] = c[ii] - del_c[ii];
}
Expand All @@ -88,18 +88,18 @@ int LinearSolver<Dimension, SolverType,

JacobianDataType ftmp[Dimension * Dimension];
JacobianDataType* fjac[Dimension];
for (int ii = 0; ii < Dimension; ii++)
for (unsigned int ii = 0; ii < Dimension; ii++)
{
fjac[ii] = &ftmp[ii * Dimension];
}

#ifndef HAVE_OPENMP_OFFLOAD
for (int ii = 0; ii < Dimension; ii++)
for (unsigned int ii = 0; ii < Dimension; ii++)
assert(conc[ii] == conc[ii]);
#endif
internalRHS(conc, fvec);
#ifndef HAVE_OPENMP_OFFLOAD
for (int ii = 0; ii < Dimension; ii++)
for (unsigned int ii = 0; ii < Dimension; ii++)
assert(fvec[ii] == fvec[ii]);
#endif

Expand Down
36 changes: 18 additions & 18 deletions src/NewtonSolver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ bool NewtonSolver<Dimension, SolverType, JacobianDataType>::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));
}
Expand All @@ -56,9 +56,9 @@ void NewtonSolver<Dimension, SolverType, JacobianDataType>::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];
}
Expand All @@ -77,7 +77,7 @@ void NewtonSolver<Dimension, SolverType, JacobianDataType>::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];
}
Expand All @@ -86,10 +86,10 @@ void NewtonSolver<Dimension, SolverType, JacobianDataType>::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];
}
Expand All @@ -103,7 +103,7 @@ void NewtonSolver<Dimension, SolverType, JacobianDataType>::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];
}
Expand All @@ -120,7 +120,7 @@ int NewtonSolver<Dimension, SolverType,
const int max_iters, const double alpha)
{
// assert(max_iters > 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
Expand All @@ -136,7 +136,7 @@ int NewtonSolver<Dimension, SolverType,

JacobianDataType ftmp[Dimension * Dimension];
JacobianDataType* fjac[Dimension];
for (int ii = 0; ii < Dimension; ii++)
for (unsigned int ii = 0; ii < Dimension; ii++)
{
fjac[ii] = &ftmp[ii * Dimension];
}
Expand All @@ -147,20 +147,20 @@ int NewtonSolver<Dimension, SolverType,
while (1)
{
#ifndef HAVE_OPENMP_OFFLOAD
for (int ii = 0; ii < Dimension; ii++)
for (unsigned int ii = 0; ii < Dimension; ii++)
assert(conc[ii] == conc[ii]);
#endif
#ifdef WITH_CONVERGENCE_HISTORY
for (int ii = 0; ii < Dimension; ii++)
for (unsigned int ii = 0; ii < Dimension; ii++)
ctmp.push_back(conc[ii]);
#endif
internalRHS(conc, fvec);
#ifndef HAVE_OPENMP_OFFLOAD
for (int ii = 0; ii < Dimension; ii++)
for (unsigned int ii = 0; ii < Dimension; ii++)
assert(fvec[ii] == fvec[ii]);
#endif
#ifdef WITH_CONVERGENCE_HISTORY
for (int ii = 0; ii < Dimension; ii++)
for (unsigned int ii = 0; ii < Dimension; ii++)
residual.push_back(fvec[ii]);
#endif

Expand All @@ -185,24 +185,24 @@ int NewtonSolver<Dimension, SolverType,
for (unsigned j = 0; j < ctmp.size(); j = j + Dimension)
{
std::cout << " conc= ";
for (int ii = 0; ii < Dimension; ii++)
for (unsigned int ii = 0; ii < Dimension; ii++)
{
std::cout << ctmp[j + ii] << " ";
}
std::cout << ", rhs = ";
for (int ii = 0; ii < Dimension; ii++)
for (unsigned int ii = 0; ii < Dimension; ii++)
{
std::cout << residual[j + ii] << " ";
}
std::cout << std::endl;
}
std::cout << "======================" << std::endl;
std::cout << "Final solution:" << std::endl;
for (int ii = 0; ii < Dimension; ii++)
for (unsigned int ii = 0; ii < Dimension; ii++)
{
std::cout << " conc[" << ii << "] = " << conc[ii] << std::endl;
}
for (int ii = 0; ii < Dimension; ii++)
for (unsigned int ii = 0; ii < Dimension; ii++)
{
std::cout << " rhs[" << ii << "] = " << fvec[ii] << std::endl;
}
Expand All @@ -213,7 +213,7 @@ int NewtonSolver<Dimension, SolverType,
#ifndef HAVE_OPENMP_OFFLOAD
std::cerr << "Error: too many iterations in NewtonSolver" << std::endl;
std::cerr << iterations << " iterations..." << std::endl;
for (int ii = 0; ii < Dimension; ii++)
for (unsigned int ii = 0; ii < Dimension; ii++)
{
std::cout << " conc[" << ii << "] = " << conc[ii] << " rhs[" << ii
<< "] = " << fvec[ii] << std::endl;
Expand Down
13 changes: 6 additions & 7 deletions src/QuadraticFreeEnergyFunctionsBinary.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,21 @@ class QuadraticFreeEnergyFunctionsBinary
std::ostream& os);

private:
EnergyInterpolationType energy_interp_func_type_;
ConcInterpolationType conc_interp_func_type_;

char* fenergy_diag_filename_;

const double Tref_;

const double Al_;
const double Aa_;

const double ceql_;
const double ceqa_;

const double m_liquid_;

const double Aa_;
const double ceqa_;
const double m_solid_;

EnergyInterpolationType energy_interp_func_type_;
ConcInterpolationType conc_interp_func_type_;

void computePhasesFreeEnergies(const double temperature,
const double* const hphi, const double conc, double& fl, double& fa);

Expand Down
17 changes: 9 additions & 8 deletions src/QuadraticFreeEnergyFunctionsBinaryThreePhase.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,20 @@ class QuadraticFreeEnergyFunctionsBinaryThreePhase
std::ostream& os);

private:
EnergyInterpolationType energy_interp_func_type_;
ConcInterpolationType conc_interp_func_type_;

char* fenergy_diag_filename_;

double Al_;
double Aa_;
double Ab_;

double ceql_;

double Aa_;
double ceqa_;

double Ab_;
double ceqb_;

EnergyInterpolationType energy_interp_func_type_;
ConcInterpolationType conc_interp_func_type_;

char* fenergy_diag_filename_;

void computePhasesFreeEnergies(const double temperature,
const double* const hphi, const double conc, double& fl, double& fa,
double& fb);
Expand Down
5 changes: 2 additions & 3 deletions src/QuadraticFreeEnergyFunctionsTernaryThreePhase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ QuadraticFreeEnergyFunctionsTernaryThreePhase::
const EnergyInterpolationType energy_interp_func_type,
const ConcInterpolationType conc_interp_func_type)
: Al_{ Al[0], Al[1] },
ceql_{ ceql[0], ceql[1] },
Aa_{ Aa[0], Aa[1] },
ceqa_{ ceqa[0], ceqa[1] },
Ab_{ Ab[0], Ab[1] },
ceql_{ ceql[0], ceql[1] },
ceqa_{ ceqa[0], ceqa[1] },
ceqb_{ ceqb[0], ceqb[1] },
energy_interp_func_type_(energy_interp_func_type),
conc_interp_func_type_(conc_interp_func_type)
Expand Down Expand Up @@ -242,5 +242,4 @@ double QuadraticFreeEnergyFunctionsTernaryThreePhase::fchem(

return (1.0 - hfphi) * fl + hfphi * fa;
}

}
7 changes: 3 additions & 4 deletions src/QuadraticFreeEnergyFunctionsTernaryThreePhase.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,12 @@ class QuadraticFreeEnergyFunctionsTernaryThreePhase
void computeSecondDerivativeFreeEnergy(const double temp,
const double* const conc, const PhaseIndex pi, double* d2fdc2);


int computePhaseConcentrations(const double temperature,
const double* const conc, const double* const phi, double* x);
double fchem(const double* const phi, const double* const conc,
const double temperature);

private:
EnergyInterpolationType energy_interp_func_type_;
ConcInterpolationType conc_interp_func_type_;

const double Al_[2];
const double Aa_[2];
const double Ab_[2];
Expand All @@ -48,6 +44,9 @@ class QuadraticFreeEnergyFunctionsTernaryThreePhase
const double ceqa_[2];
const double ceqb_[2];

EnergyInterpolationType energy_interp_func_type_;
ConcInterpolationType conc_interp_func_type_;

void computePhasesFreeEnergies(const double temperature,
const double* const hphi, const double conc0, const double conc1,
double& fl, double& fa, double& fb);
Expand Down

0 comments on commit 91582f6

Please sign in to comment.