19 #ifdef with_python_numpy
20 #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
21 #include <numpy/arrayobject.h>
38 if (solver->
nsims > 1) {
41 strcat(fname_root,
"_");
42 strcat(fname_root, index);
43 strcat(fname_root,
"_");
47 strcat(filename,fname_root);
52 strcat(filename,
".png");
58 int dim_global_x[ndims_x];
60 int dim_local_x[ndims_x];
67 xg = (
double*) calloc (size_g,
sizeof(
double));
70 int offset_global, offset_local;
71 offset_global = offset_local = 0;
72 for (d=0; d<ndims_x; d++) {
74 (mpi->
rank?NULL:&xg[offset_global]),
75 &solver->
x[offset_local+ghosts],
80 offset_global += dim_global_x[d];
81 offset_local += dim_local_x [d] + 2*ghosts;
89 field_g = (
double*) calloc (size_g,
sizeof(
double));
94 fprintf(stderr,
"Warning in VlasovPlotSpatialField():\n");
95 fprintf(stderr,
" field plotting not yet supported for >1 spatial dimensions.\n");
99 (mpi->
rank ? NULL : field_g),
110 #ifdef with_python_numpy
112 PyObject* py_plt_func = (PyObject*) solver->
py_plt_func;
114 py_plt_func_args = PyTuple_New(7);
116 PyObject* py_obj = Py_BuildValue(
"i", ndims_x);
117 PyTuple_SetItem(py_plt_func_args, 0, py_obj);
120 PyObject* py_obj = Py_BuildValue(
"i", 1);
121 PyTuple_SetItem(py_plt_func_args, 1, py_obj);
124 npy_intp shape[1] = {ndims_x};
125 PyObject* size_arr = PyArray_SimpleNewFromData(1,shape,NPY_INT,dim_global_x);
126 PyTuple_SetItem(py_plt_func_args, 2, size_arr);
129 PyObject* py_obj = Py_BuildValue(
"d", a_time);
130 PyTuple_SetItem(py_plt_func_args, 3, py_obj);
134 PyObject* x_arr = PyArray_SimpleNewFromData(1,shape,NPY_DOUBLE,xg);
135 PyTuple_SetItem(py_plt_func_args, 4, x_arr);
139 PyObject* u_arr = PyArray_SimpleNewFromData(1,shape,NPY_DOUBLE,field_g);
140 PyTuple_SetItem(py_plt_func_args, 5, u_arr);
143 PyObject* py_obj = Py_BuildValue(
"s", filename);
144 PyTuple_SetItem(py_plt_func_args, 6, py_obj);
147 fprintf(stderr,
"Error in PlotArraySerial(): solver->py_plt_func is NULL!\n");
149 PyObject_CallObject(py_plt_func, py_plt_func_args);
152 fprintf(stderr,
"Error in PlotArraySerial(): HyPar needs to be compiled with Numpy support (-Dwith_python_numpy) to use this feature..\n");
155 fprintf(stderr,
"Error in PlotArraySerial(): HyPar needs to be compiled with Python support (-Dwith_python) to use this feature..\n");
#define _ArraySetValue_(x, size, value)
void GetStringFromInteger(int, char *, int)
int MPIGatherArray1D(void *, double *, double *, int, int, int, int)
MPI related function definitions.
Function declarations for file I/O functions.
#define _MAX_STRING_SIZE_
char op_overwrite[_MAX_STRING_SIZE_]
Contains function definitions for common mathematical functions.
#define _ArrayCopy1D_(x, y, size)
Contains structure definition for hypar.
Some basic definitions and macros.
Contains macros and function definitions for common array operations.
Structure of MPI-related variables.
int VlasovPlotSpatialField(void *s, void *m, double *a_field, double a_time, char *fname_root)
Structure containing all solver-specific variables and functions.
Some common functions used here and there.