Streamlined interface to class Cabinet

This commit is contained in:
Ray Speth 2012-02-27 18:11:47 +00:00
parent 3648bfef39
commit 2da9603a15
12 changed files with 374 additions and 492 deletions

View file

@ -55,13 +55,15 @@
* instance. This function calls the constructor on the first call and
* stores the pointer to this instance. Subsequent calls simply return
* the already-created pointer.
*
* Set canDelete to false if the 'clear' method should not delete the entries.
*/
template<class M>
template<class M, bool canDelete=true>
class Cabinet
{
public:
typedef std::vector<M*>& dataRef;
/**
* Destructor. Delete all objects in the list.
*/
@ -69,41 +71,25 @@ public:
clear();
}
/**
* Static function that returns a pointer to the one Cabinet<M>
* instance. All access to the Cabinet<M> instance should go
* through this function.
*/
static Cabinet<M>* cabinet(bool canDelete = true) {
if (__storage == 0) {
__storage = new Cabinet<M>(canDelete);
}
return __storage;
}
/**
* Add a new object. The index of the object is returned.
*/
int add(M* ptr) {
//try {
__table.push_back(ptr);
return static_cast<int>(__table.size()) - 1;
//}
//catch (CanteraError) {return -1;}
//catch (...) {return -999;}
static int add(M* ptr) {
dataRef data = getData();
data.push_back(ptr);
return static_cast<int>(data.size()) - 1;
}
/**
* Make a new copy of an existing object. The index of the new
* object is returned.
*/
int newCopy(int i) {
static int newCopy(int i) {
dataRef data = getData();
try {
M* old = __table[i];
__table.push_back(new M(*old));
return static_cast<int>(__table.size()) - 1;
M* old = data[i];
data.push_back(new M(*old));
return static_cast<int>(data.size()) - 1;
} catch (Cantera::CanteraError) {
return -1;
} catch (...) {
@ -111,16 +97,16 @@ public:
}
}
/**
* Assign one object (index j) to another (index i). This method
* is not used currently, and may be removed from the class in the
* future.
*/
int assign(int i, int j) {
static int assign(int i, int j) {
dataRef data = getData();
try {
M* src = __table[j];
M* dest = __table[i];
M* src = data[j];
M* dest = data[i];
*dest = *src;
return 0;
} catch (Cantera::CanteraError) {
@ -130,96 +116,94 @@ public:
}
}
/**
* Delete all objects but the first.
*/
int clear() {
int i, n;
n = static_cast<int>(__table.size());
for (i = 1; i < n; i++) {
static int clear() {
dataRef data = getData();
int n = static_cast<int>(data.size());
for (int i = 1; i < n; i++) {
del(i);
}
if (_can_delete) {
delete __table[0];
if (canDelete) {
delete data[0];
}
__table.clear();
data.clear();
add(new M);
return 0;
}
/**
* Delete the nth object. After the object is deleted, the pointer
* to it in the list is replaced by a pointer to the first element
* in the list.
*/
void del(int n) {
static void del(int n) {
dataRef data = getData();
if (n == 0) {
return;
}
if (__table[n] != __table[0]) {
if (_can_delete) {
delete __table[n];
if (data[n] != data[0]) {
if (canDelete) {
delete data[n];
}
__table[n] = __table[0];
data[n] = data[0];
} else {
throw Cantera::CanteraError("Cabinet<M>::del",
"Attempt made to delete an already-deleted object.");
}
}
/**
* Return a pointer to object n.
* Return a reference to object n.
*/
M* item(size_t n) {
if (n < __table.size()) {
return __table[n];
static M& item(size_t n) {
dataRef data = getData();
if (n < data.size()) {
return *data[n];
} else {
throw Cantera::CanteraError("item","index out of range"+Cantera::int2str(int(n)));
//return __table[0];
}
}
/**
* Constructor.
*/
Cabinet(bool canDelete = true) : _can_delete(canDelete) {
add(new M);
Cabinet() {
__table.push_back(new M);
}
private:
/**
* Constructor.
* Static function that returns a pointer to the data member of
* the singleton Cabinet<M> instance. All member functions should
* access the data through this function.
*/
// Cabinet(bool canDelete = true) : _can_delete(canDelete) { add(new M); }
static dataRef getData() {
if (__storage == 0) {
__storage = new Cabinet<M, canDelete>();
}
return __storage->__table;
}
/**
* Pointer to the single instance of this class.
*/
static Cabinet<M>* __storage;
static Cabinet<M, canDelete>* __storage;
/**
* Vector to hold pointers to objects.
*/
std::vector<M*> __table;
/**
* Set to false if 'clear' should not delete the entries.
*/
bool _can_delete;
};
//! Declaration stating that the storage for the static member
//! of each instanteated template will exist
//! of each instantiated template will exist
/*!
* The actual storage will be allocated in .cpp files
*/
#ifdef NEEDS_GENERIC_TEMPL_STATIC_DECL
template<class M> Cabinet<M>* Cabinet<M>::__storage;
template<class M, bool canDelete> Cabinet<M, canDelete>* Cabinet<M, canDelete>::__storage;
#endif
#endif

View file

@ -32,12 +32,7 @@ using namespace Cantera;
#include "windows.h"
#endif
inline XML_Node* _xml(int i)
{
return Cabinet<Cantera::XML_Node>::cabinet(false)->item(i);
}
typedef Cabinet<XML_Node, false> XmlCabinet;
#ifdef WITH_PURE_FLUIDS
static PureFluidPhase* purefluid(int n)
@ -448,8 +443,8 @@ extern "C" {
size_t DLL_EXPORT newThermoFromXML(int mxml)
{
try {
XML_Node* x = _xml(mxml);
thermo_t* th = newPhase(*x);
XML_Node& x = XmlCabinet::item(mxml);
thermo_t* th = newPhase(x);
return Storage::storage()->addThermo(th);
} catch (CanteraError) {
return -1;
@ -879,7 +874,7 @@ extern "C" {
int neighbor4)
{
try {
XML_Node* x = _xml(mxml);
XML_Node& x = XmlCabinet::item(mxml);
vector<thermo_t*> phases;
phases.push_back(th(iphase));
if (neighbor1 >= 0) {
@ -894,7 +889,7 @@ extern "C" {
}
}
}
Kinetics* kin = newKineticsMgr(*x, phases);
Kinetics* kin = newKineticsMgr(x, phases);
if (kin) {
return Storage::storage()->addKinetics(kin);
} else {
@ -909,10 +904,10 @@ extern "C" {
char* default_phase)
{
try {
XML_Node* p = _xml(pxml);
XML_Node& p = XmlCabinet::item(pxml);
kinetics_t* k = kin(ikin);
string defphase = string(default_phase);
installReactionArrays(*p, *k, defphase);
installReactionArrays(p, *k, defphase);
return 0;
} catch (CanteraError) {
return -1;
@ -1376,10 +1371,10 @@ extern "C" {
int DLL_EXPORT import_phase(int nth, int nxml, char* id)
{
thermo_t* thrm = th(nth);
XML_Node* node = _xml(nxml);
XML_Node& node = XmlCabinet::item(nxml);
string idstr = string(id);
try {
importPhase(*node, thrm);
importPhase(node, thrm);
return 0;
} catch (CanteraError) {
return -1;
@ -1393,11 +1388,11 @@ extern "C" {
for (int i = 0; i < nphases; i++) {
phases.push_back(th(ith[i]));
}
XML_Node* node = _xml(nxml);
XML_Node& node = XmlCabinet::item(nxml);
Kinetics* k = kin(nkin);
string idstr = string(id);
try {
importKinetics(*node, phases, k);
importKinetics(node, phases, k);
return 0;
} catch (CanteraError) {
return -1;
@ -1526,7 +1521,7 @@ extern "C" {
XML_Node* root = 0;
if (ixml > 0) {
root = _xml(ixml);
root = &XmlCabinet::item(ixml);
}
thermo_t* t = th(ith);

View file

@ -15,12 +15,8 @@
using namespace std;
using namespace Cantera;
template<> Cabinet<Bdry1D>* Cabinet<Bdry1D>::__storage = 0;
inline Bdry1D* _bndry(int i)
{
return Cabinet<Bdry1D>::cabinet()->item(i);
}
typedef Cabinet<Bdry1D> BoundaryCabinet;
template<> BoundaryCabinet* BoundaryCabinet::__storage = 0;
//inline Phase* _phase(int n) {
// return Storage::__storage->__phasetable[n];
@ -57,25 +53,25 @@ extern "C" {
default:
return -2;
}
int i = Cabinet<Bdry1D>::cabinet()->add(s);
int i = BoundaryCabinet::add(s);
return i;
}
int DLL_EXPORT bndry_del(int i)
{
Cabinet<Bdry1D>::cabinet()->del(i);
BoundaryCabinet::del(i);
return 0;
}
double DLL_EXPORT bndry_temperature(int i)
{
return _bndry(i)->temperature();
return BoundaryCabinet::item(i).temperature();
}
int DLL_EXPORT bndry_settemperature(int i, double t)
{
try {
_bndry(i)->setTemperature(t);
BoundaryCabinet::item(i).setTemperature(t);
} catch (CanteraError) {
return -1;
}
@ -85,7 +81,7 @@ extern "C" {
double DLL_EXPORT bndry_spreadrate(int i)
{
try {
return ((Inlet1D*)_bndry(i))->spreadRate();
return dynamic_cast<Inlet1D*>(&BoundaryCabinet::item(i))->spreadRate();
} catch (CanteraError) {
return -1;
}
@ -95,7 +91,7 @@ extern "C" {
int DLL_EXPORT bndry_setSpreadRate(int i, double v)
{
try {
((Inlet1D*)_bndry(i))->setSpreadRate(v);
dynamic_cast<Inlet1D*>(&BoundaryCabinet::item(i))->setSpreadRate(v);
} catch (CanteraError) {
return -1;
}
@ -105,7 +101,7 @@ extern "C" {
int DLL_EXPORT bndry_setmdot(int i, double mdot)
{
try {
_bndry(i)->setMdot(mdot);
BoundaryCabinet::item(i).setMdot(mdot);
} catch (CanteraError) {
return -1;
}
@ -115,14 +111,13 @@ extern "C" {
double DLL_EXPORT bndry_mdot(int i)
{
return _bndry(i)->mdot();
return 0;
return BoundaryCabinet::item(i).mdot();
}
int DLL_EXPORT bndry_setxin(int i, double* xin)
{
try {
_bndry(i)->setMoleFractions(xin);
BoundaryCabinet::item(i).setMoleFractions(xin);
} catch (CanteraError) {
return -1;
}
@ -132,7 +127,7 @@ extern "C" {
int DLL_EXPORT bndry_setxinbyname(int i, char* xin)
{
try {
_bndry(i)->setMoleFractions(string(xin));
BoundaryCabinet::item(i).setMoleFractions(string(xin));
} catch (CanteraError) {
return -1;
}
@ -142,7 +137,7 @@ extern "C" {
int DLL_EXPORT surf_setkinetics(int i, int j)
{
try {
ReactingSurf1D* srf = (ReactingSurf1D*)_bndry(i);
ReactingSurf1D* srf = dynamic_cast<ReactingSurf1D*>(&BoundaryCabinet::item(i));
InterfaceKinetics* k = (InterfaceKinetics*)_kin(j);
srf->setKineticsMgr(k);
} catch (CanteraError) {

View file

@ -7,7 +7,6 @@
#include "cantera/numerics/Func1.h"
#include "cantera/base/ctexceptions.h"
#include "Cabinet.h"
using namespace Cantera;
@ -15,13 +14,9 @@ using namespace std;
typedef Func1 func_t;
typedef Cabinet<Func1> FuncCabinet;
// Assign storage to the Cabinet<Func1> static member
template<> Cabinet<func_t>* Cabinet<func_t>::__storage = 0;
inline func_t* _func(size_t i)
{
return Cabinet<func_t>::cabinet()->item(i);
}
template<> FuncCabinet* FuncCabinet::__storage = 0;
extern "C" {
@ -67,31 +62,31 @@ extern "C" {
"not enough Arrhenius coefficients");
r = new Arrhenius1(n, params);
} else if (type == PeriodicFuncType) {
r = new Periodic1(*_func(n), params[0]);
r = new Periodic1(FuncCabinet::item(n), params[0]);
} else if (type == SumFuncType) {
r = &newSumFunction(_func(n)->duplicate(),
_func(m)->duplicate());
r = &newSumFunction(FuncCabinet::item(n).duplicate(),
FuncCabinet::item(m).duplicate());
} else if (type == DiffFuncType) {
r = &newDiffFunction(_func(n)->duplicate(),
_func(m)->duplicate());
r = &newDiffFunction(FuncCabinet::item(n).duplicate(),
FuncCabinet::item(m).duplicate());
} else if (type == ProdFuncType) {
r = &newProdFunction(_func(n)->duplicate(),
_func(m)->duplicate());
r = &newProdFunction(FuncCabinet::item(n).duplicate(),
FuncCabinet::item(m).duplicate());
} else if (type == RatioFuncType) {
r = &newRatioFunction(_func(n)->duplicate(),
_func(m)->duplicate());
r = &newRatioFunction(FuncCabinet::item(n).duplicate(),
FuncCabinet::item(m).duplicate());
} else if (type == CompositeFuncType) {
r = &newCompositeFunction(_func(n)->duplicate(),
_func(m)->duplicate());
r = &newCompositeFunction(FuncCabinet::item(n).duplicate(),
FuncCabinet::item(m).duplicate());
} else if (type == TimesConstantFuncType) {
r = &newTimesConstFunction(_func(n)->duplicate(), params[0]);
r = &newTimesConstFunction(FuncCabinet::item(n).duplicate(), params[0]);
} else if (type == PlusConstantFuncType) {
r = &newPlusConstFunction(_func(n)->duplicate(), params[0]);
r = &newPlusConstFunction(FuncCabinet::item(n).duplicate(), params[0]);
} else {
throw CanteraError("func_new","unknown function type");
r = new Func1();
}
return Cabinet<func_t>::cabinet()->add(r);
return FuncCabinet::add(r);
} catch (CanteraError) {
return -1;
}
@ -100,44 +95,44 @@ extern "C" {
int DLL_EXPORT func_del(int i)
{
Cabinet<func_t>::cabinet()->del(i);
FuncCabinet::del(i);
return 0;
}
int DLL_EXPORT func_copy(int i)
{
return Cabinet<func_t>::cabinet()->newCopy(i);
return FuncCabinet::newCopy(i);
}
int DLL_EXPORT func_assign(int i, int j)
{
return Cabinet<func_t>::cabinet()->assign(i,j);
return FuncCabinet::assign(i,j);
}
double DLL_EXPORT func_value(int i, double t)
{
return _func(i)->eval(t);
return FuncCabinet::item(i).eval(t);
}
int DLL_EXPORT func_derivative(int i)
{
func_t* r = 0;
r = &_func(i)->derivative();
return Cabinet<func_t>::cabinet()->add(r);
r = &FuncCabinet::item(i).derivative();
return FuncCabinet::add(r);
}
int DLL_EXPORT func_duplicate(int i)
{
func_t* r = 0;
r = &_func(i)->duplicate();
return Cabinet<func_t>::cabinet()->add(r);
r = &FuncCabinet::item(i).duplicate();
return FuncCabinet::add(r);
}
int DLL_EXPORT func_write(int i, size_t lennm, const char* arg, char* nm)
{
try {
std::string a = std::string(arg);
std::string w = _func(i)->write(a);
std::string w = FuncCabinet::item(i).write(a);
size_t ws = w.size();
size_t lout = (lennm > ws ? ws : lennm);
std::copy(w.c_str(), w.c_str() + lout, nm);

View file

@ -16,14 +16,8 @@
using namespace std;
using namespace Cantera;
typedef MultiPhase mix_t;
template<> Cabinet<mix_t>* Cabinet<mix_t>::__storage = 0;
inline mix_t* _mix(int i)
{
return Cabinet<mix_t>::cabinet()->item(i);
}
typedef Cabinet<MultiPhase> mixCabinet;
template<> mixCabinet* mixCabinet::__storage = 0;
inline ThermoPhase* _th(int n)
{
@ -33,7 +27,7 @@ inline ThermoPhase* _th(int n)
static bool checkSpecies(int i, size_t k)
{
try {
if (k >= _mix(i)->nSpecies())
if (k >= mixCabinet::item(i).nSpecies())
throw CanteraError("checkSpecies",
"illegal species index ("+int2str(int(k))+") ");
return true;
@ -45,7 +39,7 @@ static bool checkSpecies(int i, size_t k)
static bool checkElement(int i, size_t m)
{
try {
if (m >= _mix(i)->nElements())
if (m >= mixCabinet::item(i).nElements())
throw CanteraError("checkElement",
"illegal element index ("+int2str(int(m))+") ");
return true;
@ -57,7 +51,7 @@ static bool checkElement(int i, size_t m)
static bool checkPhase(int i, int n)
{
try {
if (n < 0 || n >= int(_mix(i)->nPhases()))
if (n < 0 || n >= int(mixCabinet::item(i).nPhases()))
throw CanteraError("checkPhase",
"illegal phase index ("+int2str(n)+") ");
return true;
@ -75,63 +69,63 @@ extern "C" {
int DLL_EXPORT mix_new()
{
mix_t* m = new MultiPhase;
return Cabinet<mix_t>::cabinet()->add(m);
MultiPhase* m = new MultiPhase;
return mixCabinet::add(m);
}
int DLL_EXPORT mix_del(int i)
{
Cabinet<mix_t>::cabinet()->del(i);
mixCabinet::del(i);
return 0;
}
int DLL_EXPORT mix_copy(int i)
{
return Cabinet<mix_t>::cabinet()->newCopy(i);
return mixCabinet::newCopy(i);
}
int DLL_EXPORT mix_assign(int i, int j)
{
return Cabinet<mix_t>::cabinet()->assign(i,j);
return mixCabinet::assign(i,j);
}
int DLL_EXPORT mix_addPhase(int i, int j, double moles)
{
_mix(i)->addPhase(_th(j), moles);
mixCabinet::item(i).addPhase(_th(j), moles);
return 0;
}
int DLL_EXPORT mix_init(int i)
{
_mix(i)->init();
mixCabinet::item(i).init();
return 0;
}
size_t DLL_EXPORT mix_nElements(int i)
{
return _mix(i)->nElements();
return mixCabinet::item(i).nElements();
}
size_t DLL_EXPORT mix_elementIndex(int i, char* name)
{
return _mix(i)->elementIndex(string(name));
return mixCabinet::item(i).elementIndex(string(name));
}
size_t DLL_EXPORT mix_nSpecies(int i)
{
return _mix(i)->nSpecies();
return mixCabinet::item(i).nSpecies();
}
size_t DLL_EXPORT mix_speciesIndex(int i, int k, int p)
{
return _mix(i)->speciesIndex(k, p);
return mixCabinet::item(i).speciesIndex(k, p);
}
doublereal DLL_EXPORT mix_nAtoms(int i, int k, int m)
{
bool ok = (checkSpecies(i,k) && checkElement(i,m));
if (ok) {
return _mix(i)->nAtoms(k,m);
return mixCabinet::item(i).nAtoms(k,m);
} else {
return DERR;
}
@ -139,7 +133,7 @@ extern "C" {
size_t DLL_EXPORT mix_nPhases(int i)
{
return _mix(i)->nPhases();
return mixCabinet::item(i).nPhases();
}
doublereal DLL_EXPORT mix_phaseMoles(int i, int n)
@ -147,7 +141,7 @@ extern "C" {
if (!checkPhase(i, n)) {
return DERR;
}
return _mix(i)->phaseMoles(n);
return mixCabinet::item(i).phaseMoles(n);
}
int DLL_EXPORT mix_setPhaseMoles(int i, int n, double v)
@ -158,17 +152,17 @@ extern "C" {
if (v < 0.0) {
return -1;
}
_mix(i)->setPhaseMoles(n, v);
mixCabinet::item(i).setPhaseMoles(n, v);
return 0;
}
int DLL_EXPORT mix_setMoles(int i, size_t nlen, double* n)
{
try {
if (nlen < _mix(i)->nSpecies()) {
if (nlen < mixCabinet::item(i).nSpecies()) {
throw CanteraError("setMoles","array size too small.");
}
_mix(i)->setMoles(n);
mixCabinet::item(i).setMoles(n);
return 0;
} catch (CanteraError) {
return ERR;
@ -179,7 +173,7 @@ extern "C" {
int DLL_EXPORT mix_setMolesByName(int i, char* n)
{
try {
_mix(i)->setMolesByName(string(n));
mixCabinet::item(i).setMolesByName(string(n));
return 0;
} catch (CanteraError) {
return -1;
@ -191,28 +185,28 @@ extern "C" {
if (t < 0.0) {
return -1;
}
_mix(i)->setTemperature(t);
mixCabinet::item(i).setTemperature(t);
return 0;
}
doublereal DLL_EXPORT mix_temperature(int i)
{
return _mix(i)->temperature();
return mixCabinet::item(i).temperature();
}
doublereal DLL_EXPORT mix_minTemp(int i)
{
return _mix(i)->minTemp();
return mixCabinet::item(i).minTemp();
}
doublereal DLL_EXPORT mix_maxTemp(int i)
{
return _mix(i)->maxTemp();
return mixCabinet::item(i).maxTemp();
}
doublereal DLL_EXPORT mix_charge(int i)
{
return _mix(i)->charge();
return mixCabinet::item(i).charge();
}
doublereal DLL_EXPORT mix_phaseCharge(int i, int p)
@ -220,7 +214,7 @@ extern "C" {
if (!checkPhase(i,p)) {
return DERR;
}
return _mix(i)->phaseCharge(p);
return mixCabinet::item(i).phaseCharge(p);
}
int DLL_EXPORT mix_setPressure(int i, double p)
@ -228,13 +222,13 @@ extern "C" {
if (p < 0.0) {
return -1;
}
_mix(i)->setPressure(p);
mixCabinet::item(i).setPressure(p);
return 0;
}
doublereal DLL_EXPORT mix_pressure(int i)
{
return _mix(i)->pressure();
return mixCabinet::item(i).pressure();
}
doublereal DLL_EXPORT mix_speciesMoles(int i, int k)
@ -242,7 +236,7 @@ extern "C" {
if (!checkSpecies(i,k)) {
return DERR;
}
return _mix(i)->speciesMoles(k);
return mixCabinet::item(i).speciesMoles(k);
}
doublereal DLL_EXPORT mix_elementMoles(int i, int m)
@ -250,7 +244,7 @@ extern "C" {
if (!checkElement(i,m)) {
return DERR;
}
return _mix(i)->elementMoles(m);
return mixCabinet::item(i).elementMoles(m);
}
@ -259,7 +253,7 @@ extern "C" {
int maxiter, int loglevel)
{
try {
return equilibrate(*_mix(i), XY,
return equilibrate(mixCabinet::item(i), XY,
rtol, maxsteps, maxiter, loglevel);
} catch (CanteraError) {
return DERR;
@ -274,7 +268,7 @@ extern "C" {
{
try {
#ifdef WITH_VCSNONIDEAL
int retn = vcs_equilibrate(*_mix(i), XY, estimateEquil, printLvl, solver,
int retn = vcs_equilibrate(mixCabinet::item(i), XY, estimateEquil, printLvl, solver,
rtol, maxsteps, maxiter, loglevel);
#else
int retn = -1;
@ -291,10 +285,10 @@ extern "C" {
int DLL_EXPORT mix_getChemPotentials(int i, size_t lenmu, double* mu)
{
try {
if (lenmu < _mix(i)->nSpecies()) {
if (lenmu < mixCabinet::item(i).nSpecies()) {
throw CanteraError("getChemPotentials","array too small");
}
_mix(i)->getChemPotentials(mu);
mixCabinet::item(i).getChemPotentials(mu);
return 0;
} catch (CanteraError) {
return -1;
@ -306,10 +300,10 @@ extern "C" {
{
bool st = (standard == 1);
try {
if (lenmu < _mix(i)->nSpecies()) {
if (lenmu < mixCabinet::item(i).nSpecies()) {
throw CanteraError("getChemPotentials","array too small");
}
_mix(i)->getValidChemPotentials(bad_mu, mu, st);
mixCabinet::item(i).getValidChemPotentials(bad_mu, mu, st);
return 0;
} catch (CanteraError) {
return -1;
@ -318,38 +312,36 @@ extern "C" {
double DLL_EXPORT mix_enthalpy(int i)
{
return _mix(i)->enthalpy();
return mixCabinet::item(i).enthalpy();
}
double DLL_EXPORT mix_entropy(int i)
{
return _mix(i)->entropy();
return mixCabinet::item(i).entropy();
}
double DLL_EXPORT mix_gibbs(int i)
{
return _mix(i)->gibbs();
return mixCabinet::item(i).gibbs();
}
double DLL_EXPORT mix_cp(int i)
{
return _mix(i)->cp();
return mixCabinet::item(i).cp();
}
double DLL_EXPORT mix_volume(int i)
{
return _mix(i)->volume();
return mixCabinet::item(i).volume();
}
size_t DLL_EXPORT mix_speciesPhaseIndex(int i, int k)
{
return _mix(i)->speciesPhaseIndex(k);
return mixCabinet::item(i).speciesPhaseIndex(k);
}
double DLL_EXPORT mix_moleFraction(int i, int k)
{
return _mix(i)->moleFraction(k);
return mixCabinet::item(i).moleFraction(k);
}
}

View file

@ -19,25 +19,16 @@
using namespace std;
using namespace Cantera;
template<> Cabinet<Sim1D>* Cabinet<Sim1D>::__storage = 0;
template<> Cabinet<Domain1D>* Cabinet<Domain1D>::__storage = 0;
inline Sim1D* _sim1D(int i)
{
return Cabinet<Sim1D>::cabinet()->item(i);
}
inline Domain1D* _domain(int i)
{
return Cabinet<Domain1D>::cabinet()->item(i);
}
typedef Cabinet<Sim1D> SimCabinet;
typedef Cabinet<Domain1D> DomainCabinet;
template<> SimCabinet* SimCabinet::__storage = 0;
template<> DomainCabinet* DomainCabinet::__storage = 0;
static StFlow* _stflow(int i)
{
Domain1D* d = _domain(i);
Domain1D* d = &DomainCabinet::item(i);
if (d->domainType() == cFlowType) {
return (StFlow*)d;
return dynamic_cast<StFlow*>(d);
} else {
throw CanteraError("_stflow","wrong domain type");
}
@ -46,11 +37,11 @@ static StFlow* _stflow(int i)
static Bdry1D* _bdry(int i)
{
Domain1D* d = _domain(i);
Domain1D* d = &DomainCabinet::item(i);
if (! d->isConnector()) {
throw CanteraError("_bdry","wrong domain type: " +int2str(d->domainType()));
}
return (Bdry1D*)d;
return dynamic_cast<Bdry1D*>(d);
}
inline ThermoPhase* _phase(int n)
@ -79,7 +70,7 @@ extern "C" {
int DLL_EXPORT domain_clear()
{
try {
Cabinet<Domain1D>::cabinet()->clear();
DomainCabinet::clear();
return 0;
} catch (CanteraError) {
return -1;
@ -88,35 +79,34 @@ extern "C" {
int DLL_EXPORT domain_del(int i)
{
Cabinet<Domain1D>::cabinet()->del(i);
DomainCabinet::del(i);
return 0;
}
int DLL_EXPORT domain_type(int i)
{
return _domain(i)->domainType();
return DomainCabinet::item(i).domainType();
}
size_t DLL_EXPORT domain_index(int i)
{
return _domain(i)->domainIndex();
return DomainCabinet::item(i).domainIndex();
}
size_t DLL_EXPORT domain_nComponents(int i)
{
return _domain(i)->nComponents();
return DomainCabinet::item(i).nComponents();
}
size_t DLL_EXPORT domain_nPoints(int i)
{
return _domain(i)->nPoints();
return DomainCabinet::item(i).nPoints();
}
int DLL_EXPORT domain_componentName(int i, int n, int sz, char* buf)
{
try {
string nm = _domain(i)->componentName(n);
string nm = DomainCabinet::item(i).componentName(n);
size_t lout = std::min<size_t>(sz, nm.size());
copy(nm.c_str(), nm.c_str() + lout, buf);
buf[lout] = '\0';
@ -129,7 +119,7 @@ extern "C" {
size_t DLL_EXPORT domain_componentIndex(int i, char* name)
{
try {
size_t n = _domain(i)->componentIndex(string(name));
size_t n = DomainCabinet::item(i).componentIndex(string(name));
return n;
} catch (CanteraError) {
return -1;
@ -139,7 +129,7 @@ extern "C" {
double DLL_EXPORT domain_grid(int i, int n)
{
try {
return _domain(i)->grid(n);
return DomainCabinet::item(i).grid(n);
} catch (CanteraError) {
return DERR;
}
@ -148,7 +138,7 @@ extern "C" {
int DLL_EXPORT domain_setBounds(int i, int n, double lower, double upper)
{
try {
_domain(i)->setBounds(n, lower, upper);
DomainCabinet::item(i).setBounds(n, lower, upper);
return 0;
} catch (CanteraError) {
return -1;
@ -158,7 +148,7 @@ extern "C" {
double DLL_EXPORT domain_upperBound(int i, int n)
{
try {
return _domain(i)->upperBound(n);
return DomainCabinet::item(i).upperBound(n);
} catch (CanteraError) {
return DERR;
}
@ -167,7 +157,7 @@ extern "C" {
double DLL_EXPORT domain_lowerBound(int i, int n)
{
try {
return _domain(i)->lowerBound(n);
return DomainCabinet::item(i).lowerBound(n);
} catch (CanteraError) {
return DERR;
}
@ -177,7 +167,7 @@ extern "C" {
double atol, int itime)
{
try {
_domain(i)->setTolerances(n, rtol, atol, itime);
DomainCabinet::item(i).setTolerances(n, rtol, atol, itime);
return 0;
} catch (CanteraError) {
return -1;
@ -187,7 +177,7 @@ extern "C" {
double DLL_EXPORT domain_rtol(int i, int n)
{
try {
return _domain(i)->rtol(n);
return DomainCabinet::item(i).rtol(n);
} catch (CanteraError) {
return DERR;
}
@ -196,7 +186,7 @@ extern "C" {
double DLL_EXPORT domain_atol(int i, int n)
{
try {
return _domain(i)->atol(n);
return DomainCabinet::item(i).atol(n);
} catch (CanteraError) {
return DERR;
}
@ -205,7 +195,7 @@ extern "C" {
int DLL_EXPORT domain_setupGrid(int i, size_t npts, double* grid)
{
try {
_domain(i)->setupGrid(npts, grid);
DomainCabinet::item(i).setupGrid(npts, grid);
return 0;
} catch (CanteraError) {
return -1;
@ -216,7 +206,7 @@ extern "C" {
{
try {
string s = string(id);
_domain(i)->setID(s);
DomainCabinet::item(i).setID(s);
return 0;
} catch (CanteraError) {
return -1;
@ -228,7 +218,7 @@ extern "C" {
{
try {
string s = string(desc);
_domain(i)->setDesc(s);
DomainCabinet::item(i).setDesc(s);
return 0;
} catch (CanteraError) {
return -1;
@ -240,7 +230,7 @@ extern "C" {
{
try {
Inlet1D* i = new Inlet1D();
return Cabinet<Domain1D>::cabinet()->add(i);
return DomainCabinet::add(i);
} catch (CanteraError) {
return -1;
}
@ -250,7 +240,7 @@ extern "C" {
{
try {
Surf1D* i = new Surf1D();
return Cabinet<Domain1D>::cabinet()->add(i);
return DomainCabinet::add(i);
} catch (CanteraError) {
return -1;
}
@ -261,7 +251,7 @@ extern "C" {
try {
//writelog("in reactingsurf_new\n");
Domain1D* i = new ReactingSurf1D();
return Cabinet<Domain1D>::cabinet()->add(i);
return DomainCabinet::add(i);
} catch (CanteraError) {
writelog("error");
return -1;
@ -272,7 +262,7 @@ extern "C" {
{
try {
Symm1D* i = new Symm1D();
return Cabinet<Domain1D>::cabinet()->add(i);
return DomainCabinet::add(i);
} catch (CanteraError) {
return -1;
}
@ -282,7 +272,7 @@ extern "C" {
{
try {
Outlet1D* i = new Outlet1D();
return Cabinet<Domain1D>::cabinet()->add(i);
return DomainCabinet::add(i);
} catch (CanteraError) {
return -1;
}
@ -292,7 +282,7 @@ extern "C" {
{
try {
OutletRes1D* i = new OutletRes1D();
return Cabinet<Domain1D>::cabinet()->add(i);
return DomainCabinet::add(i);
} catch (CanteraError) {
return -1;
}
@ -403,12 +393,12 @@ extern "C" {
AxiStagnFlow* x = new AxiStagnFlow(ph, ph->nSpecies(), 2);
x->setKinetics(*_kinetics(ikin));
x->setTransport(*_transport(itr));
return Cabinet<Domain1D>::cabinet()->add(x);
return DomainCabinet::add(x);
} else if (itype == 2) {
FreeFlame* x = new FreeFlame(ph, ph->nSpecies(), 2);
x->setKinetics(*_kinetics(ikin));
x->setTransport(*_transport(itr));
return Cabinet<Domain1D>::cabinet()->add(x);
return DomainCabinet::add(x);
} else {
return -2;
}
@ -513,12 +503,12 @@ extern "C" {
for (size_t n = 0; n < nd; n++) {
//writelog("n = "+int2str(n)+"\n");
//writelog("dom = "+int2str(domains[n])+"\n");
d.push_back(_domain(domains[n]));
d.push_back(&DomainCabinet::item(domains[n]));
}
//writelog("in sim1D_new, calling new Sim1D\n");
Sim1D* s = new Sim1D(d);
//writelog("in sim1D_new, ret Sim1D\n");
return Cabinet<Sim1D>::cabinet()->add(s);
return SimCabinet::add(s);
} catch (CanteraError) {
return -1;
}
@ -527,7 +517,7 @@ extern "C" {
int DLL_EXPORT sim1D_clear()
{
try {
Cabinet<Sim1D>::cabinet()->clear();
SimCabinet::clear();
return 0;
} catch (CanteraError) {
return -1;
@ -536,7 +526,7 @@ extern "C" {
int DLL_EXPORT sim1D_del(int i)
{
Cabinet<Sim1D>::cabinet()->del(i);
SimCabinet::del(i);
return 0;
}
@ -544,7 +534,7 @@ extern "C" {
int localPoint, double value)
{
try {
_sim1D(i)->setValue(dom, comp, localPoint, value);
SimCabinet::item(i).setValue(dom, comp, localPoint, value);
return 0;
} catch (CanteraError) {
return -1;
@ -560,7 +550,7 @@ extern "C" {
vv.push_back(v[n]);
pv.push_back(pos[n]);
}
_sim1D(i)->setProfile(dom, comp, pv, vv);
SimCabinet::item(i).setProfile(dom, comp, pv, vv);
return 0;
} catch (CanteraError) {
return -1;
@ -570,7 +560,7 @@ extern "C" {
int DLL_EXPORT sim1D_setFlatProfile(int i, int dom, int comp, double v)
{
try {
_sim1D(i)->setFlatProfile(dom, comp, v);
SimCabinet::item(i).setFlatProfile(dom, comp, v);
return 0;
} catch (CanteraError) {
return -1;
@ -581,10 +571,10 @@ extern "C" {
{
string fn = string(fname);
if (fn == "-") {
_sim1D(i)->showSolution();
SimCabinet::item(i).showSolution();
} else {
ofstream fout(fname);
_sim1D(i)->showSolution(fout);
SimCabinet::item(i).showSolution(fout);
fout.close();
}
return 0;
@ -593,7 +583,7 @@ extern "C" {
int DLL_EXPORT sim1D_setTimeStep(int i, double stepsize, size_t ns, integer* nsteps)
{
try {
_sim1D(i)->setTimeStep(stepsize, ns, nsteps);
SimCabinet::item(i).setTimeStep(stepsize, ns, nsteps);
return 0;
} catch (CanteraError) {
return -1;
@ -603,7 +593,7 @@ extern "C" {
int DLL_EXPORT sim1D_getInitialSoln(int i)
{
try {
_sim1D(i)->getInitialSoln();
SimCabinet::item(i).getInitialSoln();
return 0;
} catch (CanteraError) {
return -1;
@ -614,7 +604,7 @@ extern "C" {
{
try {
bool r = (refine_grid == 0 ? false : true);
_sim1D(i)->solve(loglevel, r);
SimCabinet::item(i).solve(loglevel, r);
return 0;
} catch (CanteraError) {
return -1;
@ -624,7 +614,7 @@ extern "C" {
int DLL_EXPORT sim1D_refine(int i, int loglevel)
{
try {
_sim1D(i)->refine(loglevel);
SimCabinet::item(i).refine(loglevel);
return 0;
} catch (CanteraError) {
return -1;
@ -635,7 +625,7 @@ extern "C" {
double slope, double curve, double prune)
{
try {
_sim1D(i)->setRefineCriteria(dom, ratio, slope, curve, prune);
SimCabinet::item(i).setRefineCriteria(dom, ratio, slope, curve, prune);
return 0;
} catch (CanteraError) {
return -1;
@ -649,7 +639,7 @@ extern "C" {
string sname = string(fname);
string sid = string(id);
string sdesc = string(desc);
_sim1D(i)->save(sname, sid, sdesc);
SimCabinet::item(i).save(sname, sid, sdesc);
return 0;
} catch (CanteraError) {
return -1;
@ -661,7 +651,7 @@ extern "C" {
try {
string sname = string(fname);
string sid = string(id);
_sim1D(i)->restore(sname, sid);
SimCabinet::item(i).restore(sname, sid);
return 0;
} catch (CanteraError) {
return -1;
@ -671,7 +661,7 @@ extern "C" {
int DLL_EXPORT sim1D_writeStats(int i, int printTime)
{
try {
_sim1D(i)->writeStats(printTime);
SimCabinet::item(i).writeStats(printTime);
return 0;
} catch (CanteraError) {
return -1;
@ -681,7 +671,7 @@ extern "C" {
int DLL_EXPORT sim1D_domainIndex(int i, char* name)
{
try {
return (int) _sim1D(i)->domainIndex(string(name));
return (int) SimCabinet::item(i).domainIndex(string(name));
} catch (CanteraError) {
return -1;
}
@ -690,7 +680,7 @@ extern "C" {
double DLL_EXPORT sim1D_value(int i, int idom, int icomp, int localPoint)
{
try {
return _sim1D(i)->value(idom, icomp, localPoint);
return SimCabinet::item(i).value(idom, icomp, localPoint);
} catch (CanteraError) {
return DERR;
}
@ -699,7 +689,7 @@ extern "C" {
double DLL_EXPORT sim1D_workValue(int i, int idom, int icomp, int localPoint)
{
try {
return _sim1D(i)->workValue(idom, icomp, localPoint);
return SimCabinet::item(i).workValue(idom, icomp, localPoint);
} catch (CanteraError) {
return DERR;
}
@ -708,7 +698,7 @@ extern "C" {
int DLL_EXPORT sim1D_eval(int i, double rdt, int count)
{
try {
_sim1D(i)->eval(rdt, count);
SimCabinet::item(i).eval(rdt, count);
return 0;
} catch (CanteraError) {
return -1;
@ -718,7 +708,7 @@ extern "C" {
int DLL_EXPORT sim1D_setMaxJacAge(int i, int ss_age, int ts_age)
{
try {
_sim1D(i)->setJacAge(ss_age, ts_age);
SimCabinet::item(i).setJacAge(ss_age, ts_age);
return 0;
} catch (CanteraError) {
return -1;
@ -728,7 +718,7 @@ extern "C" {
int DLL_EXPORT sim1D_timeStepFactor(int i, double tfactor)
{
try {
_sim1D(i)->setTimeStepFactor(tfactor);
SimCabinet::item(i).setTimeStepFactor(tfactor);
return 0;
} catch (CanteraError) {
return -1;
@ -739,10 +729,10 @@ extern "C" {
{
try {
if (tsmin > 0.0) {
_sim1D(i)->setMinTimeStep(tsmin);
SimCabinet::item(i).setMinTimeStep(tsmin);
}
if (tsmax > 0.0) {
_sim1D(i)->setMaxTimeStep(tsmax);
SimCabinet::item(i).setMaxTimeStep(tsmax);
}
return 0;
} catch (CanteraError) {
@ -753,7 +743,7 @@ extern "C" {
int DLL_EXPORT sim1D_setFixedTemperature(int i, double temp)
{
try {
_sim1D(i)->setFixedTemperature(temp);
SimCabinet::item(i).setFixedTemperature(temp);
return 0;
} catch (CanteraError) {
return -1;
@ -763,7 +753,7 @@ extern "C" {
int DLL_EXPORT sim1D_evalSSJacobian(int i)
{
try {
_sim1D(i)->evalSSJacobian();
SimCabinet::item(i).evalSSJacobian();
return 0;
} catch (CanteraError) {
return -1;
@ -773,7 +763,7 @@ extern "C" {
double DLL_EXPORT sim1D_jacobian(int i, int m, int n)
{
try {
return _sim1D(i)->jacobian(m,n);
return SimCabinet::item(i).jacobian(m,n);
} catch (CanteraError) {
return DERR;
}
@ -782,10 +772,9 @@ extern "C" {
size_t DLL_EXPORT sim1D_size(int i)
{
try {
return _sim1D(i)->size();
return SimCabinet::item(i).size();
} catch (CanteraError) {
return -1;
}
}
}

View file

@ -19,35 +19,11 @@
using namespace Cantera;
using namespace std;
typedef ReactorBase reactor_t;
typedef ReactorNet reactornet_t;
typedef FlowDevice flowdev_t;
typedef Wall wall_t;
template<> Cabinet<reactor_t>* Cabinet<reactor_t>::__storage = 0;
template<> Cabinet<reactornet_t>* Cabinet<reactornet_t>::__storage = 0;
template<> Cabinet<flowdev_t>* Cabinet<flowdev_t>::__storage = 0;
template<> Cabinet<wall_t>* Cabinet<wall_t>::__storage = 0;
inline reactor_t* _reactor(int i)
{
return Cabinet<reactor_t>::cabinet()->item(i);
}
inline reactornet_t* _reactornet(int i)
{
return Cabinet<reactornet_t>::cabinet()->item(i);
}
inline flowdev_t* _flowdev(int i)
{
return Cabinet<flowdev_t>::cabinet()->item(i);
}
inline wall_t* _wall(int i)
{
return Cabinet<wall_t>::cabinet()->item(i);
}
typedef Cabinet<ReactorBase> ReactorCabinet;
typedef Cabinet<ReactorNet> NetworkCabinet;
typedef Cabinet<FlowDevice> FlowDeviceCabinet;
typedef Cabinet<Wall> WallCabinet;
typedef Cabinet<Func1> FuncCabinet;
inline Kinetics* _kin(int n)
{
@ -59,20 +35,18 @@ inline ThermoPhase* _th(int n)
return Storage::__storage->__thtable[n];
}
inline Func1* _func(int i)
{
return Cabinet<Func1>::cabinet()->item(i);
}
template<> ReactorCabinet* ReactorCabinet::__storage = 0;
template<> NetworkCabinet* NetworkCabinet::__storage = 0;
template<> FlowDeviceCabinet* FlowDeviceCabinet::__storage = 0;
template<> WallCabinet* WallCabinet::__storage = 0;
extern "C" {
// reactor
int DLL_EXPORT reactor_new(int type)
{
reactor_t* r=0;
ReactorBase* r=0;
if (type == ReactorType) {
r = new Reactor();
} else if (type == FlowReactorType) {
@ -84,46 +58,46 @@ extern "C" {
} else {
r = new ReactorBase();
}
return Cabinet<reactor_t>::cabinet()->add(r);
return ReactorCabinet::add(r);
}
int DLL_EXPORT reactor_del(int i)
{
Cabinet<reactor_t>::cabinet()->del(i);
ReactorCabinet::del(i);
return 0;
}
int DLL_EXPORT reactor_copy(int i)
{
return Cabinet<reactor_t>::cabinet()->newCopy(i);
return ReactorCabinet::newCopy(i);
}
int DLL_EXPORT reactor_assign(int i, int j)
{
return Cabinet<reactor_t>::cabinet()->assign(i,j);
return ReactorCabinet::assign(i,j);
}
int DLL_EXPORT reactor_setInitialVolume(int i, double v)
{
_reactor(i)->setInitialVolume(v);
ReactorCabinet::item(i).setInitialVolume(v);
return 0;
}
int DLL_EXPORT reactor_setInitialTime(int i, double t)
{
_reactor(i)->setInitialTime(t);
ReactorCabinet::item(i).setInitialTime(t);
return 0;
}
int DLL_EXPORT reactor_setThermoMgr(int i, int n)
{
_reactor(i)->setThermoMgr(*_th(n));
ReactorCabinet::item(i).setThermoMgr(*_th(n));
return 0;
}
int DLL_EXPORT reactor_setKineticsMgr(int i, int n)
{
reactor_t* r = _reactor(i);
ReactorBase* r = &ReactorCabinet::item(i);
if (r->type() >= ReactorType) {
((Reactor*)r)->setKineticsMgr(*_kin(n));
}
@ -133,7 +107,7 @@ extern "C" {
int DLL_EXPORT reactor_advance(int i, double t)
{
try {
_reactor(i)->advance(t);
ReactorCabinet::item(i).advance(t);
return 0;
} catch (CanteraError) {
return -1;
@ -142,57 +116,57 @@ extern "C" {
double DLL_EXPORT reactor_step(int i, double t)
{
return _reactor(i)->step(t);
return ReactorCabinet::item(i).step(t);
}
double DLL_EXPORT reactor_time(int i)
{
return _reactor(i)->time();
return ReactorCabinet::item(i).time();
}
double DLL_EXPORT reactor_mass(int i)
{
return _reactor(i)->mass();
return ReactorCabinet::item(i).mass();
}
double DLL_EXPORT reactor_volume(int i)
{
return _reactor(i)->volume();
return ReactorCabinet::item(i).volume();
}
double DLL_EXPORT reactor_density(int i)
{
return _reactor(i)->density();
return ReactorCabinet::item(i).density();
}
double DLL_EXPORT reactor_temperature(int i)
{
return _reactor(i)->temperature();
return ReactorCabinet::item(i).temperature();
}
double DLL_EXPORT reactor_enthalpy_mass(int i)
{
return _reactor(i)->enthalpy_mass();
return ReactorCabinet::item(i).enthalpy_mass();
}
double DLL_EXPORT reactor_intEnergy_mass(int i)
{
return _reactor(i)->intEnergy_mass();
return ReactorCabinet::item(i).intEnergy_mass();
}
double DLL_EXPORT reactor_pressure(int i)
{
return _reactor(i)->pressure();
return ReactorCabinet::item(i).pressure();
}
double DLL_EXPORT reactor_massFraction(int i, int k)
{
return _reactor(i)->massFraction(k);
return ReactorCabinet::item(i).massFraction(k);
}
int DLL_EXPORT reactor_setEnergy(int i, int eflag)
{
reactor_t* r = _reactor(i);
ReactorBase* r = &ReactorCabinet::item(i);
if (r->type() >= ReactorType) {
((Reactor*)r)->setEnergy(eflag);
}
@ -201,7 +175,7 @@ extern "C" {
int DLL_EXPORT flowReactor_setMassFlowRate(int i, double mdot)
{
reactor_t* r = _reactor(i);
ReactorBase* r = &ReactorCabinet::item(i);
if (r->type() >= ReactorType) {
((FlowReactor*)r)->setMassFlowRate(mdot);
}
@ -210,7 +184,7 @@ extern "C" {
size_t DLL_EXPORT reactor_nSensParams(int i)
{
reactor_t* r = _reactor(i);
ReactorBase* r = &ReactorCabinet::item(i);
if (r->type() >= ReactorType) {
return ((Reactor*)r)->nSensParams();
} else {
@ -221,7 +195,7 @@ extern "C" {
int DLL_EXPORT reactor_addSensitivityReaction(int i, int rxn)
{
reactor_t* r = _reactor(i);
ReactorBase* r = &ReactorCabinet::item(i);
((Reactor*)r)->addSensitivityReaction(rxn);
return 0;
}
@ -232,13 +206,13 @@ extern "C" {
int DLL_EXPORT reactornet_new()
{
ReactorNet* r = new ReactorNet();
return Cabinet<reactornet_t>::cabinet()->add(r);
return NetworkCabinet::add(r);
}
int DLL_EXPORT reactornet_del(int i)
{
try {
Cabinet<reactornet_t>::cabinet()->del(i);
NetworkCabinet::del(i);
return 0;
} catch (...) {
return -1;
@ -247,42 +221,42 @@ extern "C" {
int DLL_EXPORT reactornet_copy(int i)
{
return Cabinet<reactornet_t>::cabinet()->newCopy(i);
return NetworkCabinet::newCopy(i);
}
int DLL_EXPORT reactornet_assign(int i, int j)
{
return Cabinet<reactornet_t>::cabinet()->assign(i,j);
return NetworkCabinet::assign(i,j);
}
int DLL_EXPORT reactornet_setInitialTime(int i, double t)
{
_reactornet(i)->setInitialTime(t);
NetworkCabinet::item(i).setInitialTime(t);
return 0;
}
int DLL_EXPORT reactornet_setMaxTimeStep(int i, double maxstep)
{
_reactornet(i)->setMaxTimeStep(maxstep);
NetworkCabinet::item(i).setMaxTimeStep(maxstep);
return 0;
}
int DLL_EXPORT reactornet_setTolerances(int i, double rtol, double atol)
{
_reactornet(i)->setTolerances(rtol, atol);
NetworkCabinet::item(i).setTolerances(rtol, atol);
return 0;
}
int DLL_EXPORT reactornet_setSensitivityTolerances(int i, double rtol, double atol)
{
_reactornet(i)->setSensitivityTolerances(rtol, atol);
NetworkCabinet::item(i).setSensitivityTolerances(rtol, atol);
return 0;
}
int DLL_EXPORT reactornet_addreactor(int i, int n)
{
try {
_reactornet(i)->addReactor(_reactor(n));
NetworkCabinet::item(i).addReactor(&ReactorCabinet::item(n));
return 0;
} catch (CanteraError) {
return -1;
@ -292,7 +266,7 @@ extern "C" {
int DLL_EXPORT reactornet_advance(int i, double t)
{
try {
_reactornet(i)->advance(t);
NetworkCabinet::item(i).advance(t);
return 0;
} catch (...) {
return -1;
@ -302,7 +276,7 @@ extern "C" {
double DLL_EXPORT reactornet_step(int i, double t)
{
try {
return _reactornet(i)->step(t);
return NetworkCabinet::item(i).step(t);
} catch (...) {
return DERR;
}
@ -310,22 +284,22 @@ extern "C" {
double DLL_EXPORT reactornet_time(int i)
{
return _reactornet(i)->time();
return NetworkCabinet::item(i).time();
}
double DLL_EXPORT reactornet_rtol(int i)
{
return _reactornet(i)->rtol();
return NetworkCabinet::item(i).rtol();
}
double DLL_EXPORT reactornet_atol(int i)
{
return _reactornet(i)->atol();
return NetworkCabinet::item(i).atol();
}
double DLL_EXPORT reactornet_sensitivity(int i, char* v, int p, int r)
{
return _reactornet(i)->sensitivity(v, p, r);
return NetworkCabinet::item(i).sensitivity(v, p, r);
}
@ -333,7 +307,7 @@ extern "C" {
int DLL_EXPORT flowdev_new(int type)
{
flowdev_t* r;
FlowDevice* r;
switch (type) {
case MFC_Type:
r = new MassFlowController();
@ -347,19 +321,20 @@ extern "C" {
default:
r = new FlowDevice();
}
return Cabinet<flowdev_t>::cabinet()->add(r);
return FlowDeviceCabinet::add(r);
}
int DLL_EXPORT flowdev_del(int i)
{
Cabinet<flowdev_t>::cabinet()->del(i);
FlowDeviceCabinet::del(i);
return 0;
}
int DLL_EXPORT flowdev_install(int i, int n, int m)
{
try {
bool ok = _flowdev(i)->install(*_reactor(n), *_reactor(m));
bool ok = FlowDeviceCabinet::item(i).install(ReactorCabinet::item(n),
ReactorCabinet::item(m));
if (!ok) {
throw CanteraError("install","Could not install flow device.");
}
@ -371,38 +346,39 @@ extern "C" {
int DLL_EXPORT flowdev_setMaster(int i, int n)
{
if (_flowdev(i)->type() == PressureController_Type) {
((PressureController*)_flowdev(i))->setMaster(_flowdev(n));
if (FlowDeviceCabinet::item(i).type() == PressureController_Type) {
dynamic_cast<PressureController&>(FlowDeviceCabinet::item(i)).setMaster(
&FlowDeviceCabinet::item(n));
}
return 0;
}
double DLL_EXPORT flowdev_massFlowRate(int i, double time)
{
return _flowdev(i)->massFlowRate(time);
return FlowDeviceCabinet::item(i).massFlowRate(time);
}
int DLL_EXPORT flowdev_setMassFlowRate(int i, double mdot)
{
_flowdev(i)->setMassFlowRate(mdot);
FlowDeviceCabinet::item(i).setMassFlowRate(mdot);
return 0;
}
int DLL_EXPORT flowdev_setParameters(int i, int n, double* v)
{
_flowdev(i)->setParameters(n, v);
FlowDeviceCabinet::item(i).setParameters(n, v);
return 0;
}
int DLL_EXPORT flowdev_setFunction(int i, int n)
{
_flowdev(i)->setFunction(_func(n));
FlowDeviceCabinet::item(i).setFunction(&FuncCabinet::item(n));
return 0;
}
int DLL_EXPORT flowdev_ready(int i)
{
bool ok = _flowdev(i)->ready();
bool ok = FlowDeviceCabinet::item(i).ready();
if (ok) {
return 1;
}
@ -415,30 +391,31 @@ extern "C" {
int DLL_EXPORT wall_new(int type)
{
wall_t* r;
Wall* r;
r = new Wall();
return Cabinet<wall_t>::cabinet()->add(r);
return WallCabinet::add(r);
}
int DLL_EXPORT wall_del(int i)
{
Cabinet<wall_t>::cabinet()->del(i);
WallCabinet::del(i);
return 0;
}
int DLL_EXPORT wall_copy(int i)
{
return Cabinet<wall_t>::cabinet()->newCopy(i);
return WallCabinet::newCopy(i);
}
int DLL_EXPORT wall_assign(int i, int j)
{
return Cabinet<wall_t>::cabinet()->assign(i,j);
return WallCabinet::assign(i,j);
}
int DLL_EXPORT wall_install(int i, int n, int m)
{
_wall(i)->install(*_reactor(n), *_reactor(m));
WallCabinet::item(i).install(ReactorCabinet::item(n),
ReactorCabinet::item(m));
return 0;
}
@ -453,70 +430,70 @@ extern "C" {
if (_kin(m)->type() == cInterfaceKinetics) {
right = _kin(m);
}
_wall(i)->setKinetics(left, right);
WallCabinet::item(i).setKinetics(left, right);
return 0;
}
double DLL_EXPORT wall_vdot(int i, double t)
{
return _wall(i)->vdot(t);
return WallCabinet::item(i).vdot(t);
}
double DLL_EXPORT wall_Q(int i, double t)
{
return _wall(i)->Q(t);
return WallCabinet::item(i).Q(t);
}
double DLL_EXPORT wall_area(int i)
{
return _wall(i)->area();
return WallCabinet::item(i).area();
}
int DLL_EXPORT wall_setArea(int i, double v)
{
_wall(i)->setArea(v);
WallCabinet::item(i).setArea(v);
return 0;
}
int DLL_EXPORT wall_setThermalResistance(int i, double rth)
{
_wall(i)->setThermalResistance(rth);
WallCabinet::item(i).setThermalResistance(rth);
return 0;
}
int DLL_EXPORT wall_setHeatTransferCoeff(int i, double u)
{
_wall(i)->setHeatTransferCoeff(u);
WallCabinet::item(i).setHeatTransferCoeff(u);
return 0;
}
int DLL_EXPORT wall_setHeatFlux(int i, int n)
{
_wall(i)->setHeatFlux(_func(n));
WallCabinet::item(i).setHeatFlux(&FuncCabinet::item(n));
return 0;
}
int DLL_EXPORT wall_setExpansionRateCoeff(int i, double k)
{
_wall(i)->setExpansionRateCoeff(k);
WallCabinet::item(i).setExpansionRateCoeff(k);
return 0;
}
int DLL_EXPORT wall_setVelocity(int i, int n)
{
_wall(i)->setVelocity(_func(n));
WallCabinet::item(i).setVelocity(&FuncCabinet::item(n));
return 0;
}
int DLL_EXPORT wall_setEmissivity(int i, double epsilon)
{
_wall(i)->setEmissivity(epsilon);
WallCabinet::item(i).setEmissivity(epsilon);
return 0;
}
int DLL_EXPORT wall_ready(int i)
{
if (_wall(i)->ready()) {
if (WallCabinet::item(i).ready()) {
return 1;
} else {
return 0;
@ -525,9 +502,7 @@ extern "C" {
int DLL_EXPORT wall_addSensitivityReaction(int i, int lr, int rxn)
{
_wall(i)->addSensitivityReaction(lr, rxn);
WallCabinet::item(i).addSensitivityReaction(lr, rxn);
return 0;
}
}

View file

@ -4,9 +4,7 @@
#define CANTERA_USE_INTERNAL
#include "ctrpath.h"
// Cantera includes
#include "cantera/kinetics/ReactionPath.h"
#include "Cabinet.h"
#include "Storage.h"
@ -14,23 +12,12 @@
using namespace Cantera;
using namespace std;
typedef ReactionPathDiagram diag_t;
typedef ReactionPathBuilder builder_t;
template<> Cabinet<ReactionPathDiagram>* Cabinet<ReactionPathDiagram>::__storage = 0;
template<> Cabinet<builder_t>* Cabinet<builder_t>::__storage = 0;
inline ReactionPathDiagram* _diag(int i)
{
return Cabinet<ReactionPathDiagram>::cabinet()->item(i);
}
inline builder_t* _builder(int i)
{
return Cabinet<builder_t>::cabinet()->item(i);
}
typedef Cabinet<ReactionPathBuilder> BuilderCabinet;
typedef Cabinet<ReactionPathDiagram> DiagramCabinet;
template<> DiagramCabinet* DiagramCabinet::__storage = 0;
template<> BuilderCabinet* BuilderCabinet::__storage = 0;
inline Kinetics* _kin(int n)
{
@ -41,130 +28,130 @@ extern "C" {
int DLL_EXPORT rdiag_new()
{
diag_t* d = new ReactionPathDiagram();
return Cabinet<diag_t>::cabinet()->add(d);
ReactionPathDiagram* d = new ReactionPathDiagram();
return DiagramCabinet::add(d);
}
int DLL_EXPORT rdiag_del(int i)
{
Cabinet<diag_t>::cabinet()->del(i);
DiagramCabinet::del(i);
return 0;
}
int DLL_EXPORT rdiag_copy(int i)
{
return Cabinet<diag_t>::cabinet()->newCopy(i);
return DiagramCabinet::newCopy(i);
}
int DLL_EXPORT rdiag_assign(int i, int j)
{
return Cabinet<diag_t>::cabinet()->assign(i,j);
return DiagramCabinet::assign(i,j);
}
int DLL_EXPORT rdiag_detailed(int i)
{
_diag(i)->show_details = true;
DiagramCabinet::item(i).show_details = true;
return 0;
}
int DLL_EXPORT rdiag_brief(int i)
{
_diag(i)->show_details = false;
DiagramCabinet::item(i).show_details = false;
return 0;
}
int DLL_EXPORT rdiag_setThreshold(int i, double v)
{
_diag(i)->threshold = v;
DiagramCabinet::item(i).threshold = v;
return 0;
}
int DLL_EXPORT rdiag_setBoldColor(int i, char* color)
{
_diag(i)->bold_color = string(color);
DiagramCabinet::item(i).bold_color = string(color);
return 0;
}
int DLL_EXPORT rdiag_setNormalColor(int i, char* color)
{
_diag(i)->normal_color = string(color);
DiagramCabinet::item(i).normal_color = string(color);
return 0;
}
int DLL_EXPORT rdiag_setDashedColor(int i, char* color)
{
_diag(i)->dashed_color = string(color);
DiagramCabinet::item(i).dashed_color = string(color);
return 0;
}
int DLL_EXPORT rdiag_setDotOptions(int i, char* opt)
{
_diag(i)->dot_options = string(opt);
DiagramCabinet::item(i).dot_options = string(opt);
return 0;
}
int DLL_EXPORT rdiag_setFont(int i, char* font)
{
_diag(i)->setFont(string(font));
DiagramCabinet::item(i).setFont(string(font));
return 0;
}
int DLL_EXPORT rdiag_setBoldThreshold(int i, double v)
{
_diag(i)->bold_min = v;
DiagramCabinet::item(i).bold_min = v;
return 0;
}
int DLL_EXPORT rdiag_setNormalThreshold(int i, double v)
{
_diag(i)->dashed_max = v;
DiagramCabinet::item(i).dashed_max = v;
return 0;
}
int DLL_EXPORT rdiag_setLabelThreshold(int i, double v)
{
_diag(i)->label_min = v;
DiagramCabinet::item(i).label_min = v;
return 0;
}
int DLL_EXPORT rdiag_setScale(int i, double v)
{
_diag(i)->scale = v;
DiagramCabinet::item(i).scale = v;
return 0;
}
int DLL_EXPORT rdiag_setFlowType(int i, int iflow)
{
if (iflow == 0) {
_diag(i)->flow_type = OneWayFlow;
DiagramCabinet::item(i).flow_type = OneWayFlow;
} else {
_diag(i)->flow_type = NetFlow;
DiagramCabinet::item(i).flow_type = NetFlow;
}
return 0;
}
int DLL_EXPORT rdiag_setArrowWidth(int i, double v)
{
_diag(i)->arrow_width = v;
DiagramCabinet::item(i).arrow_width = v;
return 0;
}
int DLL_EXPORT rdiag_setTitle(int i, char* title)
{
_diag(i)->title = string(title);
DiagramCabinet::item(i).title = string(title);
return 0;
}
int DLL_EXPORT rdiag_add(int i, int n)
{
_diag(i)->add(*_diag(n));
DiagramCabinet::item(i).add(DiagramCabinet::item(n));
return 0;
}
int DLL_EXPORT rdiag_findMajor(int i, double threshold,
size_t lda, double* a)
{
_diag(i)->findMajorPaths(threshold, lda, a);
DiagramCabinet::item(i).findMajorPaths(threshold, lda, a);
return 0;
}
@ -172,9 +159,9 @@ extern "C" {
{
ofstream f(fname);
if (fmt == 0) {
_diag(i)->exportToDot(f);
DiagramCabinet::item(i).exportToDot(f);
} else {
_diag(i)->writeData(f);
DiagramCabinet::item(i).writeData(f);
}
f.close();
return 0;
@ -182,26 +169,26 @@ extern "C" {
int DLL_EXPORT rdiag_displayOnly(int i, int k)
{
_diag(i)->displayOnly(k);
DiagramCabinet::item(i).displayOnly(k);
return 0;
}
int DLL_EXPORT rbuild_new()
{
builder_t* d = new ReactionPathBuilder();
return Cabinet<builder_t>::cabinet()->add(d);
ReactionPathBuilder* d = new ReactionPathBuilder();
return BuilderCabinet::add(d);
}
int DLL_EXPORT rbuild_del(int i)
{
Cabinet<builder_t>::cabinet()->del(i);
BuilderCabinet::del(i);
return 0;
}
int DLL_EXPORT rbuild_init(int i, char* logfile, int k)
{
ofstream flog(logfile);
_builder(i)->init(flog, *_kin(k));
BuilderCabinet::item(i).init(flog, *_kin(k));
return 0;
}
@ -213,7 +200,8 @@ extern "C" {
if (iquiet > 0) {
quiet = true;
}
_builder(i)->build(*_kin(k), string(el), fdot, *_diag(idiag), quiet);
BuilderCabinet::item(i).build(*_kin(k), string(el), fdot,
DiagramCabinet::item(idiag), quiet);
return 0;
}

View file

@ -16,12 +16,6 @@
using namespace std;
using namespace Cantera;
//Cabinet<Surf1D>* Cabinet<Surf1D>::__storage = 0;
//inline Surf1D* _surface(int i) {
// return Cabinet<Surf1D>::cabinet()->item(i);
//}
inline SurfPhase* _surfphase(int n)
{
return (SurfPhase*)Storage::__storage->__thtable[n];
@ -32,22 +26,8 @@ inline InterfaceKinetics* _surfkin(int n)
return (InterfaceKinetics*)Storage::__storage->__ktable[n];
}
extern "C" {
// int DLL_EXPORT surface_new(int ikin) {
// InterfaceKinetics* sk = 0;
// if (ikin > 0) sk = _surfkin(ikin);
// Surf1D* s = new Surf1D(sk);
// return Cabinet<Surf1D>::cabinet()->add(s);
// }
// int DLL_EXPORT surface_del(int i) {
// Cabinet<Surf1D>::cabinet()->del(i);
// return 0;
// }
int DLL_EXPORT surf_setsitedensity(int i, double s0)
{
_surfphase(i)->setSiteDensity(s0);

View file

@ -15,15 +15,11 @@ using namespace std;
using namespace Cantera;
using namespace ctml;
// Assign storage for the static member of the Templated Cabinet class
// class Cabinet<XML_Node>;
template<> Cabinet<XML_Node>* Cabinet<XML_Node>::__storage = 0;
inline XML_Node* _xml(int i)
{
return Cabinet<XML_Node>::cabinet(false)->item(i);
}
typedef Cabinet<XML_Node, false> XmlCabinet;
template<> XmlCabinet* XmlCabinet::__storage = 0;
extern "C" {
@ -35,14 +31,14 @@ extern "C" {
} else {
x = new XML_Node(name);
}
return Cabinet<XML_Node>::cabinet(true)->add(x);
return XmlCabinet::add(x);
}
int DLL_EXPORT xml_get_XML_File(const char* file, int debug)
{
try {
XML_Node* x = get_XML_File(std::string(file), debug);
return Cabinet<XML_Node>::cabinet(false)->add(x);
return XmlCabinet::add(x);
} catch (CanteraError) {
return -1;
}
@ -51,7 +47,7 @@ extern "C" {
int DLL_EXPORT xml_clear()
{
try {
Cabinet<XML_Node>::cabinet(false)->clear();
XmlCabinet::clear();
close_XML_File("all");
return 0;
} catch (CanteraError) {
@ -61,24 +57,24 @@ extern "C" {
int DLL_EXPORT xml_del(int i)
{
Cabinet<XML_Node>::cabinet(false)->del(i);
XmlCabinet::del(i);
return 0;
}
int DLL_EXPORT xml_removeChild(int i, int j)
{
_xml(i)->removeChild(_xml(j));
XmlCabinet::item(i).removeChild(&XmlCabinet::item(j));
return 0;
}
int DLL_EXPORT xml_copy(int i)
{
return Cabinet<XML_Node>::cabinet(false)->newCopy(i);
return XmlCabinet::newCopy(i);
}
int DLL_EXPORT xml_assign(int i, int j)
{
return Cabinet<XML_Node>::cabinet(false)->assign(i,j);
return XmlCabinet::assign(i,j);
}
int DLL_EXPORT xml_build(int i, const char* file)
@ -91,7 +87,7 @@ extern "C" {
throw CanteraError("xml_build",
"file "+string(file)+" not found.");
}
_xml(i)->build(f);
XmlCabinet::item(i).build(f);
f.close();
return 0;
} catch (CanteraError) {
@ -102,7 +98,7 @@ extern "C" {
int DLL_EXPORT xml_preprocess_and_build(int i, const char* file, int debug)
{
try {
get_CTML_Tree(_xml(i), string(file), debug);
get_CTML_Tree(&XmlCabinet::item(i), string(file), debug);
return 0;
} catch (CanteraError) {
return -1;
@ -115,7 +111,7 @@ extern "C" {
{
try {
string ky = string(key);
XML_Node& node = *_xml(i);
XML_Node& node = XmlCabinet::item(i);
if (node.hasAttrib(ky)) {
string v = node[ky];
strncpy(value, v.c_str(), 80);
@ -133,7 +129,7 @@ extern "C" {
try {
string ky = string(key);
string val = string(value);
XML_Node& node = *_xml(i);
XML_Node& node = XmlCabinet::item(i);
node.addAttribute(ky, val);
} catch (CanteraError) {
return -1;
@ -145,7 +141,7 @@ extern "C" {
{
try {
string c = string(comment);
XML_Node& node = *_xml(i);
XML_Node& node = XmlCabinet::item(i);
node.addComment(c);
} catch (CanteraError) {
return -1;
@ -156,7 +152,7 @@ extern "C" {
int DLL_EXPORT xml_tag(int i, char* tag)
{
try {
XML_Node& node = *_xml(i);
XML_Node& node = XmlCabinet::item(i);
const string v = node.name();
strncpy(tag, v.c_str(), 80);
} catch (CanteraError) {
@ -168,7 +164,7 @@ extern "C" {
int DLL_EXPORT xml_value(int i, char* value)
{
try {
XML_Node& node = *_xml(i);
XML_Node& node = XmlCabinet::item(i);
const string v = node.value();
strncpy(value, v.c_str(), 80);
} catch (CanteraError) {
@ -180,9 +176,9 @@ extern "C" {
int DLL_EXPORT xml_child(int i, const char* loc)
{
try {
XML_Node& node = *_xml(i);
XML_Node& node = XmlCabinet::item(i);
XML_Node& c = node.child(string(loc));
return Cabinet<XML_Node>::cabinet()->add(&c);
return XmlCabinet::add(&c);
} catch (CanteraError) {
return -1;
}
@ -192,9 +188,9 @@ extern "C" {
int DLL_EXPORT xml_child_bynumber(int i, int m)
{
try {
XML_Node& node = *_xml(i);
XML_Node& node = XmlCabinet::item(i);
XML_Node& c = node.child(m);
return Cabinet<XML_Node>::cabinet()->add(&c);
return XmlCabinet::add(&c);
} catch (CanteraError) {
return -1;
}
@ -204,10 +200,10 @@ extern "C" {
int DLL_EXPORT xml_findID(int i, const char* id)
{
try {
XML_Node& node = *_xml(i);
XML_Node& node = XmlCabinet::item(i);
XML_Node* c = node.findID(string(id));
if (c) {
return Cabinet<XML_Node>::cabinet()->add(c);
return XmlCabinet::add(c);
} else {
throw CanteraError("xml_find_id","id not found: "+string(id));
}
@ -220,10 +216,10 @@ extern "C" {
int DLL_EXPORT xml_findByName(int i, const char* nm)
{
try {
XML_Node& node = *_xml(i);
XML_Node& node = XmlCabinet::item(i);
XML_Node* c = node.findByName(string(nm));
if (c) {
return Cabinet<XML_Node>::cabinet()->add(c);
return XmlCabinet::add(c);
} else
throw CanteraError("xml_findByName","name "+string(nm)
+" not found");
@ -236,7 +232,7 @@ extern "C" {
int DLL_EXPORT xml_nChildren(int i)
{
try {
XML_Node& node = *_xml(i);
XML_Node& node = XmlCabinet::item(i);
return (int) node.nChildren();
} catch (CanteraError) {
return -1;
@ -246,9 +242,9 @@ extern "C" {
int DLL_EXPORT xml_addChild(int i, const char* name, const char* value)
{
try {
XML_Node& node = *_xml(i);
XML_Node& node = XmlCabinet::item(i);
XML_Node& c = node.addChild(string(name),string(value));
return Cabinet<XML_Node>::cabinet()->add(&c);
return XmlCabinet::add(&c);
} catch (CanteraError) {
showErrors(cout);
return -1;
@ -259,10 +255,10 @@ extern "C" {
int DLL_EXPORT xml_addChildNode(int i, int j)
{
try {
XML_Node& node = *_xml(i);
XML_Node& chld = *_xml(j);
XML_Node& node = XmlCabinet::item(i);
XML_Node& chld = XmlCabinet::item(j);
XML_Node& c = node.addChild(chld);
return Cabinet<XML_Node>::cabinet()->add(&c);
return XmlCabinet::add(&c);
} catch (CanteraError) {
return -1;
}
@ -274,7 +270,7 @@ extern "C" {
try {
ofstream f(file);
if (f) {
XML_Node& node = *_xml(i);
XML_Node& node = XmlCabinet::item(i);
node.write(f);
} else {
throw CanteraError("xml_write",
@ -290,7 +286,7 @@ extern "C" {
int DLL_EXPORT ctml_getFloatArray(int i, size_t n, doublereal* data, int iconvert)
{
try {
XML_Node& node = *_xml(i);
XML_Node& node = XmlCabinet::item(i);
vector_fp v;
bool conv = false;
if (iconvert > 0) {

View file

@ -22,14 +22,11 @@
using namespace Cantera;
// Assert that there is storage
// for the templated classes' static member
// (needed to compile on solaris)
//template<> Cabinet<XML_Node> * Cabinet<XML_Node>::__storage;
typedef Cabinet<XML_Node, false> XmlCabinet;
inline XML_Node* _xml(const integer* n)
{
return Cabinet<XML_Node>::cabinet()->item(*n);
return &XmlCabinet::item(*n);
}
inline ThermoPhase* _fph(const integer* n)
@ -37,10 +34,6 @@ inline ThermoPhase* _fph(const integer* n)
return th(*n);
}
//inline Kinetics* _fkin(const integer* n) {
// return kin(*n);
//}
static Kinetics* _fkin(const integer* n)
{
if (*n >= 0) {

View file

@ -18,12 +18,12 @@ using Cantera::CanteraError;
#include "clib/Cabinet.h"
// Assign storage for the templated classes static member
template<> Cabinet<XML_Node> * Cabinet<XML_Node>::__storage = 0;
typedef Cabinet<XML_Node, false> XmlCabinet;
template<> XmlCabinet* XmlCabinet::__storage = 0;
inline XML_Node* _xml(const integer* i)
{
return Cabinet<XML_Node>::cabinet(false)->item(*i);
return &XmlCabinet::item(*i);
}
static void handleError()
@ -43,14 +43,14 @@ extern "C" {
} else {
x = new XML_Node(f2string(name, namelen), 0);
}
return Cabinet<XML_Node>::cabinet(true)->add(x);
return XmlCabinet::add(x);
}
status_t DLL_EXPORT fxml_get_xml_file_(const char* file, ftnlen filelen)
{
try {
XML_Node* x = Cantera::get_XML_File(f2string(file, filelen));
int ix = Cabinet<XML_Node>::cabinet(false)->add(x);
int ix = XmlCabinet::add(x);
return ix;
} catch (CanteraError) {
handleError();
@ -61,7 +61,7 @@ extern "C" {
status_t DLL_EXPORT fxml_clear_()
{
try {
Cabinet<XML_Node>::cabinet(false)->clear();
XmlCabinet::clear();
Cantera::close_XML_File("all");
return 0;
} catch (CanteraError) {
@ -72,7 +72,7 @@ extern "C" {
status_t DLL_EXPORT fxml_del_(const integer* i)
{
Cabinet<XML_Node>::cabinet(false)->del(*i);
XmlCabinet::del(*i);
return 0;
}
@ -84,12 +84,12 @@ extern "C" {
status_t DLL_EXPORT fxml_copy_(const integer* i)
{
return Cabinet<XML_Node>::cabinet(false)->newCopy(*i);
return XmlCabinet::newCopy(*i);
}
status_t DLL_EXPORT fxml_assign_(const integer* i, const integer* j)
{
return Cabinet<XML_Node>::cabinet(false)->assign(*i,*j);
return XmlCabinet::assign(*i,*j);
}
status_t DLL_EXPORT fxml_attrib_(const integer* i, const char* key,
@ -166,7 +166,7 @@ extern "C" {
try {
XML_Node& node = *_xml(i);
XML_Node& c = node.child(f2string(loc, loclen));
return Cabinet<XML_Node>::cabinet()->add(&c);
return XmlCabinet::add(&c);
} catch (CanteraError) {
handleError();
}
@ -178,7 +178,7 @@ extern "C" {
try {
XML_Node& node = *_xml(i);
XML_Node& c = node.child(*m);
return Cabinet<XML_Node>::cabinet()->add(&c);
return XmlCabinet::add(&c);
} catch (CanteraError) {
handleError();
}
@ -191,7 +191,7 @@ extern "C" {
XML_Node& node = *_xml(i);
XML_Node* c = node.findID(f2string(id, idlen));
if (c) {
return Cabinet<XML_Node>::cabinet()->add(c);
return XmlCabinet::add(c);
} else {
throw CanteraError("fxml_find_id","id not found: "+f2string(id, idlen));
}
@ -207,7 +207,7 @@ extern "C" {
XML_Node& node = *_xml(i);
XML_Node* c = node.findByName(f2string(nm, nmlen));
if (c) {
return Cabinet<XML_Node>::cabinet()->add(c);
return XmlCabinet::add(c);
} else
throw CanteraError("fxml_findByName","name "+f2string(nm, nmlen)
+" not found");
@ -235,7 +235,7 @@ extern "C" {
XML_Node& node = *_xml(i);
XML_Node& c = node.addChild(f2string(name, namelen),
f2string(value,valuelen));
return Cabinet<XML_Node>::cabinet()->add(&c);
return XmlCabinet::add(&c);
} catch (CanteraError) {
handleError();
}
@ -248,7 +248,7 @@ extern "C" {
XML_Node& node = *_xml(i);
XML_Node& chld = *_xml(j);
XML_Node& c = node.addChild(chld);
return Cabinet<XML_Node>::cabinet()->add(&c);
return XmlCabinet::add(&c);
} catch (CanteraError) {
handleError();
}