Cantera  3.1.0a1
Input File Handling

Handling of Cantera input files. More...

Collaboration diagram for Input File Handling:

Detailed Description

Handling of Cantera input files.

The properties of phases and interfaces are specified in text files. These procedures handle various aspects of reading these files. Input files should be read using the newSolution() or newInterface() service functions (see Objects Representing Phases).

For input files not specified by an absolute pathname, Cantera searches for input files along a path that includes platform-specific default locations, and possibly user-specified locations:

Cantera input files are written using YAML syntax. For more information on using YAML files in Cantera, see the YAML Users' Guide or the YAML Input File API Reference. Cantera provides the ck2yaml tool for converting Chemkin-format mechanisms to the YAML format. The utilities cti2yaml and ctml2yaml should be used to convert legacy CTI and XML input files (from Cantera 2.6 and earlier) to the YAML format.

Functions

void addDataDirectory (const string &dir)
 Add a directory to the data file search path. More...
 
string findInputFile (const string &name)
 Find an input file. More...
 
string getDataDirectories (const string &sep)
 Get the Cantera data directories. More...
 
void setDefaultDirectories ()
 Set the default directories for input files. More...
 
string findInputFile (const string &name)
 Find an input file. More...
 
void addDirectory (const string &dir)
 Add a directory to the data file search path. More...
 
string getDataDirectories (const string &sep)
 Get the Cantera data directories. More...
 

Function Documentation

◆ addDataDirectory()

void addDataDirectory ( const string &  dir)

Add a directory to the data file search path.

Parameters
dirString name for the directory to be added to the search path

Definition at line 284 of file application.cpp.

◆ findInputFile() [1/2]

string findInputFile ( const string &  name)

Find an input file.

This routine will search for a file in the default locations specified for the application. See the routine setDefaultDirectories() listed above. The first directory searched is usually the current working directory.

The default set of directories will not be searched if an absolute path (for example, one starting with / or C:\) or a path relative to the user's home directory (for example, starting with ~/) is specified.

The presence of the file is determined by whether the file can be opened for reading by the current user.

Parameters
nameName of the input file to be searched for
Returns
The absolute path name of the first matching file

If the file is not found a CanteraError exception is thrown.

Definition at line 313 of file application.cpp.

◆ getDataDirectories() [1/2]

string getDataDirectories ( const string &  sep)
inline

Get the Cantera data directories.

This routine returns a string including the names of all the directories searched by Cantera for data files.

Parameters
sepSeparator to use between directories in the string
Returns
A string of directories separated by the input sep

Definition at line 279 of file application.h.

◆ setDefaultDirectories()

void setDefaultDirectories ( )
protected

Set the default directories for input files.

Cantera searches for input files along a path that includes platform- specific default locations, and possibly user-specified locations. This function installs the platform-specific directories on the search path. It is invoked at startup by appinit(), and never should need to be called by user programs.

The current directory (".") is always searched first. Then, on Windows, the registry is checked to find the Cantera installation directory, and the 'data' subdirectory of the installation directory will be added to the search path.

On any platform, if environment variable CANTERA_DATA is set to a directory name or a list of directory names separated with the OS-dependent path separator (that is, ";" on Windows, ":" elsewhere), then these directories will be added to the search path.

Finally, the location where the data files were installed when Cantera was built is added to the search path.

Additional directories may be added by calling function addDirectory.

Definition at line 216 of file application.cpp.

◆ findInputFile() [2/2]

string findInputFile ( const string &  name)

Find an input file.

This routine will search for a file in the default locations specified for the application. See the routine setDefaultDirectories() listed above. The first directory searched is usually the current working directory.

The default set of directories will not be searched if an absolute path (for example, one starting with / or C:\) or a path relative to the user's home directory (for example, starting with ~/) is specified.

The presence of the file is determined by whether the file can be opened for reading by the current user.

Parameters
nameName of the input file to be searched for
Returns
The absolute path name of the first matching file

If the file is not found a CanteraError exception is thrown.

Definition at line 169 of file global.cpp.

◆ addDirectory()

void addDirectory ( const string &  dir)

Add a directory to the data file search path.

Parameters
dirString name for the directory to be added to the search path

Definition at line 159 of file global.cpp.

◆ getDataDirectories() [2/2]

string getDataDirectories ( const string &  sep)

Get the Cantera data directories.

This routine returns a string including the names of all the directories searched by Cantera for data files.

Parameters
sepSeparator to use between directories in the string
Returns
A string of directories separated by the input sep

Definition at line 164 of file global.cpp.