From a7e60c5e889d4ddb74b1c81b32580563e51c369c Mon Sep 17 00:00:00 2001 From: Dave Goodwin Date: Fri, 4 May 2007 15:15:19 +0000 Subject: [PATCH] moved base files --- Cantera/src/{ => base}/Array.h | 0 Cantera/src/{ => base}/XML_Writer.h | 0 Cantera/src/{ => base}/config.h | 4 +- Cantera/src/{ => base}/ct2ctml.cpp | 0 Cantera/src/{ => base}/ct_defs.h | 0 Cantera/src/{ => base}/ctexceptions.h | 0 Cantera/src/{ => base}/ctml.cpp | 0 Cantera/src/{ => base}/ctml.h | 0 Cantera/src/{ => base}/global.h | 98 ++++++++++++++++++++ Cantera/src/{ => base}/logger.h | 0 Cantera/src/{ => base}/misc.cpp | 118 +++++++++++++++++++++++++ Cantera/src/{ => base}/plots.cpp | 0 Cantera/src/{ => base}/plots.h | 0 Cantera/src/{ => base}/stringUtils.cpp | 0 Cantera/src/{ => base}/stringUtils.h | 0 Cantera/src/{ => base}/units.h | 0 Cantera/src/{ => base}/utilities.h | 36 ++++++++ Cantera/src/{ => base}/vec_functions.h | 0 Cantera/src/{ => base}/xml.cpp | 0 Cantera/src/{ => base}/xml.h | 0 20 files changed, 254 insertions(+), 2 deletions(-) rename Cantera/src/{ => base}/Array.h (100%) rename Cantera/src/{ => base}/XML_Writer.h (100%) rename Cantera/src/{ => base}/config.h (79%) rename Cantera/src/{ => base}/ct2ctml.cpp (100%) rename Cantera/src/{ => base}/ct_defs.h (100%) rename Cantera/src/{ => base}/ctexceptions.h (100%) rename Cantera/src/{ => base}/ctml.cpp (100%) rename Cantera/src/{ => base}/ctml.h (100%) rename Cantera/src/{ => base}/global.h (79%) rename Cantera/src/{ => base}/logger.h (100%) rename Cantera/src/{ => base}/misc.cpp (88%) rename Cantera/src/{ => base}/plots.cpp (100%) rename Cantera/src/{ => base}/plots.h (100%) rename Cantera/src/{ => base}/stringUtils.cpp (100%) rename Cantera/src/{ => base}/stringUtils.h (100%) rename Cantera/src/{ => base}/units.h (100%) rename Cantera/src/{ => base}/utilities.h (95%) rename Cantera/src/{ => base}/vec_functions.h (100%) rename Cantera/src/{ => base}/xml.cpp (100%) rename Cantera/src/{ => base}/xml.h (100%) diff --git a/Cantera/src/Array.h b/Cantera/src/base/Array.h similarity index 100% rename from Cantera/src/Array.h rename to Cantera/src/base/Array.h diff --git a/Cantera/src/XML_Writer.h b/Cantera/src/base/XML_Writer.h similarity index 100% rename from Cantera/src/XML_Writer.h rename to Cantera/src/base/XML_Writer.h diff --git a/Cantera/src/config.h b/Cantera/src/base/config.h similarity index 79% rename from Cantera/src/config.h rename to Cantera/src/base/config.h index db96ab2c9..00042f57f 100755 --- a/Cantera/src/config.h +++ b/Cantera/src/base/config.h @@ -8,13 +8,13 @@ #ifdef CANTERA_APP #include "../winconfig.h" #else -#include "../../winconfig.h" +#include "../../../winconfig.h" #endif #else #ifdef CANTERA_APP #include "../config.h" #else -#include "../../config.h" +#include "../../../config.h" #endif #endif #endif diff --git a/Cantera/src/ct2ctml.cpp b/Cantera/src/base/ct2ctml.cpp similarity index 100% rename from Cantera/src/ct2ctml.cpp rename to Cantera/src/base/ct2ctml.cpp diff --git a/Cantera/src/ct_defs.h b/Cantera/src/base/ct_defs.h similarity index 100% rename from Cantera/src/ct_defs.h rename to Cantera/src/base/ct_defs.h diff --git a/Cantera/src/ctexceptions.h b/Cantera/src/base/ctexceptions.h similarity index 100% rename from Cantera/src/ctexceptions.h rename to Cantera/src/base/ctexceptions.h diff --git a/Cantera/src/ctml.cpp b/Cantera/src/base/ctml.cpp similarity index 100% rename from Cantera/src/ctml.cpp rename to Cantera/src/base/ctml.cpp diff --git a/Cantera/src/ctml.h b/Cantera/src/base/ctml.h similarity index 100% rename from Cantera/src/ctml.h rename to Cantera/src/base/ctml.h diff --git a/Cantera/src/global.h b/Cantera/src/base/global.h similarity index 79% rename from Cantera/src/global.h rename to Cantera/src/base/global.h index cf848b94d..f1c695769 100755 --- a/Cantera/src/global.h +++ b/Cantera/src/base/global.h @@ -452,6 +452,104 @@ namespace Cantera { inline void write_logfile(std::string file = "log.html") {} #endif + + //! Search for an XML_Node either wiithin an existing XML tree structure, or in another file, + //! based on the file name or the XML id attribute. + /*! + * This routine will locate an XML node in either the input + * XML tree or in another input file specified by the file + * part of the file_ID string. Searches are based on the + * ID attribute of the XML element only. + * + * @param file_ID This is a concatenation of two strings seperated + * by the "#" character. The string before the + * pound character is the file name of an xml + * file to carry out the search. The string after + * the # character is the ID attribute + * of the xml element to search for. + * The string is interpreted as a file string if + * no # character is in the string. + * + * @param root If the file string is empty, searches for the + * xml element with matching ID attribute are + * carried out from this XML node. + * + * @return + * This routine will process the XML file, creating an XML + * tree structure. It returns a pointer to the top of the tree. + * + * + * For example, + * @code + * + * XML_Node* xn = get_XML_Node("phase", "gri30.xml#gri30_mix", 0); + * + * @endcode + * + * will search in the file gri30.xml for an XML element of the following form, where + * the XML element name, phase, is an optional hit: + * @verbatim + nodeset_t; + //! typedef for an XML_Node + typedef XML_Node node_t; + + + /// split a string at a '#' sign. Used to separate a file name + /// from an id string. + static void split(const std::string& src, std::string& file, std::string& id) { + string::size_type ipound = src.find('#'); + if (ipound != string::npos) { + id = src.substr(ipound+1,src.size()); + file = src.substr(0,ipound); + } + else { + id = ""; + file = src; + } + } + + /* + * This routine will locate an XML node in either the input + * XML tree or in another input file specified by the file + * part of the file_ID string. Searches are based on the + * ID attribute of the XML element only. + * + * param file_ID This is a concatenation of two strings seperated + * by the "#" character. The string before the + * pound character is the file name of an xml + * file to carry out the search. The string after + * the # character is the ID attribute + * of the xml element to search for. + * The string is interpreted as a file string if + * no # character is in the string. + * + * param root If the file string is empty, searches for the + * xml element with matching ID attribute are + * carried out from this XML node. + */ + XML_Node* get_XML_Node(const std::string& file_ID, XML_Node* root) { + string fname, idstr; + XML_Node *db, *doc; + split(file_ID, fname, idstr); + if (fname == "") { + if (!root) throw CanteraError("get_XML_Node", + "no file name given. file_ID = "+file_ID); + db = root->findID(idstr, 3); + } + else { + doc = get_XML_File(fname); + if (!doc) throw CanteraError("get_XML_Node", + "get_XML_File failed trying to open "+fname); + db = doc->findID(idstr, 3); + } + if (!db) { + throw CanteraError("get_XML_Node", + "id tag '"+idstr+"' not found."); + } + return db; + } + + + /* + * This routine will locate an XML node in either the input + * XML tree or in another input file specified by the file + * part of the file_ID string. Searches are based on the + * XML element name and the ID attribute of the XML element. + * An exact match of both is usually required. However, the + * ID attribute may be set to "", in which case the first + * xml element with the correct element name will be returned. + * + * @param nameTarget This is the XML element name to look for. + * + * @param file_ID This is a concatenation of two strings seperated + * by the "#" character. The string before the + * pound character is the file name of an xml + * file to carry out the search. The string after + * the # character is the ID attribute + * of the xml element to search for. + * The string is interpreted as a file string if + * no # character is in the string. + * + * @param root If the file string is empty, searches for the + * xml element with matching ID attribute are + * carried out from this XML node. + */ + XML_Node* get_XML_NameID(const std::string& nameTarget, + const std::string& file_ID, + XML_Node* root) { + string fname, idTarget; + XML_Node *db, *doc; + split(file_ID, fname, idTarget); + if (fname == "") { + if (!root) return 0; + db = root->findNameID(nameTarget, idTarget); + } else { + doc = get_XML_File(fname); + if (!doc) return 0; + db = doc->findNameID(nameTarget, idTarget); + } + return db; + } + + } diff --git a/Cantera/src/plots.cpp b/Cantera/src/base/plots.cpp similarity index 100% rename from Cantera/src/plots.cpp rename to Cantera/src/base/plots.cpp diff --git a/Cantera/src/plots.h b/Cantera/src/base/plots.h similarity index 100% rename from Cantera/src/plots.h rename to Cantera/src/base/plots.h diff --git a/Cantera/src/stringUtils.cpp b/Cantera/src/base/stringUtils.cpp similarity index 100% rename from Cantera/src/stringUtils.cpp rename to Cantera/src/base/stringUtils.cpp diff --git a/Cantera/src/stringUtils.h b/Cantera/src/base/stringUtils.h similarity index 100% rename from Cantera/src/stringUtils.h rename to Cantera/src/base/stringUtils.h diff --git a/Cantera/src/units.h b/Cantera/src/base/units.h similarity index 100% rename from Cantera/src/units.h rename to Cantera/src/base/units.h diff --git a/Cantera/src/utilities.h b/Cantera/src/base/utilities.h similarity index 95% rename from Cantera/src/utilities.h rename to Cantera/src/base/utilities.h index fdbd81329..815c22d94 100755 --- a/Cantera/src/utilities.h +++ b/Cantera/src/base/utilities.h @@ -563,6 +563,42 @@ namespace Cantera { //@} + template + R poly6(D x, R* c) { + return ((((((c[6]*x + c[5])*x + c[4])*x + c[3])*x + + c[2])*x + c[1])*x + c[0]); + } + + template + R poly8(D x, R* c) { + return ((((((((c[8]*x + c[7])*x + c[6])*x + c[5])*x + c[4])*x + c[3])*x + + c[2])*x + c[1])*x + c[0]); + } + + template + R poly10(D x, R* c) { + return ((((((((((c[10]*x + c[9])*x + c[8])*x + c[7])*x + + c[6])*x + c[5])*x + c[4])*x + c[3])*x + + c[2])*x + c[1])*x + c[0]); + } + + template + R poly5(D x, R* c) { + return (((((c[5]*x + c[4])*x + c[3])*x + + c[2])*x + c[1])*x + c[0]); + } + + template + R poly4(D x, R* c) { + return ((((c[4]*x + c[3])*x + + c[2])*x + c[1])*x + c[0]); + } + + template + R poly3(D x, R* c) { + return (((c[3]*x + c[2])*x + c[1])*x + c[0]); + } + } diff --git a/Cantera/src/vec_functions.h b/Cantera/src/base/vec_functions.h similarity index 100% rename from Cantera/src/vec_functions.h rename to Cantera/src/base/vec_functions.h diff --git a/Cantera/src/xml.cpp b/Cantera/src/base/xml.cpp similarity index 100% rename from Cantera/src/xml.cpp rename to Cantera/src/base/xml.cpp diff --git a/Cantera/src/xml.h b/Cantera/src/base/xml.h similarity index 100% rename from Cantera/src/xml.h rename to Cantera/src/base/xml.h