From 39468681dc5834942f7137f8eaeb893f6d6ac0a8 Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Mon, 28 Jun 2004 23:47:35 +0000 Subject: [PATCH] Added a few throw statements that was missing. Added a throw UnknownSpeciesThermo statement for cases where the complete thermo block is missing. This is necessary for particle species object to function. --- Cantera/src/SpeciesThermoFactory.cpp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/Cantera/src/SpeciesThermoFactory.cpp b/Cantera/src/SpeciesThermoFactory.cpp index 4456a3da6..30243ef4b 100755 --- a/Cantera/src/SpeciesThermoFactory.cpp +++ b/Cantera/src/SpeciesThermoFactory.cpp @@ -72,7 +72,8 @@ namespace Cantera { + SHOMATE*ishomate + SIMPLE*isimple); } - SpeciesThermo* SpeciesThermoFactory::newSpeciesThermo(vector nodes) { + SpeciesThermo* SpeciesThermoFactory:: + newSpeciesThermo(vector nodes) { int n = nodes.size(); int inasa = 0, ishomate = 0, isimple = 0; for (int j = 0; j < n; j++) { @@ -83,7 +84,8 @@ namespace Cantera { } - SpeciesThermo* SpeciesThermoFactory::newSpeciesThermoOpt(vector nodes) { + SpeciesThermo* SpeciesThermoFactory:: + newSpeciesThermoOpt(vector nodes) { int n = nodes.size(); int inasa = 0, ishomate = 0, isimple = 0; for (int j = 0; j < n; j++) { @@ -302,7 +304,14 @@ namespace Cantera { void SpeciesThermoFactory:: installThermoForSpecies(int k, const XML_Node& s, SpeciesThermo& spthermo) { - + /* + * Check to see that the species block has a thermo block + * before processing. Throw an error if not there. + */ + if (!(s.hasChild("thermo"))) { + throw UnknownSpeciesThermoModel("installSpecies", + s["name"], ""); + } const XML_Node& thermo = s.child("thermo"); const vector& tp = thermo.children(); int nc = tp.size(); @@ -318,7 +327,8 @@ namespace Cantera { installNasaThermoFromXML(spthermo, k, f, 0); } else { - UnknownSpeciesThermoModel("installSpecies", s["name"], f->name()); + throw UnknownSpeciesThermoModel("installSpecies", + s["name"], f->name()); } } else if (nc == 2) { @@ -331,13 +341,14 @@ namespace Cantera { installShomateThermoFromXML(spthermo, k, f0, f1); } else { - UnknownSpeciesThermoModel("installSpecies", s["name"], - f0->name() + " and " + f1->name()); + throw UnknownSpeciesThermoModel("installSpecies", s["name"], + f0->name() + " and " + + f1->name()); } } else { - UnknownSpeciesThermoModel("installSpecies", s["name"], - "multiple"); + throw UnknownSpeciesThermoModel("installSpecies", s["name"], + "multiple"); } }