From b5c1023aa8b0798b5fe2c4fc47d332af25fc6add Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Thu, 6 Jul 2006 15:40:07 +0000 Subject: [PATCH] Added a utility routine. --- Cantera/src/importCTML.cpp | 33 +++++++++++++++++++++++++++++++++ Cantera/src/importCTML.h | 3 +++ 2 files changed, 36 insertions(+) diff --git a/Cantera/src/importCTML.cpp b/Cantera/src/importCTML.cpp index 6940071b4..ec4b31e10 100755 --- a/Cantera/src/importCTML.cpp +++ b/Cantera/src/importCTML.cpp @@ -1476,5 +1476,38 @@ next: return false; } } + + /** + * Search an XML tree for species data. + * + * This utility routine will search the XML tree for the species + * named by the string, kname. It will return the XML_Node + * pointer. + * Failures of any kind return the null pointer. + */ + const XML_Node *speciesXML_Node(string kname, + const XML_Node *phaseSpecies) { + /* + * First look at the species database. + * -> Look for the subelement "stoichIsMods" + * in each of the species SS databases. + */ + if (!phaseSpecies) return ((const XML_Node *) 0); + string jname; + vector xspecies; + phaseSpecies->getChildren("species", xspecies); + int jj = xspecies.size(); + for (int j = 0; j < jj; j++) { + const XML_Node& sp = *xspecies[j]; + jname = sp["name"]; + if (jname == kname) { + return &sp; + } + } + return ((const XML_Node *) 0); + } + + + } diff --git a/Cantera/src/importCTML.h b/Cantera/src/importCTML.h index 0e871c8ef..d6b39de44 100755 --- a/Cantera/src/importCTML.h +++ b/Cantera/src/importCTML.h @@ -63,6 +63,9 @@ namespace Cantera { bool buildSolutionFromXML(XML_Node& root, string id, string nm, ThermoPhase* th, Kinetics* k); + const XML_Node *speciesXML_Node(string kname, + const XML_Node *phaseSpecies); + } #endif