Cantera 2.6.0
|
Class to hold global data. More...
#include <application.h>
Classes | |
class | Messages |
Class to carry out messages. More... | |
class | ThreadMessages |
Class that stores thread messages for each thread, and retrieves them based on the thread id. More... | |
Public Member Functions | |
virtual | ~Application () |
Destructor for class deletes global data. More... | |
void | addError (const std::string &r, const std::string &msg="") |
Set an error condition in the application class without throwing an exception. More... | |
int | getErrorCount () |
Return the number of errors that have been encountered so far. More... | |
void | popError () |
Discard the last error message. More... | |
std::string | lastErrorMessage () |
Retrieve the last error message in a string. More... | |
void | getErrors (std::ostream &f) |
Prints all of the error messages to an ostream. More... | |
void | logErrors () |
Prints all of the error messages using writelog. More... | |
void | addDataDirectory (const std::string &dir) |
Add a directory to the data file search path. More... | |
std::string | findInputFile (const std::string &name) |
Find an input file. More... | |
std::string | getDataDirectories (const std::string &sep) |
Get the Cantera data directories. More... | |
XML_Node * | get_XML_File (const std::string &file, int debug=0) |
Return a pointer to the XML tree for a Cantera input file. More... | |
XML_Node * | get_XML_from_string (const std::string &text) |
Read a CTI or CTML string and fill up an XML tree. More... | |
void | close_XML_File (const std::string &file) |
Close an XML File. More... | |
void | writelog (const std::string &msg) |
Write a message to the screen. More... | |
void | writelogendl () |
Write an endl to the screen and flush output. More... | |
void | warnlog (const std::string &warning, const std::string &msg) |
Write a warning message to the screen. More... | |
void | warn_deprecated (const std::string &method, const std::string &extra="") |
Print a warning indicating that method is deprecated. More... | |
void | suppress_deprecation_warnings () |
Globally disable printing of deprecation warnings. More... | |
void | make_deprecation_warnings_fatal () |
Turns deprecation warnings into exceptions. More... | |
void | warn (const std::string &warning, const std::string &method, const std::string &extra="") |
Generate a general purpose warning; repeated warnings are not suppressed. More... | |
void | suppress_warnings () |
Globally disable printing of (user) warnings. More... | |
bool | warnings_suppressed () |
Returns true if warnings should be suppressed. More... | |
void | make_warnings_fatal () |
Turns Cantera warnings into exceptions. More... | |
void | suppress_thermo_warnings (bool suppress=true) |
Globally disable printing of warnings about problematic thermo data, such as NASA polynomials with discontinuities at the midpoint temperature. More... | |
bool | thermo_warnings_suppressed () |
Returns true if thermo warnings should be suppressed. More... | |
void | use_legacy_rate_constants (bool legacy=true) |
Set definition used for rate constant calculation. More... | |
bool | legacy_rate_constants_used () |
Returns true if legacy rate constant definition should be used. More... | |
void | setLogger (Logger *logwriter) |
Install a logger. More... | |
void | thread_complete () |
Delete and free memory allocated per thread in multithreaded applications. More... | |
Static Public Member Functions | |
static Application * | Instance () |
Return a pointer to the one and only instance of class Application. More... | |
static void | ApplicationDestroy () |
Static function that destroys the application class's data. More... | |
Protected Types | |
typedef shared_ptr< Messages > | pMessages_t |
Typedef for thread specific messages. More... | |
Protected Member Functions | |
Application () | |
Constructor for class sets up the initial conditions Protected ctor access thru static member function Instance. More... | |
void | setDefaultDirectories () |
Set the default directories for input files. More... | |
Protected Attributes | |
std::vector< std::string > | inputDirs |
Current vector of input directories to search for input files. More... | |
std::map< std::string, std::pair< XML_Node *, int > > | xmlfiles |
Current vector of XML file trees that have been previously parsed The second element of the value is used to store the last-modified time for the file, to enable change detection. More... | |
std::set< std::string > | warnings |
Vector of deprecation warnings that have been emitted (to suppress duplicates) More... | |
bool | m_suppress_deprecation_warnings |
bool | m_fatal_deprecation_warnings |
bool | m_suppress_thermo_warnings |
bool | m_suppress_warnings |
bool | m_fatal_warnings |
bool | m_use_legacy_rate_constants |
ThreadMessages | pMessenger |
Static Private Attributes | |
static Application * | s_app = 0 |
Pointer to the single Application instance. More... | |
Class to hold global data.
Class Application is the top-level class that stores data that should persist for the duration of the process. The class should not be instantiated directly; instead, it is instantiated as needed by the functions declared here. At most one instance is created, and it is not destroyed until the process terminates.
Definition at line 46 of file application.h.
|
protected |
Typedef for thread specific messages.
Definition at line 168 of file application.h.
|
protected |
Constructor for class sets up the initial conditions Protected ctor access thru static member function Instance.
Definition at line 131 of file application.cpp.
References Application::setDefaultDirectories(), and Unit::units().
Referenced by Application::Instance().
|
virtual |
Destructor for class deletes global data.
Deletes any open XML trees.
Definition at line 158 of file application.cpp.
References Application::xmlfiles.
|
static |
Return a pointer to the one and only instance of class Application.
If the Application object has not yet been created, it is created
Definition at line 149 of file application.cpp.
References Cantera::app_mutex, Application::Application(), and Application::s_app.
Referenced by Cantera::app().
|
static |
Static function that destroys the application class's data.
Definition at line 167 of file application.cpp.
References Cantera::app_mutex, and Application::s_app.
Referenced by Cantera::appdelete().
|
inline |
Set an error condition in the application class without throwing an exception.
This routine adds an error message to the end of the stack of errors that Cantera accumulates in the Application class.
r | Procedure name which is generating the error condition |
msg | Descriptive message of the error condition. |
If only one argument is specified, that string is used as the entire message.
Definition at line 217 of file application.h.
References Application::Messages::addError().
|
inline |
Return the number of errors that have been encountered so far.
Definition at line 222 of file application.h.
References Application::Messages::getErrorCount().
|
inline |
Discard the last error message.
Cantera saves a stack of exceptions that it has caught in the Application class. This routine eliminates the last exception to be added to that stack.
Definition at line 227 of file application.h.
References Application::Messages::popError().
|
inline |
Retrieve the last error message in a string.
This routine will retrieve the last error message and return it in the return string.
Definition at line 232 of file application.h.
References Application::Messages::lastErrorMessage().
|
inline |
Prints all of the error messages to an ostream.
Write out all of the saved error messages to the ostream f using the function Logger::writelog. Cantera saves a stack of exceptions that it has caught in the Application class. This routine writes out all of the error messages to the ostream and then clears them from internal storage.
f | ostream which will receive the error messages |
Definition at line 237 of file application.h.
References Application::Messages::getErrors().
|
inline |
Prints all of the error messages using writelog.
Print all of the error messages using function writelog. Cantera saves a stack of exceptions that it has caught in the Application class. This routine writes out all of the error messages and then clears them from internal storage.
Definition at line 242 of file application.h.
References Application::Messages::logErrors().
XML_Node * get_XML_File | ( | const std::string & | file, |
int | debug = 0 |
||
) |
Return a pointer to the XML tree for a Cantera input file.
This routine will find the file and read the XML file into an XML tree structure. Then, a pointer will be returned. If the file has already been processed, then just the pointer will be returned.
file | String containing the relative or absolute file name |
debug | Debug flag |
Definition at line 205 of file application.cpp.
References Application::findInputFile(), and Cantera::xml_mutex.
Referenced by Cantera::get_XML_File().
XML_Node * get_XML_from_string | ( | const std::string & | text | ) |
Read a CTI or CTML string and fill up an XML tree.
Return a pointer to the XML tree corresponding to the specified CTI or XML string. If the given string has been processed before, the cached XML tree will be returned. Otherwise, the XML tree will be generated and stored in the cache.
text | CTI or CTML string |
Definition at line 242 of file application.cpp.
References Cantera::ct_string2ctml_string(), Cantera::xml_mutex, and Application::xmlfiles.
Referenced by Cantera::get_XML_from_string().
void close_XML_File | ( | const std::string & | file | ) |
Close an XML File.
Close a file that is opened by this application object
file | String containing the relative or absolute file name |
Definition at line 262 of file application.cpp.
References Cantera::xml_mutex, and Application::xmlfiles.
Referenced by Cantera::close_XML_File().
|
inline |
Write a message to the screen.
The string may be of any length, and may contain end-of-line characters. This method is used throughout Cantera to write log messages. It can also be called by user programs. The advantage of using writelog over writing directly to the standard output is that messages written with writelog will display correctly even when Cantera is used from MATLAB or other application that do not have a standard output stream.
msg | c++ string to be written to the screen |
Definition at line 333 of file application.h.
References Application::Messages::writelog().
Referenced by Application::Messages::logErrors(), and Cantera::writelog_direct().
|
inline |
Write an endl to the screen and flush output.
Definition at line 338 of file application.h.
References Application::Messages::writelogendl().
Referenced by Application::Messages::logErrors(), and Cantera::writelogendl().
|
inline |
Write a warning message to the screen.
warning | String specifying type of warning; |
msg | String to be written to the screen |
Definition at line 343 of file application.h.
References Application::Messages::warnlog().
Referenced by Application::warn(), and Application::warn_deprecated().
void warn_deprecated | ( | const std::string & | method, |
const std::string & | extra = "" |
||
) |
Print a warning indicating that method is deprecated.
Additional information (removal version, alternatives) can be specified in extra. Deprecation warnings are printed once per method per invocation of the application.
Definition at line 176 of file application.cpp.
References Application::warnings, and Application::warnlog().
Referenced by Cantera::_warn_deprecated().
|
inline |
Globally disable printing of deprecation warnings.
Used primarily to prevent certain tests from failing.
Definition at line 355 of file application.h.
Referenced by Cantera::suppress_deprecation_warnings().
|
inline |
Turns deprecation warnings into exceptions.
Activated within the test suite to make sure that no deprecated methods are being used.
Definition at line 362 of file application.h.
Referenced by Cantera::make_deprecation_warnings_fatal().
void warn | ( | const std::string & | warning, |
const std::string & | method, | ||
const std::string & | extra = "" |
||
) |
Generate a general purpose warning; repeated warnings are not suppressed.
warning | Warning type; |
method | Name of method triggering the warning |
extra | Additional information printed for the warning |
Definition at line 188 of file application.cpp.
References Application::warnlog().
Referenced by Cantera::_warn().
|
inline |
Globally disable printing of (user) warnings.
Used primarily to prevent certain tests from failing.
Definition at line 375 of file application.h.
Referenced by Cantera::suppress_warnings().
|
inline |
Returns true
if warnings should be suppressed.
Definition at line 381 of file application.h.
Referenced by Cantera::warnings_suppressed().
|
inline |
Turns Cantera warnings into exceptions.
Activated within the test suite to make sure that your warning message are being raised.
Definition at line 387 of file application.h.
Referenced by Cantera::make_warnings_fatal().
|
inline |
Globally disable printing of warnings about problematic thermo data, such as NASA polynomials with discontinuities at the midpoint temperature.
Definition at line 393 of file application.h.
Referenced by Cantera::suppress_thermo_warnings().
|
inline |
Returns true
if thermo warnings should be suppressed.
Definition at line 398 of file application.h.
Referenced by Cantera::thermo_warnings_suppressed().
|
inline |
Set definition used for rate constant calculation.
If set to 'false', rate constants of three-body reactions are consistent with conventional definitions. If set to 'true', output for rate constants of three-body reactions is multipied by third-body concentrations (legacy behavior). For the pre-compiled Cantera 2.6 distribution, the default value is set to 'true', which implies no change compared to previous behavior. For user-compiled Cantera, the default behavior can be changed by the SCons flag 'legacy_rate_constants'.
Definition at line 421 of file application.h.
Referenced by Cantera::use_legacy_rate_constants().
|
inline |
Returns true
if legacy rate constant definition should be used.
Definition at line 426 of file application.h.
Referenced by Cantera::legacy_rate_constants_used().
|
inline |
Install a logger.
Called by the language interfaces to install an appropriate logger. The logger is used for the writelog() function
logwriter | Pointer to a logger object |
Definition at line 431 of file application.h.
References Application::Messages::setLogger().
Referenced by Cantera::setLogger().
void thread_complete | ( | ) |
Delete and free memory allocated per thread in multithreaded applications.
Delete the memory allocated per thread by Cantera. It should be called from within the thread just before the thread terminates. If your version of Cantera has not been specifically compiled for thread safety this function does nothing.
Definition at line 200 of file application.cpp.
References Application::ThreadMessages::removeThreadMessages().
Referenced by Cantera::thread_complete().
|
protected |
Current vector of input directories to search for input files.
Definition at line 474 of file application.h.
Referenced by Application::addDataDirectory(), Application::findInputFile(), Application::getDataDirectories(), and Application::setDefaultDirectories().
|
protected |
Current vector of XML file trees that have been previously parsed The second element of the value is used to store the last-modified time for the file, to enable change detection.
Definition at line 482 of file application.h.
Referenced by Application::close_XML_File(), Application::get_XML_from_string(), and Application::~Application().
|
protected |
Vector of deprecation warnings that have been emitted (to suppress duplicates)
Definition at line 485 of file application.h.
Referenced by Application::warn_deprecated().
|
protected |
Definition at line 487 of file application.h.
|
protected |
Definition at line 488 of file application.h.
|
protected |
Definition at line 489 of file application.h.
|
protected |
Definition at line 490 of file application.h.
|
protected |
Definition at line 491 of file application.h.
|
protected |
Definition at line 492 of file application.h.
|
protected |
Definition at line 494 of file application.h.
|
staticprivate |
Pointer to the single Application instance.
Definition at line 498 of file application.h.
Referenced by Application::ApplicationDestroy(), and Application::Instance().