Fix badly-formatted else/else if/catch clauses

This commit is contained in:
Ray Speth 2015-07-29 18:10:18 -04:00
parent d24dfea036
commit 619cd20f14
31 changed files with 114 additions and 222 deletions

View file

@ -73,21 +73,18 @@ public:
if (n == 0) {
if (isLeft(j)) { // here we specify zeta(0) = 0
return zeta(x,j);
} else
} else {
// this implements d(zeta)/dz = u
{
return (zeta(x,j) - zeta(x,j-1))/(z(j)-z(j-1)) - u(x,j);
}
}
// if n = 1, then return the residual for the second ODE
else {
} else {
// if n = 1, then return the residual for the second ODE
if (isLeft(j)) { // here we specify u(0) = 0
return u(x,j);
} else if (isRight(j)) { // and here we specify u(L) = 1
return u(x,j) - 1.0;
} else
} else {
// this implements the 2nd ODE
{
return cdif2(x,1,j) + 0.5*zeta(x,j)*centralFirstDeriv(x,1,j);
}
}

View file

@ -217,16 +217,15 @@ doublereal getFloatCurrent(const XML_Node& node, const std::string& type)
writelog("\nWarning: conversion toSI() was done on node value " + node.name() +
"but wasn't explicitly requested. Type was \"" + type + "\"\n");
#endif
}
// Note, below currently produces a lot of output due to transport blocks.
// This needs to be addressed.
#ifdef DEBUG_MODE_MORE
else if (type == "" && units != "") {
} else if (type == "" && units != "") {
// Note, below currently produces a lot of output due to transport blocks.
// This needs to be addressed.
writelog("\nWarning: XML node " + node.name() +
"has a units attribute, \"" + units + "\","
"but no conversion was done because the getFloat() command didn't have a type\n");
}
#endif
}
return fctr*x;
}

View file

