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 node Root of the tree
|
||||||
* @param file Name of the file
|
* @param file Name of the file
|
||||||
* @param debug Turn on debugging printing
|
* @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,
|
void get_CTML_Tree(Cantera::XML_Node* node, const std::string& file,
|
||||||
const int debug = 0);
|
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.
|
//! Read an ctml file from a file and fill up an XML tree.
|
||||||
//! @param file Name of the file
|
//! @param file Name of the file
|
||||||
//! @return Root of the tree
|
//! @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);
|
Cantera::XML_Node getCtmlTree(const std::string& file);
|
||||||
|
|
||||||
//! Convert a cti file into a ctml 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)
|
XML_Node* findID(string)
|
||||||
int nChildren()
|
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 extern from "cantera/base/global.h" namespace "Cantera":
|
||||||
cdef void CxxAddDirectory "Cantera::addDirectory" (string)
|
cdef void CxxAddDirectory "Cantera::addDirectory" (string)
|
||||||
cdef size_t CxxNpos "Cantera::npos"
|
cdef size_t CxxNpos "Cantera::npos"
|
||||||
cdef void CxxAppdelete "Cantera::appdelete" ()
|
cdef void CxxAppdelete "Cantera::appdelete" ()
|
||||||
|
cdef XML_Node* CxxGetXmlFile "Cantera::get_XML_File" (string) except +
|
||||||
|
|
||||||
cdef extern from "cantera/thermo/mix_defs.h":
|
cdef extern from "cantera/thermo/mix_defs.h":
|
||||||
cdef int thermo_type_ideal_gas "Cantera::cIdealGas"
|
cdef int thermo_type_ideal_gas "Cantera::cIdealGas"
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ cdef class _SolutionBase:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Instantiate a set of new Cantera C++ objects
|
# Instantiate a set of new Cantera C++ objects
|
||||||
rootNode = getCtmlTree(stringify(infile))
|
rootNode = CxxGetXmlFile(stringify(infile))
|
||||||
|
|
||||||
# Get XML data
|
# Get XML data
|
||||||
cdef XML_Node* phaseNode
|
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)
|
void get_CTML_Tree(Cantera::XML_Node* rootPtr, const std::string& file, const int debug)
|
||||||
{
|
{
|
||||||
std::string ext = "";
|
warn_deprecated("get_CTML_Tree", "To be removed after Cantera 2.2. "
|
||||||
|
"Use get_XML_File instead.");
|
||||||
// find the input file on the Cantera search path
|
XML_Node* src = get_XML_File(file);
|
||||||
std::string inname = findInputFile(file);
|
src->copy(rootPtr);
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Cantera::XML_Node getCtmlTree(const std::string& file)
|
Cantera::XML_Node getCtmlTree(const std::string& file)
|
||||||
{
|
{
|
||||||
Cantera::XML_Node root;
|
warn_deprecated("getCtmlTree", "To be removed after Cantera 2.2. "
|
||||||
get_CTML_Tree(&root, file);
|
"Use get_XML_File instead.");
|
||||||
|
XML_Node root;
|
||||||
|
XML_Node* src = get_XML_File(file);
|
||||||
|
src->copy(&root);
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ extern "C" {
|
||||||
int xml_preprocess_and_build(int i, const char* file, int debug)
|
int xml_preprocess_and_build(int i, const char* file, int debug)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
get_CTML_Tree(&XmlCabinet::item(i), file, debug);
|
XmlCabinet::item(i) = *get_XML_File(file);
|
||||||
return 0;
|
return 0;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
return handleAllExceptions(-1, ERR);
|
return handleAllExceptions(-1, ERR);
|
||||||
|
|
|
||||||
|
|
@ -38,9 +38,7 @@ int main(int argc, char** argv)
|
||||||
int i, k;
|
int i, k;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
XML_Node* xc = new XML_Node();
|
XML_Node* xc = get_XML_File(infile);
|
||||||
string path = findInputFile(infile);
|
|
||||||
ctml::get_CTML_Tree(xc, path);
|
|
||||||
|
|
||||||
XML_Node* const xg = xc->findNameID("phase", "gas");
|
XML_Node* const xg = xc->findNameID("phase", "gas");
|
||||||
ThermoPhase* gasTP = newPhase(*xg);
|
ThermoPhase* gasTP = newPhase(*xg);
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,7 @@ int main(int argc, char** argv)
|
||||||
string infile = "diamond.xml";
|
string infile = "diamond.xml";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
XML_Node* xc = new XML_Node();
|
XML_Node* xc = get_XML_File(infile);
|
||||||
string path = findInputFile(infile);
|
|
||||||
ctml::get_CTML_Tree(xc, path);
|
|
||||||
cout.precision(3);
|
cout.precision(3);
|
||||||
|
|
||||||
XML_Node* const xg = xc->findNameID("phase", "gas");
|
XML_Node* const xg = xc->findNameID("phase", "gas");
|
||||||
|
|
|
||||||
|
|
@ -34,9 +34,7 @@ int main(int argc, char** argv)
|
||||||
double cdot[10], ddot[10];
|
double cdot[10], ddot[10];
|
||||||
//double fwd_rop[10];
|
//double fwd_rop[10];
|
||||||
try {
|
try {
|
||||||
XML_Node* xc = new XML_Node();
|
XML_Node* xc = get_XML_File(infile);
|
||||||
string path = findInputFile(infile);
|
|
||||||
ctml::get_CTML_Tree(xc, path);
|
|
||||||
|
|
||||||
XML_Node* const xg = xc->findNameID("phase", "gas");
|
XML_Node* const xg = xc->findNameID("phase", "gas");
|
||||||
ThermoPhase* gasTP = newPhase(*xg);
|
ThermoPhase* gasTP = newPhase(*xg);
|
||||||
|
|
@ -150,7 +148,6 @@ int main(int argc, char** argv)
|
||||||
delete iKin_ptr;
|
delete iKin_ptr;
|
||||||
iKin_ptr = 0;
|
iKin_ptr = 0;
|
||||||
delete gasTP;
|
delete gasTP;
|
||||||
delete xc;
|
|
||||||
appdelete();
|
appdelete();
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,7 @@ int main(int argc, char** argv)
|
||||||
double x[20];
|
double x[20];
|
||||||
double cdot[20], ddot[20];
|
double cdot[20], ddot[20];
|
||||||
|
|
||||||
XML_Node* xc = new XML_Node();
|
XML_Node* xc = get_XML_File(infile);
|
||||||
string path = findInputFile(infile);
|
|
||||||
ctml::get_CTML_Tree(xc, path);
|
|
||||||
|
|
||||||
XML_Node* const xg = xc->findNameID("phase", "air");
|
XML_Node* const xg = xc->findNameID("phase", "air");
|
||||||
ThermoPhase* gasTP = newPhase(*xg);
|
ThermoPhase* gasTP = newPhase(*xg);
|
||||||
size_t nsp = gasTP->nSpecies();
|
size_t nsp = gasTP->nSpecies();
|
||||||
|
|
|
||||||
|
|
@ -43,9 +43,8 @@ void printRates(InterfaceKinetics& iKin)
|
||||||
void testProblem()
|
void testProblem()
|
||||||
{
|
{
|
||||||
ss << std::scientific << std::setprecision(3) << std::uppercase;
|
ss << std::scientific << std::setprecision(3) << std::uppercase;
|
||||||
XML_Node xc;
|
XML_Node* xc = get_XML_File("ReactionSurf.xml");
|
||||||
ctml::get_CTML_Tree(&xc, "ReactionSurf.xml");
|
XML_Node* xg = xc->findNameID("phase", "reaction_surface");
|
||||||
XML_Node* xg = xc.findNameID("phase", "reaction_surface");
|
|
||||||
if (!xg) {
|
if (!xg) {
|
||||||
throw CanteraError("couldn't find file", "");
|
throw CanteraError("couldn't find file", "");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -217,9 +217,7 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************/
|
/************************************************************/
|
||||||
XML_Node* xc = new XML_Node();
|
XML_Node* xc = get_XML_File(infile);
|
||||||
string path = findInputFile(infile);
|
|
||||||
ctml::get_CTML_Tree(xc, path);
|
|
||||||
|
|
||||||
XML_Node* const xg = (XML_Node*) findXMLPhase(xc, gasPhaseName);
|
XML_Node* const xg = (XML_Node*) findXMLPhase(xc, gasPhaseName);
|
||||||
if (!xg) {
|
if (!xg) {
|
||||||
|
|
@ -436,7 +434,6 @@ int main(int argc, char** argv)
|
||||||
bulkPhaseTP = 0;
|
bulkPhaseTP = 0;
|
||||||
delete surfPhaseTP;
|
delete surfPhaseTP;
|
||||||
surfPhaseTP = 0;
|
surfPhaseTP = 0;
|
||||||
delete xc;
|
|
||||||
appdelete();
|
appdelete();
|
||||||
} catch (CanteraError& err) {
|
} catch (CanteraError& err) {
|
||||||
std::cout << err.what() << std::endl;
|
std::cout << err.what() << std::endl;
|
||||||
|
|
|
||||||
|
|
@ -219,10 +219,7 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************/
|
/************************************************************/
|
||||||
XML_Node* xc = new XML_Node();
|
XML_Node* xc = get_XML_File(infile);
|
||||||
string path = findInputFile(infile);
|
|
||||||
ctml::get_CTML_Tree(xc, path);
|
|
||||||
|
|
||||||
XML_Node* const xg = (XML_Node*) findXMLPhase(xc, gasPhaseName);
|
XML_Node* const xg = (XML_Node*) findXMLPhase(xc, gasPhaseName);
|
||||||
if (!xg) {
|
if (!xg) {
|
||||||
printf("ERROR: Could not find gas phase named, %s, in file\n",
|
printf("ERROR: Could not find gas phase named, %s, in file\n",
|
||||||
|
|
@ -479,7 +476,6 @@ int main(int argc, char** argv)
|
||||||
surfPhaseTP = 0;
|
surfPhaseTP = 0;
|
||||||
delete surfPhaseTP2;
|
delete surfPhaseTP2;
|
||||||
surfPhaseTP2 = 0;
|
surfPhaseTP2 = 0;
|
||||||
delete xc;
|
|
||||||
appdelete();
|
appdelete();
|
||||||
} catch (CanteraError& err) {
|
} catch (CanteraError& err) {
|
||||||
std::cout << err.what() << std::endl;
|
std::cout << err.what() << std::endl;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue