Input File Handling

Classes

class  Unit
 Unit conversion utility. More...

Functions

void ct2ctml (const char *file, const int debug=0)
 Convert a cti file into a ctml file.
std::string findInputFile (std::string name)
 Find an input file.
void addDirectory (std::string dir)
 Add a directory to the input file search path.
std::string canteraRoot ()
 Returns root directory where Cantera where installed.
void setTmpDir (std::string tmp)
 Sets the temporary file directory.
std::string tmpDir ()
 Retrieves the directory name where temporary files are created.
std::string sleep ()
 Delay time in seconds.
void addDataDirectory (std::string dir)
 Add a directory to the data file search path.
std::string findInputFile (std::string name)
 Find an input file.
ThermoPhase * newPhase (XML_Node &xmlphase)
void setDefaultDirectories ()
 Set the default directories for input files.

Detailed Description

The properties of phases and interfaces are specified in text files. These procedures handle various aspects of reading these files.

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.

The current directory (".") is always searched first. Then, on Windows platforms, if environment variable COMMONPROGRAMFILES is set (which it should be on Win XP or Win 2000), then directories under this one will be added to the search path. The Cantera Windows installer installs data files to this location.

On the Mac, directory '/Applications/Cantera/data' is added to the search path.

On any platform, if environment variable CANTERA_DATA is set to a directory name, then this directory is 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.

There are two different types of input files within Cantera: ctml: This is an xml file layed out in such a way that Cantera can interpret the contents. cti: A human-readable ascii format for information that Cantera will read.

Cantera can take its input from both types of files. However, given a file in cti format, the initial operation that Cantera will perform is to translate the cti file into a ctml file. The translation is carried out via a system call to a python interpretor program that actually carries out the translation. In general, a new ctml file is created by the translation that is written to the current local directory. The ctml file is then read back into Cantera as the input.

Other input routines in other modules:

See also:
importKinetics()

Function Documentation

void addDataDirectory ( std::string  dir  )  [inherited]

Add a directory to the data file search path.

Parameters:
dir String name for the directory to be added to the search path

Definition at line 1345 of file misc.cpp.

References DIR_LOCK, Application::inputDirs, Application::setDefaultDirectories(), and Cantera::stripnonprint().

Referenced by Cantera::addDirectory().

void addDirectory ( std::string  dir  ) 

Add a directory to the input file search path.

Parameters:
dir String name for the directory to be added to the search path

Definition at line 1342 of file misc.cpp.

References Application::addDataDirectory(), and Cantera::app().

string canteraRoot (  ) 

Returns root directory where Cantera where installed.

Returns:
Returns a string containing the name of the base directory where Cantera is installed. If the environmental variable CANTERA_ROOT is defined, this function will return its value, preferentially.

Definition at line 1442 of file misc.cpp.

void ct2ctml ( const char *  file,
const int  debug = 0 
)

Convert a cti file into a ctml file.

Parameters:
file Pointer to the file
debug Turn on debug printing

Referenced by Application::get_XML_File().

std::string findInputFile ( std::string  name  )  [inherited]

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 default set of directories specified for the application will be searched if a '/' or an '\' is found in the name. If either is found then a relative path name is presumed, and the default directories are not searched.

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

Parameters:
name Name of the input file to be searched for
Returns:

The absolute path name of the first matching file is returned. If a relative path name is indicated, the relative path name is returned.

If the file is not found, a message is written to stdout and a CanteraError exception is thrown.

Definition at line 1385 of file misc.cpp.

References DIR_LOCK, and Application::inputDirs.

Referenced by Cantera::findInputFile(), and Application::get_XML_File().

std::string findInputFile ( std::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 default set of directories specified for the application will be searched if a '/' or an '\' is found in the name. If either is found then a relative path name is presumed, and the default directories are not searched.

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

Parameters:
name Name of the input file to be searched for
Returns:

The absolute path name of the first matching file is returned. If a relative path name is indicated, the relative path name is returned.

If the file is not found, a message is written to stdout and a CanteraError exception is thrown.

Definition at line 1381 of file misc.cpp.

References Cantera::app(), and Application::findInputFile().

Referenced by PDSS_Water::constructPDSSFile(), PDSS_SSVol::constructPDSSFile(), PDSS_IdealGas::constructPDSSFile(), PDSS_HKFT::constructPDSSFile(), PDSS_ConstVol::constructPDSSFile(), WaterSSTP::constructPhaseFile(), IdealSolidSolnPhase::constructPhaseFile(), IdealMolalSoln::constructPhaseFile(), HMWSoln::constructPhaseFile(), DebyeHuckel::constructPhaseFile(), and ThermoPhase::initThermoFile().

ThermoPhase * newPhase ( XML_Node &  phase  ) 

This routine first looks up the identity of the model for the solution thermodynamics in the model attribute of the thermo child of the xml phase node. Then, it does a string lookup using Cantera's internal ThermoPhase Factory routines on the model to figure out what ThermoPhase derived class should be assigned. It creates a new instance of that class, and then calls importPhase() to populate that class with the correct parameters from the XML tree.

Parameters:
phase XML_Node reference pointing to the phase XML element.
Returns:
Returns a pointer to the completed and initialized ThermoPhase object.
void setDefaultDirectories (  )  [protected, inherited]

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 platforms, if environment variable COMMONPROGRAMFILES is set (which it should be on Win XP or Win 2000), then directories under this one will be added to the search path. The Cantera Windows installer installs data files to this location.

On the Mac, directory '/Applications/Cantera/data' is added to the search path.

On any platform, if environment variable CANTERA_DATA is set to a directory name, then this directory is 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 1281 of file misc.cpp.

References Application::inputDirs.

Referenced by Application::addDataDirectory(), and Application::Application().

void setTmpDir ( std::string  tmp  ) 

Sets the temporary file directory.

The default is to use the directory specified by enviroment variable TMP or TEMP. If neither of these are defined, then the current working directory will be used for temporary files. Call this function to specify some other place to put temporary files.

Parameters:
tmp String name for the temporary directory

Definition at line 1094 of file misc.cpp.

References Cantera::app(), and Application::setTmpDir().

string sleep (  ) 

Delay time in seconds.

Returns:
Returns the length of time in seconds for calls to the sleep function.

Definition at line 1106 of file misc.cpp.

References Cantera::app(), and Application::sleep().

string tmpDir (  ) 

Retrieves the directory name where temporary files are created.

Returns:
Returns a string containing the directory name

Definition at line 1100 of file misc.cpp.

References Cantera::app(), and Application::getTmpDir().

Generated by  doxygen 1.6.3