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.
118 lines
2.5 KiB
C
118 lines
2.5 KiB
C
#include <stdio.h>
|
|
#include <stddef.h>
|
|
#include <stdarg.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <math.h>
|
|
#include "geostat.h"
|
|
#include "pressure.h"
|
|
|
|
/* Build_velocity */
|
|
/* Build velocity in spectral domain */
|
|
|
|
void build_velocity(int n[3],struct grid_mod grid,struct statistic_mod stat,struct pressure_mod gradient,double *realization,double *ireal,double *xvelocity,double *ixvelocity,int direction)
|
|
{
|
|
int i,j,k,maille1;
|
|
int x,y,z;
|
|
double ki,kj,kk;
|
|
double coeff,temp,temp2;
|
|
double grad;
|
|
|
|
/* x-direction velocity calculation in the spectral domain*/
|
|
switch(direction)
|
|
{
|
|
case 1:
|
|
grad = gradient.x;
|
|
x=1;
|
|
y=0;
|
|
z=0;
|
|
break;
|
|
case 2:
|
|
grad = gradient.y;
|
|
x=0;
|
|
y=1;
|
|
z=0;
|
|
break;
|
|
case 3:
|
|
grad = gradient.z;
|
|
x=0;
|
|
y=0;
|
|
z=1;
|
|
break;
|
|
default :
|
|
printf("build_velocity.c: wrong velocity direction!!! direction: %d\n",direction);
|
|
break;
|
|
}
|
|
|
|
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];
|
|
/* if (i<n[0]/2) { */
|
|
/* ki =(double)i/(double)(grid.NX*grid.DX); */
|
|
/* } else { */
|
|
/* ki =-(double)(n[0]-i+1)/(double)(grid.NX*grid.DX); */
|
|
/* } */
|
|
/* if (j<n[1]/2) { */
|
|
/* kj =(double)j/(double)(grid.NY*grid.DY); */
|
|
/* } else { */
|
|
/* kj =-(double)(n[1]-j+1)/(double)(grid.NY*grid.DY); */
|
|
/* } */
|
|
/* if (k<n[2]/2) { */
|
|
/* kk =(double)k/(double)(grid.NZ*grid.DZ); */
|
|
/* } else { */
|
|
/* kk =-(double)(n[2]-k+1)/(double)(grid.NZ*grid.DZ); */
|
|
/* } */
|
|
|
|
if (n[0]==1)
|
|
{
|
|
ki=0;
|
|
}
|
|
else if (i<n[0]/2)
|
|
{
|
|
ki =(double)i/(double)(grid.NX*grid.DX);
|
|
}
|
|
else
|
|
{
|
|
ki =-(double)(n[0]-i+1)/(double)(grid.NX*grid.DX);
|
|
}
|
|
|
|
if (n[1]==1)
|
|
{
|
|
kj=0;
|
|
}
|
|
else if (j<n[1]/2)
|
|
{
|
|
kj =(double)j/(double)(grid.NY*grid.DY);
|
|
}
|
|
else
|
|
{
|
|
kj =-(double)(n[1]-j+1)/(double)(grid.NY*grid.DY);
|
|
}
|
|
|
|
if (n[2]==1)
|
|
{
|
|
kk=0;
|
|
}
|
|
else if (k<n[2]/2)
|
|
{
|
|
kk =(double)k/(double)(grid.NZ*grid.DZ);
|
|
}
|
|
else
|
|
{
|
|
kk =-(double)(n[2]-k+1)/(double)(grid.NZ*grid.DZ);
|
|
}
|
|
|
|
coeff = (gradient.x*ki+gradient.y*kj+gradient.z*kk)/(ki*ki+kj*kj+kk*kk);
|
|
temp = realization[maille1];
|
|
temp2= ireal[maille1];
|
|
|
|
xvelocity[maille1] = stat.mean[0]*(grad-(ki*x+kj*y+kk*z)*coeff)*temp;
|
|
ixvelocity[maille1]= stat.mean[0]*(grad-(ki*x+kj*y+kk*z)*coeff)*temp2;
|
|
}
|
|
}
|
|
}
|
|
|
|
return;
|
|
}
|