#include "geostat.h" #include #include #include #include #include #include #include #include "file_array.h" /* build_real */ /* build a realization in the spectral domain */ /*n: vector with the number of cells along the */ /* X, Y and Z axes for the underlying grid */ /* i = [0 1 2] */ /* --> 0 0 0 : n will be computed and */ /* updated as output */ /* --> nx ny nz: these dimensions are used */ /*covar: vector defining the covariance in spectral domain */ /*realization: vector defining the real part */ /*ireal: vector defining the i-part */ void build_real(int n[3], int NTOT, file_array_t* covar, file_array_t* realization, file_array_t* ireal) { int i, j, k, maille1; double temp; file_array_read(realization); file_array_read(ireal); file_array_read(covar); /*decomposition and multiplication in the spectral domain*/ for (k = 1; k <= n[2]; k++) { for (j = 1; j <= n[1]; j++) { for (i = 1; i <= n[0]; i++) { maille1 = i + (j - 1 + (k - 1) * n[1]) * n[0]; file_array_get(covar, maille1, &temp); if (temp > 0.) { temp = sqrt(temp) / (double)NTOT; } else if (temp < 0.) { temp = sqrt(-temp) / (double)NTOT; } double valuerealizationmaille1, valueirealmaille1; file_array_get(realization, maille1, &valuerealizationmaille1); file_array_get(ireal, maille1, &valueirealmaille1); file_array_save(realization, maille1, temp * valuerealizationmaille1); file_array_save(ireal, maille1, temp * valueirealmaille1); } } } }