Cantera  2.4.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  //! Make one of several transport models, and return a base class pointer to it.
58  /*!
59  * This method operates at the level of a single transport property as a
60  * function of temperature and possibly composition. It's a factory for
61  * LTPspecies classes.
62  *
63  * @param trNode XML node
64  * @param name reference to the name
65  * @param tp_ind TransportPropertyType class
66  * @param thermo Pointer to the ThermoPhase class
67  */
68  virtual LTPspecies* newLTP(const XML_Node& trNode, const std::string& name,
69  TransportPropertyType tp_ind, thermo_t* thermo);
70 
71  //! Factory function for the construction of new LiquidTranInteraction
72  //! objects, which are transport models.
73  /*!
74  * This method operates at the level of a single mixture transport property.
75  * Individual species transport properties are addressed by the LTPspecies
76  * returned by newLTP.
77  *
78  * @param trNode XML_Node containing the information for the interaction
79  * @param tp_ind TransportPropertyType object
80  * @param trParam reference to the LiquidTransportParams object
81  */
82  virtual LiquidTranInteraction* newLTI(const XML_Node& trNode,
83  TransportPropertyType tp_ind,
84  LiquidTransportParams& trParam);
85 
86  //! Build a new transport manager using a transport manager
87  //! that may not be the same as in the phase description
88  //! and return a base class pointer to it
89  /*!
90  * @param model String name for the transport manager
91  * @param thermo ThermoPhase object
92  * @param log_level log level
93  * @param ndim Number of dimensions for fluxes
94  */
95  virtual Transport* newTransport(const std::string& model, thermo_t* thermo, int log_level=0, int ndim=1);
96 
97  //! Build a new transport manager using the default transport manager
98  //! in the phase description and return a base class pointer to it
99  /*!
100  * @param thermo ThermoPhase object
101  * @param log_level log level
102  */
103  virtual Transport* newTransport(thermo_t* thermo, int log_level=0);
104 
105  //! Initialize an existing transport manager for liquid phase
106  /*!
107  * This routine sets up an existing liquid-phase transport manager. It is
108  * similar to initTransport except that it uses the LiquidTransportParams
109  * class and calls setupLiquidTransport().
110  *
111  * @param tr Pointer to the Transport manager
112  * @param thermo Pointer to the ThermoPhase object
113  * @param log_level Defaults to zero, no logging
114  */
115  virtual void initLiquidTransport(Transport* tr, thermo_t* thermo, int log_level=0);
116 
117 private:
118  //! Initialize an existing transport manager for solid phase
119  /*!
120  * This routine sets up an existing solid-phase transport manager. It is
121  * similar to initTransport except that it uses the SolidTransportData class
122  * and calls setupSolidTransport().
123  *
124  * @param tr Pointer to the Transport manager
125  * @param thermo Pointer to the ThermoPhase object
126  * @param log_level Defaults to zero, no logging
127  */
128  virtual void initSolidTransport(Transport* tr, thermo_t* thermo, int log_level=0);
129 
130  //! Static instance of the factor -> This is the only instance of this
131  //! object allowed
133 
134  //! Static instance of the mutex used to ensure the proper reading of the
135  //! transport database
136  static std::mutex transport_mutex;
137 
138  //! The constructor is private; use static method factory() to
139  //! get a pointer to a factory instance
140  /*!
141  * The default constructor for this class sets up m_models[], a mapping
142  * between the string name for a transport model and the integer name.
143  */
145 
146  //! Read transport property data from a file for a list of species that
147  //! comprise the phase.
148  /*!
149  * Given a vector of pointers to species XML data bases and a list of
150  * species names, this method constructs the LiquidTransport Params object
151  * containing the transport data for these species.
152  *
153  * It is an error to not find a "transport" XML element within each of the
154  * species XML elements listed in the names vector.
155  *
156  * @param db Reference to a vector of XML_Node pointers containing the
157  * species XML nodes.
158  * @param log Reference to an XML log file. (currently unused)
159  * @param names Vector of names of species. On output, tr will contain
160  * transport data for each of of these names in the order
161  * determined by this vector.
162  * @param tr Reference to the LiquidTransportParams object that will
163  * contain the results.
164  */
165  void getLiquidSpeciesTransportData(const std::vector<const XML_Node*> &db,
166  XML_Node& log, const std::vector<std::string>& names,
168 
169  //! Read transport property data from a file for interactions between species.
170  /*!
171  * Given the XML_Node database for transport interactions defined within the
172  * current phase and a list of species names within the phase, this method
173  * returns an instance of TransportParams containing the transport data for
174  * these species read from the file.
175  *
176  * This routine reads interaction parameters between species within the phase.
177  *
178  * @param phaseTran_db Reference to the transport XML field for the phase
179  * @param log Reference to an XML log file. (currently unused)
180  * @param names Vector of names of species. On output, tr will
181  * contain transport data for each of of these names in
182  * the order determined by this vector.
183  * @param tr Reference to the LiquidTransportParams object that
184  * will contain the results.
185  */
186  void getLiquidInteractionsTransportData(const XML_Node& phaseTran_db, XML_Node& log,
187  const std::vector<std::string>& names, LiquidTransportParams& tr);
188 
189  //! Read transport property data from a file for a solid phase
190  /*!
191  * Given a phase XML data base, this method constructs the
192  * SolidTransportData object containing the transport data for the phase.
193  *
194  * @param transportNode Reference to XML_Node containing the phase.
195  * @param log Reference to an XML log file. (currently unused)
196  * @param phaseName name of the corresponding phase
197  * @param tr Reference to the SolidTransportData object that will
198  * contain the results.
199  */
200  void getSolidTransportData(const XML_Node& transportNode,
201  XML_Node& log,
202  const std::string phaseName,
203  SolidTransportData& tr);
204 
205  //! Prepare to build a new transport manager for liquids assuming that
206  //! viscosity transport data is provided in Arrhenius form.
207  /*!
208  * @param thermo Pointer to the ThermoPhase object
209  * @param log_level log level
210  * @param trParam LiquidTransportParams structure to be filled up with information
211  */
212  void setupLiquidTransport(thermo_t* thermo, int log_level, LiquidTransportParams& trParam);
213 
214  //! Prepare to build a new transport manager for solids
215  /*!
216  * @param thermo Pointer to the ThermoPhase object
217  * @param log_level log level
218  * @param trParam SolidTransportData structure to be filled up with information
219  */
220  void setupSolidTransport(thermo_t* thermo, int log_level, SolidTransportData& trParam);
221 
222  //! Mapping between between the string name
223  //! for a transport property and the integer name.
224  std::map<std::string, TransportPropertyType> m_tranPropMap;
225 
226  //! Mapping between between the string name for a
227  //! species-specific transport property model and the integer name.
228  std::map<std::string, LTPTemperatureDependenceType> m_LTRmodelMap;
229 
230  //! Mapping between between the string name for a
231  //! liquid mixture transport property model and the integer name.
232  std::map<std::string, LiquidTranMixingModel> m_LTImodelMap;
233 
234  //! Models included in this map are initialized in CK compatibility mode
235  std::map<std::string, bool> m_CK_mode;
236 };
237 
238 Transport* newTransportMgr(const std::string& transportModel = "",
239  thermo_t* thermo = 0, int loglevel = 0, int ndim=1);
240 
241 //! Create a new transport manager instance.
242 /*!
243  * @param thermo ThermoPhase object associated with the phase
244  * @param loglevel int containing the Loglevel, defaults to zero
245  * @param f pointer to the TransportFactory object if it's been allocated
246  * @returns a transport manager for the phase
247  * @ingroup tranprops
248  */
249 Transport* newDefaultTransportMgr(thermo_t* thermo, int loglevel = 0);
250 
251 } // End of namespace Cantera
252 
253 #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< 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
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...
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:71
Class LTPspecies holds transport parameterizations for a specific liquid- phase species.
Definition: LTPspecies.h:78
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.
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: AnyMap.cpp:8
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.
Transport * newDefaultTransportMgr(thermo_t *thermo, int loglevel)
Create a new transport manager instance.
File contains the FactoryBase class declarations.