From 473827a8a613e91740d935499ba458c70dd06137 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Sat, 27 Sep 2014 00:09:02 +0000 Subject: [PATCH] [Thermo] Check to make sure parameterizations are of the correct type --- include/cantera/thermo/SimpleThermo.h | 7 ++++++- src/thermo/NasaThermo.cpp | 6 ++++++ src/thermo/ShomateThermo.h | 6 ++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/include/cantera/thermo/SimpleThermo.h b/include/cantera/thermo/SimpleThermo.h index 7799c8123..92fd700f5 100644 --- a/include/cantera/thermo/SimpleThermo.h +++ b/include/cantera/thermo/SimpleThermo.h @@ -133,7 +133,12 @@ public: */ virtual void install(const std::string& name, size_t index, int type, const doublereal* c, doublereal minTemp_, doublereal maxTemp_, doublereal refPressure_) { - + if (type != SIMPLE) { + throw CanteraError("SimpleThermo::install", + "Incompatible thermo parameterization: Got " + + int2str(type) + " but " + int2str(SIMPLE) + + " was expected."); + } m_logt0.push_back(log(c[0])); m_t0.push_back(c[0]); m_h0_R.push_back(c[1]/GasConstant); diff --git a/src/thermo/NasaThermo.cpp b/src/thermo/NasaThermo.cpp index 8bd3841d4..61282cd9f 100644 --- a/src/thermo/NasaThermo.cpp +++ b/src/thermo/NasaThermo.cpp @@ -59,6 +59,12 @@ void NasaThermo::install(const std::string& name, size_t index, int type, doublereal min_temp, doublereal max_temp, doublereal ref_pressure) { + if (type != NASA) { + throw CanteraError("NasaThermo::install", + "Incompatible thermo parameterization: Got " + + int2str(type) + " but " + int2str(NASA) + + " was expected."); + } m_name[index] = name; int imid = int(c[0]); // midpoint temp converted to integer int igrp = m_index[imid]; // has this value been seen before? diff --git a/src/thermo/ShomateThermo.h b/src/thermo/ShomateThermo.h index 78c11f3d0..9ba1bbd6d 100644 --- a/src/thermo/ShomateThermo.h +++ b/src/thermo/ShomateThermo.h @@ -148,6 +148,12 @@ public: const doublereal* c, doublereal minTemp, doublereal maxTemp, doublereal refPressure) { + if (type != SHOMATE) { + throw CanteraError("ShomateThermo::install", + "Incompatible thermo parameterization: Got " + + int2str(type) + " but " + int2str(SHOMATE) + + " was expected."); + } int imid = int(c[0]); // midpoint temp converted to integer int igrp = m_index[imid]; // has this value been seen before? if (igrp == 0) { // if not, prepare new group