Eliminate redundancy between get_XML_File and get_CTML_Tree
get_CTML_Tree and getCtmlTree are now deprecated in favor of get_XML_File
This commit is contained in:
parent
6866725b57
commit
063c2a261a
12 changed files with 22 additions and 67 deletions
|
|
@ -756,6 +756,7 @@ std::string getChildValue(const Cantera::XML_Node& parent,
|
|||
* @param node Root of the tree
|
||||
* @param file Name of the file
|
||||
* @param debug Turn on debugging printing
|
||||
* @deprecated To be removed after Cantera 2.2. Use get_XML_File() instead.
|
||||
*/
|
||||
void get_CTML_Tree(Cantera::XML_Node* node, const std::string& file,
|
||||
const int debug = 0);
|
||||
|
|
@ -763,6 +764,7 @@ void get_CTML_Tree(Cantera::XML_Node* node, const std::string& file,
|
|||
//! Read an ctml file from a file and fill up an XML tree.
|
||||
//! @param file Name of the file
|
||||
//! @return Root of the tree
|
||||
//! @deprecated To be removed after Cantera 2.2. Use get_XML_File() instead.
|
||||
Cantera::XML_Node getCtmlTree(const std::string& file);
|
||||
|
||||
//! Convert a cti file into a ctml file
|
||||
|
|
|
|||
|
|
@ -13,13 +13,11 @@ cdef extern from "cantera/base/xml.h" namespace "Cantera":
|
|||
XML_Node* findID(string)
|
||||
int nChildren()
|
||||
|
||||
cdef extern from "cantera/base/ctml.h" namespace "ctml":
|
||||
XML_Node getCtmlTree(string) except +
|
||||
|
||||
cdef extern from "cantera/base/global.h" namespace "Cantera":
|
||||
cdef void CxxAddDirectory "Cantera::addDirectory" (string)
|
||||
cdef size_t CxxNpos "Cantera::npos"
|
||||
cdef void CxxAppdelete "Cantera::appdelete" ()
|
||||
cdef XML_Node* CxxGetXmlFile "Cantera::get_XML_File" (string) except +
|
||||
|
||||
cdef extern from "cantera/thermo/mix_defs.h":
|
||||
cdef int thermo_type_ideal_gas "Cantera::cIdealGas"
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ cdef class _SolutionBase:
|
|||
return
|
||||
|
||||
# Instantiate a set of new Cantera C++ objects
|
||||
rootNode = getCtmlTree(stringify(infile))
|
||||
rootNode = CxxGetXmlFile(stringify(infile))
|
||||
|
||||
# Get XML data
|
||||
cdef XML_Node* phaseNode
|
||||
|
|
|
|||
|
|
@ -262,46 +262,19 @@ void ck2cti(const std::string& in_file, const std::string& thermo_file,
|
|||
|
||||
void get_CTML_Tree(Cantera::XML_Node* rootPtr, const std::string& file, const int debug)
|
||||
{
|
||||
std::string ext = "";
|
||||
|
||||
// find the input file on the Cantera search path
|
||||
std::string inname = findInputFile(file);
|
||||
writelog("Found file: "+inname+"\n", debug);
|
||||
|
||||
if (inname == "") {
|
||||
throw CanteraError("get_CTML_Tree", "file "+file+" not found");
|
||||
}
|
||||
|
||||
/*
|
||||
* Check whether or not the file is XML. If not, it will be first
|
||||
* processed with the preprocessor.
|
||||
*/
|
||||
std::string::size_type idot = inname.rfind('.');
|
||||
if (idot != string::npos) {
|
||||
ext = inname.substr(idot, inname.size());
|
||||
}
|
||||
if (ext != ".xml" && ext != ".ctml") {
|
||||
string phase_xml = ctml::ct2ctml_string(inname);
|
||||
stringstream s(phase_xml);
|
||||
rootPtr->build(s);
|
||||
return;
|
||||
}
|
||||
|
||||
writelog("Attempting to parse xml file " + inname + "\n", debug);
|
||||
ifstream fin(inname.c_str());
|
||||
if (!fin) {
|
||||
throw
|
||||
CanteraError("get_CTML_Tree",
|
||||
"XML file " + inname + " not found");
|
||||
}
|
||||
rootPtr->build(fin);
|
||||
fin.close();
|
||||
warn_deprecated("get_CTML_Tree", "To be removed after Cantera 2.2. "
|
||||
"Use get_XML_File instead.");
|
||||
XML_Node* src = get_XML_File(file);
|
||||
src->copy(rootPtr);
|
||||
}
|
||||
|
||||
Cantera::XML_Node getCtmlTree(const std::string& file)
|
||||
{
|
||||
Cantera::XML_Node root;
|
||||
get_CTML_Tree(&root, file);
|
||||
warn_deprecated("getCtmlTree", "To be removed after Cantera 2.2. "
|
||||
"Use get_XML_File instead.");
|
||||
XML_Node root;
|
||||
XML_Node* src = get_XML_File(file);
|
||||
src->copy(&root);
|
||||
return root;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ extern "C" {
|
|||
int xml_preprocess_and_build(int i, const char* file, int debug)
|
||||
{
|
||||
try {
|
||||
get_CTML_Tree(&XmlCabinet::item(i), file, debug);
|
||||
XmlCabinet::item(i) = *get_XML_File(file);
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return handleAllExceptions(-1, ERR);
|
||||
|
|
|
|||
|
|
@ -38,9 +38,7 @@ int main(int argc, char** argv)
|
|||
int i, k;
|
||||
|
||||
try {
|
||||
XML_Node* xc = new XML_Node();
|
||||
string path = findInputFile(infile);
|
||||
ctml::get_CTML_Tree(xc, path);
|
||||
XML_Node* xc = get_XML_File(infile);
|
||||
|
||||
XML_Node* const xg = xc->findNameID("phase", "gas");
|
||||
ThermoPhase* gasTP = newPhase(*xg);
|
||||
|
|
|
|||
|
|
@ -30,9 +30,7 @@ int main(int argc, char** argv)
|
|||
string infile = "diamond.xml";
|
||||
|
||||
try {
|
||||
XML_Node* xc = new XML_Node();
|
||||
string path = findInputFile(infile);
|
||||
ctml::get_CTML_Tree(xc, path);
|
||||
XML_Node* xc = get_XML_File(infile);
|
||||
cout.precision(3);
|
||||
|
||||
XML_Node* const xg = xc->findNameID("phase", "gas");
|
||||
|
|
|
|||
|
|
@ -34,9 +34,7 @@ int main(int argc, char** argv)
|
|||
double cdot[10], ddot[10];
|
||||
//double fwd_rop[10];
|
||||
try {
|
||||
XML_Node* xc = new XML_Node();
|
||||
string path = findInputFile(infile);
|
||||
ctml::get_CTML_Tree(xc, path);
|
||||
XML_Node* xc = get_XML_File(infile);
|
||||
|
||||
XML_Node* const xg = xc->findNameID("phase", "gas");
|
||||
ThermoPhase* gasTP = newPhase(*xg);
|
||||
|
|
@ -150,7 +148,6 @@ int main(int argc, char** argv)
|
|||
delete iKin_ptr;
|
||||
iKin_ptr = 0;
|
||||
delete gasTP;
|
||||
delete xc;
|
||||
appdelete();
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -22,10 +22,7 @@ int main(int argc, char** argv)
|
|||
double x[20];
|
||||
double cdot[20], ddot[20];
|
||||
|
||||
XML_Node* xc = new XML_Node();
|
||||
string path = findInputFile(infile);
|
||||
ctml::get_CTML_Tree(xc, path);
|
||||
|
||||
XML_Node* xc = get_XML_File(infile);
|
||||
XML_Node* const xg = xc->findNameID("phase", "air");
|
||||
ThermoPhase* gasTP = newPhase(*xg);
|
||||
size_t nsp = gasTP->nSpecies();
|
||||
|
|
|
|||
|
|
@ -43,9 +43,8 @@ void printRates(InterfaceKinetics& iKin)
|
|||
void testProblem()
|
||||
{
|
||||
ss << std::scientific << std::setprecision(3) << std::uppercase;
|
||||
XML_Node xc;
|
||||
ctml::get_CTML_Tree(&xc, "ReactionSurf.xml");
|
||||
XML_Node* xg = xc.findNameID("phase", "reaction_surface");
|
||||
XML_Node* xc = get_XML_File("ReactionSurf.xml");
|
||||
XML_Node* xg = xc->findNameID("phase", "reaction_surface");
|
||||
if (!xg) {
|
||||
throw CanteraError("couldn't find file", "");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -217,9 +217,7 @@ int main(int argc, char** argv)
|
|||
}
|
||||
|
||||
/************************************************************/
|
||||
XML_Node* xc = new XML_Node();
|
||||
string path = findInputFile(infile);
|
||||
ctml::get_CTML_Tree(xc, path);
|
||||
XML_Node* xc = get_XML_File(infile);
|
||||
|
||||
XML_Node* const xg = (XML_Node*) findXMLPhase(xc, gasPhaseName);
|
||||
if (!xg) {
|
||||
|
|
@ -436,7 +434,6 @@ int main(int argc, char** argv)
|
|||
bulkPhaseTP = 0;
|
||||
delete surfPhaseTP;
|
||||
surfPhaseTP = 0;
|
||||
delete xc;
|
||||
appdelete();
|
||||
} catch (CanteraError& err) {
|
||||
std::cout << err.what() << std::endl;
|
||||
|
|
|
|||
|
|
@ -219,10 +219,7 @@ int main(int argc, char** argv)
|
|||
}
|
||||
|
||||
/************************************************************/
|
||||
XML_Node* xc = new XML_Node();
|
||||
string path = findInputFile(infile);
|
||||
ctml::get_CTML_Tree(xc, path);
|
||||
|
||||
XML_Node* xc = get_XML_File(infile);
|
||||
XML_Node* const xg = (XML_Node*) findXMLPhase(xc, gasPhaseName);
|
||||
if (!xg) {
|
||||
printf("ERROR: Could not find gas phase named, %s, in file\n",
|
||||
|
|
@ -479,7 +476,6 @@ int main(int argc, char** argv)
|
|||
surfPhaseTP = 0;
|
||||
delete surfPhaseTP2;
|
||||
surfPhaseTP2 = 0;
|
||||
delete xc;
|
||||
appdelete();
|
||||
} catch (CanteraError& err) {
|
||||
std::cout << err.what() << std::endl;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue