OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | List of all members
FuelCellShop::SolutionMap Class Reference

Convenient storage object for SolutionVariables. More...

#include <fcst_variables.h>

Inheritance diagram for FuelCellShop::SolutionMap:
Inheritance graph
[legend]
Collaboration diagram for FuelCellShop::SolutionMap:
Collaboration graph
[legend]

Public Member Functions

void push_back (const SolutionVariable &a)
 Public function for adding SolutionVariable, uses the VariableNames stored within the SolutionVariable as a key. More...
 
SolutionVariableat (VariableNames key)
 Expose std::map<VariableNames, SolutionVariable>::at() interface publicly. More...
 
void clear ()
 Expose std::map<VariableNames, SolutionVariable>::clear() interface publicly. More...
 
void erase (const VariableNames &v)
 Expose std::map<VariableNames, SolutionVariable>::erase() interface publicly. More...
 
bool has (const VariableNames &v) const
 Find if a solution corresponding VariableNames type exist inside map. More...
 
SolutionVariable pop (const VariableNames &v)
 Returns and entry whilst removing it from the list. More...
 

Detailed Description

Convenient storage object for SolutionVariables.

Used for storing and passing sets of solutions.

Inherits of std::map< VariableNames, SolutionVariable> privately, as to no expose operator[] since we wish to check all map inserts

Usage details

Simply add Solutions using push_back(), and access them as normal using the at() function. To determine if a SolutionMap has a certain SolutionVariable corresponding to a VariableNames use the has() function.

*
* //Create a SolutionVariable
* FuelCellShop::SolutionVariable phi_s(1.5, 8, electronic_electrical_potential);
*
* //Create an object of SolutionMap
*
* //Add the solution variable to the map
* map.push_back(phi_s);
*
* //Adding the same solution again will throw an exception
* //map.push_back(phi_s) here will throw std::runtime_error
*
* //Access the solution variable from the map
* double first_value = map.at(electronic_electrical_potential)[0];
*
* //Query the solution map to see if it has a solution for a given variable type
* if(map.has(oxygen_molar_fraction) //false
* ...
*
*
Author
Philip Wardlaw
Date
2014

Member Function Documentation

SolutionVariable& FuelCellShop::SolutionMap::at ( VariableNames  key)
inline

Expose std::map<VariableNames, SolutionVariable>::at() interface publicly.

void FuelCellShop::SolutionMap::clear ( )
inline

Expose std::map<VariableNames, SolutionVariable>::clear() interface publicly.

void FuelCellShop::SolutionMap::erase ( const VariableNames v)
inline

Expose std::map<VariableNames, SolutionVariable>::erase() interface publicly.

bool FuelCellShop::SolutionMap::has ( const VariableNames v) const
inline

Find if a solution corresponding VariableNames type exist inside map.

SolutionVariable FuelCellShop::SolutionMap::pop ( const VariableNames v)
inline

Returns and entry whilst removing it from the list.

void FuelCellShop::SolutionMap::push_back ( const SolutionVariable a)
inline

Public function for adding SolutionVariable, uses the VariableNames stored within the SolutionVariable as a key.

Warning
SolutionMap will not accept multiple definitions of a solution and will throw std::runtime_error if the user tries to store two solutions of corresponding to the same VariableNames type.

To circumvent this either clear the map using clear(), or to replace a single element first using erase(key) to clear existing SolutionVariable corresponding to the same VariableNames type or pop(key) to get the SolutionVariable whilst simulataneously erasing it.

References FuelCellShop::SolutionVariable::get_variablename().

Here is the call graph for this function:


The documentation for this class was generated from the following file: