Cantera  2.3.0
Interface.h
Go to the documentation of this file.
1 /**
2  * @file Interface.h
3  * Declaration and Definition for the class Interface.
4  */
5 
6 // This file is part of Cantera. See License.txt in the top-level directory or
7 // at http://www.cantera.org/license.txt for license and copyright information.
8 
9 #ifndef CXX_INTERFACE
10 #define CXX_INTERFACE
11 
12 #include "thermo.h"
13 #include "kinetics.h"
16 
17 namespace Cantera
18 {
19 //! An interface between multiple bulk phases.
20 /*!
21  * This class is defined mostly for convenience. It inherits both from SurfPhase
22  * and InterfaceKinetics. It therefore represents a surface phase, and also acts
23  * as the kinetics manager to manage reactions occurring on the surface,
24  * possibly involving species from other phases.
25  */
26 class Interface :
27  public SurfPhase,
28  public InterfaceKinetics
29 {
30 public:
31  //! Constructor.
32  /*!
33  * Construct an Interface instance from a specification in an input file.
34  *
35  * @param infile Cantera input file in CTI or CTML format.
36  * @param id Identification string to distinguish between multiple
37  * definitions within one input file.
38  * @param otherPhases Neighboring phases that may participate in the
39  * reactions on this interface. Don't include the surface phase
40  */
41  Interface(const std::string& infile, std::string id,
42  std::vector<ThermoPhase*> otherPhases) :
43  m_ok(false),
44  m_r(0) {
45  m_r = get_XML_File(infile);
46  if (id == "-") {
47  id = "";
48  }
49 
50  XML_Node* x = get_XML_Node("#"+id, m_r);
51  if (!x) {
52  throw CanteraError("Interface","error in get_XML_Node");
53  }
54  importPhase(*x, this);
55  otherPhases.push_back(this);
56  importKinetics(*x, otherPhases, this);
57  m_ok = true;
58  }
59 
60  Interface(const Interface& ii) :
61  SurfPhase(ii),
63  m_ok(ii.m_ok),
64  m_r(ii.m_r) {
65  }
66 
67  Interface& operator=(const Interface& right) {
68  if (this == &right) {
69  return *this;
70  }
71  SurfPhase::operator=(right);
72  InterfaceKinetics::operator=(right);
73  m_ok = right.m_ok;
74  m_r = right.m_r;
75  return *this;
76  }
77 
78  //! Not operator
79  bool operator!() {
80  return !m_ok;
81  }
82 
83  //! return whether the object has been instantiated
84  bool ready() const {
85  return m_ok;
86  }
87 
88 protected:
89  //! Flag indicating that the object has been instantiated
90  bool m_ok;
91 
92  //! XML_Node pointer to the XML File object that contains the Surface and
93  //! the Interfacial Reaction object description
95 };
96 
97 //! Import an instance of class Interface from a specification in an input file.
98 /*!
99  * This is the preferred method to create an Interface instance.
100  */
101 inline Interface* importInterface(const std::string& infile,
102  const std::string& id,
103  std::vector<ThermoPhase*> phases)
104 {
105  return new Interface(infile, id, phases);
106 }
107 
108 }
109 
110 #endif
XML_Node * get_XML_Node(const std::string &file_ID, XML_Node *root)
This routine will locate an XML node in either the input XML tree or in another input file specified ...
Definition: global.cpp:214
Support for thermo property calculation from C++ application programs.
XML_Node * get_XML_File(const std::string &file, int debug)
Return a pointer to the XML tree for a Cantera input file.
Definition: global.cpp:96
Header for a simple thermodynamics model of a surface phase derived from ThermoPhase, assuming an ideal solution model (see Thermodynamic Properties and class SurfPhase).
bool operator!()
Not operator.
Definition: Interface.h:79
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:97
bool ready() const
return whether the object has been instantiated
Definition: Interface.h:84
Interface(const std::string &infile, std::string id, std::vector< ThermoPhase *> otherPhases)
Constructor.
Definition: Interface.h:41
A simple thermodynamic model for a surface phase, assuming an ideal solution model.
Definition: SurfPhase.h:143
bool m_ok
Flag indicating that the object has been instantiated.
Definition: Interface.h:90
bool importKinetics(const XML_Node &phase, std::vector< ThermoPhase *> th, Kinetics *k)
Import a reaction mechanism for a phase or an interface.
Interface * importInterface(const std::string &infile, const std::string &id, std::vector< ThermoPhase *> phases)
Import an instance of class Interface from a specification in an input file.
Definition: Interface.h:101
A kinetics manager for heterogeneous reaction mechanisms.
Support for chemical kinetics calculation from C++ application programs.
XML_Node * m_r
XML_Node pointer to the XML File object that contains the Surface and the Interfacial Reaction object...
Definition: Interface.h:94
An interface between multiple bulk phases.
Definition: Interface.h:26
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:65
void importPhase(XML_Node &phase, ThermoPhase *th)
Import a phase information into an empty ThermoPhase object.
Namespace for the Cantera kernel.
Definition: application.cpp:29