Cantera  2.3.0
KineticsFactory.cpp
Go to the documentation of this file.
1 /**
2  * @file KineticsFactory.cpp
3  */
4 
5 // This file is part of Cantera. See License.txt in the top-level directory or
6 // at http://www.cantera.org/license.txt for license and copyright information.
7 
14 #include "cantera/base/xml.h"
15 
16 using namespace std;
17 
18 namespace Cantera
19 {
20 
21 KineticsFactory* KineticsFactory::s_factory = 0;
22 std::mutex KineticsFactory::kinetics_mutex;
23 
24 Kinetics* KineticsFactory::newKinetics(XML_Node& phaseData,
25  vector<ThermoPhase*> th)
26 {
27  // Look for a child of the XML element phase called "kinetics". It has an
28  // attribute name "model". Store the value of that attribute in the variable
29  // kintype
30  string kintype = phaseData.child("kinetics")["model"];
31 
32  // Create a kinetics object of the desired type
33  Kinetics* k = newKinetics(kintype);
34  // Now that we have the kinetics manager, we can import the reaction
35  // mechanism into it.
36  importKinetics(phaseData, th, k);
37 
38  // Return the pointer to the kinetics manager
39  return k;
40 }
41 
42 KineticsFactory::KineticsFactory() {
43  reg("none", []() { return new Kinetics(); });
44  reg("gaskinetics", []() { return new GasKinetics(); });
45  reg("interface", []() { return new InterfaceKinetics(); });
46  reg("edge", []() { return new EdgeKinetics(); });
47  reg("aqueouskinetics", []() { return new AqueousKinetics(); });
48 }
49 
50 Kinetics* KineticsFactory::newKinetics(const string& model)
51 {
52  return create(ba::to_lower_copy(model));
53 }
54 
55 }
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:97
STL namespace.
bool importKinetics(const XML_Node &phase, std::vector< ThermoPhase *> th, Kinetics *k)
Import a reaction mechanism for a phase or an interface.
Classes providing support for XML data files.
Public interface for kinetics managers.
Definition: Kinetics.h:111
XML_Node & child(const size_t n) const
Return a changeable reference to the n&#39;th child of the current node.
Definition: xml.cpp:546
Definitions of global routines for the importing of data from XML files (see Input File Handling)...
Namespace for the Cantera kernel.
Definition: application.cpp:29