#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 "chunk_array.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; printf("deberia imprimir\n"); 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); printf("me localizo\n"); free(stat.mean); free(stat.variance); printf("termino stat\n"); free(variogram.var); printf("1\n"); printf("2\n"); free(variogram.alpha); printf("3\n"); free(variogram.scf); printf("4\n"); free(variogram.ap); //free(variogram.vario); printf("Termino variogram\n"); printf("aca no deberia llegar\n"); /*chunk_array_free(Z.vector_2); remove("realization1.txt");*/ 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); }