⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 params.h

📁 基于格子Boltzmann方法开源可视化软件的源代码 具有很高的实用价值。对学习LBM方法及其软件开发非常游泳
💻 H
📖 第 1 页 / 共 3 页
字号:
//##############################################################################//// Copyright (C), 2005, Michael Sukop and Danny Thorne//// params.h////  - Routines for reading and writing params.////  - Reads from params.in//  //  - Writes to params.dat//// void skip_label( FILE *in)void skip_label( FILE *in){  char c;  int  done;  c = fgetc( in);  if( ( c >= '0' && c <='9') || c == '-' || c == '.')  {    // Digit or Sign or Decimal    ungetc( c, in);  }  else  {    while( ( c = fgetc( in)) != ' ');    while( ( c = fgetc( in)) == ' ');    ungetc( c, in);  }} /* void skip_label( FILE *in) */// void read_params( struct lattice_struct *lattice)//##############################################################################//// R E A D   P A R A M S ////  - Read the problem parameters from a file.//void read_params( lattice_ptr lattice, const char *infile){  FILE   *in;  int    blank;  double dblank;  int    subs;  if( !( in = fopen( infile, "r")))  {    printf("ERROR: fopen(\"%s\",\"r\") = NULL.  Bye, bye!\n", infile);    exit(1);  }  skip_label( in); fscanf( in, "%d", &( lattice->param.LX)             );  skip_label( in); fscanf( in, "%d", &( lattice->param.LY)             );  skip_label( in); fscanf( in, "%d", &( lattice->param.length_scale    ));  skip_label( in); fscanf( in, "%d", &( lattice->param.NumFrames)      );  skip_label( in); fscanf( in, "%d", &( lattice->param.FrameRate)      );  skip_label( in); fscanf( in, "%lf",&( lattice->param.tau[0])         );  skip_label( in); fscanf( in, "%lf",   lattice->param.gforce[0]       );  skip_label( in); fscanf( in, "%lf",   lattice->param.gforce[0]+1     );  skip_label( in); fscanf( in, "%d",    lattice->param.end_grav        );  if( NUM_FLUID_COMPONENTS==2)  {  skip_label( in); fscanf( in, "%lf",&( lattice->param.tau[1])         );  skip_label( in); fscanf( in, "%lf",   lattice->param.gforce[1]       );  skip_label( in); fscanf( in, "%lf",   lattice->param.gforce[1]+1     );  skip_label( in); fscanf( in, "%d",    lattice->param.end_grav+1      );  }  else if( NUM_FLUID_COMPONENTS==1)  {  skip_label( in); fscanf( in, "%lf",   &dblank                        );  skip_label( in); fscanf( in, "%lf",   &dblank                        );  skip_label( in); fscanf( in, "%lf",   &dblank                        );  skip_label( in); fscanf( in, "%d",    &blank                         );  }  else  {    printf(      "read_params() -- "      "Unhandled case "      "NUM_FLUID_COMPONENTS = %d .  "      "Exiting!\n",       NUM_FLUID_COMPONENTS);    exit(1);  }    skip_label( in); fscanf( in, "%d ", &(lattice->param.buoyancy      ) );    skip_label( in); fscanf( in, "%d ", &(lattice->param.incompressible) );    skip_label( in); fscanf( in, "%d ", &(lattice->param.simple_diffusion) );    skip_label( in); fscanf( in, "%lf",   lattice->param.rho_A           );    skip_label( in); fscanf( in, "%lf",   lattice->param.rho_B           );#if INAMURO_SIGMA_COMPONENT    skip_label( in); fscanf( in, "%lf",&( lattice->param.rho_sigma)      );    skip_label( in); fscanf( in, "%lf",&( lattice->param.rho_sigma_in)   );    skip_label( in); fscanf( in, "%lf",&( lattice->param.rho_sigma_out)  );    skip_label( in); fscanf( in, "%lf",&( lattice->param.u_sigma)        );    skip_label( in); fscanf( in, "%lf",&( lattice->param.u_sigma_in)     );    skip_label( in); fscanf( in, "%lf",&( lattice->param.u_sigma_out)    );    skip_label( in); fscanf( in, "%d ",&( lattice->param.sigma_start)    );    skip_label( in); fscanf( in, "%d ",&( lattice->param.sigma_stop )    );    skip_label( in); fscanf( in, "%d ",&( lattice->param.sigma_btc_rate ));    skip_label( in); fscanf( in, "%d ",&( lattice->param.sigma_btc_spot ));#else /* !( INAMURO_SIGMA_COMPONENT) */    skip_label( in); fscanf( in, "%lf",   &dblank                        );    skip_label( in); fscanf( in, "%lf",   &dblank                        );    skip_label( in); fscanf( in, "%lf",   &dblank                        );    skip_label( in); fscanf( in, "%lf",   &dblank                        );    skip_label( in); fscanf( in, "%lf",   &dblank                        );    skip_label( in); fscanf( in, "%lf",   &dblank                        );    skip_label( in); fscanf( in, "%d ",   &blank                         );    skip_label( in); fscanf( in, "%d ",   &blank                         );    skip_label( in); fscanf( in, "%d ",   &blank                         );    skip_label( in); fscanf( in, "%d ",   &blank                         );#endif /* INAMURO_SIGMA_COMPONENT */    skip_label( in); fscanf( in, "%lf",&( lattice->param.rho_in)         );    skip_label( in); fscanf( in, "%lf",&( lattice->param.rho_out)        );    skip_label( in); fscanf( in, "%lf",&( lattice->param.ux_in)          );    skip_label( in); fscanf( in, "%lf",&( lattice->param.ux_out)         );printf(" %s %d >> %f\n",__FILE__,__LINE__,  lattice->param.ux_out);    skip_label( in); fscanf( in, "%lf",&( lattice->param.uy_in)          );    skip_label( in); fscanf( in, "%lf",&( lattice->param.uy_out)         );    skip_label( in); fscanf( in, "%lf",&( lattice->param.G)         );    skip_label( in); fscanf( in, "%lf",   lattice->param.Gads+0  );  if( NUM_FLUID_COMPONENTS==2)  {    skip_label( in); fscanf( in, "%lf",   lattice->param.Gads+1  );  }  else if( NUM_FLUID_COMPONENTS==1)  {    skip_label( in); fscanf( in, "%lf",  &dblank                         );  }  else  {    printf(      "read_params() -- "      "Unhandled case "      "NUM_FLUID_COMPONENTS = %d .  "      "Exiting!\n",       NUM_FLUID_COMPONENTS);    exit(1);  }    skip_label( in); fscanf( in, "%d", &( lattice->param.ns_flag)        );    skip_label( in); fscanf( in, "%lf",&( lattice->param.ns)             );    skip_label( in); fscanf( in, "%d", &( lattice->param.slice_x       ) );    skip_label( in); fscanf( in, "%d", &( lattice->param.slice_y       ) );    skip_label( in); fscanf( in, "%d", &( lattice->param.ic_poisseuille) );    skip_label( in); fscanf( in, "%d", &( lattice->param.bc_poisseuille) );    skip_label( in); fscanf( in, "%d", &( lattice->param.bc_slip_north ) );#if INAMURO_SIGMA_COMPONENT    skip_label( in); fscanf( in, "%d", &( lattice->param.bc_sigma_slip ) );    skip_label( in); fscanf( in, "%d", &( lattice->param.bc_sigma_walls) );#else /* !( INAMURO_SIGMA_COMPONENT) */    skip_label( in); fscanf( in, "%d",   &blank                          );    skip_label( in); fscanf( in, "%d",   &blank                          );#endif /* INAMURO_SIGMA_COMPONENT */    skip_label( in); fscanf( in, "%d",    lattice->param.pressure_n_in+0 );    skip_label( in); fscanf( in, "%d",    lattice->param.pressure_s_in+0 );    skip_label( in); fscanf( in, "%d",    lattice->param.pressure_n_out+0);    skip_label( in); fscanf( in, "%d",    lattice->param.pressure_s_out+0);    skip_label( in); fscanf( in, "%d",    lattice->param.velocity_n_in+0 );    skip_label( in); fscanf( in, "%d",    lattice->param.velocity_s_in+0 );    skip_label( in); fscanf( in, "%d",    lattice->param.velocity_n_out+0);    skip_label( in); fscanf( in, "%d",    lattice->param.velocity_s_out+0);    skip_label( in); fscanf( in, "%d",    lattice->param.pressure_e_in+0 );    skip_label( in); fscanf( in, "%d",    lattice->param.pressure_w_in+0 );    skip_label( in); fscanf( in, "%d",    lattice->param.pressure_e_out+0);    skip_label( in); fscanf( in, "%d",    lattice->param.pressure_w_out+0);    skip_label( in); fscanf( in, "%d",    lattice->param.velocity_e_in+0 );    skip_label( in); fscanf( in, "%d",    lattice->param.velocity_w_in+0 );    skip_label( in); fscanf( in, "%d",    lattice->param.velocity_e_out+0);    skip_label( in); fscanf( in, "%d",    lattice->param.velocity_w_out+0);  if( NUM_FLUID_COMPONENTS==2)  {    skip_label( in); fscanf( in, "%d",    lattice->param.pressure_n_in+1 );    skip_label( in); fscanf( in, "%d",    lattice->param.pressure_s_in+1 );    skip_label( in); fscanf( in, "%d",    lattice->param.pressure_n_out+1);    skip_label( in); fscanf( in, "%d",    lattice->param.pressure_s_out+1);    skip_label( in); fscanf( in, "%d",    lattice->param.velocity_n_in+1 );    skip_label( in); fscanf( in, "%d",    lattice->param.velocity_s_in+1 );    skip_label( in); fscanf( in, "%d",    lattice->param.velocity_n_out+1);    skip_label( in); fscanf( in, "%d",    lattice->param.velocity_s_out+1);    skip_label( in); fscanf( in, "%d",    lattice->param.pressure_e_in+1 );    skip_label( in); fscanf( in, "%d",    lattice->param.pressure_w_in+1 );    skip_label( in); fscanf( in, "%d",    lattice->param.pressure_e_out+1);    skip_label( in); fscanf( in, "%d",    lattice->param.pressure_w_out+1);    skip_label( in); fscanf( in, "%d",    lattice->param.velocity_e_in+1 );    skip_label( in); fscanf( in, "%d",    lattice->param.velocity_w_in+1 );    skip_label( in); fscanf( in, "%d",    lattice->param.velocity_e_out+1);    skip_label( in); fscanf( in, "%d",    lattice->param.velocity_w_out+1);  }  else if( NUM_FLUID_COMPONENTS==1)  {    skip_label( in); fscanf( in, "%d",    &blank                         );    skip_label( in); fscanf( in, "%d",    &blank                         );    skip_label( in); fscanf( in, "%d",    &blank                         );    skip_label( in); fscanf( in, "%d",    &blank                         );    skip_label( in); fscanf( in, "%d",    &blank                         );    skip_label( in); fscanf( in, "%d",    &blank                         );    skip_label( in); fscanf( in, "%d",    &blank                         );    skip_label( in); fscanf( in, "%d",    &blank                         );    skip_label( in); fscanf( in, "%d",    &blank                         );    skip_label( in); fscanf( in, "%d",    &blank                         );    skip_label( in); fscanf( in, "%d",    &blank                         );    skip_label( in); fscanf( in, "%d",    &blank                         );    skip_label( in); fscanf( in, "%d",    &blank                         );    skip_label( in); fscanf( in, "%d",    &blank                         );    skip_label( in); fscanf( in, "%d",    &blank                         );    skip_label( in); fscanf( in, "%d",    &blank                         );  }  else  {    printf(      "read_params() -- "      "Unhandled case "      "NUM_FLUID_COMPONENTS = %d .  "      "Exiting!\n",       NUM_FLUID_COMPONENTS);    exit(1);  }  if( INAMURO_SIGMA_COMPONENT)  {    skip_label( in); fscanf( in, "%d",    &lattice->param.constcon_n_in     );    skip_label( in); fscanf( in, "%d",    &lattice->param.constcon_s_in     );    skip_label( in); fscanf( in, "%d",    &lattice->param.constcon_n_out    );    skip_label( in); fscanf( in, "%d",    &lattice->param.constcon_s_out    );    skip_label( in); fscanf( in, "%d",    &lattice->param.constflx_n_in     );    skip_label( in); fscanf( in, "%d",    &lattice->param.constflx_s_in     );    skip_label( in); fscanf( in, "%d",    &lattice->param.constflx_n_out    );    skip_label( in); fscanf( in, "%d",    &lattice->param.constflx_s_out    );    skip_label( in); fscanf( in, "%d",    &lattice->param.constcon_e_in     );    skip_label( in); fscanf( in, "%d",    &lattice->param.constcon_w_in     );    skip_label( in); fscanf( in, "%d",    &lattice->param.constcon_e_out    );    skip_label( in); fscanf( in, "%d",    &lattice->param.constcon_w_out    );    skip_label( in); fscanf( in, "%d",    &lattice->param.constflx_e_in     );    skip_label( in); fscanf( in, "%d",    &lattice->param.constflx_w_in     );    skip_label( in); fscanf( in, "%d",    &lattice->param.constflx_e_out    );    skip_label( in); fscanf( in, "%d",    &lattice->param.constflx_w_out    );    skip_label( in); fscanf( in, "%d",    &lattice->param.zeroconcgrad_n    );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -