Simplify error handling to eliminate need for global error stack

All of the functions for manipulating the global error stack
(CanteraError::save, setError, showErrors, etc.) are deprecated. The ability to
store an error is retained only for use in the C and Fortran interfaces so that
the last error message can be retrieved after a function returns an error code.
This commit is contained in:
Ray Speth 2015-11-16 00:12:33 -05:00
parent eb8695dffa
commit ee95c60813
21 changed files with 183 additions and 251 deletions

View file

@ -50,9 +50,7 @@ The entire body of the program is put inside a function that is invoked within
a ``try`` block in the main program. In this way, exceptions thrown in the
function or in any procedure it calls may be caught. In this program, a
``catch`` block is defined for exceptions of type :ct:`CanteraError`. Cantera
throws exceptions of this type, so it is always a good idea to catch them. In
the ``catch`` block, function :ct:`showErrors` may be called to print the error
message associated with the exception.
throws exceptions of this type, so it is always a good idea to catch them.
The ``report`` function
=======================

View file

@ -35,9 +35,6 @@ namespace Cantera
*
* \include demo1a.cpp
*
* The function showErrors() will print out the fatal error condition to
* standard output.
*
* A group of defines may be used during debugging to assert conditions which
* should be true. These are named AssertTrace(), AssertThrow(), and
* AssertThrowMsg(). Examples of their usage is given below.
@ -69,9 +66,6 @@ class CanteraError : public std::exception
public:
//! Normal Constructor for the CanteraError base class
/*!
* In the constructor, a call to the Application class is made to store
* the strings associated with the generated error condition.
*
* @param procedure String name for the function within which the error was
* generated.
* @param msg Descriptive string describing the type of error message.
@ -87,9 +81,6 @@ public:
} else {
msg_ = fmt::format(msg, args...);
}
// Save the error in the global list of errors so that showError()
// can work
save();
}
//! Destructor for base class does nothing
@ -99,6 +90,7 @@ public:
const char* what() const throw();
//! Function to put this error onto Cantera's error stack
//! @deprecated Unused. To be removed after Cantera 2.3.
void save();
//! Method overridden by derived classes to format the error message

View file

@ -29,22 +29,28 @@ class Logger;
//! Return the number of errors that have been encountered so far
/*!
* @ingroup errorhandling
* @deprecated Unused. To be removed after Cantera 2.3.
*/
int nErrors();
//! @copydoc Application::Messages::lastErrorMessage
//! @deprecated Unused. To be removed after Cantera 2.3.
std::string lastErrorMessage();
//! @copydoc Application::Messages::addError
//! @deprecated Unused. To be removed after Cantera 2.3.
void setError(const std::string& r, const std::string& msg);
//! @copydoc Application::Messages::getErrors
//! @deprecated Unused. To be removed after Cantera 2.3.
void showErrors(std::ostream& f);
//! @copydoc Application::Messages::logErrors
//! @deprecated Unused. To be removed after Cantera 2.3.
void showErrors();
//! @copydoc Application::Messages::popError
//! @deprecated Unused. To be removed after Cantera 2.3.
void popError();
/*!

View file

@ -60,8 +60,7 @@ Application::Messages::Messages()
}
Application::Messages::Messages(const Messages& r) :
errorMessage(r.errorMessage),
errorRoutine(r.errorRoutine)
errorMessage(r.errorMessage)
{
// install a default logwriter that writes to standard
// output / standard error
@ -74,15 +73,22 @@ Application::Messages& Application::Messages::operator=(const Messages& r)
return *this;
}
errorMessage = r.errorMessage;
errorRoutine = r.errorRoutine;
logwriter.reset(new Logger(*r.logwriter));
return *this;
}
void Application::Messages::addError(const std::string& r, const std::string& msg)
{
errorMessage.push_back(msg);
errorRoutine.push_back(r);
if (msg.size() != 0) {
errorMessage.push_back(
"\n\n************************************************\n"
" Cantera Error! \n"
"************************************************\n\n"
"Procedure: " + r +
"\nError: " + msg + "\n");
} else {
errorMessage.push_back(msg);
}
}
int Application::Messages::getErrorCount()
@ -289,7 +295,6 @@ long int Application::readStringRegistryKey(const std::string& keyName, const st
void Application::Messages::popError()
{
if (!errorMessage.empty()) {
errorRoutine.pop_back();
errorMessage.pop_back();
}
}
@ -297,12 +302,7 @@ void Application::Messages::popError()
std::string Application::Messages::lastErrorMessage()
{
if (!errorMessage.empty()) {
string head =
"\n\n************************************************\n"
" Cantera Error! \n"
"************************************************\n\n";
return head+string("\nProcedure: ")+errorRoutine.back()
+string("\nError: ")+errorMessage.back();
return errorMessage.back();
} else {
return "<no Cantera error>";
}
@ -310,43 +310,19 @@ std::string Application::Messages::lastErrorMessage()
void Application::Messages::getErrors(std::ostream& f)
{
size_t i = errorMessage.size();
if (i == 0) {
return;
for (size_t j = 0; j < errorMessage.size(); j++) {
f << errorMessage[j] << endl;
}
f << endl << endl;
f << "************************************************" << endl;
f << " Cantera Error! " << endl;
f << "************************************************" << endl
<< endl;
for (size_t j = 0; j < i; j++) {
f << endl;
f << "Procedure: " << errorRoutine[j] << endl;
f << "Error: " << errorMessage[j] << endl;
}
f << endl << endl;
errorMessage.clear();
errorRoutine.clear();
}
void Application::Messages::logErrors()
{
size_t i = errorMessage.size();
if (i == 0) {
return;
for (size_t j = 0; j < errorMessage.size(); j++) {
writelog(errorMessage[j]);
writelogendl();
}
writelog("\n\n");
writelog("************************************************\n");
writelog(" Cantera Error! \n");
writelog("************************************************\n\n");
for (size_t j = 0; j < i; j++) {
writelog("\n");
writelog(string("Procedure: ")+ errorRoutine[j]+" \n");
writelog(string("Error: ")+ errorMessage[j]+" \n");
}
writelog("\n\n");
errorMessage.clear();
errorRoutine.clear();
}
void Application::setDefaultDirectories()

View file

@ -54,9 +54,12 @@ protected:
* that Cantera accumulates in the Application class.
* @param r Procedure name which is generating the error condition
* @param msg Descriptive message of the error condition.
*
* If only one argument is specified, that string is used as the
* entire message.
* @ingroup errorhandling
*/
void addError(const std::string& r, const std::string& msg);
void addError(const std::string& r, const std::string& msg="");
//! Return the number of errors that have been encountered so far.
/*!
@ -141,9 +144,6 @@ protected:
//! Current list of error messages
std::vector<std::string> errorMessage;
//! Current error Routine
std::vector<std::string> errorRoutine;
//! Current pointer to the logwriter
std::unique_ptr<Logger> logwriter;
};
@ -198,7 +198,7 @@ public:
static void ApplicationDestroy();
//! @copydoc Messages::addError
void addError(const std::string& r, const std::string& msg) {
void addError(const std::string& r, const std::string& msg="") {
pMessenger->addError(r, msg);
}

View file

@ -1,6 +1,7 @@
//! @file ctexceptions.cpp
#include "cantera/base/ctexceptions.h"
#include "application.h"
#include "cantera/base/global.h"
#include <sstream>
@ -15,12 +16,11 @@ CanteraError::CanteraError(const std::string& procedure) :
procedure_(procedure),
saved_(false)
{
// Save the error in the global list of errors so that showError() can work
save();
}
void CanteraError::save()
{
warn_deprecated("CanteraError::save", "To be removed after Cantera 2.3.");
if (!saved_) {
Application::Instance()->addError(procedure_, getMessage());
saved_ = true;

View file

@ -93,21 +93,25 @@ void close_XML_File(const std::string& file)
int nErrors()
{
warn_deprecated("nErrors", "To be removed after Cantera 2.3");
return app()->getErrorCount();
}
void popError()
{
warn_deprecated("popError", "To be removed after Cantera 2.3");
app()->popError();
}
string lastErrorMessage()
{
warn_deprecated("lastErrorMessage", "To be removed after Cantera 2.3");
return app()->lastErrorMessage();
}
void showErrors(std::ostream& f)
{
warn_deprecated("showErrors", "To be removed after Cantera 2.3");
app()->getErrors(f);
}

View file

@ -6,6 +6,7 @@
#include "cantera/base/global.h"
#include "cantera/base/ctexceptions.h"
#include "../base/application.h"
#include <iostream>
#ifdef _WIN32
@ -53,17 +54,17 @@ T handleAllExceptions(T ctErrorCode, T otherErrorCode)
try {
throw;
} catch (CanteraError& cterr) {
cterr.save();
Application::Instance()->addError(cterr.what());
return ctErrorCode;
} catch (std::exception& err) {
std::cerr << "Cantera: caught an instance of "
<< err.what() << std::endl;
setError("handleAllExceptions", err.what());
Application::Instance()->addError(err.what());
return otherErrorCode;
} catch (...) {
std::cerr << "Cantera: caught an instance of "
"an unknown exception type" << std::endl;
setError("handleAllExceptions", "unknown exception");
Application::Instance()->addError("unknown C++ exception");
return otherErrorCode;
}
}

View file

@ -1374,7 +1374,7 @@ extern "C" {
int getCanteraError(int buflen, char* buf)
{
try {
string e = lastErrorMessage();
string e = Application::Instance()->lastErrorMessage();
copyString(e, buf, buflen);
return int(e.size());
} catch (...) {

View file

@ -188,45 +188,37 @@ void ChemEquil::update(const thermo_t& s)
int ChemEquil::setInitialMoles(thermo_t& s, vector_fp& elMoleGoal,
int loglevel)
{
int iok = 0;
try {
MultiPhase mp;
mp.addPhase(&s, 1.0);
mp.init();
MultiPhaseEquil e(&mp, true, loglevel-1);
e.setInitialMixMoles(loglevel-1);
MultiPhase mp;
mp.addPhase(&s, 1.0);
mp.init();
MultiPhaseEquil e(&mp, true, loglevel-1);
e.setInitialMixMoles(loglevel-1);
// store component indices
m_nComponents = std::min(m_nComponents, m_kk);
for (size_t m = 0; m < m_nComponents; m++) {
m_component[m] = e.componentIndex(m);
}
// Update the current values of the temp, density, and mole fraction,
// and element abundance vectors kept within the ChemEquil object.
update(s);
if (DEBUG_MODE_ENABLED && ChemEquil_print_lvl > 0) {
writelog("setInitialMoles: Estimated Mole Fractions\n");
writelogf(" Temperature = %g\n", s.temperature());
writelogf(" Pressure = %g\n", s.pressure());
for (size_t k = 0; k < m_kk; k++) {
writelogf(" %-12s % -10.5g\n",
s.speciesName(k), s.moleFraction(k));
}
writelog(" Element_Name ElementGoal ElementMF\n");
for (size_t m = 0; m < m_mm; m++) {
writelogf(" %-12s % -10.5g% -10.5g\n",
s.elementName(m), elMoleGoal[m], m_elementmolefracs[m]);
}
}
iok = 0;
} catch (CanteraError& err) {
err.save();
iok = -1;
// store component indices
m_nComponents = std::min(m_nComponents, m_kk);
for (size_t m = 0; m < m_nComponents; m++) {
m_component[m] = e.componentIndex(m);
}
return iok;
// Update the current values of the temp, density, and mole fraction,
// and element abundance vectors kept within the ChemEquil object.
update(s);
if (DEBUG_MODE_ENABLED && ChemEquil_print_lvl > 0) {
writelog("setInitialMoles: Estimated Mole Fractions\n");
writelogf(" Temperature = %g\n", s.temperature());
writelogf(" Pressure = %g\n", s.pressure());
for (size_t k = 0; k < m_kk; k++) {
writelogf(" %-12s % -10.5g\n",
s.speciesName(k), s.moleFraction(k));
}
writelog(" Element_Name ElementGoal ElementMF\n");
for (size_t m = 0; m < m_mm; m++) {
writelogf(" %-12s % -10.5g% -10.5g\n",
s.elementName(m), elMoleGoal[m], m_elementmolefracs[m]);
}
}
return 0;
}
int ChemEquil::estimateElementPotentials(thermo_t& s, vector_fp& lambda_RT,
@ -676,13 +668,11 @@ int ChemEquil::equilibrate(thermo_t& s, const char* XYstr,
try {
info = solve(jac, res_trial.data());
} catch (CanteraError& err) {
err.save();
s.restoreState(state);
throw CanteraError("equilibrate",
"Jacobian is singular. \nTry adding more species, "
"changing the elemental composition slightly, \nor removing "
"unused elements.");
"unused elements.\n\n" + err.getMessage());
}
// find the factor by which the Newton step can be multiplied
@ -1320,15 +1310,11 @@ int ChemEquil::estimateEP_Brinkley(thermo_t& s, vector_fp& x,
try {
solve(a1, resid.data());
} catch (CanteraError& err) {
err.save();
if (DEBUG_MODE_ENABLED) {
debuglog("Matrix is SINGULAR.ERROR\n", ChemEquil_print_lvl);
}
s.restoreState(state);
throw CanteraError("equilibrate:estimateEP_Brinkley()",
"Jacobian is singular. \nTry adding more species, "
"changing the elemental composition slightly, \nor removing "
"unused elements.");
"unused elements.\n\n" + err.getMessage());
}
// Figure out the damping coefficient: Use a delta damping

View file

@ -569,13 +569,7 @@ double MultiPhase::equilibrate_MultiPhaseEquil(int XY, doublereal err,
if (XY == TP) {
// create an equilibrium manager
MultiPhaseEquil e(this);
try {
e.equilibrate(XY, err, maxsteps, loglevel);
} catch (CanteraError& err) {
err.save();
throw err;
}
return err;
return e.equilibrate(XY, err, maxsteps, loglevel);
} else if (XY == HP) {
h0 = enthalpy();
Tlow = 0.5*m_Tmin; // lower bound on T
@ -637,7 +631,6 @@ double MultiPhase::equilibrate_MultiPhaseEquil(int XY, doublereal err,
}
} catch (CanteraError& err) {
err.save();
if (!strt) {
strt = true;
} else {
@ -685,7 +678,6 @@ double MultiPhase::equilibrate_MultiPhaseEquil(int XY, doublereal err,
strt = false;
}
} catch (CanteraError& err) {
err.save();
if (!strt) {
strt = true;
} else {

View file

@ -1026,7 +1026,7 @@ extern "C" {
{
try {
std::string e;
e = lastErrorMessage();
e = Application::Instance()->lastErrorMessage();
int n = std::min((int) e.size(), buflen-1);
copy(e.begin(), e.begin() + n, buf);
for (int nn = n; nn < buflen; nn++) {

View file

@ -478,8 +478,7 @@ std::string MolalityVPSSTP::report(bool show_thermo, doublereal threshold) const
try {
b.write(" heat capacity c_v {:12.6g} {:12.4g} J/K\n",
cv_mass(), cv_mole());
} catch (CanteraError& e) {
e.save();
} catch (NotImplementedError& e) {
b.write(" heat capacity c_v <not implemented>\n");
}
}
@ -527,7 +526,7 @@ std::string MolalityVPSSTP::report(bool show_thermo, doublereal threshold) const
b.write(" [{:+5d} minor] {:12.6g}\n", nMinor, xMinor);
}
} catch (CanteraError& err) {
err.save();
return b.str() + err.what();
}
return b.str();
}

View file

@ -401,13 +401,12 @@ std::string MolarityIonicVPSSTP::report(bool show_thermo, doublereal threshold)
try {
b.write(" heat capacity c_v {:12.6g} {:12.4g} J/K\n",
cv_mass(), cv_mole());
} catch (CanteraError& e) {
e.save();
} catch (NotImplementedError& e) {
b.write(" heat capacity c_v <not implemented>\n");
}
}
} catch (CanteraError& e) {
e.save();
return b.str() + e.what();
}
return b.str();
}

View file

@ -374,8 +374,7 @@ std::string PureFluidPhase::report(bool show_thermo, doublereal threshold) const
try {
b.write(" heat capacity c_v {:12.6g} {:12.4g} J/K\n",
cv_mass(), cv_mole());
} catch (CanteraError& e) {
e.save();
} catch (NotImplementedError& e) {
b.write(" heat capacity c_v <not implemented>\n");
}
}

View file

@ -914,8 +914,7 @@ std::string ThermoPhase::report(bool show_thermo, doublereal threshold) const
try {
b.write(" heat capacity c_v {:12.5g} {:12.4g} J/K\n",
cv_mass(), cv_mole());
} catch (CanteraError& err) {
err.save();
} catch (NotImplementedError& err) {
b.write(" heat capacity c_v <not implemented> \n");
}
}
@ -969,7 +968,7 @@ std::string ThermoPhase::report(bool show_thermo, doublereal threshold) const
nMinor, xMinor, yMinor);
}
} catch (CanteraError& err) {
err.save();
return b.str() + err.what();
}
return b.str();
}

View file

@ -257,7 +257,6 @@ VPSSMgr* VPSSMgrFactory::newVPSSMgr(VPStandardStateTP* vp_ptr,
isimpleIG, isimpleCV, iwater, itpx, ihptx, iother);
} catch (UnknownVPSSMgrModel) {
iother = 1;
popError();
}
if (iwater == 1) {

View file

@ -157,13 +157,7 @@ void MultiTransport::solveLMatrixEquation()
// Solve it using GMRES or LU decomposition. The last solution in m_a should
// provide a good starting guess, so convergence should be fast.
m_a = m_b;
try {
solve(m_Lmatrix, m_a.data());
} catch (CanteraError& err) {
err.save();
throw CanteraError("MultiTransport::solveLMatrixEquation",
"error in solving L matrix.");
}
solve(m_Lmatrix, m_a.data());
m_lmatrix_soln_ok = true;
m_molefracs_last = m_molefracs;
// L matrix is overwritten with LU decomposition

View file

@ -368,83 +368,78 @@ void TransportFactory::getLiquidSpeciesTransportData(const std::vector<const XML
// Species with no 'transport' child are skipped. However, if that
// species is in the list, it will throw an exception below.
try {
if (sp.hasChild("transport")) {
XML_Node& trNode = sp.child("transport");
if (sp.hasChild("transport")) {
XML_Node& trNode = sp.child("transport");
// Fill datatable with LiquidTransportData objects for error checking
// and then insertion into LiquidTransportData objects below.
LiquidTransportData data;
data.speciesName = name;
data.mobilityRatio.resize(nsp*nsp,0);
data.selfDiffusion.resize(nsp,0);
ThermoPhase* temp_thermo = trParam.thermo;
size_t num = trNode.nChildren();
for (size_t iChild = 0; iChild < num; iChild++) {
XML_Node& xmlChild = trNode.child(iChild);
std::string nodeName = xmlChild.name();
// Fill datatable with LiquidTransportData objects for error checking
// and then insertion into LiquidTransportData objects below.
LiquidTransportData data;
data.speciesName = name;
data.mobilityRatio.resize(nsp*nsp,0);
data.selfDiffusion.resize(nsp,0);
ThermoPhase* temp_thermo = trParam.thermo;
size_t num = trNode.nChildren();
for (size_t iChild = 0; iChild < num; iChild++) {
XML_Node& xmlChild = trNode.child(iChild);
std::string nodeName = xmlChild.name();
switch (m_tranPropMap[nodeName]) {
case TP_VISCOSITY:
data.viscosity = newLTP(xmlChild, name, m_tranPropMap[nodeName], temp_thermo);
break;
case TP_IONCONDUCTIVITY:
data.ionConductivity = newLTP(xmlChild, name, m_tranPropMap[nodeName], temp_thermo);
break;
case TP_MOBILITYRATIO: {
for (size_t iSpec = 0; iSpec< nBinInt; iSpec++) {
XML_Node& propSpecNode = xmlChild.child(iSpec);
std::string specName = propSpecNode.name();
size_t loc = specName.find(":");
std::string firstSpec = specName.substr(0,loc);
std::string secondSpec = specName.substr(loc+1);
size_t index = temp_thermo->speciesIndex(firstSpec)+nsp*temp_thermo->speciesIndex(secondSpec);
data.mobilityRatio[index] = newLTP(propSpecNode, name, m_tranPropMap[nodeName], temp_thermo);
};
};
switch (m_tranPropMap[nodeName]) {
case TP_VISCOSITY:
data.viscosity = newLTP(xmlChild, name, m_tranPropMap[nodeName], temp_thermo);
break;
case TP_SELFDIFFUSION: {
for (size_t iSpec = 0; iSpec< nsp; iSpec++) {
XML_Node& propSpecNode = xmlChild.child(iSpec);
std::string specName = propSpecNode.name();
size_t index = temp_thermo->speciesIndex(specName);
data.selfDiffusion[index] = newLTP(propSpecNode, name, m_tranPropMap[nodeName], temp_thermo);
};
};
case TP_IONCONDUCTIVITY:
data.ionConductivity = newLTP(xmlChild, name, m_tranPropMap[nodeName], temp_thermo);
break;
case TP_THERMALCOND:
data.thermalCond = newLTP(xmlChild,
name,
m_tranPropMap[nodeName],
temp_thermo);
break;
case TP_DIFFUSIVITY:
data.speciesDiffusivity = newLTP(xmlChild,
name,
m_tranPropMap[nodeName],
temp_thermo);
break;
case TP_HYDRORADIUS:
data.hydroRadius = newLTP(xmlChild,
name,
m_tranPropMap[nodeName],
temp_thermo);
break;
case TP_ELECTCOND:
data.electCond = newLTP(xmlChild,
name,
m_tranPropMap[nodeName],
temp_thermo);
break;
default:
throw CanteraError("getLiquidSpeciesTransportData","unknown transport property: " + nodeName);
}
case TP_MOBILITYRATIO: {
for (size_t iSpec = 0; iSpec< nBinInt; iSpec++) {
XML_Node& propSpecNode = xmlChild.child(iSpec);
std::string specName = propSpecNode.name();
size_t loc = specName.find(":");
std::string firstSpec = specName.substr(0,loc);
std::string secondSpec = specName.substr(loc+1);
size_t index = temp_thermo->speciesIndex(firstSpec)+nsp*temp_thermo->speciesIndex(secondSpec);
data.mobilityRatio[index] = newLTP(propSpecNode, name, m_tranPropMap[nodeName], temp_thermo);
};
};
break;
case TP_SELFDIFFUSION: {
for (size_t iSpec = 0; iSpec< nsp; iSpec++) {
XML_Node& propSpecNode = xmlChild.child(iSpec);
std::string specName = propSpecNode.name();
size_t index = temp_thermo->speciesIndex(specName);
data.selfDiffusion[index] = newLTP(propSpecNode, name, m_tranPropMap[nodeName], temp_thermo);
};
};
break;
case TP_THERMALCOND:
data.thermalCond = newLTP(xmlChild,
name,
m_tranPropMap[nodeName],
temp_thermo);
break;
case TP_DIFFUSIVITY:
data.speciesDiffusivity = newLTP(xmlChild,
name,
m_tranPropMap[nodeName],
temp_thermo);
break;
case TP_HYDRORADIUS:
data.hydroRadius = newLTP(xmlChild,
name,
m_tranPropMap[nodeName],
temp_thermo);
break;
case TP_ELECTCOND:
data.electCond = newLTP(xmlChild,
name,
m_tranPropMap[nodeName],
temp_thermo);
break;
default:
throw CanteraError("getLiquidSpeciesTransportData","unknown transport property: " + nodeName);
}
datatable[name] = data;
}
} catch (CanteraError& err) {
err.save();
throw err;
datatable[name] = data;
}
}
@ -596,49 +591,44 @@ void TransportFactory::getSolidTransportData(const XML_Node& transportNode,
const std::string phaseName,
SolidTransportData& trParam)
{
try {
size_t num = transportNode.nChildren();
for (size_t iChild = 0; iChild < num; iChild++) {
//tranTypeNode is a type of transport property like viscosity
XML_Node& tranTypeNode = transportNode.child(iChild);
std::string nodeName = tranTypeNode.name();
ThermoPhase* temp_thermo = trParam.thermo;
size_t num = transportNode.nChildren();
for (size_t iChild = 0; iChild < num; iChild++) {
//tranTypeNode is a type of transport property like viscosity
XML_Node& tranTypeNode = transportNode.child(iChild);
std::string nodeName = tranTypeNode.name();
ThermoPhase* temp_thermo = trParam.thermo;
//tranTypeNode contains the interaction model
switch (m_tranPropMap[nodeName]) {
case TP_IONCONDUCTIVITY:
trParam.ionConductivity = newLTP(tranTypeNode, phaseName,
//tranTypeNode contains the interaction model
switch (m_tranPropMap[nodeName]) {
case TP_IONCONDUCTIVITY:
trParam.ionConductivity = newLTP(tranTypeNode, phaseName,
m_tranPropMap[nodeName],
temp_thermo);
break;
case TP_THERMALCOND:
trParam.thermalConductivity = newLTP(tranTypeNode, phaseName,
m_tranPropMap[nodeName],
temp_thermo);
break;
case TP_THERMALCOND:
trParam.thermalConductivity = newLTP(tranTypeNode, phaseName,
m_tranPropMap[nodeName],
temp_thermo);
break;
case TP_DEFECTDIFF:
trParam.defectDiffusivity = newLTP(tranTypeNode, phaseName,
m_tranPropMap[nodeName],
temp_thermo);
break;
case TP_DEFECTCONC:
trParam.defectActivity = newLTP(tranTypeNode, phaseName,
m_tranPropMap[nodeName],
temp_thermo);
break;
case TP_ELECTCOND:
trParam.electConductivity = newLTP(tranTypeNode, phaseName,
m_tranPropMap[nodeName],
temp_thermo);
break;
default:
throw CanteraError("getSolidTransportData","unknown transport property: " + nodeName);
}
break;
case TP_DEFECTDIFF:
trParam.defectDiffusivity = newLTP(tranTypeNode, phaseName,
m_tranPropMap[nodeName],
temp_thermo);
break;
case TP_DEFECTCONC:
trParam.defectActivity = newLTP(tranTypeNode, phaseName,
m_tranPropMap[nodeName],
temp_thermo);
break;
case TP_ELECTCOND:
trParam.electConductivity = newLTP(tranTypeNode, phaseName,
m_tranPropMap[nodeName],
temp_thermo);
break;
default:
throw CanteraError("getSolidTransportData","unknown transport property: " + nodeName);
}
} catch (CanteraError) {
showErrors(std::cout);
}
return;
}

View file

@ -286,9 +286,7 @@ int main()
try {
w->setState_HP(Hset, OneAtm);
} catch (CanteraError& err) {
err.save();
printf(" %10g, -> Failed to converge, beyond the spinodal probably \n\n", Hset);
popError();
break;
}
vapFrac = w->vaporFraction();

View file

@ -69,8 +69,8 @@ int main(int argc, char** argv)
Cantera::appdelete();
return 0;
} catch (CanteraError) {
showErrors();
} catch (CanteraError& err) {
std::cout << err.what() << std::endl;
return -1;
}
}