lbm.c
来自「格子Boltzmann方法 格子Boltzmann方法是为了保留格子气自动机方」· C语言 代码 · 共 54 行
C
54 行
// lbm.c#include <stdio.h>#include "D2Q9.h"#include <sys/times.h>#include <sys/time.h>double CPU_time(){ #ifndef CLK_TCK #define CLK_TCK 100.0 #endif struct tms t; times(&t); return (1.0*t.tms_utime + t.tms_stime)/CLK_TCK;}void ShowBdy(){ int i, j; for(j=0; j<Ny; j++) { for(i=0; i<Nx; i++) printf("%d", boundary[i][j]); printf("\n"); }}int main(int argc, char *argv[]){ double ctime; int i; if(argc>1) Init(argv[1]); else Init("bdy.lbm"); printf("Re=%f, omega=%f\n", Re, omega); ShowBdy(); ctime = CPU_time(); for(i=0; i<5000; i++) { evolution();// printf("\rn=%d, t=%f ", n, t); } ctime = CPU_time() - ctime; SaveFile(); Finish(); printf("\nCPU_time: %lf(s)", ctime); printf("\nu.dat, v.dat, rho.dat AND u.txt, v.txt, rho.txt are saved.\n"); return 0;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?