20 #ifdef with_python_numpy 21 #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION 22 #include <numpy/arrayobject.h> 27 static int PlotArraySerial (
int,
int,
int*,
int*,
int,
double*,
double*,
double,
void*,
void*,
char*);
82 int size_global_x = 0;
83 int size_global_u = 0;
90 for (
int d=0; d<a_ndims; d++) size_global_u *= a_dim_global[d];
91 ug = (
double*) calloc (size_global_u*a_nvars,
sizeof(
double));
95 for (
int d=0; d<a_ndims; d++) size_global_x += a_dim_global[d];
96 xg = (
double*) calloc (size_global_x,
sizeof(
double));
115 int offset_global, offset_local;
116 offset_global = offset_local = 0;
117 for (
int d=0; d<a_ndims; d++) {
119 (mpi->
rank?NULL:&xg[offset_global]),
120 &a_x[offset_local+a_ghosts],
125 offset_global += a_dim_global[d];
126 offset_local += a_dim_local [d] + 2*a_ghosts;
132 strcat(filename,a_fname_root);
134 strcat(filename,
"_");
140 #ifdef with_python_numpy 142 PyObject* py_plt_func = (PyObject*) solver->
py_plt_func;
144 py_plt_func_args = PyTuple_New(7);
146 PyObject* py_obj = Py_BuildValue(
"i", a_ndims);
147 PyTuple_SetItem(py_plt_func_args, 0, py_obj);
150 PyObject* py_obj = Py_BuildValue(
"i", a_nvars);
151 PyTuple_SetItem(py_plt_func_args, 1, py_obj);
154 npy_intp shape[1] = {a_ndims};
155 PyObject* size_arr = PyArray_SimpleNewFromData(1,shape,NPY_INT,a_dim_global);
156 PyTuple_SetItem(py_plt_func_args, 2, size_arr);
159 PyObject* py_obj = Py_BuildValue(
"d", a_time);
160 PyTuple_SetItem(py_plt_func_args, 3, py_obj);
163 npy_intp shape[1] = {size_global_x};
164 PyObject* x_arr = PyArray_SimpleNewFromData(1,shape,NPY_DOUBLE,xg);
165 PyTuple_SetItem(py_plt_func_args, 4, x_arr);
168 npy_intp shape[1] = {size_global_u*a_nvars};
169 PyObject* u_arr = PyArray_SimpleNewFromData(1,shape,NPY_DOUBLE,ug);
170 PyTuple_SetItem(py_plt_func_args, 5, u_arr);
173 PyObject* py_obj = Py_BuildValue(
"s", filename);
174 PyTuple_SetItem(py_plt_func_args, 6, py_obj);
177 fprintf(stderr,
"Error in PlotArraySerial(): solver->py_plt_func is NULL!\n");
179 PyObject_CallObject(py_plt_func, py_plt_func_args);
182 fprintf(stderr,
"Error in PlotArraySerial(): HyPar needs to be compiled with Numpy support (-Dwith_python_numpy) to use this feature..\n");
185 fprintf(stderr,
"Error in PlotArraySerial(): HyPar needs to be compiled with Python support (-Dwith_python) to use this feature..\n");
MPI related function definitions.
char plotfilename_extn[_MAX_STRING_SIZE_]
Some basic definitions and macros.
int MPIGatherArraynD(int, void *, double *, double *, int *, int *, int, int)
Structure containing all solver-specific variables and functions.
Function declarations for plotting functions.
#define _MAX_STRING_SIZE_
int MPIGatherArray1D(void *, double *, double *, int, int, int, int)
Contains structure definition for hypar.
char op_overwrite[_MAX_STRING_SIZE_]
#define _ArraySetValue_(x, size, value)
int PlotArray(int a_ndims, int a_nvars, int *a_dim_global, int *a_dim_local, int a_ghosts, double *a_x, double *a_u, double a_time, void *a_s, void *a_m, char *a_fname_root)
Structure of MPI-related variables.
Contains macros and function definitions for common array operations.
static int PlotArraySerial(int, int, int *, int *, int, double *, double *, double, void *, void *, char *)