[Thermo] Use findXMLPhase in initThermoFile
This allows many constructors which take a filename to work with CTI files directly, and to make use of the parsed XML cache.
This commit is contained in:
parent
337c573958
commit
f3fc8f2ce2
1 changed files with 3 additions and 22 deletions
|
|
@ -631,33 +631,14 @@ SpeciesThermo& ThermoPhase::speciesThermo(int k)
|
||||||
void ThermoPhase::initThermoFile(const std::string& inputFile,
|
void ThermoPhase::initThermoFile(const std::string& inputFile,
|
||||||
const std::string& id)
|
const std::string& id)
|
||||||
{
|
{
|
||||||
if (inputFile.size() == 0) {
|
XML_Node* fxml = get_XML_File(inputFile);
|
||||||
throw CanteraError("ThermoPhase::initThermoFile",
|
|
||||||
"input file is null");
|
|
||||||
}
|
|
||||||
string path = findInputFile(inputFile);
|
|
||||||
ifstream fin(path.c_str());
|
|
||||||
if (!fin) {
|
|
||||||
throw CanteraError("initThermoFile","could not open "
|
|
||||||
+path+" for reading.");
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* The phase object automatically constructs an XML object.
|
|
||||||
* Use this object to store information.
|
|
||||||
*/
|
|
||||||
XML_Node* fxml = new XML_Node();
|
|
||||||
fxml->build(fin);
|
|
||||||
XML_Node* fxml_phase = findXMLPhase(fxml, id);
|
XML_Node* fxml_phase = findXMLPhase(fxml, id);
|
||||||
if (!fxml_phase) {
|
if (!fxml_phase) {
|
||||||
throw CanteraError("ThermoPhase::initThermo",
|
throw CanteraError("ThermoPhase::initThermoFile",
|
||||||
"ERROR: Can not find phase named " +
|
"ERROR: Can not find phase named " +
|
||||||
id + " in file named " + inputFile);
|
id + " in file named " + inputFile);
|
||||||
}
|
}
|
||||||
bool m_ok = importPhase(*fxml_phase, this);
|
importPhase(*fxml_phase, this);
|
||||||
if (!m_ok) {
|
|
||||||
throw CanteraError("ThermoPhase::initThermoFile","importPhase failed ");
|
|
||||||
}
|
|
||||||
delete fxml;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThermoPhase::initThermoXML(XML_Node& phaseNode, const std::string& id)
|
void ThermoPhase::initThermoXML(XML_Node& phaseNode, const std::string& id)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue