2015-02-10 07:17:40 +00:00
|
|
|
%module timedomaineuler
|
|
|
|
%{
|
2015-02-20 09:34:05 +00:00
|
|
|
#define PY_ARRAY_UNIQUE_SYMBOL npy_array_api
|
|
|
|
/* #define NO_IMPORT_ARRAY */
|
|
|
|
#define SWIG_FILE_WITH_INIT
|
|
|
|
#include <cerrno>
|
|
|
|
#include <cstdlib>
|
2015-02-10 09:07:29 +00:00
|
|
|
#include "vtypes.h"
|
2015-02-20 09:34:05 +00:00
|
|
|
#include "arma_numpy.h"
|
2015-02-10 07:17:40 +00:00
|
|
|
#include "tube.h"
|
2015-02-20 09:34:05 +00:00
|
|
|
|
2015-02-10 09:07:29 +00:00
|
|
|
#include "globalconf.h"
|
|
|
|
SPOILNAMESPACE
|
|
|
|
namespace td{
|
|
|
|
extern tasystem::Globalconf gc;
|
|
|
|
}
|
2015-02-10 07:17:40 +00:00
|
|
|
%}
|
|
|
|
|
2015-02-20 09:34:05 +00:00
|
|
|
/* Call import_array() on loading module*/
|
|
|
|
%init%{
|
|
|
|
cout << "Import array called\n";
|
|
|
|
import_array();
|
|
|
|
%}
|
2015-02-10 09:07:29 +00:00
|
|
|
|
2015-02-20 09:34:05 +00:00
|
|
|
// A better way is the following
|
|
|
|
// Convert from numpy to vd and vice versa
|
|
|
|
class vd{
|
|
|
|
public:
|
|
|
|
virtual ~vd();
|
|
|
|
};
|
|
|
|
|
|
|
|
%typemap(in) const vd& INPUT {
|
|
|
|
PyArrayObject* arr = (PyArrayObject*) PyArray_FROM_OTF($input, NPY_DOUBLE, NPY_IN_ARRAY);
|
|
|
|
if(arr==NULL)
|
|
|
|
return NULL;
|
|
|
|
int ndims=PyArray_DIM(arr,0);
|
|
|
|
if(ndims!=1){
|
|
|
|
PyErr_SetString(PyExc_TypeError,"Number of dimensions not equal to 1");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
$1= vd_from_npy(arr);
|
|
|
|
}
|
|
|
|
%typemap(out) vd {
|
|
|
|
cout << "Hoi\n";
|
|
|
|
$result=npy_from_vd($1);
|
|
|
|
}
|
2015-02-10 07:17:40 +00:00
|
|
|
typedef double d;
|
2015-02-10 09:07:29 +00:00
|
|
|
typedef unsigned us;
|
|
|
|
|
|
|
|
namespace tasystem{
|
|
|
|
|
|
|
|
class Globalconf{
|
|
|
|
public:
|
|
|
|
d T0,p0; /* Reference temperature and pressure (used to initialize a lot of variables. */
|
|
|
|
// finite volume size, speed of sound,
|
|
|
|
// deltax of volume
|
|
|
|
d kappa; // Artificial viscosity tuning factor,
|
|
|
|
// typically between 0.25 and 0.75
|
|
|
|
|
|
|
|
gases::Gas gas;
|
|
|
|
|
|
|
|
Globalconf(us Nf=0,d freq=100,const string& gasstring="air",d T0=293.15,d p0=101325.0,d kappa=1.0,bool driven=true);
|
|
|
|
const us& Nf() const;
|
|
|
|
const us& Ns() const;
|
|
|
|
static Globalconf airSTP(us Nf,d freq,d kappa=1.0);
|
|
|
|
~Globalconf(){TRACE(-5,"~Globalconf()");}
|
|
|
|
bool isDriven() const;
|
|
|
|
void setDriven(bool d);
|
|
|
|
d getomg() const;
|
|
|
|
d getfreq() const;
|
|
|
|
d c0() const;
|
|
|
|
d rho0() const;
|
|
|
|
d deltanu0() const;
|
|
|
|
vd omgvec;
|
|
|
|
void setNf(us);
|
|
|
|
/* %rename set setNffreq */
|
|
|
|
/* void set(us Nf,d freq); // Set data for new frequency and */
|
|
|
|
// number of samples
|
|
|
|
void setomg(d omg);
|
|
|
|
void setfreq(d freq);
|
|
|
|
|
|
|
|
void setGas(const string& mat);
|
|
|
|
const string& getGas() const;
|
|
|
|
|
|
|
|
void setMass(d mass);
|
|
|
|
d getMass() const;
|
|
|
|
|
|
|
|
void show() const;
|
|
|
|
// void setgas(string g){ gas(g);}
|
|
|
|
|
|
|
|
}; /* Class Globalconf */
|
|
|
|
|
|
|
|
} /* namespace tasystem */
|
|
|
|
|
2015-02-10 07:17:40 +00:00
|
|
|
|
|
|
|
namespace td{
|
2015-02-10 09:07:29 +00:00
|
|
|
|
2015-02-10 07:17:40 +00:00
|
|
|
class SolutionAtGp {
|
|
|
|
public:
|
|
|
|
const d& rho() const;
|
|
|
|
const d& m() const;
|
|
|
|
const d& rhoE() const;
|
|
|
|
d u() const;
|
|
|
|
d ekin() const;
|
|
|
|
d estat() const;
|
|
|
|
d p() const;
|
|
|
|
|
|
|
|
d Cflux() const;
|
|
|
|
d Mflux() const;
|
|
|
|
d Eflux() const;
|
|
|
|
SolutionAtGp();
|
|
|
|
~SolutionAtGp(){}
|
|
|
|
void setData(d rho,d m=0,d rhoE=0);
|
|
|
|
};
|
|
|
|
class SolutionInstance{
|
|
|
|
public:
|
|
|
|
SolutionInstance(int gp);
|
|
|
|
~SolutionInstance(){}
|
|
|
|
d getTime() const;
|
2015-02-20 09:34:05 +00:00
|
|
|
vd getrho() const;
|
|
|
|
vd getp() const;
|
2015-02-10 07:17:40 +00:00
|
|
|
void setTime(d t);
|
2015-02-10 09:07:29 +00:00
|
|
|
void setData(us i,SolutionAtGp& sol);
|
2015-02-10 07:17:40 +00:00
|
|
|
SolutionAtGp& get(us i);
|
|
|
|
void setrho(d rho);
|
|
|
|
};
|
|
|
|
|
2015-02-10 09:07:29 +00:00
|
|
|
tasystem::Globalconf gc;
|
|
|
|
|
2015-02-10 07:17:40 +00:00
|
|
|
class Tube{
|
|
|
|
public:
|
|
|
|
Tube(double L,int gp);
|
|
|
|
~Tube(){}
|
2015-02-10 09:07:29 +00:00
|
|
|
SolutionInstance& getSol();
|
|
|
|
void setSol(const SolutionInstance& sol);
|
|
|
|
void DoIntegration(d dt,int n=1);
|
|
|
|
d getTime();
|
2015-02-10 07:17:40 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|