Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
KineticsFactory.cpp
Go to the documentation of this file.
1 /**
2  * @file KineticsFactory.cpp
3  */
4 // Copyright 2001 California Institute of Technology
5 
7 
13 #include "cantera/base/xml.h"
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 Kinetics* KineticsFactory::newKinetics(XML_Node& phaseData,
24  vector<ThermoPhase*> th)
25 {
26  /*
27  * Look for a child of the XML element phase called
28  * "kinetics". It has an attribute name "model".
29  * Store the value of that attribute in the variable kintype
30  */
31  string kintype = phaseData.child("kinetics")["model"];
32 
33  // Create a kinetics object of the desired type
34  Kinetics* k = newKinetics(kintype);
35  // Now that we have the kinetics manager, we can
36  // import the reaction mechanism into it.
37  importKinetics(phaseData, th, k);
38 
39  // Return the pointer to the kinetics manager
40  return k;
41 }
42 
43 Kinetics* KineticsFactory::newKinetics(const string& model)
44 {
45  string lcmodel = lowercase(model);
46  if (lcmodel == "none") {
47  return new Kinetics();
48  } else if (lcmodel == "gaskinetics") {
49  return new GasKinetics();
50  } else if (lcmodel == "interface") {
51  return new InterfaceKinetics();
52  } else if (lcmodel == "edge") {
53  return new EdgeKinetics();
54  } else if (lcmodel == "aqueouskinetics") {
55  return new AqueousKinetics();
56  } else {
57  throw UnknownKineticsModel("KineticsFactory::newKinetics", model);
58  }
59 }
60 
61 }
Kinetics manager for elementary aqueous-phase chemistry.
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:100
std::string lowercase(const std::string &s)
Cast a copy of a string to lower case.
Definition: stringUtils.cpp:73
Kinetics manager for elementary gas-phase chemistry.
Definition: GasKinetics.h:26
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
Definition: xml.cpp:573
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.
Classes providing support for XML data files.
Public interface for kinetics managers.
Definition: Kinetics.h:128
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