资源描述:
《方柱绕流的LBM代码(C++)》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、//1.头文件及声明文件#include#include#include#include#include#include#includeusingnamespacestd;constintQ=9;constintNX=200;constintNY=45;constintDX=20;constintDY=19;constintH=5;constdoubleU=0.1;inte[Q][2]={{0,0},{
2、1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1}};doublew[Q]={4.0/9,1.0/9,1.0/9,1.0/9,1.0/9,1.0/36,1.0/36,1.0/36,1.0/36};doublerho[NX+1][NY+1],u[NX+1][NY+1][2],u0[NX+1][NY+1][2],f[NX+1][NY+1][Q],F[NX+1][NY+1][Q],p[NX+1][NY+1],uv[NX+1][NY+1];inti,j,k,ip,jp,n;do
3、ublec,Re,dx,dy,Lx,Ly,dt,rho0,tau_f,niu,error;voidinit();doublefeq(intk,doublerho,doubleu[2]);voidevolution();voidstatistic();voidboundary();voidoutput(intm);voidError();//2.主程序文件intmain(){usingnamespacestd;init();for(n=0;n<40000;n++){evolution();statistic();bounda
4、ry();if(n%10==0){Error();cout<<"The"<=1000)
5、{if(error<1.0e-6)break;}}}return0;}//3.初始化文件voidinit()//初始函数{dx=1.0;dy=1.0;Lx=dx*double(NX);Ly=dy*double(NY);dt=dx;c=dx/dt;rho0=1.0;Re=100;niu=U*H/Re;tau_f=3.0*niu+0.5;std::cout<<"tau_f="<6、u[0][j][0]=U;rho[i][j]=rho0;for(k=0;k7、碰撞以及迁移代码voidevolution(){for(i=1;i=DX&&i<=DX+H&&j>=DY&&j<=DY+H)continue;for(k=0;k8、){for(i=1;i=DX&&i<=DX+H&&j>=DY&&j<=DY+H)continue;//抛去圆柱边界格点u0[i][j][0]=u[i][j][0];u0[i][j][1]=u[i][j][1];//不需要收