Eliminated the Cantera_CXX namespace

This commit is contained in:
Ray Speth 2012-01-23 03:35:46 +00:00
parent cea05ab5a5
commit d832f32625
35 changed files with 47 additions and 144 deletions

View file

@ -1,3 +0,0 @@
This directory contains files that are part of the C++ user
interface. For the kernel C++ files, see directory ../src.

View file

@ -4,16 +4,6 @@ Import('env', 'buildTargets', 'installTargets', 'demoTargets')
localenv = env.Clone()
### C++ Interface Library ###
lib = localenv.Library(pjoin('../../lib', 'ctcxx'),
source=mglob(localenv, 'src', 'cpp'))
inst = localenv.Install('$inst_libdir', lib)
buildTargets.extend(lib)
installTargets.extend(inst)
### Demos ###
# (subdir, program name, [source extensions])

View file

@ -5,7 +5,6 @@
#include <cantera/transport.h>
using namespace Cantera;
using namespace Cantera_CXX;
int flamespeed(int np, void* p) {
try {

View file

@ -8,10 +8,6 @@
#ifndef CANTERA_H_INCL
#define CANTERA_H_INCL
namespace Cantera_CXX{ }
using namespace Cantera_CXX;
#include "kernel/ct_defs.h"
// some useful functions

View file

@ -7,11 +7,10 @@
#include "kernel/EdgeKinetics.h"
#include "kernel/importKinetics.h"
using namespace Cantera;
namespace Cantera_CXX {
namespace Cantera {
class Edge :
public Cantera::EdgePhase, public Cantera::EdgeKinetics
public EdgePhase, public EdgeKinetics
{
public:
Edge(std::string infile, std::string id, std::vector<ThermoPhase*> phases)

View file

@ -8,7 +8,7 @@
#include "kernel/importKinetics.h"
#include "kernel/stringUtils.h"
namespace Cantera_CXX {
namespace Cantera {
/**
* This class is a convenience class for use in C++ programs that
@ -20,15 +20,15 @@ namespace Cantera_CXX {
* methods like "getNetReactionRates."
*/
class GRI30 :
public Cantera::IdealGasPhase,
public Cantera::GRI_30_Kinetics
public IdealGasPhase,
public GRI_30_Kinetics
{
public:
GRI30() : m_ok(false), m_r(0) {
m_r = Cantera::get_XML_File("gri30.xml");
m_ok = Cantera::buildSolutionFromXML(*m_r, "gri30",
m_r = get_XML_File("gri30.xml");
m_ok = buildSolutionFromXML(*m_r, "gri30",
"phase", this, this);
if (!m_ok) throw Cantera::CanteraError("GRI30",
if (!m_ok) throw CanteraError("GRI30",
"buildSolutionFromXML returned false");
}
@ -37,7 +37,7 @@ namespace Cantera_CXX {
bool operator!() { return !m_ok;}
bool ready() const { return m_ok; }
friend std::ostream& operator<<(std::ostream& s, GRI30& mix) {
std::string r = Cantera::report(mix, true);
std::string r = mix.report(true);
s << r;
return s;
}

View file

@ -8,11 +8,11 @@
#include "kernel/importKinetics.h"
#include "kernel/stringUtils.h"
namespace Cantera_CXX {
namespace Cantera {
class IdealGasMix :
public Cantera::IdealGasPhase,
public Cantera::GasKinetics
public IdealGasPhase,
public GasKinetics
{
public:
@ -21,36 +21,33 @@ namespace Cantera_CXX {
IdealGasMix(std::string infile, std::string id="") :
m_ok(false), m_r(0) {
m_r = Cantera::get_XML_File(infile);
m_r = get_XML_File(infile);
m_id = id;
if (id == "-") id = "";
m_ok = Cantera::buildSolutionFromXML(*m_r,
m_ok = buildSolutionFromXML(*m_r,
m_id, "phase", this, this);
if (!m_ok) throw Cantera::CanteraError("IdealGasMix",
if (!m_ok) throw CanteraError("IdealGasMix",
"Cantera::buildSolutionFromXML returned false");
}
IdealGasMix(Cantera::XML_Node& root,
IdealGasMix(XML_Node& root,
std::string id) : m_ok(false), m_r(&root), m_id(id) {
m_ok = Cantera::buildSolutionFromXML(root, id,
"phase", this, this);
m_ok = buildSolutionFromXML(root, id, "phase", this, this);
}
IdealGasMix(const IdealGasMix& other) : m_ok(false),
m_r(other.m_r),
m_id(other.m_id) {
m_ok = Cantera::buildSolutionFromXML(*m_r, m_id,
"phase", this, this);
m_ok = buildSolutionFromXML(*m_r, m_id, "phase", this, this);
}
virtual ~IdealGasMix() {}
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);
std::string r = mix.report(true);
s << r;
return s;
}
@ -58,7 +55,7 @@ namespace Cantera_CXX {
protected:
bool m_ok;
Cantera::XML_Node* m_r;
XML_Node* m_r;
std::string m_id;
private:

View file

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

View file

@ -1,7 +1,6 @@
/**
* @file Interface.h
* Declaration and Definition for the class Interface, part of
* Cantera's Cantera_CXX namespace.
* Declaration and Definition for the class Interface.
*/
#ifndef CXX_INTERFACE
#define CXX_INTERFACE
@ -14,22 +13,19 @@
// #include "kernel/InterfaceKinetics.h"
// #include "kernel/importKinetics.h"
/**
* This namespace is used for the Cantera C++ user interface.
*/
namespace Cantera_CXX {
namespace Cantera {
/**
* An interface between multiple bulk phases. This class is
* defined mostly for convenience. It inherits both from
* Cantera::SurfPhase and Cantera::InterfaceKinetics. It therefore
* SurfPhase and InterfaceKinetics. It therefore
* represents a surface phase, and also acts as the kinetics
* manager to manage reaction occurring on the surface, possibly
* involving species from other phases.
*/
class Interface :
public Cantera::SurfPhase,
public Cantera::InterfaceKinetics
public SurfPhase,
public InterfaceKinetics
{
public:
@ -43,18 +39,18 @@ namespace Cantera_CXX {
* reactions on this interface.
*/
Interface(std::string infile, std::string id,
std::vector<Cantera::ThermoPhase*> phases)
std::vector<ThermoPhase*> phases)
: m_ok(false), m_r(0) {
m_r = Cantera::get_XML_File(infile);
m_r = get_XML_File(infile);
if (id == "-") id = "";
Cantera::XML_Node* x = Cantera::get_XML_Node("#"+id, m_r);
XML_Node* x = get_XML_Node("#"+id, m_r);
if (!x)
throw Cantera::CanteraError("Interface","error in get_XML_Node");
throw CanteraError("Interface","error in get_XML_Node");
Cantera::importPhase(*x, this);
importPhase(*x, this);
phases.push_back(this);
Cantera::importKinetics(*x, phases, this);
importKinetics(*x, phases, this);
m_ok = true;
}
@ -66,7 +62,7 @@ namespace Cantera_CXX {
protected:
bool m_ok;
Cantera::XML_Node* m_r;
XML_Node* m_r;
private:
};
@ -77,7 +73,7 @@ namespace Cantera_CXX {
* instance.
*/
inline Interface* importInterface(std::string infile, std::string id,
std::vector<Cantera::ThermoPhase*> phases) {
std::vector<ThermoPhase*> phases) {
return new Interface(infile, id, phases);
}

View file

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

View file

@ -35,7 +35,7 @@ namespace Cantera {
bool operator!() { return !m_ok;}
bool ready() const { return m_ok; }
friend std::ostream& operator<<(std::ostream& s, PureFluid& mix) {
std::string r = Cantera::report(mix, true);
std::string r = mix.report(true);
s << r;
return s;
}

View file

@ -1,25 +0,0 @@
#ifndef CXX_IMPORTPHASE
#define CXX_IMPORTPHASE
#include <string>
#include "kernel/ThermoPhase.h"
#include "kernel/ThermoFactory.h"
/*
* The Definitions for these functions are all located in
* libctxx.a
*/
namespace Cantera_CXX {
Cantera::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 Cantera::ThermoPhase& th, bool show_thermo);
std::string formatCompList(const Cantera::Phase& mix, int xyc);
}
#endif

View file

@ -10,7 +10,6 @@
#define CT_THERMO_INCL
#include "kernel/ThermoFactory.h"
#include "importPhase.h"
#include "kernel/SurfPhase.h"
#include "kernel/EdgePhase.h"

View file

@ -1,20 +0,0 @@
/**
* @file cxx/src/importPhase.cpp
*/
#include <string>
#include "kernel/ThermoPhase.h"
#include "kernel/ThermoFactory.h"
namespace Cantera {}
namespace Cantera_CXX {
Cantera::ThermoPhase* importPhase(std::string infile, std::string id) {
Cantera::ThermoPhase* p = Cantera::newPhase(infile, id);
return p;
}
}

View file

@ -30,7 +30,6 @@
#include <cantera/IdealGasMix.h>
using namespace Cantera;
using namespace Cantera_CXX;
// store a pointer to an IdealGasMix object
static IdealGasMix* _gas = 0;

View file

@ -8,7 +8,6 @@
using namespace std;
using namespace Cantera;
using namespace Cantera_CXX;
int main(int argc, char **argv) {
#ifdef _MSC_VER

View file

@ -15,7 +15,6 @@
using namespace std;
using namespace Cantera;
using namespace Cantera_CXX;
int main(int argc, char **argv) {
#ifdef _MSC_VER

View file

@ -12,7 +12,6 @@
using namespace std;
using namespace Cantera;
using namespace Cantera_CXX;
int main(int argc, char **argv) {
#ifdef _MSC_VER

View file

@ -4,7 +4,6 @@
using namespace std;
using namespace Cantera;
using namespace Cantera_CXX;
int main(int argc, char **argv) {
#ifdef _MSC_VER

View file

@ -15,7 +15,6 @@
using namespace std;
using namespace Cantera;
using namespace Cantera_CXX;
int main(int argc, char **argv) {
#ifdef _MSC_VER

View file

@ -27,7 +27,6 @@ using namespace std;
#include "kernel/TransportFactory.h"
using namespace Cantera;
using namespace Cantera_CXX;
void printDbl(double val) {
if (fabs(val) < 5.0E-17) {

View file

@ -12,7 +12,6 @@
#include <cantera/IdealGasMix.h>
using namespace Cantera;
using namespace Cantera_CXX;
//-------------------------------------------------------------------
// utility functions for plotting

View file

@ -11,7 +11,6 @@
#include <cantera/IdealGasMix.h>
#include "example_utils.h"
using namespace Cantera;
using namespace Cantera_CXX;
using namespace CanteraZeroD;
using namespace std;

View file

@ -12,7 +12,6 @@
#include "example_utils.h"
using namespace Cantera;
using namespace Cantera_CXX;
/**
* Same as kinetics_example1, except that it uses class GRI30 instead
* of class IdealGasMix.

View file

@ -12,7 +12,6 @@
#include "example_utils.h"
using namespace Cantera;
using namespace Cantera_CXX;
// Kinetics example. This is written as a function so that one
// driver program can run multiple examples.

View file

@ -15,7 +15,6 @@
// #include <iostream>
// using namespace std;
using namespace Cantera;
using namespace Cantera_CXX;
void writeRxnPathDiagram(double time, ReactionPathBuilder& b,
IdealGasMix& gas, ostream& logfile, ostream& outfile) {

View file

@ -12,7 +12,6 @@
#include <cantera/IdealGasMix.h>
using namespace Cantera;
using namespace Cantera_CXX;
template<class G, class V>
void makeTransportDataLabels(const G& gas, V& names) {

View file

@ -13,7 +13,6 @@
#include <cantera/IdealGasMix.h>
using namespace Cantera;
using namespace Cantera_CXX;
template<class G, class V>
void makeTransportDataLabels(const G& gas, V& names) {

View file

@ -39,7 +39,6 @@ using namespace std;
#include "kernel/TransportFactory.h"
using namespace Cantera;
using namespace Cantera_CXX;
void printDbl(double val) {
if (fabs(val) < 5.0E-17) {

View file

@ -39,7 +39,6 @@ using namespace std;
#include "kernel/TransportFactory.h"
using namespace Cantera;
using namespace Cantera_CXX;
void printDbl(double val) {
if (fabs(val) < 1.0E-17) {

View file

@ -15,7 +15,6 @@
using namespace std;
using namespace Cantera;
using namespace Cantera_CXX;
int main(int argc, char **argv) {
#ifdef _MSC_VER

View file

@ -9,9 +9,7 @@
#include "Interface.h"
using namespace Cantera;
using namespace Cantera_CXX;
using namespace std;
using namespace Cantera_CXX;
int main() {

View file

@ -4,7 +4,7 @@ Import('env', 'buildTargets', 'installTargets')
localenv = env.Clone()
programs = [('cti2ctml', ['src/cti2ctml.cpp'], ['ctbase']),
('ck2cti', ['src/ck2cti.cpp'], ['converters','ctbase','tpx','ctcxx']),
('ck2cti', ['src/ck2cti.cpp'], ['converters','ctbase','tpx']),
('csvdiff', mglob(localenv, 'testtools', 'cpp'), [])]
for name, src, libs in programs:

View file

@ -19,15 +19,11 @@
#include <cantera/equilibrium.h> // chemical equilibrium
#include <cantera/transport.h> // transport properties
// 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.

View file

@ -30,7 +30,6 @@
#include <cantera/IdealGasMix.h>
using namespace Cantera;
using namespace Cantera_CXX;
// store a pointer to an IdealGasMix object
static IdealGasMix* _gas = 0;