Linter to c files

milestone_5_without_improvements
chortas 3 years ago
parent 83d7d29273
commit 4fd1d5ddc6

@ -1,16 +1,15 @@
#include <Python.h>
#include <numpy/arrayobject.h>
#include <stdio.h>
#include <stddef.h>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#include "genlib.h"
#include "simpio.h"
#include "geostat.h"
#include "pressure.h"
#include "simpio.h"
#include "toolsIO.h"
#include <Python.h>
#include <numpy/arrayobject.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int Py_getvalues(PyObject*, long*, struct grid_mod*, struct vario_mod*, struct statistic_mod*);
void Py_kgeneration(long,struct grid_mod,struct statistic_mod,struct vario_mod,struct realization_mod*,struct realization_mod*,struct realization_mod*, int [3]);
void Py_kgeneration(long, struct grid_mod, struct statistic_mod, struct vario_mod, struct realization_mod*, struct realization_mod*, struct realization_mod*, int[3]);

@ -3,8 +3,6 @@
#ifndef _CONDOR_H_
#define _CONDOR_H_
/*=======================================================*/
/*FUNCTIONS*/
/*---------*/
@ -23,8 +21,7 @@
/*grid: structure defining the grid */
/*OUTPUT */
/*realout: structure defining the output realization */
void condit(int k,struct welldata_mod well,struct vario_mod variogram,struct grid_mod grid,struct realization_mod *realin,struct realization_mod *realout);
void condit(int k, struct welldata_mod well, struct vario_mod variogram, struct grid_mod grid, struct realization_mod* realin, struct realization_mod* realout);
/*d_kriging */
/*interpolation from ponctual data with simple dual */
@ -38,8 +35,7 @@ void condit(int k,struct welldata_mod well,struct vario_mod variogram,struct gri
/*grid: structure defining the grid */
/*OUTPUT */
/*realout: structure defining the output realization */
void d_kriging(int k,struct welldata_mod well,struct vario_mod variogram,struct grid_mod grid,struct realization_mod *realout);
void d_kriging(int k, struct welldata_mod well, struct vario_mod variogram, struct grid_mod grid, struct realization_mod* realout);
/*dual_condit */
/*conditioning of a Gaussian realization using */
@ -54,8 +50,7 @@ void d_kriging(int k,struct welldata_mod well,struct vario_mod variogram,struct
/*realin: structure defining the input realization */
/*OUTPUT */
/*realout: structure defining the output realization */
void dual_condit(int k,struct welldata_mod well,struct vario_mod variogram,struct grid_mod grid,struct realization_mod *realin,struct realization_mod *realout);
void dual_condit(int k, struct welldata_mod well, struct vario_mod variogram, struct grid_mod grid, struct realization_mod* realin, struct realization_mod* realout);
/*dual_condit_gen */
/*conditioning of a Gaussian realization using */
@ -73,7 +68,7 @@ void dual_condit(int k,struct welldata_mod well,struct vario_mod variogram,struc
/*OUTPUT */
/*realout: structure defining the output realization */
void dual_condit_gen(int k,struct welldata_mod wellin,struct vario_mod variogram,struct grid_mod grid,struct realization_mod *realin,struct statistic_mod stat, struct realization_mod *realout);
void dual_condit_gen(int k, struct welldata_mod wellin, struct vario_mod variogram, struct grid_mod grid, struct realization_mod* realin, struct statistic_mod stat, struct realization_mod* realout);
/*FAST FOURIER TRANSFORM MOVING AVERAGE METHOD */
/*PLUS GRADIENT CALCULATIONS - GRADIENTS ARE */
@ -99,8 +94,7 @@ void dual_condit_gen(int k,struct welldata_mod wellin,struct vario_mod variogram
/*------- */
/*realout: structure defining a realization - */
/*DYoverDRHO : structure with the output gradients */
void FFTMA_gradient(struct vario_mod variogram,struct grid_mod grid,int n[3],struct realization_mod *realin,struct gradients_mod *DZoverDRHO,struct realization_mod *realout,struct gradients_mod *DYoverDRHO);
void FFTMA_gradient(struct vario_mod variogram, struct grid_mod grid, int n[3], struct realization_mod* realin, struct gradients_mod* DZoverDRHO, struct realization_mod* realout, struct gradients_mod* DYoverDRHO);
/* GENERATION OF A GAUSSIAN WHITE NOISE VECTOR */
/*input: */
@ -108,10 +102,9 @@ void FFTMA_gradient(struct vario_mod variogram,struct grid_mod grid,int n[3],str
/* n: number of components in the vector */
/*output: */
/* realization: structure defining the realization*/
void generate(long *seed, int n, struct realization_mod *realization);
void ikrig(int option, struct statfacies_mod facies, int kk,struct welldata_mod data, struct variotable_mod variogram,struct grid_mod grid,float *krigout);
void generate(long* seed, int n, struct realization_mod* realization);
void ikrig(int option, struct statfacies_mod facies, int kk, struct welldata_mod data, struct variotable_mod variogram, struct grid_mod grid, float* krigout);
/*kriging */
/*interpolation from ponctual data with simple */
@ -125,8 +118,7 @@ void ikrig(int option, struct statfacies_mod facies, int kk,struct welldata_mod
/*grid: structure defining the grid */
/*OUTPUT */
/*realout: structure defining the output realization */
void kriging(int k,struct welldata_mod data,struct vario_mod variogram,struct grid_mod grid,struct realization_mod *realout);
void kriging(int k, struct welldata_mod data, struct vario_mod variogram, struct grid_mod grid, struct realization_mod* realout);
/*CHOLESKY SIMULATION TECHNIQUE - LUSIM */
/*appropriate for regular grids and small number */
@ -137,10 +129,9 @@ void kriging(int k,struct welldata_mod data,struct vario_mod variogram,struct gr
/* must be a Gaussian white noise */
/*output: */
/*realout: structure defining a realization - */
void LUSIM(struct vario_mod variogram,struct grid_mod grid,struct realization_mod *realin,struct realization_mod *realout);
void LUSIM(struct vario_mod variogram, struct grid_mod grid, struct realization_mod* realin, struct realization_mod* realout);
void nor2any(struct cdf_mod *pcumulf,struct realization_mod *realin,struct realization_mod *realout);
void nor2any(struct cdf_mod* pcumulf, struct realization_mod* realin, struct realization_mod* realout);
/*TURNS NORMAL NUMBERS INTO LOGNORMAL NUMBERS */
/*input: */
@ -151,8 +142,7 @@ void nor2any(struct cdf_mod *pcumulf,struct realization_mod *realin,struct reali
/*output: */
/*realout: structure defining a realization - */
/* lognormal numbers */
void nor2log(struct realization_mod *realin, int typelog, struct realization_mod *realout);
void nor2log(struct realization_mod* realin, int typelog, struct realization_mod* realout);
/*TURNS NORMAL NUMBERS INTO UNIFORM NUMBERS */
/*input: */
@ -161,8 +151,7 @@ void nor2log(struct realization_mod *realin, int typelog, struct realization_mod
/*output: */
/*realout: structure defining a realization - */
/* uniform numbers */
void nor2unif(struct realization_mod *realin,struct realization_mod *realout);
void nor2unif(struct realization_mod* realin, struct realization_mod* realout);
/*o_kriging */
/*interpolation from ponctual data with ordinary kriging */
@ -175,8 +164,7 @@ void nor2unif(struct realization_mod *realin,struct realization_mod *realout);
/*grid: structure defining the grid */
/*OUTPUT */
/*realout: structure defining the kriged realization */
void o_kriging(int k,struct vario_mod variogram,struct welldata_mod data,struct grid_mod grid,struct realization_mod *realout);
void o_kriging(int k, struct vario_mod variogram, struct welldata_mod data, struct grid_mod grid, struct realization_mod* realout);
/*od_kriging */
/*interpolation from ponctual data with ordinary dual*/
@ -190,8 +178,7 @@ void o_kriging(int k,struct vario_mod variogram,struct welldata_mod data,struct
/*grid: structure defining the grid */
/*OUTPUT */
/*realout: structure defining the output realization */
void od_kriging(int k,struct welldata_mod well,struct vario_mod variogram,struct grid_mod grid,struct realization_mod *realout);
void od_kriging(int k, struct welldata_mod well, struct vario_mod variogram, struct grid_mod grid, struct realization_mod* realout);
/*PLURIGAUSSIAN METHOD */
/*Starting from two independent Gaussian realizations Y1*/
@ -212,8 +199,7 @@ void od_kriging(int k,struct welldata_mod well,struct vario_mod variogram,struct
/*Y2: second starting realization - same length as Y1 */
/*OUTPUT: */
/*Y: output realization */
void plurigau(struct statfacies_mod facies,struct inequalities_mod ineq,struct realization_mod *Y1, struct realization_mod *Y2, struct realization_mod *Y);
void plurigau(struct statfacies_mod facies, struct inequalities_mod ineq, struct realization_mod* Y1, struct realization_mod* Y2, struct realization_mod* Y);
/*tr_kriging */
/*kriging with an external drift */
@ -229,8 +215,7 @@ void plurigau(struct statfacies_mod facies,struct inequalities_mod ineq,struct r
/*y: secondary external variable */
/*OUTPUT: */
/*realout: kriged realization */
void tr_kriging(int k, struct vario_mod variogram,struct welldata_mod data,struct grid_mod grid,struct realization_mod *Y,struct realization_mod *realout);
void tr_kriging(int k, struct vario_mod variogram, struct welldata_mod data, struct grid_mod grid, struct realization_mod* Y, struct realization_mod* realout);
/*truncat */
/*TRUNCATES A STANDARD GAUSSIAN REALIZATION */
@ -246,8 +231,7 @@ void tr_kriging(int k, struct vario_mod variogram,struct welldata_mod data,struc
/*realout: structure defining a realization - */
/*thresholds: Gaussian thresholds corresponding*/
/* to the facies volume fractions if*/
void truncat(struct statfacies_mod facies,struct realization_mod *realin,struct realization_mod *realout, struct statfacies_mod *thresholds);
void truncat(struct statfacies_mod facies, struct realization_mod* realin, struct realization_mod* realout, struct statfacies_mod* thresholds);
/*TURNS UNIFORM NUMBERS INTO NORMAL NUMBERS*/
/*INPUT: */
@ -256,8 +240,7 @@ void truncat(struct statfacies_mod facies,struct realization_mod *realin,struct
/*OUTPUT: */
/*realout: structure defining a realization - */
/* must have zero mean and unit variance */
void unif2nor(struct realization_mod *realin,struct realization_mod *realout);
void unif2nor(struct realization_mod* realin, struct realization_mod* realout);
/*Wany2nor */
/*converts any kind of continuous data to Gaussian data*/
@ -269,8 +252,7 @@ void unif2nor(struct realization_mod *realin,struct realization_mod *realout);
/*wellout: structure with the output well data */
/*pcumulf: structure describing the experimental */
/* cumulative distribution */
void Wany2nor(int k, struct welldata_mod wellin, long *seed,struct welldata_mod *wellout, struct cdf_mod *pcumulf);
void Wany2nor(int k, struct welldata_mod wellin, long* seed, struct welldata_mod* wellout, struct cdf_mod* pcumulf);
/*Wfac2nor0 */
/*turns the facies well measurements into Gaussian data */
@ -288,8 +270,7 @@ void Wany2nor(int k, struct welldata_mod wellin, long *seed,struct welldata_mod
/*output: */
/*wellout: structure defining well data - the kth vector*/
/*of measures are converted to standard normal data */
void Wfac2nor0(int k,struct grid_mod grid,struct welldata_mod wellin,struct statfacies_mod facies,long *seed,struct welldata_mod *wellout);
void Wfac2nor0(int k, struct grid_mod grid, struct welldata_mod wellin, struct statfacies_mod facies, long* seed, struct welldata_mod* wellout);
/*Wfac2nor1 */
/*turns the facies well measurements into Gaussian data */
@ -308,8 +289,7 @@ void Wfac2nor0(int k,struct grid_mod grid,struct welldata_mod wellin,struct stat
/*output: */
/*wellout: structure defining well data - the kth vector*/
/*of measures are converted to standard normal data */
void Wfac2nor1(int k,struct vario_mod variogram,struct grid_mod grid,struct welldata_mod wellin,struct statfacies_mod facies,long *seed,struct welldata_mod *wellout);
void Wfac2nor1(int k, struct vario_mod variogram, struct grid_mod grid, struct welldata_mod wellin, struct statfacies_mod facies, long* seed, struct welldata_mod* wellout);
/*Wfac2norPG0 */
/*turns the facies well measurements into Gaussian data */
@ -332,8 +312,7 @@ void Wfac2nor1(int k,struct vario_mod variogram,struct grid_mod grid,struct well
/*OUTPUT: */
/*wellout: structure defining well data - the kth vector*/
/*of measures are converted to standard normal data */
void Wfac2norPG0(int k,struct inequalities_mod ineq,struct grid_mod grid,struct welldata_mod wellin,struct statfacies_mod facies,long *seed,int idreal,struct welldata_mod *wellout);
void Wfac2norPG0(int k, struct inequalities_mod ineq, struct grid_mod grid, struct welldata_mod wellin, struct statfacies_mod facies, long* seed, int idreal, struct welldata_mod* wellout);
/*Wfac2norPG1 */
/*turns the facies well measurements into Gaussian data */
@ -361,8 +340,7 @@ void Wfac2norPG0(int k,struct inequalities_mod ineq,struct grid_mod grid,struct
/*realization 1 - the kth vector */
/*wellout2: structure with converted well data for */
/*realization 2 - the kth vector */
void Wfac2norPG1(int k,struct inequalities_mod ineq,struct vario_mod variogram1,struct vario_mod variogram2,struct grid_mod grid,struct welldata_mod wellin,struct statfacies_mod facies,long *seed,struct welldata_mod *wellout1,struct welldata_mod *wellout2);
void Wfac2norPG1(int k, struct inequalities_mod ineq, struct vario_mod variogram1, struct vario_mod variogram2, struct grid_mod grid, struct welldata_mod wellin, struct statfacies_mod facies, long* seed, struct welldata_mod* wellout1, struct welldata_mod* wellout2);
/*Wlog2nor */
/*turns the log well measurements into std Gaussian data*/
@ -377,8 +355,7 @@ void Wfac2norPG1(int k,struct inequalities_mod ineq,struct vario_mod variogram1,
/*output: */
/*wellout: structure defining well data - the kth vector*/
/*of measures are converted to standard normal data */
void Wlog2nor(int k, struct welldata_mod wellin,struct grid_mod grid,struct statistic_mod stat,struct welldata_mod *wellout);
void Wlog2nor(int k, struct welldata_mod wellin, struct grid_mod grid, struct statistic_mod stat, struct welldata_mod* wellout);
/*Wnor2nor */
/*converts Well Normal numbers to the standard Gaussian */
@ -390,8 +367,7 @@ void Wlog2nor(int k, struct welldata_mod wellin,struct grid_mod grid,struct stat
/*output: */
/*wellout: structure defining well data - the kth vector*/
/*of measures are converted to standard normal data */
void Wnor2nor(int k, struct welldata_mod wellin,struct grid_mod grid,struct statistic_mod stat,struct welldata_mod *wellout);
void Wnor2nor(int k, struct welldata_mod wellin, struct grid_mod grid, struct statistic_mod stat, struct welldata_mod* wellout);
/*Wunif2nor */
/*converts Well uniform numbers to the standard Gaussian*/
@ -401,8 +377,6 @@ void Wnor2nor(int k, struct welldata_mod wellin,struct grid_mod grid,struct stat
/*output: */
/*wellout: structure defining well data - the kth vector*/
/*of measures are converted to standard normal data */
void Wunif2nor(int k, struct welldata_mod wellin,struct welldata_mod *wellout);
void Wunif2nor(int k, struct welldata_mod wellin, struct welldata_mod* wellout);
#endif // define _CONDOR_H_

@ -25,9 +25,9 @@
#ifndef _genlib_h
#define _genlib_h
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
/* Section 1 -- Define new "primitive" types */
@ -45,20 +45,20 @@
*/
#ifdef THINK_C
typedef int bool;
typedef int bool;
#else
#ifdef TRUE
#ifndef bool
#define bool int
#endif
#else
#ifdef bool
#define FALSE 0
#define TRUE 1
#else
# ifdef TRUE
# ifndef bool
# define bool int
# endif
# else
# ifdef bool
# define FALSE 0
# define TRUE 1
# else
// typedef enum {FALSE, TRUE} bool;
# endif
# endif
#endif
#endif
#endif
/*
@ -72,7 +72,7 @@
* Declaring it as a string emphasizes this atomicity.
*/
typedef char *string;
typedef char* string;
/*
* Constant: UNDEFINED
@ -84,7 +84,7 @@ typedef char *string;
* therefore inappropriate as a sentinel.
*/
#define UNDEFINED ((void *) undefined_object)
#define UNDEFINED ((void*)undefined_object)
extern char undefined_object[];
@ -111,7 +111,7 @@ extern char undefined_object[];
* no memory is available, GetBlock generates an error.
*/
void *GetBlock(size_t nbytes);
void* GetBlock(size_t nbytes);
/*
* Function: FreeBlock
@ -121,7 +121,7 @@ void *GetBlock(size_t nbytes);
* have been allocated using GetBlock, New, or NewArray.
*/
void FreeBlock(void *ptr);
void FreeBlock(void* ptr);
/*
* Macro: New
@ -135,7 +135,7 @@ void FreeBlock(void *ptr);
* target type.
*/
#define New(type) ((type) GetBlock(sizeof *((type) NULL)))
#define New(type) ((type)GetBlock(sizeof *((type)NULL)))
/*
* Macro: NewArray
@ -145,7 +145,7 @@ void FreeBlock(void *ptr);
* values of the specified element type.
*/
#define NewArray(n, type) ((type *) GetBlock((n) * sizeof(type)))
#define NewArray(n, type) ((type*)GetBlock((n) * sizeof(type)))
/* Section 3 -- Basic error handling */

@ -1,8 +1,7 @@
#include <stdio.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#ifndef _GEOSTAT_H
#define _GEOSTAT_H
@ -27,7 +26,6 @@
/* cdf_mod */
/* realization_mod */
/* List of functions: */
/* ------------------ */
@ -44,9 +42,6 @@
/* test_fract, trun1, trungasdev,vec_vec, */
/* vf2gthres,polint */
/*STRUCTURES*/
/*----------*/
/*variogram */
@ -67,16 +62,14 @@
/*scf: correlation lengths per variogram model */
/*var: normalized variance per variogram model(sum = 1)*/
struct vario_mod {
int Nvario;
int *vario;
double *alpha;
double *ap;
double *scf;
double *var;
int Nvario;
int* vario;
double* alpha;
double* ap;
double* scf;
double* var;
};
/*variogram table */
/*Nvario: number of combined variogram models */
/*vario: model of variogram per variogram model */
@ -95,20 +88,15 @@ struct vario_mod {
/*scf: correlation lengths per variogram model */
/*var: normalized variance per variogram model(sum = 1)*/
struct variotable_mod {
int number_of_variograms;
int *Nvario;
int *vario;
float *alpha;
float *ap;
float *scf;
float *var;
int number_of_variograms;
int* Nvario;
int* vario;
float* alpha;
float* ap;
float* scf;
float* var;
};
/*grid */
/*NX: number of gridblocks along the X axis*/
/*NY: number of gridblocks along the Y axis*/
@ -120,12 +108,11 @@ struct variotable_mod {
/*Yo: Y-cell number of the origin cell */
/*Zo: Z-cell number of the origin cell */
struct grid_mod {
int NX, NY, NZ;
double DX,DY,DZ;
double Xo,Yo,Zo;
int NX, NY, NZ;
double DX, DY, DZ;
double Xo, Yo, Zo;
};
/*well data */
/*nwell: number of wells */
/*n: number of measurement points per well */
@ -154,18 +141,16 @@ struct grid_mod {
/* type 2 : */
/* i=[sum(n[k])... sum(n[k])+n[0]-1 ... 2*(sum(n[k])-1)]*/
struct welldata_mod {
int nwell;
int *n;
int ntype;
int *code;
float *x;
float *y;
float *z;
float *measure;
int nwell;
int* n;
int ntype;
int* code;
float* x;
float* y;
float* z;
float* measure;
};
/*volume fractions for facies */
/*ncat: number of facies */
/*nblock: number of gridblocks with different */
@ -175,12 +160,11 @@ struct welldata_mod {
/*vf: volume fractions for the first ncat-1 facies*/
/* i = [0...ncat-2]*nblock */
struct statfacies_mod {
int ncat;
int nblock;
float *vf;
int ncat;
int nblock;
float* vf;
};
/*inequalities for truncated plurigaussian realizations*/
/*only two basic realizations Y1 and Y2 are considered */
/*Y1 and Y2 are independent */
@ -203,14 +187,13 @@ struct statfacies_mod {
/* the values in address_sY2 are integers */
/* ranging from 0 to n+1 with n = nsY1+nsY2*/
struct inequalities_mod {
int nsY1;
int nsY2;
float *thresholds;
int *address_sY1;
int *address_sY2;
int nsY1;
int nsY2;
float* thresholds;
int* address_sY1;
int* address_sY2;
};
/*statistical data */
/*type --> 0 : normal */
/* --> 1 : natural log */
@ -228,14 +211,13 @@ struct inequalities_mod {
/*variance: variance of the variable i = [0...nblock_var]*/
/* DHF CHANGE: FOR TYPE 1 AND TYPE 2, VAR IS LOG VAR ! */
struct statistic_mod {
int type;
int nblock_mean;
double *mean;
int nblock_var;
double *variance;
int type;
int nblock_mean;
double* mean;
int nblock_var;
double* variance;
};
/*gradual deformation parameters */
/*Nadded: number of complementary realizations */
/*NZONES: number of subregions */
@ -246,12 +228,11 @@ struct statistic_mod {
/*cellfin[NZONES*(0...2)] upper cell bound for */
/*for subregions along axes X,Y,Z */
struct grad_mod {
int Nadded, NZONES;
float *rho;
int *cellini, *cellfin;
int Nadded, NZONES;
float* rho;
int *cellini, *cellfin;
};
/*gradient structures */
/*Nparam : number of parameters for which gradients are */
/* required */
@ -264,24 +245,21 @@ struct grad_mod {
/* Ncells....2*Ncells-1 for the second parameter */
/* and so on */
struct gradients_mod {
int Nparam,Ncells;
float *grad;
int Nparam, Ncells;
float* grad;
};
/*description of discretized cumulative distributions */
/*n: number of points */
/*x: values along the x axis i = [0...n-1] */
/*fx: corresponding values for the cumulative */
/* distribution i = [0...n-1] */
struct cdf_mod {
int n;
float *x;
float *fx;
int n;
float* x;
float* fx;
};
/*realization */
/*n: number of components */
/*code: status of the realization */
@ -302,9 +280,9 @@ struct cdf_mod {
/* --> 14: conditional any type */
/*vector: realization vector i = [0...n-1] */
struct realization_mod {
int n;
int code;
double *vector;
int n;
int code;
double* vector;
};
/*=====================================================*/
@ -312,18 +290,15 @@ struct realization_mod {
/*FUNCTIONS*/
/*---------*/
/*normalization of the anostropy axes */
/*ap: anisotropy axes */
/*scf: correlation lengths */
/* The returned normalized axes are in ap */
void axes(double *ap, double *scf, int N);
void axes(double* ap, double* scf, int N);
/*cardsin covariance value for lag h*/
double cardsin(double h);
/*Cholesky decomposition of matrix C */
/* C : symetric positive-definite matrix recorded */
/* (per raws) as a vector with only components */
@ -331,8 +306,7 @@ double cardsin(double h);
/* n : dimension of matrix Cij */
/* */
/* C is turned into the lower triangular cholesky matrix*/
void choldc(double *C, int n);
void choldc(double* C, int n);
/*computes the coordinates of a given cell */
/*as numbers of cells along the X,Y and Z axes*/
@ -342,8 +316,7 @@ void choldc(double *C, int n);
/*grid: structure defining the grid */
/*output: */
/*i: vector with the coordinates */
void coordinates(int maille, int i[3],struct grid_mod grid);
void coordinates(int maille, int i[3], struct grid_mod grid);
/*builds the sampled covariance function */
/*dimensions are even */
@ -352,7 +325,7 @@ void coordinates(int maille, int i[3],struct grid_mod grid);
/*variogram: structure defined above */
/*grid: structure defined above */
/*n: number of gridblocks along X,Y and Z*/
void covariance(double *covar,struct vario_mod variogram, struct grid_mod grid, int n[3]);
void covariance(double* covar, struct vario_mod variogram, struct grid_mod grid, int n[3]);
/*computation of the covariance matrix for the well data*/
/*well coordinates are given as a number of cells */
@ -363,8 +336,7 @@ void covariance(double *covar,struct vario_mod variogram, struct grid_mod grid,
/*variogram: structure defined above */
/*well: structure defined above */
/*grid: structure defined above */
void cov_matrix(double *C, struct vario_mod variogram, struct welldata_mod well, struct grid_mod grid);
void cov_matrix(double* C, struct vario_mod variogram, struct welldata_mod well, struct grid_mod grid);
/*calculation of the covariance value for a distance h */
/*defined by i,j,k */
@ -383,12 +355,11 @@ void cov_matrix(double *C, struct vario_mod variogram, struct welldata_mod well,
/*dj: distance along the Y axis */
/*dk: distance along the Z axis */
/* The returned value is the computed covariance value */
double cov_value(struct vario_mod variogram,double di,double dj,double dk);
double cov_value(struct vario_mod variogram, double di, double dj, double dk);
/*cubic covariance value for lag h*/
double cubic(double h);
/*truncation of the power spectrum to remove */
/*high frequencies - isotropic case */
/*covar: power spectrum */
@ -396,8 +367,7 @@ double cubic(double h);
/*ky: number of cells to save along the y-axis */
/*kz: number of cells to save along the z-axis */
/*n[3]: number of cells along the X, Y and Z axes*/
void cutspectr(float *covar, int kx, int ky, int kz, int n[3]);
void cutspectr(float* covar, int kx, int ky, int kz, int n[3]);
/*defines the threshold interval for a facies x*/
/*lim_inf: lower bound */
@ -406,8 +376,7 @@ void cutspectr(float *covar, int kx, int ky, int kz, int n[3]);
/*thresholds: Gaussian threshold vector */
/*facies: structure defined above */
/*nblock: gridcell number of point x */
void deflimit(double *plim_inf, double *plim_sup, float x, float *thresholds, struct statfacies_mod facies,int nblock);
void deflimit(double* plim_inf, double* plim_sup, float x, float* thresholds, struct statfacies_mod facies, int nblock);
/*kriges the realization considering weights */
/*realin: input realization */
@ -417,14 +386,11 @@ void deflimit(double *plim_inf, double *plim_sup, float x, float *thresholds, st
/*grid: structure defined above */
/*D: weight vector of length Ndata, Di, i = 0...Ndata-1*/
/*The kriged realization is stored in realout */
void dual_kri(struct realization_mod *realin, struct vario_mod variogram,struct welldata_mod well, struct grid_mod grid, double *D,struct realization_mod *realout);
void dual_kri(struct realization_mod* realin, struct vario_mod variogram, struct welldata_mod well, struct grid_mod grid, double* D, struct realization_mod* realout);
/*exponential covariance value for lag h*/
double exponential(double h);
/*Fast Fourier Transform - Cooley-Tukey algorithm */
/*datar: real part vector - to be transformed */
/*datai: imaginary part vector - to be transformed */
@ -435,44 +401,36 @@ double exponential(double h);
/*workr: utility real part vector for storage */
/*worki: utility imaginary part vector for storage */
/*The transformed data are returned in datar and datai*/
void fourt(double *datar,double *datai, int nn[3], int ndim, int ifrwd, int icplx,double *workr,double *worki);
void fourt(double* datar, double* datai, int nn[3], int ndim, int ifrwd, int icplx, double* workr, double* worki);
/*calculates F(x) = (1/a)*exp(-x*x/2)*/
double funtrun1(double x);
/*cumulative standard normal value*/
float G(float x);
/*gamma covariance value for lag h and exponent alpha*/
double gammf(double h, double alpha);
/*returns the value ln(G(x))*/
float gammln(float xx);
/*incomplete gamma fnction*/
float gammp(float a, float x);
/*returns a normally distributed deviate with 0 mean*/
/*and unit variance, using ran1(idum) as the source */
/*of uniform deviates */
/*idum: seed */
double gasdev(long *idum, long *idum2, long *iy, long *iv, int *iset);
double gasdev(long* idum, long* idum2, long* iy, long* iv, int* iset);
/*gaussian covariance value for lag h*/
double gaussian(double h);
/*incomplete gamma function evaluated by its continued */
/*fraction represented as gammcf, also returns ln(G(a))*/
/*as gln */
void gcf(float *gammcf, float a, float x, float *gln);
void gcf(float* gammcf, float a, float x, float* gln);
/*computation of the covariance matrix for the well data*/
/*well coordinates have no specific unit */
@ -483,8 +441,7 @@ void gcf(float *gammcf, float a, float x, float *gln);
/*and k = j+i(i+1)/2 */
/*variogram: structure defined above */
/*well: structure defined above */
void gen_cov_matrix(double *C, struct vario_mod variogram, struct welldata_mod well, int n);
void gen_cov_matrix(double* C, struct vario_mod variogram, struct welldata_mod well, int n);
/*Ginv */
/*Computes the inverse of the standard normal cumulative*/
@ -495,7 +452,6 @@ void gen_cov_matrix(double *C, struct vario_mod variogram, struct welldata_mod w
/*p: cumulative probability value */
float Ginv(float p);
/*gradual combination of 1 realization + Nadded */
/*complementary realizations */
/*rho: gradual deformation parameters */
@ -511,8 +467,7 @@ float Ginv(float p);
/*n: number of components per realization */
/*NZONES: number of subregions */
/*grid: grid definition */
void gradual(struct grad_mod grad,float *Zo,float *Z,float *Zfinal,int n,struct grid_mod grid);
void gradual(struct grad_mod grad, float* Zo, float* Z, float* Zfinal, int n, struct grid_mod grid);
/*computes the size of the underlying grid for FFTs*/
/*input: */
@ -527,8 +482,7 @@ void cgrid(struct vario_mod variogram, struct grid_mod grid, int n[3]);
/*incomplete gamma function evaluated by its series*/
/*representation as gamser, also returns ln(G(a)) */
/*as gln */
void gser(float *gamser, float a, float x, float *gln);
void gser(float* gamser, float a, float x, float* gln);
/*calculates x so that x = invF(u) */
/*F is the cumulative density function for the */
@ -539,18 +493,16 @@ void gser(float *gamser, float a, float x, float *gln);
/*C: normalizing constant */
double invtrun1(double u, double lim_inf, double lim_sup, double C);
/*computes the kriging mean and variance*/
/*for the vector bi, i = [0...n-1] */
void krig_stat(float *b, int n, struct vario_mod variogram, struct welldata_mod well, float *mean, float *var);
void krig_stat(float* b, int n, struct vario_mod variogram, struct welldata_mod well, float* mean, float* var);
/* computes the number of gridblocks for one dimension*/
/*N: initial number of gridblocks */
/*i: considered direction */
/*scf: correlation length */
/*ap: normalized anisotropy axes */
int length(int N, int i, double *scf, double *ap, double D, int Nvari);
int length(int N, int i, double* scf, double* ap, double D, int Nvari);
/*calculates L.Z/
/* L : lower triangular matrix recorded */
@ -561,7 +513,7 @@ int length(int N, int i, double *scf, double *ap, double D, int Nvari);
/* n : dimension of matrix Lij */
/* */
/* The solution vector is returned in b */
void LtimeZ(double *L, float *Z, float *b, int n);
void LtimeZ(double* L, float* Z, float* b, int n);
/*determines the greatest prime factor of an integer*/
int maxfactor(int n);
@ -571,40 +523,32 @@ int maxfactor(int n);
/*defined by the probability ratio "ratio". */
/*If ratio >= 1, metrop = 1(true), while if ratio < 1, */
/*metrop is only true with probability "ratio" */
int metrop(double ratio,long *idum,long *idum2, long *iy, long *iv);
int metrop(double ratio, long* idum, long* idum2, long* iy, long* iv);
/*2-norm of vector b */
/* b : vector */
/* n : length of b, bi, i = [0...n-1]*/
/*returns the norm of b */
double norm(double *b,int n);
double norm(double* b, int n);
/*value of g(x) where g is the normal function*/
double normal(double x);
/*nugget covariance value for lag h*/
double nugget(double h);
/*power covariance value for lag h and exponent alpha*/
double power(double h,double alpha);
double power(double h, double alpha);
/*generates uniform deviates between 0 and 1*/
/*idum: seed */
double ran2(long *idum, long *idum2, long *iy, long *iv);
double ran2(long* idum, long* idum2, long* iy, long* iv);
/*calculates bt.b */
/* b : vector, bi, i = [0...n-1] */
/* n : length of b */
/*returns the scalar product of b*/
double scal_vec(double *b,int n);
double scal_vec(double* b, int n);
/*solves the set of n linear equations Cx = D */
/* C : symmetric positive-definite matrix recorded */
@ -615,32 +559,26 @@ double scal_vec(double *b,int n);
/* */
/* The solution vector is returned in D */
/* CONJUGATE GRADIENT method */
void solve3(double *C, double *D, int n);
void solve3(double* C, double* D, int n);
/*sorts an array [0...n-1] into ascending order using */
/*shell */
void sort(float n, float *arr);
void sort(float n, float* arr);
/*spherical covariance value for lag h*/
double spherical(double h);
/*stable covariance value for lag h and exponent alpha*/
double stable(double h, double alpha);
/*conversion of log mean and variance to nor*/
void statlog2nor(struct statistic_mod *pstat);
void statlog2nor(struct statistic_mod* pstat);
/*tries factor */
/*pnum: number to be decomposed */
/*fact: suggested factor */
/*pmaxfac: memory to keep the greatest factor*/
int test_fact(int *pnum, int fact, int *pmaxfac);
int test_fact(int* pnum, int fact, int* pmaxfac);
/*calculates the integrale of an approximate function*/
/*for the Gaussian function over an interval defined */
@ -649,29 +587,25 @@ int test_fact(int *pnum, int fact, int *pmaxfac);
/*lim_sup: upper bound of the considered interval */
double trun1(double lim_inf, double lim_sup);
/*draws a truncated gaussian variable between lim_inf*/
/*and lim_sup */
/*idum: seed */
double trungasdev(long *idum,double lim_inf,double lim_sup,long *idum2, long *iy, long iv[NTAB]);
double trungasdev(long* idum, double lim_inf, double lim_sup, long* idum2, long* iy, long iv[NTAB]);
/* tb1.b2 */
/* b1 : vector */
/* b2 : vector */
/* n : length of b1 and b2, bi, i = [0...n-1]*/
/*returns the norm the product tb1.b2 */
double vec_vec(double *b1, double *b2,int n);
double vec_vec(double* b1, double* b2, int n);
/*turns the volume fractions into Gaussian thresholds */
/*facies: structure defined above */
/*thresholds: output threshold vector fot i = [0...n-1]*/
/*where n is the number of facies-1 */
/*USES normal*/
void vf2gthres(struct statfacies_mod facies,float *thresholds);
void polint(float xa[],float ya[],int n,float x, float *y,float *dy);
void vf2gthres(struct statfacies_mod facies, float* thresholds);
void polint(float xa[], float ya[], int n, float x, float* y, float* dy);
#endif

@ -1,7 +1,7 @@
#include <stdlib.h>
#include <string.h>
#include "genlib.h"
#include "geostat.h"
#include <stdlib.h>
#include <string.h>
#ifndef _PRESSURE_H
#define _PRESSURE_H
@ -14,8 +14,7 @@
/* y: macroscopic gradient value in x direction */
/* z: macroscopic gradient value in x direction */
struct pressure_mod {
double x,y,z;
double x, y, z;
};
#endif // define _PRESSURE_H

@ -23,7 +23,7 @@
*/
#ifndef RAND_MAX
# define RAND_MAX ((int) ((unsigned) ~0 >> 1))
#define RAND_MAX ((int)((unsigned)~0 >> 1))
#endif
/*

@ -60,7 +60,7 @@
* internal representation are hidden from the client.
*/
typedef struct scannerCDT *scannerADT;
typedef struct scannerCDT* scannerADT;
/*
* Function: NewScanner
@ -151,7 +151,8 @@ void SaveToken(scannerADT scanner, string token);
* of this option.
*/
typedef enum { PreserveSpaces, IgnoreSpaces } spaceOptionT;
typedef enum { PreserveSpaces,
IgnoreSpaces } spaceOptionT;
void SetScannerSpaceOption(scannerADT scanner, spaceOptionT option);
spaceOptionT GetScannerSpaceOption(scannerADT scanner);

@ -70,6 +70,6 @@ string GetLine(void);
* is at the end-of-file position.
*/
string ReadLine(FILE *infile);
string ReadLine(FILE* infile);
#endif

@ -22,7 +22,7 @@
* be changed by editing this definition line.
*/
typedef void *stackElementT;
typedef void* stackElementT;
/*
* Type: stackADT
@ -34,7 +34,7 @@ typedef void *stackElementT;
* the underlying fields.
*/
typedef struct stackCDT *stackADT;
typedef struct stackCDT* stackADT;
/*
* Function: NewStack

@ -15,7 +15,7 @@
* This type is the ADT used to represent a symbol table.
*/
typedef struct symtabCDT *symtabADT;
typedef struct symtabCDT* symtabADT;
/*
* Type: symtabFnT
@ -24,8 +24,8 @@ typedef struct symtabCDT *symtabADT;
* map over the entries in a symbol table.
*/
typedef void (*symtabFnT)(string key, void *value,
void *clientData);
typedef void (*symtabFnT)(string key, void* value,
void* clientData);
/* Exported entries */
@ -55,7 +55,7 @@ void FreeSymbolTable(symtabADT table);
* Each call to Enter supersedes any previous definition for key.
*/
void Enter(symtabADT table, string key, void *value);
void Enter(symtabADT table, string key, void* value);
/*
* Function: Lookup
@ -65,7 +65,7 @@ void Enter(symtabADT table, string key, void *value);
* table, or UNDEFINED, if no such value exists.
*/
void *Lookup(symtabADT table, string key);
void* Lookup(symtabADT table, string key);
/*
* Function: MapSymbolTable
@ -80,6 +80,6 @@ void *Lookup(symtabADT table, string key);
*/
void MapSymbolTable(symtabFnT fn, symtabADT table,
void *clientData);
void* clientData);
#endif

@ -1,7 +1,7 @@
#include <stdlib.h>
#include <string.h>
#include "genlib.h"
#include "geostat.h"
#include <stdlib.h>
#include <string.h>
#ifndef _TOOLSFFTMA_H
#define _TOOLSFFTMA_H
@ -13,7 +13,6 @@
/* ------------------ */
/* kgeneration, FFTMA2, prebuild_gwn, build_real, , clean_real */
/*FAST FOURIER TRANSFORM Pressure Simulation */
/*Turns a Gaussian white noise vector into a */
/*spatially correlated vector */
@ -37,7 +36,7 @@
/*realout4: structure defining a yvelocity field */
/*realout5: structure defining a zvelocity field */
void FFTMA2(struct vario_mod variogram,struct grid_mod grid,int n[3],struct realization_mod *realin,struct realization_mod *realout);
void FFTMA2(struct vario_mod variogram, struct grid_mod grid, int n[3], struct realization_mod* realin, struct realization_mod* realout);
/* prebuild_gwn */
/* Produce a first construction in real space of the Gaussian white noise */
@ -52,7 +51,7 @@ void FFTMA2(struct vario_mod variogram,struct grid_mod grid,int n[3],struct real
/* must be a Gaussian white noise */
/*realization: structure defining a realization*/
void prebuild_gwn(struct grid_mod grid,int n[3],struct realization_mod *realin,double *realization,int solver);
void prebuild_gwn(struct grid_mod grid, int n[3], struct realization_mod* realin, double* realization, int solver);
/* build_real */
/* build a realization in the spectral domain */
@ -66,8 +65,8 @@ void prebuild_gwn(struct grid_mod grid,int n[3],struct realization_mod *realin,d
/*realization: vector defining the real part */
/*ireal: vector defining the i-part */
void build_real(int n[3],int NTOT,double *covar,double *realization,double *ireal);
void build_real(int n[3], int NTOT, double* covar, double* realization, double* ireal);
void clean_real(struct realization_mod *realin,int n[3],struct grid_mod grid,double *vectorresult,struct realization_mod *realout);
void clean_real(struct realization_mod* realin, int n[3], struct grid_mod grid, double* vectorresult, struct realization_mod* realout);
#endif // define _TOOLSFFTMA_H

@ -1,7 +1,6 @@
#include <string.h>
#include "geostat.h"
#include "pressure.h"
#include <string.h>
#ifndef _TOOLSFFTPSIM_H
#define _TOOLSFFTPSIM_H
@ -15,9 +14,9 @@
/*Functions */
/*----------*/
void FFTPSim(struct vario_mod variogram,struct statistic_mod stat,struct grid_mod grid,int n[3],struct realization_mod *realin,struct pressure_mod gradient,struct realization_mod *realout,struct realization_mod *realout2,struct realization_mod *realout3,struct realization_mod *realout4,struct realization_mod *realout5);
void FFTPSim(struct vario_mod variogram, struct statistic_mod stat, struct grid_mod grid, int n[3], struct realization_mod* realin, struct pressure_mod gradient, struct realization_mod* realout, struct realization_mod* realout2, struct realization_mod* realout3, struct realization_mod* realout4, struct realization_mod* realout5);
void normAxes(double *vec, double *normed);
void waveVectorCompute1D(int n,double *vec);
void normAxes(double* vec, double* normed);
void waveVectorCompute1D(int n, double* vec);
#endif // define _TOOLSFFTPSIM_H

@ -1,8 +1,8 @@
#include <stdlib.h>
#include <string.h>
#include "genlib.h"
#include "geostat.h"
#include "pressure.h"
#include <stdlib.h>
#include <string.h>
#ifndef _TOOLSIO_H
#define _TOOLSIO_H
@ -14,11 +14,10 @@
/* ------------------ */
/* testmemory */
/*FUNCTIONS*/
/*----------*/
/* Allocation test */
void testmemory(double *realint);
void testmemory(double* realint);
#endif // define _TOOLSIO_H

@ -1,20 +1,20 @@
#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 "genlib.h"
#include "geostat.h"
#include "toolsIO.h"
#include "toolsFFTMA.h"
#include "pressure.h"
#include "simpio.h"
#include "toolsFFTMA.h"
#include "toolsFFTPSIM.h"
#include "toolsIO.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 */
@ -23,43 +23,38 @@
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];
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;
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];
if (!Py_getvalues(args, &seed, &grid, &variogram, &stat))
return NULL;
Py_kgeneration(seed, grid, stat, variogram, &Z, &Y, &Y1, n);
out_array = PyArray_SimpleNewFromData(NDIMENSIONS,out_dims,NPY_DOUBLE,Y.vector);
if (out_array == NULL)
return NULL;
out_dims[0] = grid.NZ;
out_dims[1] = grid.NY;
out_dims[2] = grid.NX;
PyArray_ENABLEFLAGS(out_array, NPY_ARRAY_OWNDATA);
out_array = PyArray_SimpleNewFromData(NDIMENSIONS, out_dims, NPY_DOUBLE, Y.vector);
if (out_array == NULL)
return NULL;
return out_array;
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 PyMethodDef FFTMAMethods[] = {
{ "gen", genFunc, METH_VARARGS, "Generates a permeability 3D field." },
{ NULL, NULL, 0, NULL }
};
static struct PyModuleDef cFFTMADef =
{
static struct PyModuleDef cFFTMADef = {
PyModuleDef_HEAD_INIT,
"FFTMA", "",
-1,
@ -69,6 +64,6 @@ static struct PyModuleDef cFFTMADef =
PyMODINIT_FUNC
PyInit_FFTMA(void)
{
import_array();
return PyModule_Create(&cFFTMADef);
import_array();
return PyModule_Create(&cFFTMADef);
}

Loading…
Cancel
Save