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