www.gusucode.com > LBM格子波尔兹曼 matlab例程源码程序 > cylinder2d.m
clc clear % Load LBM-C Variables % lbm_c_vars % Project Variables ProjName = 'cylinder2d'; DomainFile = 'cylinder2d.cgns'; OutputFile = 'cylinder2d.res'; % Solution Constants Tau = 1.0; Lx = 500; Ly = 100; Lz = 1; DeltaX = 1; DeltaT = 1; C_smag = 0; % Solution Configuration ColType = 'BGK'; Force = 0; MicroBC = 1; MacroBC = 1; Init = 0; Tolerance = 0; % Timing Data MaxT = 10000; FileOut = 500; ScreenMes = 50; SteadyCheck = 0; % Output Variables Ux = 1; Uy = 1; Uz = 0; Rho = 1; P = 1; ScreenX = 0; ScreenY = floor(Ly/2); ScreenZ = 0; Interactive = 0; % Domain Arrays porosity = zeros(Lx,Ly); micro_bc = zeros(Lx,Ly); macro_bc = zeros(Lx,Ly); rho = zeros(Lx,Ly); velocity = zeros(3,Lx,Ly); porosity(:,[1,Ly]) = 1; obst_x = floor((1/5)*Lx); obst_y = floor((1/2)*Ly)-2; obst_r = 20; for i = 0:(Lx) for j = 0:(Ly) if (i-obst_x)^2 + (j-obst_y)^2<= obst_r^2 porosity(i,j) = 1; end end end micro_bc(1,:) = ZOU_HE_P_x; micro_bc(Lx,:) = ZOU_HE_P_X; macro_bc(1,:) = PRESCRIBED_RHO; macro_bc(Lx,:) = PRESCRIBED_RHO rho(1,:) = 1.00002; rho(Lx,:) = 0.99998; write_ascii_input write_cgns_input fname_in = [ProjName,'.lbmc']; command = ['lbm-c-2d ',fname_in]; system(command); time_values = read_output_times(OutputFile); ux = read_output_field(OutputFile,length(time_values),'VelocityX'); uy = read_output_field(OutputFile,length(time_values),'VelocityY'); rho = read_output_field(OutputFile,length(time_values),'Density'); for i = 1:length(time_values) ux = read_output_field(OutputFile,i,'VelocityX'); uy = read_output_field(OutputFile,i,'VelocityY'); u = sqrt(ux.*ux+uy.*uy); imagesc(u'); pause end