12 #include <boost/core/demangle.hpp>
32 }
catch (
const std::bad_alloc&) {
33 logwriter->
error(
"bad alloc thrown by app()");
47void writeline(
char repeat,
size_t count,
bool endl_after,
bool endl_before)
63void _warn(
const std::string& warning,
64 const std::string& method,
const std::string& extra)
66 app()->
warn(warning, method, extra);
170doublereal
toSI(
const std::string& unit)
176 throw CanteraError(
"toSI",
"unknown unit string: "+unit);
193 "Unused in Cantera. To be removed after Cantera 2.6");
194 char* ctroot = getenv(
"CANTERA_ROOT");
196 return string(ctroot);
199 return string(CANTERA_ROOT);
223static void split_at_pound(
const std::string& src, std::string& file, std::string&
id)
225 string::size_type ipound = src.find(
'#');
227 id = src.substr(ipound+1,src.size());
228 file = src.substr(0,ipound);
237 std::string fname, idstr;
242 "no file name given. file_ID = "+file_ID);
243 db = root->
findID(idstr, 3);
249 if (fname.rfind(
".xml") == fname.size() - 4) {
250 fname.replace(fname.size() - 3, 3,
"cti");
251 }
else if (fname.rfind(
".cti") == fname.size() - 4) {
252 fname.replace(fname.size() - 3, 3,
"xml");
263 "get_XML_File failed trying to open "+fname);
264 db = doc->
findID(idstr, 3);
268 "id tag '"+idstr+
"' not found.");
274 const std::string& file_ID,
277 string fname, idTarget;
299 static std::map<std::string, std::string> typenames = {
300 {
typeid(void).name(),
"void"},
301 {
typeid(double).name(),
"double"},
302 {
typeid(
long int).name(),
"long int"},
303 {
typeid(bool).name(),
"bool"},
304 {
typeid(std::string).name(),
"string"},
305 {
typeid(vector<AnyValue>).name(),
"vector<AnyValue>"},
306 {
typeid(vector<AnyMap>).name(),
"vector<AnyMap>"},
307 {
typeid(vector<double>).name(),
"vector<double>"},
308 {
typeid(vector<long int>).name(),
"vector<long int>"},
309 {
typeid(vector<bool>).name(),
"vector<bool>"},
310 {
typeid(vector<string>).name(),
"vector<string>"},
311 {
typeid(vector<vector<double>>).name(),
"vector<vector<double>>"},
312 {
typeid(vector<vector<long int>>).name(),
"vector<vector<long int>>"},
313 {
typeid(vector<vector<bool>>).name(),
"vector<vector<bool>>"},
314 {
typeid(vector<vector<string>>).name(),
"vector<vector<string>>"},
315 {
typeid(
AnyMap).name(),
"AnyMap"},
318 if (typenames.count(type.name())) {
319 return typenames[type.name()];
321 #ifdef CT_USE_DEMANGLE
File contains the FactoryBase class declarations.
A map of string keys to values whose type can vary at runtime.
Class to hold global data.
bool warnings_suppressed()
Returns true if warnings should be suppressed.
void warn(const std::string &warning, const std::string &method, const std::string &extra="")
Generate a general purpose warning; repeated warnings are not suppressed.
void use_legacy_rate_constants(bool legacy=true)
Set definition used for rate constant calculation.
XML_Node * get_XML_File(const std::string &file, int debug=0)
Return a pointer to the XML tree for a Cantera input file.
void suppress_deprecation_warnings()
Globally disable printing of deprecation warnings.
void writelog(const std::string &msg)
Write a message to the screen.
bool thermo_warnings_suppressed()
Returns true if thermo warnings should be suppressed.
void make_warnings_fatal()
Turns Cantera warnings into exceptions.
void setLogger(Logger *logwriter)
Install a logger.
void make_deprecation_warnings_fatal()
Turns deprecation warnings into exceptions.
static Application * Instance()
Return a pointer to the one and only instance of class Application.
XML_Node * get_XML_from_string(const std::string &text)
Read a CTI or CTML string and fill up an XML tree.
bool legacy_rate_constants_used()
Returns true if legacy rate constant definition should be used.
void close_XML_File(const std::string &file)
Close an XML File.
void suppress_warnings()
Globally disable printing of (user) warnings.
void thread_complete()
Delete and free memory allocated per thread in multithreaded applications.
void suppress_thermo_warnings(bool suppress=true)
Globally disable printing of warnings about problematic thermo data, such as NASA polynomials with di...
void warn_deprecated(const std::string &method, const std::string &extra="")
Print a warning indicating that method is deprecated.
void writelogendl()
Write an endl to the screen and flush output.
static void ApplicationDestroy()
Static function that destroys the application class's data.
Base class for exceptions thrown by Cantera classes.
static std::vector< FactoryBase * > s_vFactoryRegistry
statically held list of Factories.
static void deleteFactories()
static function that deletes all factories in the internal registry maintained in a static variable
Base class for 'loggers' that write text messages to log files.
virtual void error(const std::string &msg)
Write an error message and quit.
static void deleteUnit()
Destroy the static Unit class.
static std::mutex units_mutex
Decl for static locker for Units singleton.
doublereal actEnergyToSI(const std::string &units_)
Return the multiplier required to convert an activation energy to SI units.
doublereal toSI(const std::string &units_)
Return the multiplier required to convert a dimensional quantity with units specified by string 'unit...
static Unit * s_u
pointer to the single instance of Unit
static Unit * units()
Initialize the static Unit class.
Class XML_Node is a tree-based representation of the contents of an XML file.
XML_Node * findID(const std::string &id, const int depth=100) const
This routine carries out a recursive search for an XML node based on the XML element attribute "id".
XML_Node * findNameID(const std::string &nameTarget, const std::string &idTarget) const
This routine carries out a recursive search for an XML node based on both the XML element name and th...
Namespace for the Cantera kernel.
const size_t npos
index returned by functions to indicate "no position"
bool warnings_suppressed()
Returns true if warnings should be suppressed.
void _warn(const std::string &warning, const std::string &method, const std::string &extra)
helper function passing generic warning to global handler
void use_legacy_rate_constants(bool legacy=true)
Set definition used for rate constant calculation.
XML_Node * get_XML_File(const std::string &file, int debug=0)
Return a pointer to the XML tree for a Cantera input file.
bool debugModeEnabled()
Returns true if Cantera was compiled in debug mode.
void suppress_deprecation_warnings()
Globally disable printing of deprecation warnings.
bool thermo_warnings_suppressed()
Returns true if thermo warnings should be suppressed.
void make_warnings_fatal()
Turns Cantera warnings into exceptions.
void setLogger(Logger *logwriter)
Install a logger.
XML_Node * get_XML_Node(const std::string &file_ID, XML_Node *root)
This routine will locate an XML node in either the input XML tree or in another input file specified ...
void make_deprecation_warnings_fatal()
Turns deprecation warnings into exceptions.
void warn_deprecated(const std::string &source, const AnyBase &node, const std::string &message)
A deprecation warning for syntax in an input file.
XML_Node * get_XML_from_string(const std::string &text)
Read a CTI or CTML string and fill up an XML tree.
doublereal actEnergyToSI(const std::string &unit)
Return the conversion factor to convert activation energy unit std::string 'unit' to Kelvin.
bool legacy_rate_constants_used()
Returns true if legacy rate constant definition should be used.
std::string gitCommit()
Returns the hash of the git commit from which Cantera was compiled, if known.
void close_XML_File(const std::string &file)
Close an XML File.
void suppress_warnings()
Globally disable printing of (user) warnings.
void _warn_deprecated(const std::string &method, const std::string &extra="")
helper function passing deprecation warning to global handler
static Application * app()
Return a pointer to the application object.
void thread_complete()
Delete and free memory allocated per thread in multithreaded applications.
doublereal toSI(const std::string &unit)
Return the conversion factor to convert unit std::string 'unit' to SI units.
void writelog_direct(const std::string &msg)
Write a message to the screen.
void suppress_thermo_warnings(bool suppress=true)
Globally disable printing of warnings about problematic thermo data, such as NASA polynomials with di...
void appdelete()
Delete and free all memory associated with the application.
XML_Node * get_XML_NameID(const std::string &nameTarget, const std::string &file_ID, XML_Node *root)
This routine will locate an XML node in either the input XML tree or in another input file specified ...
void writelogendl()
Write an end of line character to the screen and flush output.
static void split_at_pound(const std::string &src, std::string &file, std::string &id)
split a string at a '#' sign. Used to separate a file name from an id string.
std::string demangle(const std::type_info &type)
Convert a type name to a human readable string, using boost::core::demangle if available.
Header for units conversion utilities, which are used to translate user input from input files (See I...
Classes providing support for XML data files.