Cantera  2.1.2
IdealGasMix.h
Go to the documentation of this file.
1 //! @file IdealGasMix.h
2 #ifndef CXX_IDEALGASMIX
3 #define CXX_IDEALGASMIX
4 
5 #include "thermo/IdealGasPhase.h"
6 #include "kinetics/GasKinetics.h"
8 #include "base/stringUtils.h"
9 
10 namespace Cantera
11 {
12 
13 class IdealGasMix :
14  public IdealGasPhase,
15  public GasKinetics
16 {
17 public:
18 
19  IdealGasMix() : m_ok(false), m_r(0) {}
20 
21  IdealGasMix(const std::string& infile, std::string id_="") :
22  m_ok(false), m_r(0) {
23 
24  m_r = get_XML_File(infile);
25  m_id = id_;
26  if (id_ == "-") {
27  id_ = "";
28  }
29  m_ok = buildSolutionFromXML(*m_r,
30  m_id, "phase", this, this);
31  if (!m_ok) throw CanteraError("IdealGasMix",
32  "Cantera::buildSolutionFromXML returned false");
33  }
34 
35 
36  IdealGasMix(XML_Node& root,
37  std::string id_) : m_ok(false), m_r(&root), m_id(id_) {
38  m_ok = buildSolutionFromXML(root, id_, "phase", this, this);
39  }
40 
41  IdealGasMix(const IdealGasMix& other) : m_ok(false),
42  m_r(other.m_r),
43  m_id(other.m_id) {
44  m_ok = buildSolutionFromXML(*m_r, m_id, "phase", this, this);
45  }
46 
47  bool operator!() {
48  return !m_ok;
49  }
50  bool ready() const {
51  return m_ok;
52  }
53  friend std::ostream& operator<<(std::ostream& s, IdealGasMix& mix) {
54  std::string r = mix.report(true);
55  s << r;
56  return s;
57  }
58 
59 
60 protected:
61  bool m_ok;
62  XML_Node* m_r;
63  std::string m_id;
64 
65 private:
66 };
67 }
68 
69 
70 #endif
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:144
bool buildSolutionFromXML(XML_Node &root, const std::string &id, const std::string &nm, ThermoPhase *th, Kinetics *k)
Build a single-phase ThermoPhase object with associated kinetics mechanism.
ThermoPhase object for the ideal gas equation of state - workhorse for Cantera (see Thermodynamic Pro...
Definitions of global routines for the importing of data from XML files (see Input File Handling)...
Contains declarations for string manipulation functions within Cantera.