#include "Py_py-api.h" #include "condor.h" #include "genlib.h" #include "geostat.h" #include "pressure.h" #include "simpio.h" #include "toolsFFTMA.h" #include "toolsFFTPSIM.h" #include "toolsIO.h" #include "lib_src/log.h" #include #include #include #include #include #include #include #include #define NDIMENSIONS 3 /* Z is the GWN with 0-mean and 1-variance */ /* Y is the realization with mean and variance wanted */ static PyObject* genFunc(PyObject* self, PyObject* args) { log_info("RESULT = in progress"); int n[3]; struct realization_mod Z, Y; struct grid_mod grid; struct vario_mod variogram; long seed; struct statistic_mod stat; PyObject* out_array; npy_intp out_dims[NPY_MAXDIMS]; int cores; if (!Py_getvalues(args, &seed, &grid, &variogram, &stat, &cores)) return NULL; Py_kgeneration(seed, grid, stat, variogram, &Z, &Y, n, cores); out_dims[0] = grid.NZ; out_dims[1] = grid.NY; out_dims[2] = grid.NX; out_array = PyArray_SimpleNewFromData(NDIMENSIONS, out_dims, NPY_DOUBLE, Y.vector); if (out_array == NULL) return NULL; PyArray_ENABLEFLAGS(out_array, NPY_ARRAY_OWNDATA); free(stat.mean); free(stat.variance); free(variogram.var); free(variogram.vario); free(variogram.alpha); free(variogram.scf); free(variogram.ap); free(Z.vector); log_info("RESULT = success"); return out_array; } static PyMethodDef FFTMAMethods[] = { { "gen", genFunc, METH_VARARGS, "Generates a permeability 3D field." }, { NULL, NULL, 0, NULL } }; static struct PyModuleDef cFFTMADef = { PyModuleDef_HEAD_INIT, "FFTMA", "", -1, FFTMAMethods }; PyMODINIT_FUNC PyInit_FFTMA(void) { import_array(); return PyModule_Create(&cFFTMADef); }