put all C++ interface code in the Cantera_CXX namespace

This commit is contained in:
Dave Goodwin 2008-02-14 04:37:43 +00:00
parent 12650d695a
commit 4a1d303fe4
11 changed files with 78 additions and 67 deletions

View file

@ -7,7 +7,7 @@
#include "kernel/EdgeKinetics.h"
#include "kernel/importKinetics.h"
namespace Cantera {
namespace Cantera_CXX {
class Edge :
public EdgePhase, public EdgeKinetics

View file

@ -11,20 +11,30 @@
#include "kernel/importKinetics.h"
#include "kernel/stringUtils.h"
namespace Cantera {
namespace Cantera_CXX {
/**
* This class is a convenience class for use in C++ programs that
* hard-wires the GRI 3.0 reaction mechanism. It derivees from
* both Cantera::IdealGasPhase, which handles all composition and
* state information, as well as thermodynamic properties, and
* class GRI_30_Kinetics, which is the kinetics manager with
* hard-wired replacements for some of the generic kinetics
* methods like "getNetReactionRates."
*/
class GRI30 :
public IdealGasPhase, public GRI_30_Kinetics
public Cantera::IdealGasPhase,
public Cantera::GRI_30_Kinetics
{
public:
GRI30() : m_ok(false), m_r(0) {
m_r = get_XML_File("gri30.xml");
m_ok = buildSolutionFromXML(*m_r, "gri30", "phase", this, this);
m_ok = Cantera::buildSolutionFromXML(*m_r, "gri30",
"phase", this, this);
if (!m_ok) throw CanteraError("GRI30",
"buildSolutionFromXML returned false");
}
virtual ~GRI30() {}
bool operator!() { return !m_ok;}
@ -37,7 +47,7 @@ namespace Cantera {
protected:
bool m_ok;
XML_Node* m_r;
Cantera::XML_Node* m_r;
private:
};

View file

@ -8,27 +8,32 @@
#include "kernel/importKinetics.h"
#include "kernel/stringUtils.h"
namespace Cantera {
namespace Cantera_CXX {
class IdealGasMix :
public IdealGasPhase, public GasKinetics
public Cantera::IdealGasPhase,
public Cantera::GasKinetics
{
public:
IdealGasMix() : m_ok(false), m_r(0) {}
IdealGasMix(std::string infile, std::string id="") : m_ok(false), m_r(0) {
IdealGasMix(std::string infile, std::string id="") :
m_ok(false), m_r(0) {
m_r = get_XML_File(infile);
if (id == "-") id = "";
m_ok = buildSolutionFromXML(*m_r, id, "phase", this, this);
if (!m_ok) throw CanteraError("IdealGasMix",
"buildSolutionFromXML returned false");
m_r = Cantera::get_XML_File(infile);
if (id == "-") id = "";
m_ok = Cantera::buildSolutionFromXML(*m_r,
id, "phase", this, this);
if (!m_ok) throw Cantera::CanteraError("IdealGasMix",
"Cantera::buildSolutionFromXML returned false");
}
IdealGasMix(XML_Node& root, std::string id) : m_ok(false), m_r(0) {
m_ok = buildSolutionFromXML(root, id, "phase", this, this);
IdealGasMix(Cantera::XML_Node& root,
std::string id) : m_ok(false), m_r(0) {
m_ok = Cantera::buildSolutionFromXML(root, id,
"phase", this, this);
}
virtual ~IdealGasMix() {}
@ -43,7 +48,7 @@ namespace Cantera {
protected:
bool m_ok;
XML_Node* m_r;
Cantera::XML_Node* m_r;
private:
};

View file

@ -6,18 +6,19 @@
#include "kernel/ConstDensityThermo.h"
#include "kernel/importKinetics.h"
namespace Cantera {
namespace Cantera_CXX {
class IncompressibleSolid : public ConstDensityThermo
class IncompressibleSolid : public Cantera::ConstDensityThermo
{
public:
IncompressibleSolid(std::string infile, std::string id="") : m_ok(false), m_r(0) {
IncompressibleSolid(std::string infile,
std::string id="") : m_ok(false), m_r(0) {
m_r = get_XML_File(infile);
if (id == "-") id = "";
m_ok = buildSolutionFromXML(*m_r, id, "phase", this, 0);
if (!m_ok) throw CanteraError("IncompressibleSolid",
"buildSolutionFromXML returned false");
m_r = Cantera::get_XML_File(infile);
if (id == "-") id = "";
m_ok = Cantera::buildSolutionFromXML(*m_r, id, "phase", this, 0);
if (!m_ok) throw Cantera::CanteraError("IncompressibleSolid",
"buildSolutionFromXML returned false");
}
@ -33,7 +34,7 @@ namespace Cantera {
protected:
bool m_ok;
XML_Node* m_r;
Cantera::XML_Node* m_r;
private:
};

View file

@ -6,34 +6,28 @@
#include "kernel/MetalPhase.h"
#include "kernel/importKinetics.h"
namespace Cantera {
namespace Cantera_CXX {
class Metal : public MetalPhase
class Metal : public Cantera::MetalPhase
{
public:
Metal(std::string infile, std::string id="") : m_ok(false), m_r(0) {
m_r = get_XML_File(infile);
if (id == "-") id = "";
m_ok = buildSolutionFromXML(*m_r, id, "phase", this, 0);
if (!m_ok) throw CanteraError("Metal",
"buildSolutionFromXML returned false");
m_r = Cantera::get_XML_File(infile);
if (id == "-") id = "";
m_ok = Cantera::buildSolutionFromXML(*m_r, id, "phase", this, 0);
if (!m_ok) throw Cantera::CanteraError("Metal",
"buildSolutionFromXML returned false");
}
virtual ~Metal() {}
bool operator!() { return !m_ok;}
bool ready() const { return m_ok; }
//friend std::ostream& operator<<(std::ostream& s, IdealGasMix& mix) {
// std::string r = Cantera::report(mix, true);
// s << r;
// return s;
protected:
bool m_ok;
XML_Node* m_r;
Cantera::XML_Node* m_r;
private:
};

View file

@ -11,15 +11,14 @@
* libctxx.a
*/
namespace Cantera {
ThermoPhase* importPhase(std::string infile, std::string id="");
namespace Cantera_CXX {
ThermoPhase* importPhase(std::string infile, std::string id="");
// -> this is a duplicate of a src/thermo/phasereport function
// We'll leave it here so that these are available externally
std::string report(const ThermoPhase& th, bool show_thermo);
// -> this is a duplicate of a src/thermo/phasereport function
// We'll leave it here so that these are available externally
std::string report(const Cantera::ThermoPhase& th, bool show_thermo);
std::string formatCompList(const Phase& mix, int xyc);
std::string formatCompList(const Cantera::Phase& mix, int xyc);
}

View file

@ -8,10 +8,10 @@
#include "ThermoFactory.h"
//#include "../include/importPhase.h"
namespace Cantera {
namespace Cantera_CXX {
ThermoPhase* importPhase(std::string infile, std::string id) {
ThermoPhase* p = newPhase(infile, id);
Cantera::ThermoPhase* importPhase(std::string infile, std::string id) {
Cantera::ThermoPhase* p = Cantera::newPhase(infile, id);
return p;
}
}

View file

@ -10,9 +10,9 @@
#include <string>
#include <iostream>
using namespace std;
//using namespace std;
namespace Cantera {
namespace Cantera_CXX {
/**
*
* writelog():
@ -38,14 +38,14 @@ namespace Cantera {
* own versions of writelog.
*/
void writelog(const string& s) {
cout << s;
std::cout << s;
}
/**
* Write an error message and quit.
*/
void error(const string& msg) {
cerr << msg << endl;
void error(const std::string& msg) {
std::cerr << msg << endl;
exit(-1);
}

View file

@ -221,11 +221,12 @@ namespace Cantera {
*/
virtual void getNetProductionRates(doublereal* net) {
updateROP();
#ifdef HWMECH
get_wdot(&m_kdata->m_ropnet[0], net);
#else
m_rxnstoich->getNetProductionRates(m_kk, &m_kdata->m_ropnet[0], net);
#endif
//#ifdef HWMECH
//get_wdot(&m_kdata->m_ropnet[0], net);
//#else
m_rxnstoich->getNetProductionRates(m_kk,
&m_kdata->m_ropnet[0], net);
//#endif
}
/**

View file

@ -24,18 +24,17 @@
namespace Cantera {
//! A simple thermoydnamics model for a surface phase,
//! assuming an ideal solution model.
/*!
* The surface consists of a grid of equivalent sites. Surface species may be defined to
* The surface consists of a grid of equivalent sites.
* Surface species may be defined to
* occupy one or more sites. The surface species are assumed to be
* independent, and thus the species form an ideal solution.
*
* The density of surface sites is given by the variable \f$ n_0 \f$, which has MKS units
* of kmol m-2.
*
* The density of surface sites is given by the variable \f$ n_0 \f$,
* which has SI units of kmol m-2.
*
* <b> Specification of Species Standard State Properties </b>
*

View file

@ -20,11 +20,13 @@
#include <cantera/transport.h> // transport properties
// All Cantera names are in namespace Cantera. You can either
// All Cantera kernel names are in namespace Cantera. You can either
// reference everything as Cantera::<name>, or include the following
// 'using namespace' line.
using namespace Cantera;
using namespace Cantera_CXX;
// All Cantera C++ interface names are in namespace Cantera_CXX
// The program is put into a function so that error handling code can
// be conveniently put around the whole thing. See main() below.