@ -585,9 +585,7 @@ double MultiPhase::equilibrate_MultiPhaseEquil(int XY, doublereal err,
throw err;
}
return err;
}
else if (XY == HP) {
} else if (XY == HP) {
h0 = enthalpy();
Tlow = 0.5*m_Tmin; // lower bound on T
Thigh = 2.0*m_Tmax; // upper bound on T
@ -610,10 +608,9 @@ double MultiPhase::equilibrate_MultiPhaseEquil(int XY, doublereal err,
Tlow = m_temp;
Hlow = hnow;
}
}
// the current enthalpy is greater than the target; therefore the
// current temperature is too high.
else {
} else {
// the current enthalpy is greater than the target; therefore the
// current temperature is too high.
if (m_temp < Thigh) {
Thigh = m_temp;
Hhigh = hnow;
@ -649,9 +646,7 @@ double MultiPhase::equilibrate_MultiPhaseEquil(int XY, doublereal err,
strt = false;
}
}
catch (CanteraError& err) {
} catch (CanteraError& err) {
err.save();
if (!strt) {
strt = true;
@ -699,9 +694,7 @@ double MultiPhase::equilibrate_MultiPhaseEquil(int XY, doublereal err,
if (dta < 100.0) {
strt = false;
}
}
catch (CanteraError& err) {
} catch (CanteraError& err) {
err.save();
if (!strt) {
strt = true;
@ -736,9 +729,7 @@ double MultiPhase::equilibrate_MultiPhaseEquil(int XY, doublereal err,
dVdP = (volume() - vnow)/(0.01*pnow);
setPressure(pnow + 0.5*(v0 - vnow)/dVdP);
}
}
else {
} else {
throw CanteraError("MultiPhase::equilibrate_MultiPhaseEquil",
"unknown option");
}

View file

@ -210,10 +210,9 @@ int vcs_MultiPhaseEquil::equilibrate_HP(doublereal Htarget,
Tlow = Tnow;
Hlow = Hnow;
}
}
// the current enthalpy is greater than the target; therefore the
// current temperature is too high. Set the high bounds.
else {
} else {
// the current enthalpy is greater than the target; therefore the
// current temperature is too high. Set the high bounds.
if (Tnow < Thigh) {
Thigh = Tnow;
Hhigh = Hnow;
@ -340,10 +339,9 @@ int vcs_MultiPhaseEquil::equilibrate_SP(doublereal Starget,
}
}
}
}
// the current enthalpy is greater than the target; therefore the
// current temperature is too high. Set the high bounds.
else {
} else {
// the current enthalpy is greater than the target; therefore the
// current temperature is too high. Set the high bounds.
if (Tnow < Thigh) {
Thigh = Tnow;
Shigh = Snow;

View file

@ -80,9 +80,8 @@ bool VCS_SOLVE::vcs_popPhasePossible(const size_t iphasePop) const
if (foundJrxn) {
return true;
}
}
// Second we are here if the component is a reactant in the reaction, and the reaction goes backwards.
else if (m_stoichCoeffRxnMatrix(kspec,jrxn) < 0.0) {
} else if (m_stoichCoeffRxnMatrix(kspec,jrxn) < 0.0) {
// Second we are here if the component is a reactant in the reaction, and the reaction goes backwards.
foundJrxn = true;
size_t jspec = jrxn + m_numComponents;
if (m_molNumSpecies_old[jspec] <= VCS_DELETE_ELEMENTABS_CUTOFF*0.5) {

View file

@ -1482,8 +1482,7 @@ void VCS_SOLVE::solve_tp_equilib_check(bool& allMinorZeroedSpecies,
plogf(" MAJOR SPECIES CONVERGENCE achieved");
plogendl();
}
}
else if (DEBUG_MODE_ENABLED && m_debug_print_lvl >= 2) {
} else if (DEBUG_MODE_ENABLED && m_debug_print_lvl >= 2) {
plogf(" MAJOR SPECIES CONVERGENCE achieved "
"(because there are no major species)");
plogendl();
@ -2755,8 +2754,7 @@ int VCS_SOLVE::vcs_basopt(const bool doJustComponents, double aw[], double sa[],
}
vcs_switch_pos(false, jr, k);
std::swap(aw[jr], aw[k]);
}
else if (DEBUG_MODE_ENABLED && m_debug_print_lvl >= 2) {
} else if (DEBUG_MODE_ENABLED && m_debug_print_lvl >= 2) {
plogf(" --- %-12.12s", m_speciesName[k].c_str());
if (m_speciesUnknownType[k] == VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) {
plogf("(Volts = %9.2g) remains ", m_molNumSpecies_old[k]);
@ -4201,11 +4199,10 @@ void VCS_SOLVE::vcs_deltag_Phase(const size_t iphase, const bool doDeleted,
deltaGRxn[irxn] += m_stoichCoeffRxnMatrix(kcomp,irxn) * feSpecies[kcomp];
}
}
}
/*
* Multispecies Phase
*/
else {
} else {
/*
* Multispecies Phase
*/
bool zeroedPhase = true;
for (size_t irxn = 0; irxn < irxnl; ++irxn) {

View file

@ -508,9 +508,8 @@ void Kinetics::addPhase(thermo_t& thermo)
if (m_thermo.size() > 0) {
m_start.push_back(m_start.back()
+ m_thermo.back()->nSpecies());
}
// otherwise start at 0
else {
} else {
// otherwise start at 0
m_start.push_back(0);
}

View file

@ -330,9 +330,7 @@ void ReactionPathDiagram::exportToDot(ostream& s)
}
}
}
}
else {
} else {
for (size_t i = 0; i < nPaths(); i++) {
p = path(i);
flmax = std::max(p->flow(), flmax);
@ -862,16 +860,13 @@ int ReactionPathBuilder::build(Kinetics& s, const string& element,
f = g[kkr][kkp].nAtoms(m);
}
}
}
// no ambiguity about where the m-atoms come
// from or go to. Either all reactant m atoms
// end up in one product, or only one reactant
// contains all the m-atoms. In either case,
// the number of atoms transferred is given by
// the same expression.
else {
} else {
// no ambiguity about where the m-atoms come
// from or go to. Either all reactant m atoms
// end up in one product, or only one reactant
// contains all the m-atoms. In either case,
// the number of atoms transferred is given by
// the same expression.
f = m_atoms(kkp,m) * m_atoms(kkr,m) / m_elatoms(m, i);
}

View file

@ -276,12 +276,11 @@ int solveSP::solveSurfProb(int ifunc, doublereal time_scale, doublereal TKelvin,
info = m_Jac.factor();
if (info==0) {
m_Jac.solve(&m_resid[0]);
}
/*
* Force convergence if residual is small to avoid
* "nan" results from the linear solve.
*/
else {
} else {
/*
* Force convergence if residual is small to avoid
* "nan" results from the linear solve.
*/
if (m_ioflag) {
printf("solveSurfSS: Zero pivot, assuming converged: %g (%d)\n",
resid_norm, info);

View file

@ -64,12 +64,8 @@ void flowdevicemethods(int nlhs, mxArray* plhs[],
reportError();
}
return;
}
// options that return a value of type 'double'
else if (job < 40) {
} else if (job < 40) {
// options that return a value of type 'double'
switch (job) {
case 21:
r = flowdev_massFlowRate(i, v);

View file

@ -33,9 +33,7 @@ void funcmethods(int nlhs, mxArray* plhs[],
reportError();
}
return;
}
else {
} else {
int nn = 0;
double t;
double v = 0.0;

View file

@ -29,10 +29,8 @@ void kineticsmethods(int nlhs, mxArray* plhs[],
double* h = mxGetPr(plhs[0]);
*h = vv;
return;
}
// methods
else if (job > 0) {
} else if (job > 0) {
// methods
int isp = 1;
if (job < 5 || job > 6) {
checkNArgs(4,nrhs);
@ -147,10 +145,7 @@ void kineticsmethods(int nlhs, mxArray* plhs[],
reportError();
}
}
}
else {
} else {
// set attributes
int iok = -1;
job = -job;

View file

@ -77,12 +77,8 @@ void mixturemethods(int nlhs, mxArray* plhs[],
reportError();
}
return;
}
// options that return a value of type 'double'
else if (job < 40) {
} else if (job < 40) {
// options that return a value of type 'double'
switch (job) {
case 19:
r = (double) mix_nPhases(i);
@ -143,11 +139,8 @@ void mixturemethods(int nlhs, mxArray* plhs[],
reportError();
}
return;
}
// species properties
else if (job < 60) {
} else if (job < 60) {
// species properties
int iok = 0;
mwSize nsp = (mwSize) mix_nSpecies(i);
std::vector<double> x(nsp);

View file

@ -105,10 +105,8 @@ void onedimmethods(int nlhs, mxArray* plhs[],
reportError();
}
return;
}
// methods
else if (job < 40) {
} else if (job < 40) {
// methods
int k;
switch (job) {
@ -185,9 +183,7 @@ void onedimmethods(int nlhs, mxArray* plhs[],
reportError();
}
return;
}
else if (job < 50) {
} else if (job < 50) {
int iok = -1;
int buflen, icomp;
char* output_buf;
@ -208,10 +204,8 @@ void onedimmethods(int nlhs, mxArray* plhs[],
mexErrMsgTxt("error or unknown method.");
return;
}
}
} else {
// set parameters
else {
int iok = -1;
double lower, upper, rtol, atol, *grid, *pos, *values,
mdot, t, p, val, *temp, ratio, slope, curve, tstep, *dts,

View file

@ -45,10 +45,8 @@ void phasemethods(int nlhs, mxArray* plhs[],
default:
mexErrMsgTxt("Unknown job number");
}
}
// set array attributes
else if (mjob < 30) {
} else if (mjob < 30) {
// set array attributes
if ((m == nsp && n == 1) || (m == 1 && n == nsp)) {
int norm = 1;
switch (mjob) {
@ -72,10 +70,8 @@ void phasemethods(int nlhs, mxArray* plhs[],
} else {
mexErrMsgTxt("wrong array size");
}
}
// set attributes from a string
else {
} else {
// set attributes from a string
int status;
mwSize buflen;
char* input_buf;
@ -107,11 +103,8 @@ void phasemethods(int nlhs, mxArray* plhs[],
mexErrMsgTxt("expected a string.");
}
}
}
else if (job < 20) {
} else if (job < 20) {
double threshold;
switch (job) {
case 0:
vv = (double) newThermoFromXML(ph);
@ -166,9 +159,7 @@ void phasemethods(int nlhs, mxArray* plhs[],
double* h = mxGetPr(plhs[0]);
*h = vv;
return;
}
else if (job < 30) {
} else if (job < 30) {
iok = 0;
size_t nsp = phase_nSpecies(ph);
std::vector<double> x(nsp);
@ -199,9 +190,7 @@ void phasemethods(int nlhs, mxArray* plhs[],
mexErrMsgTxt("unknown attribute");
return;
}
}
else if (job < 40) {
} else if (job < 40) {
iok = 0;
size_t nel = phase_nElements(ph);
std::vector<double> x(nel);
@ -226,9 +215,7 @@ void phasemethods(int nlhs, mxArray* plhs[],
mexErrMsgTxt("unknown attribute");
return;
}
}
else if (job < 50) {
} else if (job < 50) {
iok = -1;
int ksp, mel;
int buflen;

View file

@ -67,12 +67,8 @@ void reactormethods(int nlhs, mxArray* plhs[],
reportError();
}
return;
}
// options that return a value of type 'double'
else if (job < 40) {
} else if (job < 40) {
// options that return a value of type 'double'
switch (job) {
case 23:
r = reactor_mass(i);

View file

@ -71,11 +71,8 @@ void reactornetmethods(int nlhs, mxArray* plhs[],
reportError();
}
return;
}
// options that return a value of type 'double'
else if (job < 40) {
} else if (job < 40) {
// options that return a value of type 'double'
switch (job) {
case 21:
r = reactornet_step(i, v);

View file

@ -60,10 +60,8 @@ void surfmethods(int nlhs, mxArray* plhs[],
double* h = mxGetPr(plhs[0]);
*h = double(iok);
return;
}
// return array parameters
else if (job < 200) {
} else if (job < 200) {
// return array parameters
nsp = phase_nSpecies(surf);
std::vector<double> x(nsp);
iok = -1;

View file

@ -36,10 +36,8 @@ static void thermoset(int nlhs, mxArray* plhs[],
default:
mexErrMsgTxt("unknown attribute.");
}
}
// property pairs
else if (job < 40) {
} else if (job < 40) {
// property pairs
if ((m == 2 && n == 1) || (m == 1 && n == 2)) {
switch (job) {
case 20:
@ -69,10 +67,8 @@ static void thermoset(int nlhs, mxArray* plhs[],
} else {
mexErrMsgTxt("wrong size");
}
}
// equilibrate
else if (job == 50) {
} else if (job == 50) {
// equilibrate
char* xy = getString(prhs[3]);
int solver = getInt(prhs[4]);
double rtol = getDouble(prhs[5]);
@ -230,9 +226,7 @@ static void thermoget(int nlhs, mxArray* plhs[],
mexErrMsgTxt("unknown attribute");
return;
}
}
else {
} else {
mexErrMsgTxt("unknown attribute");
}
}

View file

@ -72,9 +72,7 @@ void transportmethods(int nlhs, mxArray* plhs[],
default:
mexErrMsgTxt("unknown Transport method");
}
}
else if (job < 30) {
} else if (job < 30) {
nsp = getInt(prhs[3]);
plhs[0] = mxCreateNumericMatrix(nsp,nsp,mxDOUBLE_CLASS,mxREAL);
h = mxGetPr(plhs[0]);
@ -88,10 +86,8 @@ void transportmethods(int nlhs, mxArray* plhs[],
default:
mexErrMsgTxt("unknown Transport method");
}
}
// set parameters
else if (job < 40) {
} else if (job < 40) {
// set parameters
double* params;
int typ, k;
switch (job) {

View file

@ -83,12 +83,8 @@ void wallmethods(int nlhs, mxArray* plhs[],
reportError();
}
return;
}
// options that return a value of type 'double'
else if (job < 40) {
} else if (job < 40) {
// options that return a value of type 'double'
switch (job) {
case 21:
r = wall_vdot(i, v);

View file

@ -855,9 +855,7 @@ int RootFind::solve(doublereal xmin, doublereal xmax, int itmax, doublereal& fun
converged = 1;
rfT.reasoning += "NormalConvergence";
retn = ROOTFIND_SUCCESS;
}
else if (fabs(slope) > 1.0E-100) {
} else if (fabs(slope) > 1.0E-100) {
double xdels = fabs(fnew / slope);
if (xdels < deltaXConverged_ * 0.3) {
converged = 1;

View file

@ -379,18 +379,14 @@ int MultiNewton::solve(doublereal* x0, doublereal* x1,
// step, and try again.
if (m == 0) {
copy(x1, x1 + m_n, m_x.begin());
}
// convergence
else if (m == 1) {
} else if (m == 1) {
// convergence
jac.setAge(0); // for efficient sensitivity analysis
break;
}
// If dampStep fails, first try a new Jacobian if an old
// one was being used. If it was a new Jacobian, then
// return -1 to signify failure.
else if (m < 0) {
} else if (m < 0) {
// If dampStep fails, first try a new Jacobian if an old
// one was being used. If it was a new Jacobian, then
// return -1 to signify failure.
if (jac.age() > 1) {
forceNewJac = true;
if (nJacReeval > 3) {

View file

@ -349,11 +349,9 @@ doublereal OneDim::timeStep(int nsteps, doublereal dt, doublereal* x,
dt *= 1.5;
}
dt = std::min(dt, m_tmax);
}
// No solution could be found with this time step.
// Decrease the stepsize and try again.
else {
} else {
// No solution could be found with this time step.
// Decrease the stepsize and try again.
writelog("...failure.\n", loglevel);
dt *= m_tfactor;
if (dt < m_tmin)

View file

@ -378,9 +378,7 @@ void StFlow::eval(size_t jg, doublereal* xg,
-(m_flux(k,0) + rho_u(x,0)* Y(x,k,0));
}
rsd[index(c_offset_Y, 0)] = 1.0 - sum;
}
else if (j == m_points - 1) {
} else if (j == m_points - 1) {
evalRightBoundary(x, rsd, diag, rdt);
} else { // interior points
@ -983,9 +981,7 @@ void FreeFlame::evalContinuity(size_t j, doublereal* x, doublereal* rsd,
rsd[index(c_offset_U,j)] =
- (rho_u(x,j) - rho_u(x,j-1))/m_dz[j-1]
- (density(j-1)*V(x,j-1) + density(j)*V(x,j));
}
else if (grid(j) == m_zfixed) {
} else if (grid(j) == m_zfixed) {
if (m_do_energy[j]) {
rsd[index(c_offset_U,j)] = (T(x,j) - m_tfixed);
} else {

View file

@ -205,10 +205,8 @@ void Inlet1D::eval(size_t jg, doublereal* xg, doublereal* rg,
r[0] = m_mdot - x[0];
rb[3] = xb[3];
}
}
// right inlet.
else {
} else {
// right inlet.
size_t boffset = m_flow->nComponents();
xb = x - boffset;
rb = r - boffset;

View file

@ -4925,11 +4925,10 @@ void HMWSoln::calc_thetas(int z1, int z2,
if (z1*z2 < 0) {
*etheta = 0.0;
*etheta_prime = 0.0;
}
/*
* Actually calculate the interaction.
*/
else {
} else {
/*
* Actually calculate the interaction.
*/
double f1 = (double)i / (2.0 * j);
double f2 = (double)j / (2.0 * i);
*etheta = elambda[i*j] - f1*elambda[j*j] - f2*elambda[i*i];
@ -5007,9 +5006,8 @@ void HMWSoln::s_updateIMS_lnMolalityActCoeff() const
}
IMS_lnActCoeffMolal_[m_indexSolvent] = lngammao;
}
}
// Exponentials - trial 2
else if (IMS_typeCutoff_ == 2) {
} else if (IMS_typeCutoff_ == 2) {
// Exponentials - trial 2
if (xmolSolvent > IMS_X_o_cutoff_) {
for (size_t k = 1; k < m_kk; k++) {
IMS_lnActCoeffMolal_[k]= 0.0;

View file

@ -696,10 +696,8 @@ void IdealMolalSoln::s_updateIMS_lnMolalityActCoeff() const
}
IMS_lnActCoeffMolal_[m_indexSolvent] = lngammao;
}
}
// Exponentials - trial 2
else if (IMS_typeCutoff_ == 2) {
} else if (IMS_typeCutoff_ == 2) {
// Exponentials - trial 2
if (xmolSolvent > IMS_X_o_cutoff_) {
for (size_t k = 1; k < m_kk; k++) {
IMS_lnActCoeffMolal_[k]= 0.0;

View file

@ -1019,8 +1019,7 @@ std::string ThermoPhase::report(bool show_thermo, doublereal threshold) const
nMinor, xMinor, yMinor);
s += p;
}
}
catch (CanteraError& err) {
} catch (CanteraError& err) {
err.save();
}
return s;

View file

@ -555,10 +555,8 @@ void GasTransport::fitCollisionIntegrals(MMCollisionInt& integrals)
m_cstar_poly.push_back(cc);
m_poly[i][j] = static_cast<int>(m_astar_poly.size()) - 1;
fitlist.push_back(dstar);
}
// delta* found in fitlist, so just point to this polynomial
else {
} else {
// delta* found in fitlist, so just point to this polynomial
m_poly[i][j] = static_cast<int>((dptr - fitlist.begin()));
}
m_poly[j][i] = m_poly[i][j];
@ -719,25 +717,26 @@ void GasTransport::fitProperties(MMCollisionInt& integrals)
writelogf("Maximum viscosity relative error: %12.6g\n", mxrelerr);
writelog("\nPolynomial fits for conductivity:\n");
if (m_mode == CK_Mode)
if (m_mode == CK_Mode) {
writelog("log(conductivity) fit to cubic polynomial in log(T)");
else {
} else {
writelogf("conductivity/sqrt(T) fit to "
"polynomial of degree %d in log(T)", degree);
}
if (m_log_level >= 2)
if (m_log_level >= 2) {
for (size_t k = 0; k < m_nsp; k++) {
writelog(m_thermo->speciesName(k) + ": [" +
vec2str(m_condcoeffs[k]) + "]\n");
}
}
writelogf("Maximum conductivity absolute error: %12.6g\n", mxerr_cond);
writelogf("Maximum conductivity relative error: %12.6g\n", mxrelerr_cond);
// fit the binary diffusion coefficients for each species pair
writelogf("\nbinary diffusion coefficients:\n");
if (m_mode == CK_Mode)
if (m_mode == CK_Mode) {
writelog("log(D) fit to cubic polynomial in log(T)");
else {
} else {
writelogf("D/T**(3/2) fit to polynomial of degree %d in log(T)",degree);
}
}

View file

@ -81,9 +81,7 @@ int main(int argc, char** argv)
}
delete gas;
fclose(FF);
}
catch (CanteraError& err) {
} catch (CanteraError& err) {
std::cout << err.what() << std::endl;
return -1;
}