Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VPSSMgrFactory.h
Go to the documentation of this file.
1 /**
2  * @file VPSSMgrFactory.h
3  * Header for factory to build instances of classes that manage the
4  * standard-state thermodynamic properties of a set of species
5  * (see \ref mgrpdssthermocalc and class \link Cantera::VPSSMgrFactory VPSSMgrFactory\endlink);
6  */
7 /*
8  * Copyright (2006) Sandia Corporation. Under the terms of
9  * Contract DE-AC04-94AL85000 with Sandia Corporation, the
10  * U.S. Government retains certain rights in this software.
11  */
12 
13 #ifndef VPSSSPECIESTHERMO_FACTORY_H
14 #define VPSSSPECIESTHERMO_FACTORY_H
15 
18 #include "cantera/base/ct_thread.h"
19 #include "cantera/thermo/VPSSMgr.h"
20 
21 namespace Cantera
22 {
23 //! Throw a named error for an unknown or missing vpss species thermo model.
24 /*!
25  * @ingroup mgrpdssthermocalc
26  */
28 {
29 public:
30  //! Constructor
31  /*!
32  * @param proc Function name error occurred.
33  * @param VPSSMgrModel Unrecognized species thermo calculator name
34  */
35  UnknownVPSSMgrModel(const std::string& proc,
36  const std::string& VPSSMgrModel) :
37  CanteraError(proc, "Specified VPSSMgr model "
38  + VPSSMgrModel +
39  " does not match any known type.") {}
40 };
41 
42 //! Factory to build instances of classes that manage the
43 //! standard-state thermodynamic properties of a set of species.
44 /*!
45  * This class is responsible for making the decision concerning
46  * which derivative of VPSSMgr object to use.
47  * The VPSSMgr object is used to calculate
48  * thermodynamic functions for the standard state.
49  * It queries the database of species to understand what
50  * the requirements are for the submodels for all of the
51  * species in the phase. Then, it picks the derived VPSSMgr
52  * object to use and passes it back to the calling routine.
53  * It doesn't load any data into the derived
54  * VPSSMgr object.
55  *
56  * Making the choice of VPSSMgr types is the only
57  * thing this class does.
58  *
59  * This class is implemented as a singleton -- one in which
60  * only one instance is needed. The recommended way to access
61  * the factory is to call this static method, which
62  * instantiates the class if it is the first call, but
63  * otherwise simply returns the pointer to the existing
64  * instance.
65  *
66  * @ingroup mgrpdssthermocalc
67  */
69 {
70 
71 public:
72 
73  //! Static method to return an instance of this class
74  /*!
75  * This class is implemented as a singleton -- one in which
76  * only one instance is needed. The recommended way to access
77  * the factory is to call this static method, which
78  * instantiates the class if it is the first call, but
79  * otherwise simply returns the pointer to the existing
80  * instance.
81  */
82  static VPSSMgrFactory* factory() {
83  ScopedLock lock(vpss_species_thermo_mutex);
84  if (!s_factory) {
86  }
87  return s_factory;
88  }
89 
90  //! Delete static instance of this class
91  /*!
92  * If it is necessary to explicitly delete the factory before
93  * the process terminates (for example, when checking for
94  * memory leaks) then this method can be called to delete it.
95  */
96  void deleteFactory();
97 
98  //! String conversion to an enumType
99  /*!
100  * This routine is a string conversion. The string is obtained from the
101  * standardState model attribute and converted to a VPSSMgr_enumType
102  * type.
103  *
104  * @param ssModel String representing the VPSSMGr object
105  */
106  virtual VPSSMgr_enumType
107  VPSSMgr_StringConversion(const std::string& ssModel) const;
108 
109  //! Create a new species variable pressure standard state calculator
110  /*!
111  * @param type The enumerated type of the standard state calculator
112  * @param vp_ptr Variable pressure standard state ThermoPhase object
113  * that will be the owner.
114  */
115  virtual VPSSMgr* newVPSSMgr(VPSSMgr_enumType type, VPStandardStateTP* vp_ptr);
116 
117  //! Create a new species property manager for a group of species
118  /*!
119  * This routine will look through species nodes. It will discover what
120  * each species needs for its species property managers. Then,
121  * it will malloc and return the proper species property manager to use.
122  *
123  * @param vp_ptr Variable pressure standard state ThermoPhase object
124  * that will be the owner.
125  * @param phaseNode_ptr Pointer to the ThermoPhase phase XML Node
126  * @param spDataNodeList Vector of XML_Nodes, each of which is a species XML Node.
127  * There are m_kk of these.
128  *
129  * @return Returns a pointer to a newly malloced species property
130  * manager object.
131  */
132  virtual VPSSMgr* newVPSSMgr(VPStandardStateTP* vp_ptr,
133  XML_Node* phaseNode_ptr,
134  std::vector<XML_Node*> & spDataNodeList);
135 
136 private:
137  //! pointer to the sole instance of this class
139 
140  //! Decl of the static mutex variable that locks the
141  //! VPSSMgr factory singleton
143 
144  //! Constructor. This is made private, so that only the static
145  //! method factory() can instantiate the class.
147 };
148 
149 
150 ////////////////////// Convenience functions ////////////////////
151 //
152 // These functions allow using a different factory class that
153 // derives from SpeciesThermoFactory.
154 //
155 //////////////////////////////////////////////////////////////////
156 
157 
158 //! Create a new species thermo manager instance, by specifying
159 //! the type and (optionally) a pointer to the factory to use to create it.
160 /*!
161  * This utility program will look through species nodes. It will discover what
162  * each species needs for its species property managers. Then, it will malloc
163  * and return the proper species property manager to use.
164  *
165  * These functions allow using a different factory class that
166  * derives from SpeciesThermoFactory.
167  *
168  * @param type Species thermo type.
169  * @param vp_ptr Variable pressure standard state ThermoPhase object
170  * that will be the owner.
171  * @param f Pointer to a SpeciesThermoFactory. optional parameter.
172  * Defaults to NULL.
173  */
174 VPSSMgr* newVPSSMgr(VPSSMgr_enumType type,
175  VPStandardStateTP* vp_ptr, VPSSMgrFactory* f=0);
176 
177 //! Function to return VPSSMgr manager
178 /*!
179  * This utility program will look through species nodes. It will discover what
180  * each species needs for its species property managers. Then, it will alloc
181  * and return the proper species property manager to use.
182  *
183  * These functions allow using a different factory class that
184  * derives from SpeciesThermoFactory.
185  *
186  * @param vp_ptr Variable pressure standard state ThermoPhase object
187  * that will be the owner.
188  * @param phaseNode_ptr Pointer to the ThermoPhase phase XML Node
189  * @param spDataNodeList This vector contains a list
190  * of species XML nodes that will be in the phase
191  * @param f Pointer to a SpeciesThermoFactory. optional
192  * parameter. Defaults to NULL.
193  */
194 VPSSMgr* newVPSSMgr(VPStandardStateTP* vp_ptr,
195  XML_Node* phaseNode_ptr,
196  std::vector<XML_Node*> & spDataNodeList,
197  VPSSMgrFactory* f=0);
198 
199 }
200 
201 #endif
static VPSSMgrFactory * s_factory
pointer to the sole instance of this class
Virtual base class for the classes that manage the calculation of standard state properties for all t...
Definition: VPSSMgr.h:235
Declaration file for a virtual base class that manages the calculation of standard state properties f...
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:100
void deleteFactory()
Delete static instance of this class.
Base class for factories.
Definition: FactoryBase.h:18
VPSSMgr_enumType
enum for VPSSMgr types that are responsible for calculating the species standard state and reference-...
Definition: mix_defs.h:135
UnknownVPSSMgrModel(const std::string &proc, const std::string &VPSSMgrModel)
Constructor.
static mutex_t vpss_species_thermo_mutex
Decl of the static mutex variable that locks the VPSSMgr factory singleton.
Throw a named error for an unknown or missing vpss species thermo model.
VPSSMgr * newVPSSMgr(VPSSMgr_enumType type, VPStandardStateTP *vp_ptr, Cantera::VPSSMgrFactory *f)
Create a new species thermo manager instance, by specifying the type and (optionally) a pointer to th...
Factory to build instances of classes that manage the standard-state thermodynamic properties of a se...
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:99
This is a filter class for ThermoPhase that implements some prepatory steps for efficiently handling ...
virtual VPSSMgr_enumType VPSSMgr_StringConversion(const std::string &ssModel) const
String conversion to an enumType.
static VPSSMgrFactory * factory()
Static method to return an instance of this class.
virtual VPSSMgr * newVPSSMgr(VPSSMgr_enumType type, VPStandardStateTP *vp_ptr)
Create a new species variable pressure standard state calculator.
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
File contains the FactoryBase class declarations.
VPSSMgrFactory()
Constructor.