#include #include #include "math.h" #include #include // pyl 05/12 // 0K 01/2014 // // cc sv_plage.c ;./a.out | gnuplot // // // Lagree //A fast and stable well-balanced scheme with hydrostatic reconstruction for shallow water flows // Emmanuel Audusse, Franccois Bouchut, Marie-Odile Bristeau, Rupert Klein and Benoıt Perthame // Delestre These double*x=NULL,*h=NULL,*u=NULL,*Q=NULL,*U=NULL,*Z=NULL,*dZ=NULL,*Zp=NULL; double t,dt,tmax,dx,Fr,Cf,h0,xbosse,lbosse,abosse,h0,alpha,e; int cas,nx,icl; void reconsetat(double hl,double hr,double dz,double *hil,double *hir) { *hil=fmax(0.,hl-fmax(0.0,dz)); *hir=fmax(0.,hr-fmax(0.0,-dz)); // *hil=hl ; // *hir=hr; } double FR1(double ug,double ud,double hg,double hd) { double c; //Rusanov c=fmax(fabs(ug)+sqrt(hg),fabs(ud)+sqrt(hd)); return (hg*ug+hd*ud)*0.5-c*(hd-hg)*0.5; } double FR2(double ug,double ud,double hg,double hd) { double c; //Rusanov c=fmax(fabs(ug)+sqrt(hg),fabs(ud)+sqrt(hd)); return (ug*ug*hg + hg*hg/2. + ud*ud*hd + hd*hd/2.)*0.5 - c*(hd*ud-hg*ug)*0.5; } double FR3(double ug,double ud,double hg,double hd) { return fmax(fabs(ug)+sqrt(hg),fabs(ud)+sqrt(hd)); } double F(double ug,double ud,double hg,double hd,double *f1,double *f2,double *cfl) { double c; //Rusanov c=fmax(fabs(ug)+sqrt(hg),fabs(ud)+sqrt(hd)); *f1=(hg*ug+hd*ud)*0.5-c*(hd-hg)*0.5; *f2=(ug*ug*hg + hg*hg/2. + ud*ud*hd + hd*hd/2.)*0.5 - c*(hd*ud-hg*ug)*0.5; *cfl=fabs(c); } double FHLL1(double ug,double ud,double hg,double hd) { double cfl,c1,c2,c3,f1,f2; //HLL c1=fmin(ug -sqrt(hg),ud-sqrt(hd)); c2=fmax(ug +sqrt(hg),ud+sqrt(hd)); // c2=fmax(fabs(ug)+sqrt(hg),fabs(ud)+sqrt(hd)); // c1=-c2; if (c1>=0.){ f1=hg*ug; f2=hg*ug*ug+hg*hg/2; cfl=fabs(c2);} else{ if ((c1<0.)&&(0.=0.){ f1=hg*ug; f2=hg*ug*ug+hg*hg/2; cfl=fabs(c2);} else{ if ((c1<0.)&&(0.=0.){ cfl=fabs(c2);} else{ if ((c1<0.)&&(0.xbosse)*(x[i]-xbosse); h[i]=fmax(1+abosse*exp(-x[i]*x[i])-Z[i],0); u[i]=0; Q[i]=0; } for(i=0;idx/dt){ dt = dx/cfl2/2;} // boucle principale // U=(h,hu) // Unouveau = Uancien + dt (Flux gauche-Flux droit) for(i=1;i0.){ //conservation qunatité de mouvement q=h[i]*u[i]-dt*(fd[i+1]-fd[i])/dx -dt*( hig[i]*hig[i]/2 - hg[i]*hg[i]/2 + hd[i]*hd[i]/2- hid[i]*hid[i]/2)/dx; // frottement if(q>0) sign= 1; if(q<0) sign=-1; if((q!=0)&&(Cf>0)) q = q/(1+dt*Cf/h[i]/h[i]); un[i]=q/hn[i];} else{ un[i]=0.;} } hn[0]=hn[1]; un[0]=un[1]; hn[nx]=hn[nx-1]; un[nx]=un[nx-1]; //u[nx]=u[nx-1]-sqrt(h[nx-1]) + sqrt(h[nx]); //; e=0; for(i=0;i<=nx;i++) { e=e + hn[i]*dx; h[i]=hn[i]; u[i]=un[i]; Q[i]=hn[i]*un[i]; } if(it%150==0)ecrit(); } free(x); free(fp); free(fd); free(hd); free(hg); return 0; }