You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
simulacion-permeabilidad/fftma_module/gen/moduleFFTMA.c

101 lines
2.1 KiB
C

#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 "chunk_array.h"
#include <Python.h>
#include <math.h>
#include <numpy/arrayobject.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#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);
}