1 | #include "Python.h" |
---|
2 | #include "numpy/arrayobject.h" |
---|
3 | #include "math.h" |
---|
4 | #include <stdio.h> |
---|
5 | |
---|
6 | const double pi = 3.14159265358979; |
---|
7 | |
---|
8 | // Shared code snippets |
---|
9 | #include "util_ext.h" |
---|
10 | #include "solver.h" |
---|
11 | #include "python_solver.h" |
---|
12 | #include "sqpipe_pressurised_fixed_width_a_d.h" |
---|
13 | #include "sqpipe_python.h" |
---|
14 | |
---|
15 | //========================================================================= |
---|
16 | // Python Glue |
---|
17 | //========================================================================= |
---|
18 | |
---|
19 | PyObject *compute_fluxes_ext(PyObject *self, PyObject *args) { |
---|
20 | struct domain *D = (struct domain *) sqpipe_pressurised_fixed_width_a_d_domain_new(); |
---|
21 | double timestep; |
---|
22 | PyObject *domain; |
---|
23 | |
---|
24 | // Convert Python arguments to C |
---|
25 | if (!PyArg_ParseTuple(args, "dO", ×tep, &domain)) { |
---|
26 | PyErr_SetString(PyExc_RuntimeError, "comp_flux_ext.c: compute_fluxes_ext could not parse input"); |
---|
27 | return NULL; |
---|
28 | } |
---|
29 | |
---|
30 | D = (struct domain *) sqpipe_domain_python_get((struct sqpipe_domain *)D, domain, timestep); |
---|
31 | |
---|
32 | timestep = domain_compute_fluxes(D); |
---|
33 | domain_destroy(D); |
---|
34 | |
---|
35 | return Py_BuildValue("d", timestep); |
---|
36 | } |
---|
37 | |
---|
38 | //------------------------------- |
---|
39 | // Method table for python module |
---|
40 | //------------------------------- |
---|
41 | |
---|
42 | static struct PyMethodDef MethodTable[] = { |
---|
43 | {"compute_fluxes_ext", compute_fluxes_ext, METH_VARARGS, "Print out"}, |
---|
44 | {NULL, NULL} |
---|
45 | }; |
---|
46 | |
---|
47 | // Module initialisation |
---|
48 | void initsqpipe_pressurised_fixed_width_a_d_comp_flux(void){ |
---|
49 | Py_InitModule("sqpipe_pressurised_fixed_width_a_d_comp_flux", MethodTable); |
---|
50 | import_array(); |
---|
51 | } |
---|