//12 12 03 #include #include #include "math.h" #define randzard() ((float)rand()/(float)RAND_MAX)*2-1; void fondinit(double x[],double yw[],int nx,double dx,double Lx,double Lb,double h0,int type) {static double xhmax,seed; static double *TFf; extern double Pi; int i; /* initialisation de la bosse */ for (i=0; i<=nx;i++) {x[i]=-Lx+ i*dx;} /* bruit blanc */ if((type)==0){ TFf =(double*)calloc(2*nx+30,sizeof(double)); TFf[0]=0; TFf[1]=0; for (i=2; i<=2*nx;i++){ seed=randzard(); TFf[i]=h0 *seed *nx ; } dfour1(TFf,nx,-1); for (i=1; i<=2*nx;i++){TFf[i]=TFf[i]/nx;} for (i=0; i<=nx;i++){yw[i]=TFf[2*i+1];} free(TFf); } /* expon */ if((type)==1){ xhmax=0; for (i=0; i<=nx;i++) { yw[i]= h0*exp(-Pi*pow((x[i]-xhmax)/Lb,2)); } } /* cos */ if((type)==2){ for (i=0; i<=nx;i++) { yw[i]= h0*cos( 4*Pi*x[i]/Lb /2) ; } } /* expon */ if((type)==3){ xhmax=-3*Lx/4; for (i=0; i<=nx;i++) { yw[i]= h0*exp(-Pi*pow((x[i]-xhmax)/Lb,2)); } } /* reprise if((type)==4){ g= fopen("xyptqA.OUT","r"); for (i=0; i0){yw[i]=h0*(1-x[i]/Lb);} if(x[i]<0){yw[i]=h0*(1+x[i]/Lb);} if(fabs(x[i])>Lb){yw[i]=0;} } } /* fin init geometrie */ }