Cantera  2.1.2
KineticsFactory.cpp
Go to the documentation of this file.
1 /**
2  * @file KineticsFactory.cpp
3  */
4 // Copyright 2001 California Institute of Technology
5 
7 
14 
15 using namespace std;
16 
17 namespace Cantera
18 {
19 
20 KineticsFactory* KineticsFactory::s_factory = 0;
21 mutex_t KineticsFactory::kinetics_mutex;
22 
23 static int ntypes = 6;
24 static string _types[] = {"none", "GasKinetics", "GRI30", "Interface", "Edge", "AqueousKinetics"};
25 static int _itypes[] = {0, cGasKinetics, cGRI30, cInterfaceKinetics, cEdgeKinetics, cAqueousKinetics};
26 
27 Kinetics* KineticsFactory::
28 newKinetics(XML_Node& phaseData, vector<ThermoPhase*> th)
29 {
30  /*
31  * Look for a child of the xml element phase called
32  * "kinetics". It has an attribute name "model".
33  * Store the value of that attribute in the variable kintype
34  */
35  string kintype = phaseData.child("kinetics")["model"];
36  /*
37  * look up the string kintype in the list of known
38  * kinetics managers (list is kept at the top of this file).
39  * Translate it to an integer value, ikin.
40  */
41  int ikin=-1;
42  int n;
43  for (n = 0; n < ntypes; n++) {
44  if (kintype == _types[n]) {
45  ikin = _itypes[n];
46  }
47  }
48  /*
49  * Assign the kinetics manager based on the value of ikin.
50  * Kinetics managers are classes derived from the base
51  * Kinetics class. Unknown kinetics managers will throw a
52  * CanteraError here.
53  */
54  Kinetics* k=0;
55  switch (ikin) {
56 
57  case 0:
58  k = new Kinetics;
59  break;
60 
61  case cGasKinetics:
62  k = new GasKinetics;
63  break;
64 
65  case cGRI30:
66  k = new GRI_30_Kinetics;
67  break;
68 
69  case cInterfaceKinetics:
70  k = new InterfaceKinetics;
71  break;
72 
73  case cEdgeKinetics:
74  k = new EdgeKinetics;
75  break;
76 
77  case cAqueousKinetics:
78  k = new AqueousKinetics;
79  break;
80 
81  default:
82  throw UnknownKineticsModel("KineticsFactory::newKinetics",
83  kintype);
84  }
85 
86  // Now that we have the kinetics manager, we can
87  // import the reaction mechanism into it.
88  importKinetics(phaseData, th, k);
89 
90  // Return the pointer to the kinetics manager
91  return k;
92 }
93 
94 Kinetics* KineticsFactory::newKinetics(const string& model)
95 {
96 
97  int ikin = -1;
98  int n;
99  for (n = 0; n < ntypes; n++) {
100  if (model == _types[n]) {
101  ikin = _itypes[n];
102  }
103  }
104  Kinetics* k=0;
105  switch (ikin) {
106 
107  case cGasKinetics:
108  k = new GasKinetics;
109  break;
110 
111  case cGRI30:
112  k = new GRI_30_Kinetics;
113  break;
114 
115  case cInterfaceKinetics:
116  k = new InterfaceKinetics;
117  break;
118 
119  default:
120  throw UnknownKineticsModel("KineticsFactory::newKinetics",
121  model);
122  }
123  return k;
124 }
125 
126 }
Kinetics manager for elementary aqueous-phase chemistry.
Kinetics manager implementing reaction mechanism GRI-Mech 3.0.
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:100
Kinetics manager for elementary gas-phase chemistry.
Definition: GasKinetics.h:35
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
Definition: xml.cpp:584
bool importKinetics(const XML_Node &phase, std::vector< ThermoPhase * > th, Kinetics *k)
Import a reaction mechanism for a phase or an interface.
A kinetics manager for heterogeneous reaction mechanisms.
Public interface for kinetics managers.
Definition: Kinetics.h:131
Definitions of global routines for the importing of data from XML files (see Input File Handling)...
Heterogeneous reactions at one-dimensional interfaces between multiple adjacent two-dimensional surfa...
Definition: EdgeKinetics.h:20