Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Interface.h
Go to the documentation of this file.
1 /**
2  * @file Interface.h
3  * Declaration and Definition for the class Interface.
4  */
5 #ifndef CXX_INTERFACE
6 #define CXX_INTERFACE
7 
8 #include "thermo.h"
9 #include "kinetics.h"
10 
11 namespace Cantera
12 {
13 //! An interface between multiple bulk phases.
14 /*!
15  * This class is defined mostly for convenience. It inherits both from
16  * Cantera::SurfPhase and Cantera::InterfaceKinetics. It therefore
17  * represents a surface phase, and also acts as the kinetics
18  * manager to manage reactions occurring on the surface, possibly
19  * involving species from other phases.
20  */
21 class Interface :
22  public SurfPhase,
23  public InterfaceKinetics
24 {
25 public:
26  //! Constructor.
27  /*!
28  * Construct an Interface instance from a specification in an input file.
29  *
30  * @param infile Cantera input file in CTI or CTML format.
31  * @param id Identification string to distinguish between
32  * multiple definitions within one input file.
33  * @param otherPhases Neighboring phases that may participate in the
34  * reactions on this interface. Don't include the
35  * surface phase
36  */
37  Interface(const std::string& infile, std::string id,
38  std::vector<Cantera::ThermoPhase*> otherPhases) :
39  m_ok(false),
40  m_r(0) {
41  m_r = Cantera::get_XML_File(infile);
42  if (id == "-") {
43  id = "";
44  }
45 
47  if (!x) {
48  throw Cantera::CanteraError("Interface","error in get_XML_Node");
49  }
50  Cantera::importPhase(*x, this);
51  otherPhases.push_back(this);
52  Cantera::importKinetics(*x, otherPhases, this);
53  m_ok = true;
54  }
55 
56  //! Copy Constructor
57  /*!
58  * @param ii Interface object to be copied.
59  */
60  Interface(const Interface& ii) :
61  Cantera::SurfPhase(ii),
62  Cantera::InterfaceKinetics(ii),
63  m_ok(ii.m_ok),
64  m_r(ii.m_r) {
65  }
66 
67  //! Assignment operator
68  /*!
69  * @param right Interface object to be copied.
70  */
71  Interface& operator=(const Interface& right) {
72  if (this == &right) {
73  return *this;
74  }
77  m_ok = right.m_ok;
78  m_r = right.m_r;
79  return *this;
80  }
81 
82  //! Not operator
83  bool operator!() {
84  return !m_ok;
85  }
86 
87  //! return whether the object has been instantiated
88  /*!
89  * @return Returns a bool.
90  */
91  bool ready() const {
92  return m_ok;
93  }
94 
95 protected:
96  //! Flag indicating that the object has been instantiated
97  bool m_ok;
98 
99  //! XML_Node pointer to the XML File object that contains the Surface and the Interfacial Reaction object
100  //! description
102 };
103 
104 //! Import an instance of class Interface from a specification in an input file.
105 /*!
106  * This is the preferred method to create an Interface instance.
107  */
108 inline Interface* importInterface(const std::string& infile,
109  const std::string& id,
110  std::vector<Cantera::ThermoPhase*> phases)
111 {
112  return new Interface(infile, id, phases);
113 }
114 
115 }
116 
117 #endif
Interface(const Interface &ii)
Copy Constructor.
Definition: Interface.h:60
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:105
bool operator!()
Not operator.
Definition: Interface.h:83
bool ready() const
return whether the object has been instantiated
Definition: Interface.h:91
Interface & operator=(const Interface &right)
Assignment operator.
Definition: Interface.h:71
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:100
Interface(const std::string &infile, std::string id, std::vector< Cantera::ThermoPhase * > otherPhases)
Constructor.
Definition: Interface.h:37
Interface * importInterface(const std::string &infile, const std::string &id, std::vector< Cantera::ThermoPhase * > phases)
Import an instance of class Interface from a specification in an input file.
Definition: Interface.h:108
A simple thermodynamic model for a surface phase, assuming an ideal solution model.
Definition: SurfPhase.h:143
bool importPhase(XML_Node &phase, ThermoPhase *th, SpeciesThermoFactory *spfactory)
Import a phase information into an empty ThermoPhase object.
SurfPhase & operator=(const SurfPhase &right)
Assignment operator.
Definition: SurfPhase.cpp:68
bool m_ok
Flag indicating that the object has been instantiated.
Definition: Interface.h:97
bool importKinetics(const XML_Node &phase, std::vector< ThermoPhase * > th, Kinetics *k)
Import a reaction mechanism for a phase or an interface.
Cantera::XML_Node * m_r
XML_Node pointer to the XML File object that contains the Surface and the Interfacial Reaction object...
Definition: Interface.h:101
A kinetics manager for heterogeneous reaction mechanisms.
An interface between multiple bulk phases.
Definition: Interface.h:21
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:99
InterfaceKinetics & operator=(const InterfaceKinetics &right)
Assignment operator.