OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Functions
FcstUtilities Namespace Reference

Classes

class  FCSTdatabase
 This class is for interfacing with SQL databases, *for the purpose of accessing and storing simulation results. More...
 
class  DatabaseOC
 This class is for storing a list of up to 5 parameters and is used as a way of informing the FCSTdatabase class about the model you wish to store/access. More...
 

Functions

 DeclException1 (ExcWrongString, std::string,<< "Can't convert the string "<< arg1<< " to the desired Number type")
 Exception shown when a particular string can't be converted to Number type.
 
template<typename NumType >
NumType string_to_number (const std::string &)
 Function to convert a std::string into Number template.
 
template<typename NumType >
std::vector< NumType > string_to_number (const std::vector< std::string > &)
 Function to convert a std::vector< std::string > into std::vector < Number template >.
 
template<typename KeyType , typename ValueType >
std::map< KeyType, ValueType > string_to_map (const std::vector< std::string > &)
 Function to convert a std::vector< std::string > into std::map< KeyType, ValueType >.
 
template<typename KeyType , typename ValueType >
std::map< KeyType, ValueType > string_to_map (const std::string &name)
 This function is the same as the previous one.
 
template<>
std::map< unsigned int,
std::string > 
string_to_map (const std::string &name)
 This function is a particular reimplementation of the previous one.
 
template<typename KeyType , typename ValueType >
std::map< KeyType, std::vector
< ValueType > > 
split_mapvalue_list (const std::map< KeyType, std::string > &, const char delimiter= ';')
 This function takes a std::map<KeyType, std::string>, and std::string contains text separated by a delimiter.
 
void print_parameter_file_XML (ParameterHandler &param)
 This function prepares an XML file with ALL your data inside.
 
std::string find_fcst_root ()
 This function returns the address of the fcst root directory.
 
void run_python (std::string script_name, std::string arg)
 This function runs external python scripts.
 
template<typename NumType >
std::string number_to_string (const NumType &num)
 Function for casting from double to string.
 

Function Documentation

FcstUtilities::DeclException1 ( ExcWrongString  ,
std::string  ,
<< "Can't convert the string "<< arg1<< " to the desired Number type"   
)

Exception shown when a particular string can't be converted to Number type.

std::string FcstUtilities::find_fcst_root ( )

This function returns the address of the fcst root directory.

It presumes that you are executing from within the data folder - an exception will be thrown otherwise.

template<typename NumType >
std::string FcstUtilities::number_to_string ( const NumType &  num)

Function for casting from double to string.

Uses boost lexical cast.

void FcstUtilities::print_parameter_file_XML ( ParameterHandler &  param)

This function prepares an XML file with ALL your data inside.

void FcstUtilities::run_python ( std::string  script_name,
std::string  arg 
)

This function runs external python scripts.

User must provide the script name and argument. It is presumed that the script resides in the python folder.

template<typename KeyType , typename ValueType >
std::map< KeyType, std::vector<ValueType> > FcstUtilities::split_mapvalue_list ( const std::map< KeyType, std::string > &  ,
const char  delimiter = ';' 
)

This function takes a std::map<KeyType, std::string>, and std::string contains text separated by a delimiter.

It splits the std::string into std::vector<ValueType>, removing all the leading and trailing spaces. It returns std::map< KeyType, std::vector<ValueType> >. The default value of the delimiter is semi-colon ";".

Note
It is necessary to have the delimiter "atleast once" in the Value string.
template<typename KeyType , typename ValueType >
std::map< KeyType, ValueType > FcstUtilities::string_to_map ( const std::vector< std::string > &  )

Function to convert a std::vector< std::string > into std::map< KeyType, ValueType >.

This function is used to convert a string like "2 : 3.86" into a std::map where Key is 2 and Value is 3.86. This function is useful to convert a Patterns::Map (of ParameterHandler class of deal.ii) into a useful data map.

Warning
String should contain ":" to distinguish between key and corresponding value. Also a key should not be repeated in the parameter strings. Also Input strings should be free from blank spaces at the beginning and end.
Note
Currently, it is templated only to have KeyType as unsigned int and ValueType as double. But, the capabilities can be extended.
template<typename KeyType , typename ValueType >
std::map< KeyType, ValueType > FcstUtilities::string_to_map ( const std::string &  name)

This function is the same as the previous one.

The only difference is that this function takes std::string instead of std::vector<std::string>.

template<>
std::map< unsigned int, std::string > FcstUtilities::string_to_map ( const std::string &  name)

This function is a particular reimplementation of the previous one.

template<typename NumType >
NumType FcstUtilities::string_to_number ( const std::string &  )

Function to convert a std::string into Number template.

Currently, it is templated only for double and unsigned int types. But it can be easily extended for other numeric data types.

Input string should be free from blank spaces at the beginning and end.

Note
There is a similar function in deal.ii Utilities namespace, but it has certain limitations as it doesn't do effective error checking for wrong input arguments. For that purpose, a new function is written here using boost::lexical_cast.
template<typename NumType >
std::vector<NumType> FcstUtilities::string_to_number ( const std::vector< std::string > &  )

Function to convert a std::vector< std::string > into std::vector < Number template >.

Currently, it is templated only for double and unsigned int types. But it can be easily extended for other numeric data types.

Input strings should be free from blank spaces at the beginning and end.

Note
Before extending its capabilities to deal with other numeric data types, capability of string_to_number should be extended.