Class to hold global data. More...
#include <application.h>
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 41 of file 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. | |
void | addError (const string &r, const string &msg="") |
Set an error condition in the application class without throwing an exception. | |
int | getErrorCount () |
Return the number of errors that have been encountered so far. | |
void | popError () |
Discard the last error message. | |
string | lastErrorMessage () |
Retrieve the last error message in a string. | |
void | getErrors (std::ostream &f) |
Prints all of the error messages to an ostream. | |
void | logErrors () |
Prints all of the error messages using writelog. | |
void | addDataDirectory (const string &dir) |
Add a directory to the data file search path. | |
string | findInputFile (const string &name) |
Find an input file. | |
string | getDataDirectories (const string &sep) |
Get the Cantera data directories. | |
void | loadExtension (const string &extType, const string &name) |
Load an extension implementing user-defined models. | |
void | searchPythonVersions (const string &versions) |
Set the versions of Python to try when loading user-defined extensions, in order of preference. | |
void | writelog (const string &msg) |
Write a message to the logger. | |
void | writelogendl () |
Write an end of line character to the logger and flush output. | |
void | warnlog (const string &warning, const string &msg) |
Write a warning message to the logger. | |
void | warn_deprecated (const string &method, const string &extra="") |
Print a warning indicating that method is deprecated. | |
void | suppress_deprecation_warnings () |
Globally disable printing of deprecation warnings. | |
void | make_deprecation_warnings_fatal () |
Turns deprecation warnings into exceptions. | |
void | warn (const string &warning, const string &method, const string &extra="") |
Generate a general purpose warning; repeated warnings are not suppressed. | |
void | suppress_warnings () |
Globally disable printing of (user) warnings. | |
bool | warnings_suppressed () |
Returns true if warnings should be suppressed. | |
void | make_warnings_fatal () |
Turns Cantera warnings into exceptions. | |
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. | |
bool | thermo_warnings_suppressed () |
Returns true if thermo warnings should be suppressed. | |
void | use_legacy_rate_constants (bool legacy=true) |
Set definition used for rate constant calculation. | |
bool | legacy_rate_constants_used () |
Returns true if legacy rate constant definition is used. | |
void | setLogger (Logger *logwriter) |
Install a logger. | |
void | setLogger (unique_ptr< Logger > logwriter) |
Install a Logger. | |
void | thread_complete () |
Delete and free memory allocated per thread in multithreaded applications. | |
Static Public Member Functions | |
static Application * | Instance () |
Return a pointer to the one and only instance of class Application. | |
static void | ApplicationDestroy () |
Static function that destroys the application class's data. | |
Protected Types | |
typedef shared_ptr< Messages > | pMessages_t |
Typedef for thread specific messages. | |
Protected Member Functions | |
Application () | |
Constructor for class sets up the initial conditions Protected ctor access thru static member function Instance. | |
void | setDefaultDirectories () |
Set the default directories for input files. | |
Protected Attributes | |
vector< string > | inputDirs |
Current vector of input directories to search for input files. | |
vector< string > | m_pythonSearchVersions = {"3.14", "3.13", "3.12", "3.11", "3.10"} |
Versions of Python to consider when attempting to load user extensions. | |
set< string > | warnings |
Set of deprecation warnings that have been emitted (to suppress duplicates) | |
bool | m_suppress_deprecation_warnings = false |
bool | m_fatal_deprecation_warnings = false |
bool | m_suppress_thermo_warnings = false |
bool | m_suppress_warnings = false |
bool | m_fatal_warnings = false |
bool | m_use_legacy_rate_constants = false |
set< pair< string, string > > | m_loaded_extensions |
ThreadMessages | pMessenger |
unique_ptr< Logger > | m_logwriter |
Current log writer. | |
Static Private Attributes | |
static Application * | s_app = 0 |
Pointer to the single Application instance. | |
|
protected |
Typedef for thread specific messages.
Definition at line 122 of file application.h.
|
protected |
Constructor for class sets up the initial conditions Protected ctor access thru static member function Instance.
Definition at line 83 of file application.cpp.
|
inlinevirtual |
Destructor for class deletes global data.
Definition at line 162 of file application.h.
|
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 90 of file application.cpp.
|
static |
Static function that destroys the application class's data.
Definition at line 99 of file application.cpp.
|
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 168 of file application.h.
|
inline |
Return the number of errors that have been encountered so far.
Definition at line 173 of file application.h.
|
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 178 of file application.h.
|
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 183 of file application.h.
|
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 188 of file application.h.
|
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 193 of file application.h.
void loadExtension | ( | const string & | extType, |
const string & | name | ||
) |
Load an extension implementing user-defined models.
extType | Specifies the interface / language of the extension, for example "python" |
name | Specifies the name of the extension. The meaning of this parameter depends on the specific extension interface. For example, for Python extensions, this is the name of the Python module containing the models. |
Definition at line 378 of file application.cpp.
void searchPythonVersions | ( | const string & | versions | ) |
Set the versions of Python to try when loading user-defined extensions, in order of preference.
Separate multiple versions with commas, for example "3.11,3.10"
.
Definition at line 429 of file application.cpp.
void writelogendl | ( | ) |
Write an end of line character to the logger and flush output.
Definition at line 206 of file application.cpp.
void warn_deprecated | ( | const string & | method, |
const 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 108 of file application.cpp.
|
inline |
Globally disable printing of deprecation warnings.
Used primarily to prevent certain tests from failing.
Definition at line 296 of file application.h.
|
inline |
Turns deprecation warnings into exceptions.
Activated within the test suite to make sure that no deprecated methods are being used.
Definition at line 303 of file application.h.
void warn | ( | const string & | warning, |
const string & | method, | ||
const string & | extra = "" |
||
) |
Generate a general purpose warning; repeated warnings are not suppressed.
warning | Warning type; see Logger::warn() |
method | Name of method triggering the warning |
extra | Additional information printed for the warning |
Definition at line 119 of file application.cpp.
|
inline |
Globally disable printing of (user) warnings.
Used primarily to prevent certain tests from failing.
Definition at line 315 of file application.h.
|
inline |
Returns true
if warnings should be suppressed.
Definition at line 321 of file application.h.
|
inline |
Turns Cantera warnings into exceptions.
Activated within the test suite to make sure that your warning message are being raised.
Definition at line 327 of file application.h.
|
inline |
Globally disable printing of warnings about problematic thermo data, such as NASA polynomials with discontinuities at the midpoint temperature.
Definition at line 333 of file application.h.
|
inline |
Returns true
if thermo warnings should be suppressed.
Definition at line 338 of file application.h.
|
inline |
Set definition used for rate constant calculation.
If set to false
(default value), rate constants of three-body reactions are consistent with conventional definitions (for example Eq. 9.75 in Kee, et al. [20]). If set to true
, output for rate constants of three-body reactions is multiplied by third-body concentrations, consistent with Cantera's behavior prior to version 3.0.
Definition at line 352 of file application.h.
|
inline |
Returns true
if legacy rate constant definition is used.
Definition at line 357 of file application.h.
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 129 of file application.cpp.
|
protected |
Current vector of input directories to search for input files.
Definition at line 422 of file application.h.
|
protected |
Versions of Python to consider when attempting to load user extensions.
Definition at line 425 of file application.h.
|
protected |
Set of deprecation warnings that have been emitted (to suppress duplicates)
Definition at line 428 of file application.h.
|
protected |
Definition at line 430 of file application.h.
|
protected |
Definition at line 431 of file application.h.
|
protected |
Definition at line 432 of file application.h.
|
protected |
Definition at line 433 of file application.h.
|
protected |
Definition at line 434 of file application.h.
|
protected |
Definition at line 435 of file application.h.
|
protected |
Definition at line 437 of file application.h.
|
protected |
Definition at line 439 of file application.h.
|
protected |
Current log writer.
Definition at line 442 of file application.h.
|
staticprivate |
Pointer to the single Application instance.
Definition at line 446 of file application.h.