moved base files

This commit is contained in:
Dave Goodwin 2007-05-04 15:15:19 +00:00
parent 50cc50fa70
commit a7e60c5e88
20 changed files with 254 additions and 2 deletions

View file

@ -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

View file

@ -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
<phase id="gri30_mix>
. . .
</phase>
* @endverbatim
*
* It will return a pointer to an xml tree for the XML phase element.
*
* @ingroup inputfiles
*/
XML_Node* get_XML_Node(const std::string& file_ID, XML_Node* root);
//! Search for an XML node based on the XML element name, file name, or 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
* 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 XML 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.
*
* @return
* This routine will process the XML file, possibly creating an XML
* tree structure. It returns a pointer to the XML node searched for.
*
* For example,
* @code
*
* XML_Node* xn = get_XML_NameID("phase", "gri30.xml#gri30_mix", 0);
*
* @endcode
*
* will search in the file gri30.xml for an XML element of the following form:
* @verbatim
* <phase id="gri30_mix>
* . . .
* </phase>
* @endverbatim
*
* It will return a pointer to an xml tree for the XML phase element.
*
* @ingroup inputfiles
*/
XML_Node* get_XML_NameID(const std::string& nameTarget,
const std::string& file_ID, XML_Node* root);
}
#endif

View file

@ -24,9 +24,14 @@
#include "units.h"
#include "xml.h"
#include "ctml.h"
#define DGG_MOD
#ifndef DGG_MOD
#include "SpeciesThermoFactory.h"
#include "ThermoFactory.h"
#include "FalloffFactory.h"
#endif
#include "logger.h"
#undef DEBUG_PATHS
@ -178,10 +183,12 @@ namespace Cantera {
delete s_app;
s_app = 0;
}
#ifndef DGG_MOD
SpeciesThermoFactory::deleteFactory();
ThermoFactory::deleteFactory();
FalloffFactory::deleteFalloffFactory();
Unit::deleteUnit();
#endif
}
Application* app() {
@ -904,5 +911,116 @@ namespace Cantera {
}
#endif // WITH_HTML_LOGS
/*
* First we define a couple of typedefs that will
* be used throught this file
*/
//! typedef for a pointer to an XML_Node
typedef const vector<XML_Node*> 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;
}
}

View file

@ -563,6 +563,42 @@ namespace Cantera {
//@}
template<class D, class R>
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<class D, class R>
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<class D, class R>
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<class D, class R>
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<class D, class R>
R poly4(D x, R* c) {
return ((((c[4]*x + c[3])*x +
c[2])*x + c[1])*x + c[0]);
}
template<class D, class R>
R poly3(D x, R* c) {
return (((c[3]*x + c[2])*x + c[1])*x + c[0]);
}
}