Cantera  2.1.2
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 
19 #include "cantera/base/ct_thread.h"
20 #include "cantera/thermo/VPSSMgr.h"
21 
22 namespace Cantera
23 {
24 
25 class XML_Node;
26 class VPStandardStateTP;
27 
28 //! Throw a named error for an unknown or missing vpss species thermo model.
29 /*!
30  * @ingroup mgrpdssthermocalc
31  */
33 {
34 public:
35  //! Constructor
36  /*!
37  * @param proc Function name error occurred.
38  * @param VPSSMgrModel Unrecognized species thermo calculator name
39  */
40  UnknownVPSSMgrModel(const std::string& proc,
41  const std::string& VPSSMgrModel) :
42  CanteraError(proc, "Specified VPSSMgr model "
43  + VPSSMgrModel +
44  " does not match any known type.") {}
45 };
46 
47 //! Factory to build instances of classes that manage the
48 //! standard-state thermodynamic properties of a set of species.
49 /*!
50  * This class is responsible for making the decision concerning
51  * which derivative of VPSSMgr object to use.
52  * The VPSSMgr object is used to calculate
53  * thermodynamic functions for the standard state.
54  * It queries the database of species to understand what
55  * the requirements are for the submodels for all of the
56  * species in the phase. Then, it picks the derived VPSSMgr
57  * object to use and passes it back to the calling routine.
58  * It doesn't load any data into the derived
59  * VPSSMgr object.
60  *
61  * Making the choice of VPSSMgr types is the only
62  * thing this class does.
63  *
64  * This class is implemented as a singleton -- one in which
65  * only one instance is needed. The recommended way to access
66  * the factory is to call this static method, which
67  * instantiates the class if it is the first call, but
68  * otherwise simply returns the pointer to the existing
69  * instance.
70  *
71  * @ingroup mgrpdssthermocalc
72  */
74 {
75 
76 public:
77 
78  //! Static method to return an instance of this class
79  /*!
80  * This class is implemented as a singleton -- one in which
81  * only one instance is needed. The recommended way to access
82  * the factory is to call this static method, which
83  * instantiates the class if it is the first call, but
84  * otherwise simply returns the pointer to the existing
85  * instance.
86  */
87  static VPSSMgrFactory* factory() {
88  ScopedLock lock(vpss_species_thermo_mutex);
89  if (!s_factory) {
91  }
92  return s_factory;
93  }
94 
95  //! Delete static instance of this class
96  /*!
97  * If it is necessary to explicitly delete the factory before
98  * the process terminates (for example, when checking for
99  * memory leaks) then this method can be called to delete it.
100  */
101  void deleteFactory();
102 
103  //! String conversion to an enumType
104  /*!
105  * This routine is a string conversion. The string is obtained from the
106  * standardState model attribute and converted to a VPSSMgr_enumType
107  * type.
108  *
109  * @param ssModel String representing the VPSSMGr object
110  */
111  virtual VPSSMgr_enumType
112  VPSSMgr_StringConversion(const std::string& ssModel) const;
113 
114  //! Create a new species variable pressure standard state calculator
115  /*!
116  * @param type The enumerated type of the standard state calculator
117  * @param vp_ptr Variable pressure standard state ThermoPhase object
118  * that will be the owner.
119  */
120  virtual VPSSMgr* newVPSSMgr(VPSSMgr_enumType type, VPStandardStateTP* vp_ptr);
121 
122  //! Create a new species property manager for a group of species
123  /*!
124  * This routine will look through species nodes. It will discover what
125  * each species needs for its species property managers. Then,
126  * it will malloc and return the proper species property manager to use.
127  *
128  * @param vp_ptr Variable pressure standard state ThermoPhase object
129  * that will be the owner.
130  * @param phaseNode_ptr Pointer to the ThermoPhase phase XML Node
131  * @param spDataNodeList Vector of XML_Nodes, each of which is a species XML Node.
132  * There are m_kk of these.
133  *
134  * @return Returns a pointer to a newly malloced species property
135  * manager object.
136  */
137  virtual VPSSMgr* newVPSSMgr(VPStandardStateTP* vp_ptr,
138  XML_Node* phaseNode_ptr,
139  std::vector<XML_Node*> & spDataNodeList);
140 
141 private:
142  //! pointer to the sole instance of this class
144 
145  //! Decl of the static mutex variable that locks the
146  //! %VPSSMgr factory singleton
148 
149  //! Constructor. This is made private, so that only the static
150  //! method factory() can instantiate the class.
152 };
153 
154 
155 ////////////////////// Convenience functions ////////////////////
156 //
157 // These functions allow using a different factory class that
158 // derives from SpeciesThermoFactory.
159 //
160 //////////////////////////////////////////////////////////////////
161 
162 
163 //! Create a new species thermo manager instance, by specifying
164 //! the type and (optionally) a pointer to the factory to use to create it.
165 /*!
166  * This utility program will look through species nodes. It will discover what
167  * each species needs for its species property managers. Then, it will malloc
168  * and return the proper species property manager to use.
169  *
170  * These functions allow using a different factory class that
171  * derives from SpeciesThermoFactory.
172  *
173  * @param type Species thermo type.
174  * @param vp_ptr Variable pressure standard state ThermoPhase object
175  * that will be the owner.
176  * @param f Pointer to a SpeciesThermoFactory. optional parameter.
177  * Defaults to NULL.
178  */
179 VPSSMgr* newVPSSMgr(VPSSMgr_enumType type,
180  VPStandardStateTP* vp_ptr, VPSSMgrFactory* f=0);
181 
182 //! Function to return VPSSMgr manager
183 /*!
184  * This utility program will look through species nodes. It will discover what
185  * each species needs for its species property managers. Then, it will alloc
186  * and return the proper species property manager to use.
187  *
188  * These functions allow using a different factory class that
189  * derives from SpeciesThermoFactory.
190  *
191  * @param vp_ptr Variable pressure standard state ThermoPhase object
192  * that will be the owner.
193  * @param phaseNode_ptr Pointer to the ThermoPhase phase XML Node
194  * @param spDataNodeList This vector contains a list
195  * of species XML nodes that will be in the phase
196  * @param f Pointer to a SpeciesThermoFactory. optional
197  * parameter. Defaults to NULL.
198  */
199 VPSSMgr* newVPSSMgr(VPStandardStateTP* vp_ptr,
200  XML_Node* phaseNode_ptr,
201  std::vector<XML_Node*> & spDataNodeList,
202  VPSSMgrFactory* f=0);
203 
204 }
205 
206 #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:238
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.
Virtual base class for the calculation of multiple-species thermodynamic reference-state property man...
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:133
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:68
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.