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

78 lines
1.5 KiB
C

#include <Python.h>
#include <numpy/arrayobject.h>
#include <stdio.h>
#include <stddef.h>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#include <math.h>
#include "Py_py-api.h"
#include "genlib.h"
#include "simpio.h"
#include "condor.h"
#include "geostat.h"
#include "toolsIO.h"
#include "toolsFFTMA.h"
#include "pressure.h"
#include "toolsFFTPSIM.h"
#define NDIMENSIONS 3
/* Z is the GWN with 0-mean and 1-variance */
/* Y1 is the realization with 0-mean and variance wanted */
/* Y is the realization with mean and variance wanted */
static PyObject* genFunc(PyObject* self, PyObject* args)
{
int n[3];
struct realization_mod Z,Y,Y1;
struct grid_mod grid;
struct vario_mod variogram;
long seed;
struct statistic_mod stat;
PyObject* out_array;
npy_intp out_dims[NPY_MAXDIMS];
printf("estoy edsn genfunc");
if(!Py_getvalues(args, &seed, &grid, &variogram, &stat)) return NULL;
Py_kgeneration(seed,grid,stat,variogram,&Z,&Y,&Y1,n);
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);
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);
}