Cantera  2.3.0
TransportFactory.h
Go to the documentation of this file.
1 /**
2  * @file TransportFactory.h
3  * Header file defining class TransportFactory
4  * (see \link Cantera::TransportFactory TransportFactory\endlink)
5  */
6 
7 // This file is part of Cantera. See License.txt in the top-level directory or
8 // at http://www.cantera.org/license.txt for license and copyright information.
9 
10 #ifndef CT_TRANSPORTFACTORY_H
11 #define CT_TRANSPORTFACTORY_H
12 
13 // Cantera includes
14 #include "TransportBase.h"
16 #include "LiquidTransportParams.h"
17 
18 namespace Cantera
19 {
20 
21 //! Factory class for creating new instances of classes derived from Transport.
22 /*!
23  * Creates 'transport managers', which are classes derived from class
24  * Transport that provide transport properties. TransportFactory handles all
25  * initialization required, including evaluation of collision integrals and
26  * generating polynomial fits. Transport managers can also be created in
27  * other ways.
28  *
29  * @ingroup tranprops
30  */
31 class TransportFactory : public Factory<Transport>
32 {
33 public:
34  //! Return a pointer to a TransportFactory instance.
35  /*!
36  * TransportFactory is implemented as a 'singleton', which means that at
37  * most one instance may be created. The constructor is private. When a
38  * TransportFactory instance is required, call static method factory() to
39  * return a pointer to the TransportFactory instance.
40  *
41  * @code
42  * TransportFactory* f;
43  * f = TransportFactory::factory();
44  * @endcode
45  */
47  std::unique_lock<std::mutex> transportLock(transport_mutex);
48  if (!s_factory) {
50  }
51  return s_factory;
52  }
53 
54  //! Deletes the statically allocated factory instance.
55  virtual void deleteFactory();
56 
57  //! Get the name of the transport model corresponding to the specified constant.
58  /*!
59  * @param model Integer representing the model name
60  * @deprecated To be removed after Cantera 2.3.
61  */
62  static std::string modelName(int model);
63 
64  //! Make one of several transport models, and return a base class pointer to it.
65  /*!
66  * This method operates at the level of a single transport property as a
67  * function of temperature and possibly composition. It's a factory for
68  * LTPspecies classes.
69  *
70  * @param trNode XML node
71  * @param name reference to the name
72  * @param tp_ind TransportPropertyType class
73  * @param thermo Pointer to the ThermoPhase class
74  */
75  virtual LTPspecies* newLTP(const XML_Node& trNode, const std::string& name,
76  TransportPropertyType tp_ind, thermo_t* thermo);
77 
78  //! Factory function for the construction of new LiquidTranInteraction
79  //! objects, which are transport models.
80  /*!
81  * This method operates at the level of a single mixture transport property.
82  * Individual species transport properties are addressed by the LTPspecies
83  * returned by newLTP.
84  *
85  * @param trNode XML_Node containing the information for the interaction
86  * @param tp_ind TransportPropertyType object
87  * @param trParam reference to the LiquidTransportParams object
88  */
89  virtual LiquidTranInteraction* newLTI(const XML_Node& trNode,
90  TransportPropertyType tp_ind,
91  LiquidTransportParams& trParam);
92 
93  //! Build a new transport manager using a transport manager
94  //! that may not be the same as in the phase description
95  //! and return a base class pointer to it
96  /*!
97  * @param model String name for the transport manager
98  * @param thermo ThermoPhase object
99  * @param log_level log level
100  * @param ndim Number of dimensions for fluxes
101  */
102  virtual Transport* newTransport(const std::string& model, thermo_t* thermo, int log_level=0, int ndim=1);
103 
104  //! Build a new transport manager using the default transport manager
105  //! in the phase description and return a base class pointer to it
106  /*!
107  * @param thermo ThermoPhase object
108  * @param log_level log level
109  */
110  virtual Transport* newTransport(thermo_t* thermo, int log_level=0);
111 
112  //! Initialize an existing transport manager for liquid phase
113  /*!
114  * This routine sets up an existing liquid-phase transport manager. It is
115  * similar to initTransport except that it uses the LiquidTransportParams
116  * class and calls setupLiquidTransport().
117  *
118  * @param tr Pointer to the Transport manager
119  * @param thermo Pointer to the ThermoPhase object
120  * @param log_level Defaults to zero, no logging
121  */
122  virtual void initLiquidTransport(Transport* tr, thermo_t* thermo, int log_level=0);
123 
124 private:
125  //! Initialize an existing transport manager for solid phase
126  /*!
127  * This routine sets up an existing solid-phase transport manager. It is
128  * similar to initTransport except that it uses the SolidTransportData class
129  * and calls setupSolidTransport().
130  *
131  * @param tr Pointer to the Transport manager
132  * @param thermo Pointer to the ThermoPhase object
133  * @param log_level Defaults to zero, no logging
134  */
135  virtual void initSolidTransport(Transport* tr, thermo_t* thermo, int log_level=0);
136 
137  //! Static instance of the factor -> This is the only instance of this
138  //! object allowed
140 
141  //! Static instance of the mutex used to ensure the proper reading of the
142  //! transport database
143  static std::mutex transport_mutex;
144 
145  //! The constructor is private; use static method factory() to
146  //! get a pointer to a factory instance
147  /*!
148  * The default constructor for this class sets up m_models[], a mapping
149  * between the string name for a transport model and the integer name.
150  */
152 
153  //! Read transport property data from a file for a list of species that
154  //! comprise the phase.
155  /*!
156  * Given a vector of pointers to species XML data bases and a list of
157  * species names, this method constructs the LiquidTransport Params object
158  * containing the transport data for these species.
159  *
160  * It is an error to not find a "transport" XML element within each of the
161  * species XML elements listed in the names vector.
162  *
163  * @param db Reference to a vector of XML_Node pointers containing the
164  * species XML nodes.
165  * @param log Reference to an XML log file. (currently unused)
166  * @param names Vector of names of species. On output, tr will contain
167  * transport data for each of of these names in the order
168  * determined by this vector.
169  * @param tr Reference to the LiquidTransportParams object that will
170  * contain the results.
171  */
172  void getLiquidSpeciesTransportData(const std::vector<const XML_Node*> &db,
173  XML_Node& log, const std::vector<std::string>& names,
175 
176  //! Read transport property data from a file for interactions between species.
177  /*!
178  * Given the XML_Node database for transport interactions defined within the
179  * current phase and a list of species names within the phase, this method
180  * returns an instance of TransportParams containing the transport data for
181  * these species read from the file.
182  *
183  * This routine reads interaction parameters between species within the phase.
184  *
185  * @param phaseTran_db Reference to the transport XML field for the phase
186  * @param log Reference to an XML log file. (currently unused)
187  * @param names Vector of names of species. On output, tr will
188  * contain transport data for each of of these names in
189  * the order determined by this vector.
190  * @param tr Reference to the LiquidTransportParams object that
191  * will contain the results.
192  */
193  void getLiquidInteractionsTransportData(const XML_Node& phaseTran_db, XML_Node& log,
194  const std::vector<std::string>& names, LiquidTransportParams& tr);
195 
196  //! Read transport property data from a file for a solid phase
197  /*!
198  * Given a phase XML data base, this method constructs the
199  * SolidTransportData object containing the transport data for the phase.
200  *
201  * @param transportNode Reference to XML_Node containing the phase.
202  * @param log Reference to an XML log file. (currently unused)
203  * @param phaseName name of the corresponding phase
204  * @param tr Reference to the SolidTransportData object that will
205  * contain the results.
206  */
207  void getSolidTransportData(const XML_Node& transportNode,
208  XML_Node& log,
209  const std::string phaseName,
210  SolidTransportData& tr);
211 
212  //! Prepare to build a new transport manager for liquids assuming that
213  //! viscosity transport data is provided in Arrhenius form.
214  /*!
215  * @param thermo Pointer to the ThermoPhase object
216  * @param log_level log level
217  * @param trParam LiquidTransportParams structure to be filled up with information
218  */
219  void setupLiquidTransport(thermo_t* thermo, int log_level, LiquidTransportParams& trParam);
220 
221  //! Prepare to build a new transport manager for solids
222  /*!
223  * @param thermo Pointer to the ThermoPhase object
224  * @param log_level log level
225  * @param trParam SolidTransportData structure to be filled up with information
226  */
227  void setupSolidTransport(thermo_t* thermo, int log_level, SolidTransportData& trParam);
228 
229  //! Mapping between between the string name for a transport model and the
230  //! integer name.
231  //! @deprecated To be removed after Cantera 2.3.
232  std::map<std::string, int> m_models;
233 
234  //! Inverse mapping of transport models, from integer constant to string
235  //! @deprecated To be removed after Cantera 2.3.
236  std::map<int, std::string> m_modelNames;
237 
238  //! Mapping between between the string name
239  //! for a transport property and the integer name.
240  std::map<std::string, TransportPropertyType> m_tranPropMap;
241 
242  //! Mapping between between the string name for a
243  //! species-specific transport property model and the integer name.
244  std::map<std::string, LTPTemperatureDependenceType> m_LTRmodelMap;
245 
246  //! Mapping between between the string name for a
247  //! liquid mixture transport property model and the integer name.
248  std::map<std::string, LiquidTranMixingModel> m_LTImodelMap;
249 
250  //! Models included in this map are initialized in CK compatibility mode
251  std::map<std::string, bool> m_CK_mode;
252 };
253 
254 //! Create a new transport manager instance.
255 /*!
256  * @param transportModel String identifying the transport model to be
257  * instantiated, defaults to the empty string
258  * @param thermo ThermoPhase object associated with the phase, defaults
259  * to null pointer
260  * @param loglevel int containing the Loglevel, defaults to zero
261  * @param f optional pointer to the TransportFactory object
262  * @param ndim Number of dimensions for transport fluxes
263  * @deprecated Use the version which does not take a `TransportFactory*`.To be
264  * removed after Cantera 2.3.
265  * @ingroup tranprops
266  */
267 Transport* newTransportMgr(const std::string& transportModel, thermo_t* thermo, int loglevel,
268  TransportFactory* f, int ndim=1);
269 
270 Transport* newTransportMgr(const std::string& transportModel = "",
271  thermo_t* thermo = 0, int loglevel = 0, int ndim=1);
272 
273 //! Create a new transport manager instance.
274 /*!
275  * @param thermo ThermoPhase object associated with the phase
276  * @param loglevel int containing the Loglevel, defaults to zero
277  * @param f pointer to the TransportFactory object if it's been allocated
278  * @returns a transport manager for the phase
279  * @deprecated The `TransportFactory*` argument to this function is deprecated
280  * and will be removed after Cantera 2.3.
281  * @ingroup tranprops
282  */
283 Transport* newDefaultTransportMgr(thermo_t* thermo, int loglevel = 0, TransportFactory* f = 0);
284 
285 } // End of namespace Cantera
286 
287 #endif
TransportPropertyType
Enumeration of the types of transport properties that can be handled by the variables in the various ...
Definition: LTPspecies.h:34
static std::mutex transport_mutex
Static instance of the mutex used to ensure the proper reading of the transport database.
virtual Transport * newTransport(const std::string &model, thermo_t *thermo, int log_level=0, int ndim=1)
Build a new transport manager using a transport manager that may not be the same as in the phase desc...
Factory class for creating new instances of classes derived from Transport.
void getSolidTransportData(const XML_Node &transportNode, XML_Node &log, const std::string phaseName, SolidTransportData &tr)
Read transport property data from a file for a solid phase.
Headers for the Transport object, which is the virtual base class for all transport property evaluato...
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:97
Base class for transport property managers.
std::map< int, std::string > m_modelNames
Inverse mapping of transport models, from integer constant to string.
std::map< std::string, bool > m_CK_mode
Models included in this map are initialized in CK compatibility mode.
static TransportFactory * s_factory
Static instance of the factor -> This is the only instance of this object allowed.
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:93
static std::string modelName(int model)
Get the name of the transport model corresponding to the specified constant.
Class LiquidTransportParams holds transport model parameters relevant to transport in mixtures...
void getLiquidInteractionsTransportData(const XML_Node &phaseTran_db, XML_Node &log, const std::vector< std::string > &names, LiquidTransportParams &tr)
Read transport property data from a file for interactions between species.
Header file defining class LiquidTransportParams.
TransportFactory()
The constructor is private; use static method factory() to get a pointer to a factory instance...
std::map< std::string, TransportPropertyType > m_tranPropMap
Mapping between between the string name for a transport property and the integer name.
std::map< std::string, LiquidTranMixingModel > m_LTImodelMap
Mapping between between the string name for a liquid mixture transport property model and the integer...
void setupLiquidTransport(thermo_t *thermo, int log_level, LiquidTransportParams &trParam)
Prepare to build a new transport manager for liquids assuming that viscosity transport data is provid...
virtual LiquidTranInteraction * newLTI(const XML_Node &trNode, TransportPropertyType tp_ind, LiquidTransportParams &trParam)
Factory function for the construction of new LiquidTranInteraction objects, which are transport model...
std::map< std::string, int > m_models
Mapping between between the string name for a transport model and the integer name.
void getLiquidSpeciesTransportData(const std::vector< const XML_Node *> &db, XML_Node &log, const std::vector< std::string > &names, LiquidTransportParams &tr)
Read transport property data from a file for a list of species that comprise the phase.
Factory class that supports registering functions to create objects.
Definition: FactoryBase.h:69
Class LTPspecies holds transport parameterizations for a specific liquid- phase species.
Definition: LTPspecies.h:76
static TransportFactory * factory()
Return a pointer to a TransportFactory instance.
virtual void initLiquidTransport(Transport *tr, thermo_t *thermo, int log_level=0)
Initialize an existing transport manager for liquid phase.
std::map< std::string, LTPTemperatureDependenceType > m_LTRmodelMap
Mapping between between the string name for a species-specific transport property model and the integ...
void setupSolidTransport(thermo_t *thermo, int log_level, SolidTransportData &trParam)
Prepare to build a new transport manager for solids.
Transport * newTransportMgr(const std::string &transportModel, thermo_t *thermo, int loglevel, TransportFactory *f, int ndim)
Create a new transport manager instance.
virtual LTPspecies * newLTP(const XML_Node &trNode, const std::string &name, TransportPropertyType tp_ind, thermo_t *thermo)
Make one of several transport models, and return a base class pointer to it.
Transport * newDefaultTransportMgr(thermo_t *thermo, int loglevel, TransportFactory *f)
Create a new transport manager instance.
virtual void initSolidTransport(Transport *tr, thermo_t *thermo, int log_level=0)
Initialize an existing transport manager for solid phase.
Namespace for the Cantera kernel.
Definition: application.cpp:29
virtual void deleteFactory()
Deletes the statically allocated factory instance.
Class SolidTransportData holds transport parameters for a specific solid- phase species.
Base class to handle transport property evaluation in a mixture.
File contains the FactoryBase class declarations.