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