SCons now builds the C, C++ and Fortran interfaces
This commit is contained in:
parent
b6bfca8e94
commit
39d46d1f28
13 changed files with 67 additions and 975 deletions
14
Cantera/SConscript
Normal file
14
Cantera/SConscript
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
from buildutils import *
|
||||
|
||||
Import('env', 'build')
|
||||
|
||||
# (subdir, library name, (file extensions))
|
||||
libs = [LibOpts('cxx/src', 'ctcxx'),
|
||||
LibOpts('clib/src', 'clib')]
|
||||
|
||||
print os.getcwd()
|
||||
for lib in libs:
|
||||
localenv = env.Clone()
|
||||
localenv.Library(pjoin('../lib', lib.name),
|
||||
source=mglob(localenv, lib.subdir, *lib.extensions))
|
||||
|
||||
|
|
@ -27,7 +27,7 @@
|
|||
using namespace std;
|
||||
using namespace Cantera;
|
||||
|
||||
Cabinet<Bdry1D>* Cabinet<Bdry1D>::__storage = 0;
|
||||
template<> Cabinet<Bdry1D>* Cabinet<Bdry1D>::__storage = 0;
|
||||
|
||||
inline Bdry1D* _bndry(int i) {
|
||||
return Cabinet<Bdry1D>::cabinet()->item(i);
|
||||
|
|
|
|||
|
|
@ -1,183 +0,0 @@
|
|||
|
||||
// Cantera includes
|
||||
#include "numerics.h"
|
||||
#include "Cabinet.h"
|
||||
inline DenseMatrix* _matrix(int i) {
|
||||
return Cabinet<DenseMatrix>::cabinet()->item(i);
|
||||
}
|
||||
|
||||
inline BandMatrix* _bmatrix(int i) {
|
||||
return Cabinet<BandMatrix>::cabinet()->item(i);
|
||||
}
|
||||
|
||||
// Build as a DLL under Windows
|
||||
#ifdef WIN32
|
||||
#ifdef NO_DLL_BUILD
|
||||
#define DLL_EXPORT
|
||||
#else
|
||||
#define DLL_EXPORT __declspec(dllexport)
|
||||
#endif
|
||||
#pragma warning(disable:4786)
|
||||
#pragma warning(disable:4503)
|
||||
#else
|
||||
#define DLL_EXPORT
|
||||
#endif
|
||||
|
||||
// Values returned for error conditions
|
||||
#define ERR -999
|
||||
#define DERR -999.999
|
||||
|
||||
Cabinet<DenseMatrix>* Cabinet<DenseMatrix>::__storage = 0;
|
||||
Cabinet<BandMatrix>* Cabinet<BandMatrix>::__storage = 0;
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
///// Matrix //////
|
||||
|
||||
int DLL_EXPORT newMatrix(int m, int n) {
|
||||
DenseMatrix* x = new DenseMatrix(m,n);
|
||||
return Cabinet<DenseMatrix>::cabinet()->add(x);
|
||||
}
|
||||
|
||||
int DLL_EXPORT delMatrix(int i) {
|
||||
Cabinet<DenseMatrix>::cabinet()->del(i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT matrix_copy(int i) {
|
||||
return Cabinet<DenseMatrix>::cabinet()->newCopy(i);
|
||||
}
|
||||
|
||||
int DLL_EXPORT matrix_assign(int i, int j) {
|
||||
return Cabinet<DenseMatrix>::cabinet()->assign(i,j);
|
||||
}
|
||||
|
||||
int DLL_EXPORT matrix_nRows(int i) {
|
||||
return _matrix(i)->nRows();
|
||||
}
|
||||
|
||||
int DLL_EXPORT matrix_nColumns(int i) {
|
||||
return _matrix(i)->nColumns();
|
||||
}
|
||||
|
||||
int DLL_EXPORT matrix_resize(int i, int m, int n, double v) {
|
||||
_matrix(i)->resize(m,n,v);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT matrix_appendColumn(int i, double* c) {
|
||||
_matrix(i)->appendColumn(c);
|
||||
return 0;
|
||||
}
|
||||
|
||||
double DLL_EXPORT matrix_value(int i, int m, int n) {
|
||||
return _matrix(i)->value(m,n);
|
||||
}
|
||||
|
||||
double DLL_EXPORT matrix_setvalue(int i, int m, int n, double v) {
|
||||
_matrix(i)->value(m,n) = v;
|
||||
return v;
|
||||
}
|
||||
|
||||
int DLL_EXPORT matrix_solve(int i1, int i2) {
|
||||
try {
|
||||
int info = solve(*_matrix(i1), *_matrix(i2));
|
||||
return info;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
catch (...) { return ERR; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT matrix_multiply(int ma, int mb, int mp) {
|
||||
try {
|
||||
DenseMatrix* a = _matrix(ma);
|
||||
DenseMatrix* b = _matrix(mb);
|
||||
DenseMatrix* p = _matrix(mp);
|
||||
multiply(*a, b->begin(), p->begin());
|
||||
return 0;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
catch (...) { return ERR; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT matrix_invert(int ma) {
|
||||
try {
|
||||
invert(*_matrix(ma));
|
||||
return 0;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
catch (...) { return ERR; }
|
||||
}
|
||||
|
||||
|
||||
///////////////// BandMatrix //////////////////////
|
||||
|
||||
|
||||
int DLL_EXPORT bmatrix_new(int n, int kl, int ku) {
|
||||
BandMatrix* x = new BandMatrix(n, kl, ku);
|
||||
return Cabinet<BandMatrix>::cabinet()->add(x);
|
||||
}
|
||||
|
||||
int DLL_EXPORT bmatrix_del(int i) {
|
||||
Cabinet<BandMatrix>::cabinet()->del(i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT bmatrix_copy(int i) {
|
||||
return Cabinet<BandMatrix>::cabinet()->newCopy(i);
|
||||
}
|
||||
|
||||
int DLL_EXPORT bmatrix_assign(int i, int j) {
|
||||
return Cabinet<BandMatrix>::cabinet()->assign(i,j);
|
||||
}
|
||||
|
||||
int DLL_EXPORT bmatrix_nRows(int i) {
|
||||
return _bmatrix(i)->rows();
|
||||
}
|
||||
|
||||
int DLL_EXPORT bmatrix_nColumns(int i) {
|
||||
return _bmatrix(i)->columns();
|
||||
}
|
||||
|
||||
int DLL_EXPORT bmatrix_resize(int i, int m, int n, double v) {
|
||||
_bmatrix(i)->resize(m,n,v);
|
||||
return 0;
|
||||
}
|
||||
|
||||
double DLL_EXPORT bmatrix_value(int i, int m, int n) {
|
||||
return _bmatrix(i)->value(m,n);
|
||||
}
|
||||
|
||||
double DLL_EXPORT bmatrix_setvalue(int i, int m, int n, double v) {
|
||||
try {
|
||||
_bmatrix(i)->value(m,n) = v;
|
||||
return v;
|
||||
}
|
||||
catch (...) { return ERR; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT bmatrix_solve(int ma, int mb) {
|
||||
try {
|
||||
int n = _bmatrix(ma)->nColumns();
|
||||
_bmatrix(ma)->solve(n,
|
||||
_matrix(mb)->begin());
|
||||
return 0;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
catch (...) { return ERR; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT bmatrix_multiply(int ma, int mb, int mp) {
|
||||
try {
|
||||
BandMatrix* a = _bmatrix(ma);
|
||||
DenseMatrix* b = _matrix(mb);
|
||||
DenseMatrix* p = _matrix(mp);
|
||||
a->mult(b->begin(), p->begin());
|
||||
return 0;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
catch (...) { return ERR; }
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
/**
|
||||
* @file ctnum.h
|
||||
*/
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef CTC_CTNUM_H
|
||||
#define CTC_CTNUM_H
|
||||
|
||||
#include "clib_defs.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
EEXXTT int DLL_CPREFIX newMatrix(int m, int n);
|
||||
EEXXTT int DLL_CPREFIX delMatrix(int i);
|
||||
EEXXTT int DLL_CPREFIX matrix_copy(int i);
|
||||
EEXXTT int DLL_CPREFIX matrix_assign(int i, int j);
|
||||
EEXXTT int DLL_CPREFIX matrix_nRows(int i);
|
||||
EEXXTT int DLL_CPREFIX matrix_nColumns(int i);
|
||||
EEXXTT int DLL_CPREFIX matrix_resize(int i, int m, int n, double v);
|
||||
EEXXTT int DLL_CPREFIX matrix_appendColumn(int i, double* c);
|
||||
EEXXTT double DLL_CPREFIX matrix_value(int i, int m, int n);
|
||||
EEXXTT double DLL_CPREFIX matrix_setvalue(int i, int m, int n, double v);
|
||||
EEXXTT int DLL_CPREFIX matrix_solve(int i1, int i2);
|
||||
EEXXTT int DLL_CPREFIX matrix_multiply(int ma, int mb, int mp);
|
||||
EEXXTT int DLL_CPREFIX matrix_invert(int ma);
|
||||
|
||||
EEXXTT int DLL_CPREFIX bmatrix_new(int n, int kl, int ku);
|
||||
EEXXTT int DLL_CPREFIX bmatrix_del(int i);
|
||||
EEXXTT int DLL_CPREFIX bmatrix_copy(int i);
|
||||
EEXXTT int DLL_CPREFIX bmatrix_assign(int i, int j);
|
||||
EEXXTT int DLL_CPREFIX bmatrix_nRows(int i);
|
||||
EEXXTT int DLL_CPREFIX bmatrix_nColumns(int i);
|
||||
EEXXTT int DLL_CPREFIX bmatrix_resize(int i, int m, int n, double v);
|
||||
EEXXTT double DLL_CPREFIX bmatrix_value(int i, int m, int n);
|
||||
EEXXTT double DLL_CPREFIX bmatrix_setvalue(int i, int m, int n, double v);
|
||||
EEXXTT int DLL_CPREFIX bmatrix_solve(int ma, int mb);
|
||||
EEXXTT int DLL_CPREFIX bmatrix_multiply(int ma, int mb, int mp);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,456 +0,0 @@
|
|||
|
||||
// Cantera includes
|
||||
#include "oneD/OneDim.h"
|
||||
#include "oneD/StFlow.h"
|
||||
#include "oneD/Inlet1D.h"
|
||||
#include "oneD/MultiNewton.h"
|
||||
#include "DenseMatrix.h"
|
||||
#include "Cabinet.h"
|
||||
#include "Storage.h"
|
||||
|
||||
// Build as a DLL under Windows
|
||||
#ifdef WIN32
|
||||
#ifdef NO_DLL_BUILD
|
||||
#define DLL_EXPORT
|
||||
#else
|
||||
#define DLL_EXPORT __declspec(dllexport)
|
||||
#endif
|
||||
#pragma warning(disable:4786)
|
||||
#pragma warning(disable:4503)
|
||||
#else
|
||||
#define DLL_EXPORT
|
||||
#endif
|
||||
|
||||
// Values returned for error conditions
|
||||
#define ERR -999
|
||||
#define DERR -999.999
|
||||
|
||||
using namespace FlowBdry;
|
||||
|
||||
Cabinet<OneDim>* Cabinet<OneDim>::__storage = 0;
|
||||
Cabinet<StFlow>* Cabinet<StFlow>::__storage = 0;
|
||||
Cabinet<Boundary>* Cabinet<Boundary>::__storage = 0;
|
||||
//Cabinet<Surf1D>* Cabinet<Surf1D>::__storage = 0;
|
||||
|
||||
inline OneDim* _onedim(int i) {
|
||||
return Cabinet<OneDim>::cabinet()->item(i);
|
||||
}
|
||||
|
||||
inline StFlow* _flow(int i) {
|
||||
return Cabinet<StFlow>::cabinet()->item(i);
|
||||
}
|
||||
|
||||
inline Boundary* _boundary(int i) {
|
||||
return Cabinet<Boundary>::cabinet()->item(i);
|
||||
}
|
||||
|
||||
inline Bdry1D* _bndry(int i) {
|
||||
return Cabinet<Bdry1D>::cabinet()->item(i);
|
||||
}
|
||||
|
||||
//inline SurfKinetics* _surfkin(int i) {
|
||||
// return Cabinet<SurfKinetics>::cabinet()->item(i);
|
||||
//}
|
||||
|
||||
//inline Surf1D* _surface(int i) {
|
||||
// return Cabinet<Surf1D>::cabinet()->item(i);
|
||||
//}
|
||||
|
||||
inline DenseMatrix* _matrix(int i) {
|
||||
return Cabinet<DenseMatrix>::cabinet()->item(i);
|
||||
}
|
||||
|
||||
inline ThermoPhase* _phase(int n) {
|
||||
return Storage::__storage->__thtable[n];
|
||||
}
|
||||
|
||||
inline Kinetics* _kinetics(int n) {
|
||||
return Storage::__storage->__ktable[n];
|
||||
}
|
||||
|
||||
inline ThermoPhase* _thermo(int n) {
|
||||
return Storage::__storage->__thtable[n];
|
||||
}
|
||||
|
||||
inline Transport* _transport(int n) {
|
||||
return Storage::__storage->__trtable[n];
|
||||
}
|
||||
|
||||
|
||||
extern "C" {
|
||||
|
||||
int DLL_EXPORT flow_new(int type, int iph, int np) {
|
||||
IdealGasPhase* ph = (IdealGasPhase*)_thermo(iph);
|
||||
StFlow* x;
|
||||
try {
|
||||
switch (type) {
|
||||
case 0:
|
||||
x = new AxiStagnFlow(ph, ph->nSpecies(), np); break;
|
||||
case 1:
|
||||
x = new OneDFlow(ph, ph->nSpecies(), np); break;
|
||||
default:
|
||||
return -2;
|
||||
}
|
||||
return Cabinet<StFlow>::cabinet()->add(x);
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
|
||||
int DLL_EXPORT flow_del(int i) {
|
||||
Cabinet<StFlow>::cabinet()->del(i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT flow_copy(int i) {
|
||||
return Cabinet<StFlow>::cabinet()->newCopy(i);
|
||||
}
|
||||
|
||||
int DLL_EXPORT flow_assign(int i, int j) {
|
||||
return Cabinet<StFlow>::cabinet()->assign(i,j);
|
||||
}
|
||||
|
||||
// int DLL_EXPORT flow_readinputs(int i, char* infile) {
|
||||
// try {
|
||||
// ifstream f(infile);
|
||||
// if (!f) throw CanteraError("flow_readinputs",
|
||||
// "error opening input file");
|
||||
// // _flow(i)->readInputs(f);
|
||||
// f.close();
|
||||
// return 0;
|
||||
// }
|
||||
// catch (CanteraError) { return -1; }
|
||||
// catch (...) { return ERR; }
|
||||
// }
|
||||
|
||||
int DLL_EXPORT flow_setupgrid(int i, int npts, double* grid) {
|
||||
try {
|
||||
_flow(i)->setupGrid(npts, grid);
|
||||
return 0;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
//catch (...) { return ERR; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT flow_setthermo(int i, int k) {
|
||||
IdealGasPhase* th = (IdealGasPhase*)_thermo(k);
|
||||
_flow(i)->setThermo(*th);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT flow_setkinetics(int i, int k) {
|
||||
Kinetics* kin = _kinetics(k);
|
||||
_flow(i)->setKinetics(*kin);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT flow_settransport(int i, int k, int soret) {
|
||||
try {
|
||||
Transport* tr = _transport(k);
|
||||
bool withSoret = (soret == 1);
|
||||
_flow(i)->setTransport(*tr, withSoret);
|
||||
return 0;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT flow_settemperature(int i, int j, double t) {
|
||||
_flow(i)->setTemperature(j, t);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT flow_setmassfraction(int i, int j, int k, double t) {
|
||||
_flow(i)->setMassFraction(j, k, t);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT flow_setpressure(int i, double p) {
|
||||
_flow(i)->setPressure(p);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT flow_showsolution(int i, char* fname, double* soln) {
|
||||
string fn = string(fname);
|
||||
if (fn == "-")
|
||||
_flow(i)->showSolution(cout, soln);
|
||||
else {
|
||||
ofstream fout(fname);
|
||||
_flow(i)->showSolution(fout, soln);
|
||||
fout.close();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT flow_outputtec(int i, doublereal* x,
|
||||
char* fname, char* title, int zone) {
|
||||
ofstream f(fname);
|
||||
//DenseMatrix* mat = _matrix(m);
|
||||
_flow(i)->outputTEC(f, x, string(title), zone);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// solve / fix
|
||||
|
||||
int DLL_EXPORT flow_solveenergyeqn(int i, int j) {
|
||||
_flow(i)->solveEnergyEqn(j);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT flow_fixtemperature(int i, int j) {
|
||||
_flow(i)->fixTemperature(j);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT flow_setenergyfactor(int i, double e) {
|
||||
_flow(i)->setEnergyFactor(e);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT flow_fixspecies(int i, int j) {
|
||||
_flow(i)->fixSpecies(j);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT flow_solvespecies(int i, int j) {
|
||||
_flow(i)->solveSpecies(j);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT flow_resize(int i, int points) {
|
||||
_flow(i)->resize(points);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// int DLL_EXPORT flow_integratechem(int i, doublereal* x, double dt) {
|
||||
// try{
|
||||
// _flow(i)->integrateChem(x, dt);
|
||||
// return 0;
|
||||
// }
|
||||
// catch (CanteraError) { return -1; }
|
||||
// }
|
||||
|
||||
int DLL_EXPORT flow_settolerances(int i, int nr,
|
||||
doublereal* rtol, int na, doublereal* atol) {
|
||||
try {
|
||||
_flow(i)->setTolerances(nr, rtol, na, atol);
|
||||
return 0;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
//catch (...) { return ERR; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT flow_eval(int i, int j, doublereal* x, doublereal* r, integer* m) {
|
||||
try {
|
||||
_flow(i)->eval(j, x, r, m);
|
||||
return 0;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT flow_restore(int i, int job, char* fname, char* id,
|
||||
int& size_z, doublereal* z, int& size_soln, doublereal* soln) {
|
||||
try {
|
||||
_flow(i)->restore(job, fname, string(id), size_z, z,
|
||||
size_soln, soln);
|
||||
return 0;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
catch (...) { return ERR; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT flow_setfixedpoint(int i, int j0, doublereal t0) {
|
||||
_flow(i)->setFixedPoint(j0, t0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int DLL_EXPORT flow_setboundaries(int i, int nleft, int nright) {
|
||||
Boundary *left=0, *right=0;
|
||||
if (nleft > 0) left = _boundary(nleft);
|
||||
if (nright > 0) right = _boundary(nright);
|
||||
_flow(i)->setBoundaries(left, right);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//==========================================================
|
||||
|
||||
int DLL_EXPORT bdry_new(int type, int iph, int kin) {
|
||||
Boundary* x=0;
|
||||
//const doublereal* wt = _phase(iph)->molecularWeights().begin();
|
||||
int nsp = _phase(iph)->nSpecies();
|
||||
switch (type) {
|
||||
case 0:
|
||||
x = new Inlet(nsp); break;
|
||||
case 1:
|
||||
x = new Outlet(nsp); break;
|
||||
//case 2:
|
||||
//if (kin > 0)
|
||||
// x = new Surface(nsp, _surfkin(kin));
|
||||
//else
|
||||
// x = new Surface(nsp, 0);
|
||||
//break;
|
||||
case 3:
|
||||
x = new SymmPlane(nsp); break;
|
||||
default:
|
||||
return -2;
|
||||
}
|
||||
return Cabinet<Boundary>::cabinet()->add(x);
|
||||
}
|
||||
|
||||
|
||||
int DLL_EXPORT bdry_del(int i) {
|
||||
Cabinet<Boundary>::cabinet()->del(i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT bdry_copy(int i) {
|
||||
return Cabinet<Boundary>::cabinet()->newCopy(i);
|
||||
}
|
||||
|
||||
int DLL_EXPORT bdry_assign(int i, int j) {
|
||||
return Cabinet<Boundary>::cabinet()->assign(i,j);
|
||||
}
|
||||
|
||||
int DLL_EXPORT bdry_set(int i, int n, doublereal* v) {
|
||||
switch (n) {
|
||||
case 1:
|
||||
_boundary(i)->set_mdot(*v); break;
|
||||
case 2:
|
||||
_boundary(i)->set_V(*v); break;
|
||||
case 3:
|
||||
_boundary(i)->set_T(*v); break;
|
||||
case 4:
|
||||
_boundary(i)->set_Y(v); break;
|
||||
default:
|
||||
throw CanteraError("bdry_set","unknown option");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
|
||||
|
||||
int DLL_EXPORT onedim_new(int nd, int* domains, int* types) {
|
||||
int i;
|
||||
vector<Domain1D*> doms;
|
||||
for (i = 0; i < nd; i++) {
|
||||
switch (types[i]) {
|
||||
case 0:
|
||||
doms.push_back(_flow(domains[i])); break;
|
||||
//case 1:
|
||||
//doms.push_back(_surface(domains[i])); break;
|
||||
case 2:
|
||||
doms.push_back(_bndry(domains[i])); break;
|
||||
default:
|
||||
throw CanteraError("onedim_new", "unknown domain type");
|
||||
}
|
||||
}
|
||||
try {
|
||||
OneDim* x = new OneDim(doms);
|
||||
return Cabinet<OneDim>::cabinet()->add(x);
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
}
|
||||
|
||||
|
||||
int DLL_EXPORT onedim_del(int i) {
|
||||
Cabinet<OneDim>::cabinet()->del(i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT onedim_addFlow(int i, int n) {
|
||||
try {
|
||||
_onedim(i)->addDomain(_flow(n));
|
||||
return 0;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
// catch (...) { return ERR; }
|
||||
}
|
||||
|
||||
// int DLL_EXPORT onedim_addSurf(int i, int n) {
|
||||
// try {
|
||||
// _onedim(i)->addDomain(_surface(n));
|
||||
// return 0;
|
||||
// }
|
||||
// catch (CanteraError) { return -1; }
|
||||
// }
|
||||
|
||||
int DLL_EXPORT onedim_eval(int i, doublereal* x0, doublereal* r) {
|
||||
try {
|
||||
_onedim(i)->eval(-1, x0, r, 0.0);
|
||||
return 0;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
// catch (...) { return ERR; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT onedim_solve(int i, doublereal* x0, doublereal* x1,
|
||||
int loglevel) {
|
||||
try {
|
||||
int m = _onedim(i)->solve(x0, x1, loglevel);
|
||||
return m;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
//catch (...) { return ERR; }
|
||||
}
|
||||
|
||||
double DLL_EXPORT onedim_ssnorm(int i, doublereal* x0, doublereal* x1) {
|
||||
return _onedim(i)->ssnorm(x0, x1);
|
||||
}
|
||||
|
||||
int DLL_EXPORT onedim_setsteadymode(int i) {
|
||||
if (_onedim(i)->transient()) {
|
||||
_onedim(i)->setSteadyMode();
|
||||
//_onedim(i)->jacobian().setAge(10000);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT onedim_settransientmode(int i, doublereal dt, doublereal* x) {
|
||||
_onedim(i)->initTimeInteg(dt, x);
|
||||
double rr = fabs(_onedim(i)->rdt()*dt - 1.0);
|
||||
if ((rr > 1.e-5) || _onedim(i)->steady()) {
|
||||
//_onedim(i)->jacobian().setAge(10000);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT onedim_setnewtonoptions(int i, int maxage) {
|
||||
_onedim(i)->newton().setOptions(maxage);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT onedim_resize(int i) {
|
||||
_onedim(i)->resize();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DLL_EXPORT onedim_writeStats(int i) {
|
||||
_onedim(i)->writeStats();
|
||||
return 0;
|
||||
}
|
||||
|
||||
double DLL_EXPORT onedim_timestep(int i, int nsteps, doublereal dt,
|
||||
doublereal* x, doublereal* xnew, int loglevel) {
|
||||
try {
|
||||
return _onedim(i)->timeStep(nsteps, dt, x, xnew, loglevel);
|
||||
}
|
||||
catch (CanteraError) { return -1.0; }
|
||||
}
|
||||
|
||||
int DLL_EXPORT onedim_save(int i, char* fname, char* id,
|
||||
char* desc, doublereal* soln) {
|
||||
try {
|
||||
_onedim(i)->save(string(fname), string(id), string(desc), soln);
|
||||
return 0;
|
||||
}
|
||||
catch (CanteraError) { return -1; }
|
||||
//catch (...) { return ERR; }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
/**
|
||||
* @file ctstagn.h
|
||||
*/
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef CTC_STAGN_H
|
||||
#define CTC_STAGN_H
|
||||
|
||||
// Cantera includes
|
||||
//#include "stagn.h"
|
||||
|
||||
//#include "Cabinet.h"
|
||||
//#include "Storage.h"
|
||||
#include "clib_defs.h"
|
||||
|
||||
//inline StFlow* _flow(int i) {
|
||||
// return Cabinet<StFlow>::cabinet()->item(i);
|
||||
//}
|
||||
|
||||
extern "C" {
|
||||
|
||||
int DLL_IMPORT flow_new(int type, int iph, int np);
|
||||
int DLL_IMPORT flow_del(int i);
|
||||
int DLL_IMPORT flow_copy(int i);
|
||||
int DLL_IMPORT flow_assign(int i, int j);
|
||||
int DLL_IMPORT flow_setupgrid(int i, int npts, double* grid);
|
||||
int DLL_EXPORT flow_setthermo(int i, int k);
|
||||
int DLL_IMPORT flow_setkinetics(int i, int k);
|
||||
int DLL_IMPORT flow_settransport(int i, int k, int soret);
|
||||
int DLL_IMPORT flow_solveenergyeqn(int i, int j);
|
||||
int DLL_IMPORT flow_fixtemperature(int i, int j);
|
||||
int DLL_IMPORT flow_setenergyfactor(int i, double e);
|
||||
int DLL_IMPORT flow_fixspecies(int i, int j);
|
||||
int DLL_IMPORT flow_solvespecies(int i, int j);
|
||||
// int DLL_IMPORT flow_integratechem(int i, double* x, double dt);
|
||||
int DLL_IMPORT flow_settemperature(int i, int j, double t);
|
||||
int DLL_IMPORT flow_setpressure(int i, double p);
|
||||
int DLL_IMPORT flow_setmassfraction(int i, int j, int k, double t);
|
||||
int DLL_IMPORT flow_outputtec(int i, double* x, char* fname,
|
||||
char* title, int zone);
|
||||
int DLL_IMPORT flow_showsolution(int i, char* fname, double* x);
|
||||
int DLL_IMPORT flow_settolerances(int i, int nr,
|
||||
double* rtol, int na, double* atol);
|
||||
int DLL_IMPORT flow_resize(int i, int points);
|
||||
int DLL_IMPORT flow_setsteadymode(int i);
|
||||
int DLL_IMPORT flow_settransientmode(int i, double dt, double* x);
|
||||
|
||||
int DLL_IMPORT flow_restore(int i, int job, char* fname, char* id,
|
||||
int& size_z, double* z, int& size_soln, double* soln);
|
||||
int DLL_IMPORT flow_setfixedpoint(int i, int j0, double t0);
|
||||
int DLL_IMPORT flow_setboundaries(int i, int nleft, int nright);
|
||||
int DLL_IMPORT bdry_new(int type, int iph, int kin);
|
||||
int DLL_IMPORT bdry_del(int i);
|
||||
int DLL_IMPORT bdry_copy(int i);
|
||||
int DLL_IMPORT bdry_assign(int i, int j);
|
||||
int DLL_IMPORT bdry_set(int i, int n, double* v);
|
||||
|
||||
int DLL_IMPORT onedim_new(int nd, int* domains, int* types);
|
||||
int DLL_IMPORT onedim_del(int i);
|
||||
int DLL_IMPORT onedim_addFlow(int i, int n);
|
||||
//int DLL_IMPORT onedim_addSurf(int i, int n);
|
||||
int DLL_EXPORT onedim_eval(int i, double* x0, double* r);
|
||||
int DLL_IMPORT onedim_solve(int i, double* x0, double* x1, int loglevel);
|
||||
double DLL_IMPORT onedim_ssnorm(int i, double* x0, double* x1);
|
||||
int DLL_IMPORT onedim_setsteadymode(int i);
|
||||
int DLL_IMPORT onedim_settransientmode(int i, double dt, double* x);
|
||||
int DLL_IMPORT onedim_setnewtonoptions(int i, int maxage);
|
||||
int DLL_IMPORT onedim_resize(int i);
|
||||
int DLL_IMPORT onedim_writeStats(int i);
|
||||
double DLL_IMPORT onedim_timestep(int i, int nsteps, double dt,
|
||||
double* x, double* xnew, int loglevel);
|
||||
int DLL_IMPORT onedim_save(int i, char* fname, char* id, char* desc, double* soln);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,198 +0,0 @@
|
|||
""" Python script to generate a Python extension module from a clib
|
||||
header file. """
|
||||
|
||||
import sys
|
||||
|
||||
_class = ''
|
||||
_newclass = 1
|
||||
|
||||
def getargs(line):
|
||||
"""Get the function name and arguments."""
|
||||
i1 = line.find('(')
|
||||
i2 = line.find(')')
|
||||
if (i1 < 0 or i2 < 0):
|
||||
raise 'syntax error: missing open or close quote'
|
||||
nm = line[:i1].split()
|
||||
nm = nm[-1]
|
||||
argline = line[i1+1:i2]
|
||||
args = argline.split(',')
|
||||
for n in range(len(args)): args[n] = args[n].split()
|
||||
v = []
|
||||
for a in args:
|
||||
if len(a) == 2: v.append(a)
|
||||
return nm, v
|
||||
|
||||
_itype = {'int':'i', 'double':'d', 'char*':'s', 'double*':'O', 'int*':'O'}
|
||||
|
||||
|
||||
def isoutput(name):
|
||||
if len(name) >= 3 and name[-3:] == 'out':
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
|
||||
def writepyfunc(rtype, name, args):
|
||||
"""Write the Python extension module function."""
|
||||
|
||||
print """
|
||||
static PyObject *
|
||||
py_"""+name+"""(PyObject *self, PyObject *args)
|
||||
{
|
||||
"""+rtype+""" _val;"""
|
||||
|
||||
global _class, _newclass
|
||||
toks = name.split('_')
|
||||
cls = toks[0]
|
||||
if len(toks) == 2:
|
||||
func = toks[1]
|
||||
else:
|
||||
func = toks[1] + toks[2]
|
||||
|
||||
if cls != _class:
|
||||
_class = cls
|
||||
_newclass = 1
|
||||
else:
|
||||
_newclass = 0
|
||||
|
||||
na = len(args)
|
||||
ain = []
|
||||
output = []
|
||||
if na > 0:
|
||||
vtype = []
|
||||
for a in args:
|
||||
# if the argument is an array, then the previous argument
|
||||
# must have been the array size. The Python argument list
|
||||
# will not include the size
|
||||
if a[0] == 'double*' or a[0] == 'int*':
|
||||
if not isoutput(a[1]):
|
||||
vtype[-1] = 'PyObject*'
|
||||
ain[-1] = a
|
||||
else:
|
||||
output.append(a)
|
||||
elif a[0] == 'char*' and isoutput(a[1]):
|
||||
output.append(a)
|
||||
ain.pop()
|
||||
else:
|
||||
vtype.append(a[0])
|
||||
ain.append(a)
|
||||
for n in range(len(ain)):
|
||||
print ' ',vtype[n],ain[n][1]+';'
|
||||
print ' if (!PyArg_ParseTuple(args,',
|
||||
s = '"'
|
||||
for a in ain:
|
||||
s += _itype[a[0]]
|
||||
s += ':'+name+'",'
|
||||
for a in ain:
|
||||
s += ' &'+a[1]+','
|
||||
s = s[:-1]+'))'
|
||||
print s,
|
||||
print """
|
||||
return NULL;
|
||||
"""
|
||||
v = []
|
||||
for a in output:
|
||||
if a[0] == 'char*':
|
||||
print ' int '+a[1]+'_sz = 80;'
|
||||
print ' char* '+a[1]+' = new char['+a[1]+'_sz];'
|
||||
print
|
||||
|
||||
for a in args:
|
||||
if a[0] == 'double*' or a[0] == 'int*':
|
||||
v[-1] = a[1]+'_len'
|
||||
v.append(a[1]+'_data')
|
||||
array = a[1]+'_array'
|
||||
print
|
||||
print ' PyArrayObject* '+array+' = (PyArrayObject*)'+a[1]+';'
|
||||
print ' '+a[0]+' '+a[1]+'_data = ('+a[0]+')'+array+'->data;'
|
||||
print ' int '+a[1]+'_len = '+array+'->dimensions[0];'
|
||||
print
|
||||
elif a[0] == 'char*' and isoutput(a[1]):
|
||||
v[-1] = a[1]+'_sz'
|
||||
v.append(a[1])
|
||||
else:
|
||||
v.append(a[1])
|
||||
|
||||
s = ' _val = '+name+'('
|
||||
for a in v:
|
||||
s += a+','
|
||||
if s[-1] == ',': s = s[:-1]
|
||||
s += ');'
|
||||
print s,
|
||||
if (output):
|
||||
print '\n PyObject* _ret = Py_BuildValue("'+_itype[output[0][0]]+'",'+output[0][1]+');'
|
||||
print ' delete '+output[0][1]+';'
|
||||
print ' if (int(_val) == -1) return reportCanteraError();'
|
||||
print """ return _ret;\n
|
||||
}
|
||||
"""
|
||||
else:
|
||||
print """
|
||||
if (int(_val) == -1) return reportCanteraError();
|
||||
"""+'return Py_BuildValue("'+_itype[rtype]+'",_val);'+"""
|
||||
}
|
||||
"""
|
||||
return ain
|
||||
|
||||
|
||||
def writepyclass(f, name, args):
|
||||
global _newclass
|
||||
if _newclass == 1:
|
||||
f.write("class "+_class.capitalize()+":\n")
|
||||
f.write(" def __init__(self):\n")
|
||||
f.write(" pass\n");
|
||||
_newclass = 0
|
||||
|
||||
toks = name.split('_')
|
||||
cls = toks[0]
|
||||
if len(toks) == 2:
|
||||
nm = toks[1]
|
||||
else:
|
||||
nm = toks[1] + toks[2]
|
||||
|
||||
f.write(' def '+nm+'(self')
|
||||
for a in args[1:]:
|
||||
f.write(', '+a[1])
|
||||
f.write('):\n')
|
||||
f.write(' return _cantera.'+name+'(self._index')
|
||||
for a in args[1:]:
|
||||
f.write(', '+a[1])
|
||||
f.write(')\n')
|
||||
|
||||
fname = sys.argv[1]
|
||||
base, ext = fname.split('.')
|
||||
mfile = 'py'+base+'_methods.h'
|
||||
pfile = base+'.py'
|
||||
|
||||
_rtypes = ['int', 'double']
|
||||
|
||||
f = open(fname,'r')
|
||||
fm = open(mfile,'w')
|
||||
fp = open(pfile,'w')
|
||||
|
||||
lines = f.readlines()
|
||||
f.close()
|
||||
|
||||
infunc = 0
|
||||
funcline = ''
|
||||
for line in lines:
|
||||
toks = line.split()
|
||||
if len(toks) > 0:
|
||||
if not infunc and toks[0] in _rtypes:
|
||||
infunc = 1
|
||||
funcline = line
|
||||
elif infunc:
|
||||
funcline += line
|
||||
last = toks[-1]
|
||||
if last[-1] == ';':
|
||||
infunc = 0
|
||||
name, args = getargs(funcline)
|
||||
toks = funcline.split()
|
||||
a = writepyfunc(toks[0], name, args)
|
||||
writepyclass(fp, name, a)
|
||||
fm.write(' {"'+name+'", py_'+name+', METH_VARARGS},\n')
|
||||
funcline = ''
|
||||
|
||||
fm.close()
|
||||
fp.close()
|
||||
|
||||
|
||||
13
Cantera/fortran/SConscript
Normal file
13
Cantera/fortran/SConscript
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
from buildutils import *
|
||||
|
||||
Import('env', 'build')
|
||||
|
||||
localenv = env.Clone()
|
||||
|
||||
localenv.Library(target=pjoin('..','..','lib','fct'),
|
||||
source=mglob(localenv, 'src', 'f90', 'cpp'))
|
||||
|
||||
# Copy the mod files to the include directory
|
||||
for mod in mglob(localenv, 'src', 'mod'):
|
||||
env.Command('../../include/cantera/%s' % mod.name, mod,
|
||||
Copy('$TARGET', '$SOURCE'))
|
||||
|
|
@ -23,8 +23,8 @@
|
|||
#include "ThermoFactory.h"
|
||||
#include "ctml.h"
|
||||
#include "importKinetics.h"
|
||||
#include "../../clib/src/Storage.h"
|
||||
#include "../../clib/src/Cabinet.h"
|
||||
#include "clib/Storage.h"
|
||||
#include "clib/Cabinet.h"
|
||||
#include "InterfaceKinetics.h"
|
||||
#include "PureFluidPhase.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
using namespace ctml;
|
||||
using namespace std;
|
||||
|
||||
#include "../../clib/src/Cabinet.h"
|
||||
#include "clib/Cabinet.h"
|
||||
|
||||
// Assign storage for the templated classes static member
|
||||
template<> Cabinet<XML_Node> * Cabinet<XML_Node>::__storage = 0;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
#define ERR -999
|
||||
#define DERR -999.999
|
||||
|
||||
#include "../../src/base/config.h"
|
||||
#include "config.h"
|
||||
|
||||
typedef integer status_t;
|
||||
|
||||
|
|
|
|||
38
SConstruct
38
SConstruct
|
|
@ -129,20 +129,16 @@ opts.Save('cantera.conf', env)
|
|||
# ********************************************
|
||||
env['OS'] = platform.system()
|
||||
|
||||
#def ArithCheck(context):
|
||||
# context.Message('Trying to generate arith.h\n')
|
||||
# exitStatus = context.TryLink(file('ext/f2c_libs/arithchk.c').read(), '.c')
|
||||
# print exitStatus
|
||||
# exitStatus, output = context.TryRun(file('ext/f2c_libs/arithchk.c').read(), '.c')
|
||||
# print exitStatus, output
|
||||
# context.Result(output)
|
||||
# return exitStatus
|
||||
if env['F90'] == 'gfortran':
|
||||
env['FORTRANMODDIRPREFIX'] = '-J'
|
||||
elif env['F90'] == 'g95':
|
||||
env['FORTRANMODDIRPREFIX'] = '-fmod='
|
||||
|
||||
env['FORTRANMODDIR'] = '${TARGET.dir}'
|
||||
|
||||
conf = Configure(env)
|
||||
#conf = Configure(env, custom_tests = {'ArithCheck':ArithCheck})
|
||||
|
||||
env['HAS_SSTREAM'] = conf.CheckCXXHeader('sstream', '<>')
|
||||
#conf.ArithCheck()
|
||||
|
||||
env = conf.Finish()
|
||||
|
||||
|
|
@ -223,9 +219,23 @@ if env['use_sundials'] == 'y' and env['sundials_include']:
|
|||
# *********************
|
||||
# *** Build Cantera ***
|
||||
# *********************
|
||||
|
||||
# Put headers in place
|
||||
for header in mglob(env, 'Cantera/cxx/include', 'h'):
|
||||
env.Command('build/include/cantera/%s' % header.name, header,
|
||||
Copy('$TARGET', '$SOURCE'))
|
||||
|
||||
for header in mglob(env, 'Cantera/clib/src', 'h'):
|
||||
env.Command('build/include/cantera/clib/%s' % header.name, header,
|
||||
Copy('$TARGET', '$SOURCE'))
|
||||
|
||||
|
||||
build = 'build'
|
||||
env.SConsignFile()
|
||||
env.Append(CPPPATH=[Dir(os.getcwd()), Dir('build/include/cantera/kernel/')])
|
||||
env.Append(CPPPATH=[Dir(os.getcwd()),
|
||||
Dir('build/include/cantera/kernel'),
|
||||
Dir('build/include/cantera')])
|
||||
|
||||
Export('env', 'build')
|
||||
|
||||
VariantDir('build/ext', 'ext', duplicate=0)
|
||||
|
|
@ -233,3 +243,9 @@ SConscript('build/ext/SConscript')
|
|||
|
||||
VariantDir('build/kernel', 'Cantera/src', duplicate=0)
|
||||
SConscript('build/kernel/SConscript')
|
||||
|
||||
VariantDir('build/interfaces/', 'Cantera', duplicate=0)
|
||||
SConscript('build/interfaces/SConscript')
|
||||
|
||||
VariantDir('build/interfaces/fortran/', 'Cantera/fortran', duplicate=1)
|
||||
SConscript('build/interfaces/fortran/SConscript')
|
||||
|
|
|
|||
|
|
@ -63,6 +63,14 @@ class CopyNoPrefix(object):
|
|||
shutil.copyfile(str(source[0]), pjoin(*targetpath[depth:]))
|
||||
|
||||
|
||||
class LibOpts(object):
|
||||
def __init__(self, subdir, name, exts=('cpp',), **kwargs):
|
||||
self.subdir = subdir
|
||||
self.name = name
|
||||
self.extensions = exts
|
||||
self.linklibs = kwargs.get('libs', [])
|
||||
|
||||
|
||||
def quoted(s):
|
||||
return '"%s"' % s
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue