Removed some unused CTML functions
This commit is contained in:
parent
7442ecd88b
commit
346605abc4
3 changed files with 3 additions and 453 deletions
|
|
@ -187,15 +187,6 @@ void addFloatArray(Cantera::XML_Node& node, const std::string& titleString,
|
|||
const doublereal minval = Cantera::Undef,
|
||||
const doublereal maxval = Cantera::Undef);
|
||||
|
||||
void addNamedFloatArray(Cantera::XML_Node& parentNode, const std::string& name, const int n,
|
||||
const doublereal* const vals, const std::string units = "",
|
||||
const std::string type = "",
|
||||
const doublereal minval = Cantera::Undef,
|
||||
const doublereal maxval = Cantera::Undef);
|
||||
|
||||
|
||||
|
||||
|
||||
//! This function adds a child node with the name string with a string value
|
||||
//! to the current node
|
||||
/*!
|
||||
|
|
@ -699,59 +690,6 @@ doublereal getFloatDefaultUnits(const Cantera::XML_Node& parent, std::string nam
|
|||
bool getOptionalModel(const Cantera::XML_Node& parent, const std::string nodeName,
|
||||
std::string& modelName);
|
||||
|
||||
//! This function reads a child node with the default name, "floatArray", with a value
|
||||
//! consisting of a comma separated list of floats
|
||||
/*!
|
||||
* This function will read a child node to the current XML node, with the
|
||||
* name "floatArray". It will have a title attribute, and the body
|
||||
* of the XML node will be filled out with a comma separated list of
|
||||
* doublereals.
|
||||
* Get an array of floats from the XML Node. The argument field
|
||||
* is assumed to consist of an arbitrary number of comma
|
||||
* separated floats, with an arbitrary amount of white space
|
||||
* separating each field.
|
||||
* If the node array has an units attribute field, then
|
||||
* the units are used to convert the floats, iff convert is true.
|
||||
* This function is a wrapper around the function getFloatArray().
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* Code snippet:
|
||||
* @verbatim
|
||||
const XML_Node &State_XMLNode;
|
||||
vector_fp v;
|
||||
bool convert = true;
|
||||
unitsString = "";
|
||||
nodeName="floatArray";
|
||||
getFloatArray(State_XMLNode, v, convert, unitsString, nodeName);
|
||||
@endverbatim
|
||||
*
|
||||
* reads the corresponding XML file:
|
||||
*
|
||||
* @verbatim
|
||||
<state>
|
||||
<floatArray units="m3"> 32.4, 1, 100. <\floatArray>
|
||||
<\state>
|
||||
@endverbatim
|
||||
*
|
||||
* Will produce the vector
|
||||
*
|
||||
* v[0] = 32.4
|
||||
* v[1] = 1.0
|
||||
* v[2] = 100.
|
||||
*
|
||||
*
|
||||
* @param node XML parent node of the floatArray
|
||||
* @param typeString Returns the type attribute of the current node.
|
||||
* @param xmin Returns the minimum value attribute of the
|
||||
* current node.
|
||||
* @param xmax Returns the maximum value attribute of the
|
||||
* current node.
|
||||
* @param coeffs Output vector of floats containing the floatArray information.
|
||||
*/
|
||||
void getFunction(const Cantera::XML_Node& node, std::string& typeString,
|
||||
doublereal& xmin, doublereal& xmax, std::vector<doublereal> & coeffs);
|
||||
|
||||
//! Search the child nodes of the current node for an XML Node with a Title
|
||||
//! attribute of a given name.
|
||||
/*!
|
||||
|
|
@ -763,40 +701,6 @@ void getFunction(const Cantera::XML_Node& node, std::string& typeString,
|
|||
*/
|
||||
Cantera::XML_Node* getByTitle(const Cantera::XML_Node& node, const std::string& title);
|
||||
|
||||
//! This function reads a child node with the name string with a specific
|
||||
//! title attribute named titleString
|
||||
/*!
|
||||
* This function will read a child node to the current XML node with the name "string".
|
||||
* It must have a title attribute, named titleString, and the body
|
||||
* of the XML node will be read into the valueString output argument.
|
||||
*
|
||||
* If the child node is not found then the empty string is returned.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* Code snippet:
|
||||
* @verbatim
|
||||
const XML_Node &node;
|
||||
getString(XML_Node& node, std::string titleString, std::string valueString,
|
||||
std::string typeString);
|
||||
@endverbatim
|
||||
*
|
||||
* Reads the following the snippet in the XML file:
|
||||
* @verbatim
|
||||
<string title="titleString" type="typeString">
|
||||
valueString
|
||||
<\string>
|
||||
@endverbatim
|
||||
*
|
||||
* @param node Reference to the XML_Node object of the parent XML element
|
||||
* @param titleString String name of the title attribute of the child node
|
||||
* @param valueString Value string that is found in the child node. output variable
|
||||
* @param typeString String type. This is an optional output variable. It is filled
|
||||
* with the attribute "type" of the XML entry.
|
||||
*/
|
||||
void getString(const Cantera::XML_Node& node, const std::string& titleString,
|
||||
std::string& valueString, std::string& typeString);
|
||||
|
||||
//! This function attempts to read a named child node and returns with the contents in the value string.
|
||||
//! title attribute named "titleString"
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -246,97 +246,7 @@ void addFloatArray(Cantera::XML_Node& node, const std::string& title, const size
|
|||
f.addAttribute("max",maxval);
|
||||
}
|
||||
}
|
||||
//====================================================================================================================
|
||||
// This function adds a child node with the name given by the first parameter with a value
|
||||
// consisting of a comma separated list of floats
|
||||
/*
|
||||
* This function will add a child node to the current XML node, with the
|
||||
* name given in the list. It will have a title attribute, and the body
|
||||
* of the XML node will be filled out with a comma separated list of
|
||||
* integers
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* Code snippet:
|
||||
* @verbatim
|
||||
const XML_Node &node;
|
||||
std::string titleString = "additionalTemperatures";
|
||||
int n = 3;
|
||||
int Tcases[3] = [273.15, 298.15, 373.15];
|
||||
std::string typeString = "optional";
|
||||
std::string units = "Kelvin";
|
||||
addNamedFloatArray(node, titleString, n, &cases[0], typeString, units);
|
||||
@endverbatim
|
||||
*
|
||||
* Creates the following the snippet in the XML file:
|
||||
* @verbatim
|
||||
<parentNode>
|
||||
<additionalTemperatures type="optional" vtype="floatArray" size = "3" units="Kelvin">
|
||||
273.15, 298.15, 373.15
|
||||
<\additionalTemperatures>
|
||||
<\parentNode>
|
||||
@endverbatim
|
||||
*
|
||||
* @param node reference to the XML_Node object of the parent XML element
|
||||
* @param name Name of the XML node
|
||||
* @param n Length of the doubles vector.
|
||||
* @param values Pointer to a vector of doubles
|
||||
* @param unitsString String name of the Units attribute. This is an optional
|
||||
* parameter. The default is to
|
||||
* have an empty string.
|
||||
* @param type String type. This is an optional parameter. The default
|
||||
* is to have an empty string.
|
||||
* @param minval Minimum allowed value of the int. This is an optional
|
||||
* parameter. The default is the
|
||||
* special double, Cantera::Undef, which means to ignore the
|
||||
* entry.
|
||||
* @param maxval Maximum allowed value of the int. This is an optional
|
||||
* parameter. The default is the
|
||||
* special double, Cantera::Undef, which means to ignore the
|
||||
* entry.
|
||||
*
|
||||
* @todo I don't think this is used. Figure out what is used for writing integers,
|
||||
* and codify that. unitsString shouldn't be here, since it's an int.
|
||||
* typeString should be codified as to its usage.
|
||||
*/
|
||||
void addNamedFloatArray(Cantera::XML_Node& node, const std::string& name, const int n,
|
||||
const doublereal* const vals, const std::string units,
|
||||
const std::string type, const doublereal minval,
|
||||
const doublereal maxval)
|
||||
{
|
||||
int i;
|
||||
std::string v = "";
|
||||
for (i = 0; i < n; i++) {
|
||||
v += fp2str(vals[i],FP_Format);
|
||||
if (i == n-1) {
|
||||
v += "\n";
|
||||
} else if (i > 0 && (i+1) % 3 == 0) {
|
||||
v += ",\n";
|
||||
} else {
|
||||
v += ", ";
|
||||
}
|
||||
}
|
||||
XML_Node& f = node.addChild(name, v);
|
||||
if (type != "") {
|
||||
f.addAttribute("type",type);
|
||||
}
|
||||
/*
|
||||
* Add vtype, which indicates the type of the value. Here we specify it as a list of floats separated
|
||||
* by commas, with a length given by size attribute.
|
||||
*/
|
||||
f.addAttribute("vtype", "floatArray");
|
||||
|
||||
f.addAttribute("size", n);
|
||||
if (units != "") {
|
||||
f.addAttribute("units", units);
|
||||
}
|
||||
if (minval != Undef) {
|
||||
f.addAttribute("min", minval);
|
||||
}
|
||||
if (maxval != Undef) {
|
||||
f.addAttribute("max", maxval);
|
||||
}
|
||||
}
|
||||
//====================================================================================================================
|
||||
// This function adds a child node with the name string with a string value
|
||||
// to the current node
|
||||
|
|
@ -424,113 +334,7 @@ std::string getChildValue(const Cantera::XML_Node& parent, const std::string& na
|
|||
}
|
||||
return parent(nameString);
|
||||
}
|
||||
//====================================================================================================================
|
||||
// This function reads a child node with the name, "string", with a specific
|
||||
// title attribute named "titleString"
|
||||
/*
|
||||
* This function will read a child node to the current XML node, with the
|
||||
* name "string". It must have a title attribute, named titleString, and the body
|
||||
* of the XML node will be read into the valueString output argument.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* Code snippet:
|
||||
* @verbatim
|
||||
const XML_Node &node;
|
||||
getString(XML_Node& node, std::string titleString, std::string valueString,
|
||||
std::string typeString);
|
||||
@endverbatim
|
||||
*
|
||||
* Reads the following the snippet in the XML file:
|
||||
* @verbatim
|
||||
<string title="titleString" type="typeString">
|
||||
valueString
|
||||
<\string>
|
||||
@endverbatim
|
||||
*
|
||||
* @param node Reference to the XML_Node object of the parent XML element
|
||||
* @param titleString String name of the title attribute of the child node
|
||||
* @param valueString Value string that is found in the child node. output variable
|
||||
* @param typeString String type. This is an optional output variable. It is filled
|
||||
* with the attribute "type" of the XML entry.
|
||||
*/
|
||||
void getString(const Cantera::XML_Node& node, const std::string& titleString, std::string& valueString,
|
||||
std::string& typeString)
|
||||
{
|
||||
valueString = "";
|
||||
typeString = "";
|
||||
XML_Node* s = getByTitle(node, titleString);
|
||||
if (s)
|
||||
if (s->name() == "string") {
|
||||
valueString = (*s).value();
|
||||
typeString = (*s)["type"];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//====================================================================================================================
|
||||
// This function attempts to read a named child node and returns with the contents in the value string.
|
||||
// title attribute named "titleString"
|
||||
/*
|
||||
* This function will read a child node to the current XML node, with the
|
||||
* name "string". It must have a title attribute, named titleString, and the body
|
||||
* of the XML node will be read into the valueString output argument.
|
||||
*
|
||||
* If the child node is not found then the empty string is returned.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* Code snippet:
|
||||
* @verbatim
|
||||
const XML_Node &node;
|
||||
std::string valueString;
|
||||
std::string typeString;
|
||||
std::string nameString = "timeIncrement";
|
||||
getString(XML_Node& node, nameString, valueString, valueString, typeString);
|
||||
@endverbatim
|
||||
*
|
||||
* Reads the following the snippet in the XML file:
|
||||
*
|
||||
* * @verbatim
|
||||
<nameString type="typeString">
|
||||
valueString
|
||||
<\nameString>
|
||||
@endverbatim
|
||||
*
|
||||
* or alternatively as a retrofit and special case, it also reads the following case
|
||||
*
|
||||
* @verbatim
|
||||
<string title="nameString" type="typeString">
|
||||
valueString
|
||||
<\string>
|
||||
@endverbatim
|
||||
*
|
||||
* @param node Reference to the XML_Node object of the parent XML element
|
||||
* @param nameString Name of the XML Node input variable
|
||||
* @param valueString Value string that is found in the child node. output variable
|
||||
* @param typeString String type. This is an optional output variable. It is filled
|
||||
* with the attribute "type" of the XML entry. output variable
|
||||
*/
|
||||
void getNamedStringValue(const Cantera::XML_Node& node, const std::string& nameString, std::string& valueString,
|
||||
std::string& typeString)
|
||||
{
|
||||
valueString = "";
|
||||
typeString = "";
|
||||
if (node.hasChild(nameString)) {
|
||||
XML_Node& xc = node.child(nameString);
|
||||
valueString = xc.value();
|
||||
typeString = xc["type"];
|
||||
} else {
|
||||
XML_Node* s = getByTitle(node, nameString);
|
||||
if (s) {
|
||||
if (s->name() == "string") {
|
||||
valueString = (*s).value();
|
||||
typeString = (*s)["type"];
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//====================================================================================================================
|
||||
// Get a vector of integer values from a child element.
|
||||
/*
|
||||
|
|
@ -1130,98 +934,7 @@ size_t getFloatArray(const Cantera::XML_Node& node, std::vector<doublereal> & v,
|
|||
}
|
||||
return v.size();
|
||||
}
|
||||
//====================================================================================================================
|
||||
size_t getNamedFloatArray(const Cantera::XML_Node& parentNode, const std::string& nodeName, std::vector<doublereal> & v,
|
||||
const bool convert, const std::string unitsString)
|
||||
{
|
||||
std::string::size_type icom;
|
||||
std::string numstr;
|
||||
doublereal dtmp;
|
||||
std::string nn = parentNode.name();
|
||||
v.clear();
|
||||
const Cantera::XML_Node* readNode = parentNode.findByName(nodeName);
|
||||
if (!readNode) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
doublereal vmin = Undef;
|
||||
doublereal vmax = Undef;
|
||||
doublereal funit = 1.0;
|
||||
/*
|
||||
* Get the attributes field, units, from the XML node
|
||||
*/
|
||||
std::string units = (*readNode)["units"];
|
||||
if (units != "" && convert) {
|
||||
if (unitsString == "actEnergy" && units != "") {
|
||||
funit = actEnergyToSI(units);
|
||||
} else if (unitsString != "" && units != "") {
|
||||
funit = toSI(units);
|
||||
}
|
||||
}
|
||||
|
||||
if ((*readNode)["min"] != "") {
|
||||
vmin = atofCheck((*readNode)["min"].c_str());
|
||||
}
|
||||
if ((*readNode)["max"] != "") {
|
||||
vmax = atofCheck((*readNode)["max"].c_str());
|
||||
}
|
||||
|
||||
size_t expectedSize = 0;
|
||||
nn = (*readNode)["size"];
|
||||
expectedSize = atoi(nn.c_str());
|
||||
|
||||
nn = (*readNode)["vtype"];
|
||||
if (nn != "floatArray") {
|
||||
throw CanteraError("getNamedFloatArray",
|
||||
"node named " + nodeName + "didn't have correct vtype");
|
||||
}
|
||||
|
||||
doublereal vv;
|
||||
std::string val = readNode->value();
|
||||
while (1 > 0) {
|
||||
icom = val.find(',');
|
||||
if (icom != string::npos) {
|
||||
numstr = val.substr(0,icom);
|
||||
val = val.substr(icom+1,val.size());
|
||||
dtmp = atofCheck(numstr.c_str());
|
||||
v.push_back(dtmp);
|
||||
} else {
|
||||
/*
|
||||
* This little bit of code is to allow for the
|
||||
* possibility of a comma being the last
|
||||
* item in the value text. This was allowed in
|
||||
* previous versions of Cantera, even though it
|
||||
* would appear to be odd. So, we keep the
|
||||
* possibilty in for backwards compatibility.
|
||||
*/
|
||||
size_t nlen = strlen(val.c_str());
|
||||
if (nlen > 0) {
|
||||
dtmp = atofCheck(val.c_str());
|
||||
v.push_back(dtmp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
vv = v.back();
|
||||
if (vmin != Undef && vv < vmin - Tiny) {
|
||||
writelog("\nWarning: value "+fp2str(vv)+
|
||||
" is below lower limit of " +fp2str(vmin)+".\n");
|
||||
}
|
||||
if (vmax != Undef && vv > vmax + Tiny) {
|
||||
writelog("\nWarning: value "+fp2str(vv)+
|
||||
" is above upper limit of " +fp2str(vmin)+".\n");
|
||||
}
|
||||
}
|
||||
size_t nv = v.size();
|
||||
for (size_t n = 0; n < nv; n++) {
|
||||
v[n] *= funit;
|
||||
}
|
||||
if (nv != expectedSize) {
|
||||
throw CanteraError("getNamedFloatArray",
|
||||
"node named " + nodeName + "didn't have correct number of floats"
|
||||
+ int2str(expectedSize) + " vs " + int2str(nv));
|
||||
}
|
||||
return nv;
|
||||
}
|
||||
//====================================================================================================================
|
||||
// This routine is used to interpret the value portions of XML
|
||||
// elements that contain colon separated pairs.
|
||||
|
|
@ -1458,72 +1171,5 @@ void getStringArray(const Cantera::XML_Node& node, std::vector<std::string>& v)
|
|||
std::string val = node.value();
|
||||
tokenizeString(val, v);
|
||||
}
|
||||
//====================================================================================================================
|
||||
// This function reads a child node with the default name, "floatArray", with a value
|
||||
// consisting of a comma separated list of floats
|
||||
/*
|
||||
* This function will read a child node to the current XML node, with the
|
||||
* name "floatArray". It will have a title attribute, and the body
|
||||
* of the XML node will be filled out with a comma separated list of
|
||||
* doublereals.
|
||||
* Get an array of floats from the XML Node. The argument field
|
||||
* is assumed to consist of an arbitrary number of comma
|
||||
* separated floats, with an arbitrary amount of white space
|
||||
* separating each field.
|
||||
* If the node array has an units attribute field, then
|
||||
* the units are used to convert the floats, iff convert is true.
|
||||
* This function is a wrapper around the function getFloatArray().
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* Code snippet:
|
||||
* @verbatim
|
||||
const XML_Node &State_XMLNode;
|
||||
vector_fp v;
|
||||
bool convert = true;
|
||||
unitsString = "";
|
||||
nodeName="floatArray";
|
||||
getFloatArray(State_XMLNode, v, convert, unitsString, nodeName);
|
||||
@endverbatim
|
||||
*
|
||||
* reads the corresponding XML file:
|
||||
*
|
||||
* @verbatim
|
||||
<state>
|
||||
<floatArray units="m3"> 32.4, 1, 100. <\floatArray>
|
||||
<\state>
|
||||
@endverbatim
|
||||
*
|
||||
* Will produce the vector
|
||||
*
|
||||
* v[0] = 32.4
|
||||
* v[1] = 1.0
|
||||
* v[2] = 100.
|
||||
*
|
||||
*
|
||||
* @param node XML parent node of the floatArray
|
||||
* @param typeString Returns the type attribute of the current node.
|
||||
* @param xmin Returns the minimum value attribute of the
|
||||
* current node.
|
||||
* @param xmax Returns the maximum value attribute of the
|
||||
* current node.
|
||||
* @param coeffs Output vector of floats containing the floatArray information.
|
||||
*/
|
||||
void getFunction(const Cantera::XML_Node& node, std::string& type, doublereal& xmin,
|
||||
doublereal& xmax, std::vector<doublereal> & coeffs)
|
||||
{
|
||||
const XML_Node& c = node.child("floatArray");
|
||||
coeffs.clear();
|
||||
getFloatArray(c,coeffs);
|
||||
xmin = Cantera::Undef;
|
||||
xmin = Cantera::Undef;
|
||||
if (node["min"] != "") {
|
||||
xmin = fpValue(node["min"]);
|
||||
}
|
||||
if (node["max"] != "") {
|
||||
xmax = fpValue(node["max"]);
|
||||
}
|
||||
type = node["type"];
|
||||
}
|
||||
//====================================================================================================================
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -822,8 +822,8 @@ void TransportFactory::getTransportData(const std::vector<const XML_Node*> &xspe
|
|||
// parameters are converted to SI units before storing
|
||||
|
||||
// Molecular geometry; rotational heat capacity / R
|
||||
std::string geom, type;
|
||||
ctml::getString(node, "geometry", geom, type);
|
||||
XML_Node* geomNode = ctml::getByTitle(node, "geometry");
|
||||
std::string geom = (geomNode) ? geomNode->value() : "";
|
||||
if (geom == "atom") {
|
||||
tr.crot[j] = 0.0;
|
||||
} else if (geom == "linear") {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue