19 return Application::Instance();
28 }
catch (std::bad_alloc) {
29 logwriter->
error(
"bad alloc thrown by app()");
43 void writeline(
char repeat,
size_t count,
bool endl_after,
bool endl_before)
82 std::mutex Unit::units_mutex;
86 Application::ApplicationDestroy();
87 FactoryBase::deleteFactories();
125 warn_deprecated(
"lastErrorMessage",
"To be removed after Cantera 2.3");
140 void setError(
const std::string& r,
const std::string& msg)
160 doublereal
toSI(
const std::string& unit)
162 doublereal f = Unit::units()->toSI(unit);
166 throw CanteraError(
"toSI",
"unknown unit string: "+unit);
173 doublereal f = Unit::units()->actEnergyToSI(unit);
182 char* ctroot = getenv(
"CANTERA_ROOT");
184 return string(ctroot);
187 return string(CANTERA_ROOT);
202 static void split_at_pound(
const std::string& src, std::string& file, std::string&
id)
204 string::size_type ipound = src.find(
'#');
206 id = src.substr(ipound+1,src.size());
207 file = src.substr(0,ipound);
216 std::string fname, idstr;
221 "no file name given. file_ID = "+file_ID);
222 db = root->
findID(idstr, 3);
228 if (fname.rfind(
".xml") == fname.size() - 4) {
229 fname.replace(fname.size() - 3, 3,
"cti");
230 }
else if (fname.rfind(
".cti") == fname.size() - 4) {
231 fname.replace(fname.size() - 3, 3,
"xml");
242 "get_XML_File failed trying to open "+fname);
243 db = doc->
findID(idstr, 3);
247 "id tag '"+idstr+
"' not found.");
253 const std::string& file_ID,
256 string fname, idTarget;
274 std::vector<FactoryBase*> FactoryBase::s_vFactoryRegistry;
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.
XML_Node * get_XML_File(const std::string &file, int debug)
Return a pointer to the XML tree for a Cantera input file.
void writelogendl()
Write an endl to the screen and flush output.
Base class for 'loggers' that write text messages to log files.
void popError()
Discard the last error message.
Class to hold global data.
string lastErrorMessage()
Retrieve the last error message in a string.
doublereal actEnergyToSI(const std::string &unit)
Return the conversion factor to convert activation energy unit std::string 'unit' to Kelvin...
std::string lastErrorMessage()
Retrieve the last error message in a string.
doublereal toSI(const std::string &unit)
Return the conversion factor to convert unit std::string 'unit' to SI units.
void thread_complete()
Delete and free memory allocated per thread in multithreaded applications.
const size_t npos
index returned by functions to indicate "no position"
void setLogger(Logger *logwriter)
Install a logger.
void setError(const std::string &r, const std::string &msg)
Set an error condition in the application class without throwing an exception.
static Application * app()
Return a pointer to the application object.
Class XML_Node is a tree-based representation of the contents of an XML file.
void showErrors()
Prints all of the error messages using writelog.
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
virtual void error(const std::string &msg)
Write an error message and quit.
void writelog(const std::string &msg)
Write a message to the screen.
XML_Node * get_XML_from_string(const std::string &text)
Read a CTI or CTML string and fill up an XML tree.
XML_Node * get_XML_from_string(const std::string &text)
Read a CTI or CTML string and fill up an XML tree.
void suppress_thermo_warnings(bool suppress)
Globally disable printing of warnings about problematic thermo data, e.g.
void close_XML_File(const std::string &file)
Close an XML File.
Classes providing support for XML data files.
Base class for exceptions thrown by Cantera classes.
void suppress_deprecation_warnings()
Globally disable printing of deprecation warnings.
void warn_deprecated(const std::string &method, const std::string &extra="")
Print a warning indicating that method is deprecated.
Header for units conversion utilities, which are used to translate user input from input files (See I...
void appdelete()
Delete and free all memory associated with the application.
void popError()
Discard the last error message.
XML_Node * get_XML_File(const std::string &file, int debug=0)
Return a pointer to the XML tree for a Cantera input file.
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...
void thread_complete()
Delete and free memory allocated per thread in multithreaded applications.
void writelogendl()
Write an end of line character to the screen and flush output.
void logErrors()
Prints all of the error messages using writelog.
void getErrors(std::ostream &f)
Prints all of the error messages to an ostream.
void addError(const std::string &r, const std::string &msg="")
Set an error condition in the application class without throwing an exception.
bool thermo_warnings_suppressed()
Returns true if thermo warnings should be suppressed.
void suppress_deprecation_warnings()
Globally disable printing of deprecation warnings.
void make_deprecation_warnings_fatal()
Turns deprecation warnings into exceptions.
bool thermo_warnings_suppressed()
Returns true if thermo warnings should be suppressed.
Namespace for the Cantera kernel.
int nErrors()
Return the number of errors that have been encountered so far.
void suppress_thermo_warnings(bool suppress=true)
Globally disable printing of warnings about problematic thermo data, e.g.
int getErrorCount()
Return the number of errors that have been encountered so far.
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 ...
File contains the FactoryBase class declarations.
void writelog_direct(const std::string &msg)
Write a message to the screen.
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...
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.
void setLogger(Logger *logwriter)
Install a logger.
void close_XML_File(const std::string &file)
Close an XML File.