|
|
@ -22,7 +22,7 @@
|
|
|
|
/* must be a Gaussian white noise */
|
|
|
|
/* must be a Gaussian white noise */
|
|
|
|
/*realization: structure defining a realization*/
|
|
|
|
/*realization: structure defining a realization*/
|
|
|
|
|
|
|
|
|
|
|
|
void prebuild_gwn(struct grid_mod grid, int n[3], struct realization_mod* realin, double* realization, int solver, int cores) {
|
|
|
|
void prebuild_gwn(struct grid_mod grid, int n[3], struct realization_mod* realin, double* realization, int solver, int cores, long* seed) {
|
|
|
|
double* used_ram_t0 = malloc(sizeof(double));
|
|
|
|
double* used_ram_t0 = malloc(sizeof(double));
|
|
|
|
getVirtualMemUsed(used_ram_t0);
|
|
|
|
getVirtualMemUsed(used_ram_t0);
|
|
|
|
|
|
|
|
|
|
|
@ -31,6 +31,13 @@ void prebuild_gwn(struct grid_mod grid, int n[3], struct realization_mod* realin
|
|
|
|
int i, j, k, maille0, maille1;
|
|
|
|
int i, j, k, maille0, maille1;
|
|
|
|
int ntot;
|
|
|
|
int ntot;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
long idum2 = 123456789, iy = 0;
|
|
|
|
|
|
|
|
long* iv = (long*)malloc(NTAB * sizeof(long));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*negative seed*/
|
|
|
|
|
|
|
|
if (*seed > 0.0)
|
|
|
|
|
|
|
|
*seed = -(*seed);
|
|
|
|
|
|
|
|
|
|
|
|
log_info("RESULT = in progress, n[0] = %d, n[1] = %d, n[2] = %d, solver = %d", n[0], n[1], n[2], solver);
|
|
|
|
log_info("RESULT = in progress, n[0] = %d, n[1] = %d, n[2] = %d, solver = %d", n[0], n[1], n[2], solver);
|
|
|
|
|
|
|
|
|
|
|
|
struct cpustat initial[cores];
|
|
|
|
struct cpustat initial[cores];
|
|
|
@ -42,10 +49,14 @@ void prebuild_gwn(struct grid_mod grid, int n[3], struct realization_mod* realin
|
|
|
|
|
|
|
|
|
|
|
|
ntot = n[0] * n[1] * n[2];
|
|
|
|
ntot = n[0] * n[1] * n[2];
|
|
|
|
realization[0] = 0.;
|
|
|
|
realization[0] = 0.;
|
|
|
|
|
|
|
|
/*printf("Antes de llamar a chunkarray read\n");
|
|
|
|
chunk_array_read((*realin).vector_2);
|
|
|
|
chunk_array_read((*realin).vector_2);
|
|
|
|
|
|
|
|
printf("Despues de llamar a chunkarray read\n");*/
|
|
|
|
if (solver == 1) {
|
|
|
|
if (solver == 1) {
|
|
|
|
for (i = 0; i < ntot; i++) {
|
|
|
|
for (i = 0; i < ntot; i++) {
|
|
|
|
chunk_array_get((*realin).vector_2, i, &realization[i + 1]);
|
|
|
|
double value = gasdev(seed, &idum2, &iy, iv, cores);
|
|
|
|
|
|
|
|
realization[i+1] = value;
|
|
|
|
|
|
|
|
//chunk_array_get((*realin).vector_2, i, &realization[i + 1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
for (k = 1; k <= n[2]; k++) {
|
|
|
|
for (k = 1; k <= n[2]; k++) {
|
|
|
@ -53,8 +64,11 @@ void prebuild_gwn(struct grid_mod grid, int n[3], struct realization_mod* realin
|
|
|
|
for (i = 1; i <= n[0]; i++) {
|
|
|
|
for (i = 1; i <= n[0]; i++) {
|
|
|
|
maille1 = i + (j - 1 + (k - 1) * n[1]) * n[0];
|
|
|
|
maille1 = i + (j - 1 + (k - 1) * n[1]) * n[0];
|
|
|
|
if (i <= grid.NX && j <= grid.NY && k <= grid.NZ) {
|
|
|
|
if (i <= grid.NX && j <= grid.NY && k <= grid.NZ) {
|
|
|
|
maille0 = i - 1 + (j - 1 + (k - 1) * grid.NY) * grid.NX;
|
|
|
|
//maille0 = i - 1 + (j - 1 + (k - 1) * grid.NY) * grid.NX;
|
|
|
|
chunk_array_get((*realin).vector_2, maille0, &realization[maille1]);
|
|
|
|
//printf("Maille0 es %d", maille0);
|
|
|
|
|
|
|
|
double value = gasdev(seed, &idum2, &iy, iv, cores);
|
|
|
|
|
|
|
|
realization[maille1] = value;
|
|
|
|
|
|
|
|
//chunk_array_get((*realin).vector_2, maille0, &realization[maille1]);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
realization[maille1] = 0.;
|
|
|
|
realization[maille1] = 0.;
|
|
|
|
}
|
|
|
|
}
|
|
|
|