当前位置: 首页>>代码示例>>C++>>正文


C++ Communicator::add方法代码示例

本文整理汇总了C++中Communicator::add方法的典型用法代码示例。如果您正苦于以下问题:C++ Communicator::add方法的具体用法?C++ Communicator::add怎么用?C++ Communicator::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Communicator的用法示例。


在下文中一共展示了Communicator::add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: physics_init

int physics_init()
{
  // 2D initial profiles
  Field2D rho0, p0;
  Vector2D v0, B0;

  // read options
  options.setSection("mhd");
  OPTION(gamma,          5.0/3.0);
  OPTION(include_viscos, false);
  OPTION(viscos,         0.1);


  // Read 2D initial profiles
  GRID_LOAD(rho0);
  GRID_LOAD(p0);
  v0.covariant = true; // Read covariant components of v0
  GRID_LOAD(v0);
  B0.covariant = false; // Read contravariant components of B0
  GRID_LOAD(B0);

  // tell BOUT which variables to evolve
  
  bout_solve(rho, F_rho, "density");
  bout_solve(p, F_p, "pressure");
  v.covariant = true; // evolve covariant components
  bout_solve(v, F_v, "v");
  B.covariant = false; // evolve contravariant components
  bout_solve(B, F_B, "B");

  output.write("dx[0,0] = %e, dy[0,0] = %e, dz = %e\n", dx[0][0], dy[0][0], dz);

  dump.add(divB, "divB", 1);

  if(!restarting) {
    // Set variables to these values (+ the initial perturbation)
    // NOTE: This must be after the calls to bout_solve
    rho += rho0;
    p += p0;
    v += v0;
    B += B0;
    
    // Added this for modifying the Orszag-Tang vortex problem
    real v_fact;
    options.get("v_fact",         v_fact,         1.0);
    v *= v_fact;
  }

  // Set communications
  
  comms.add(rho);
  comms.add(p);
  comms.add(v);
  comms.add(B);

  return 0;
}
开发者ID:bendudson,项目名称:BOUT-0.8,代码行数:57,代码来源:mhd.cpp

示例2: physics_init

int physics_init()
{
  real v0_multiply;

  // Read initial conditions

  grid_load2d(N0, "density");
  grid_load2d(P0, "pressure");
  V0.covariant = false; // Read contravariant components
  V.covariant = false; // Evolve contravariant components
  grid_load2d(V0, "v");
  g.covariant = false;
  grid_load2d(g, "g");
  
  // read options
  
  options.setSection("gas");
  
  options.get("gamma",  gamma_ratio, 5.0/3.0);
  options.get("viscosity", nu, 0.1);
  options.get("include_viscosity", include_viscosity, false);
  options.get("v0_multiply", v0_multiply, 1.0);
  options.get("sub_initial", sub_initial, false);

  V0 *= v0_multiply;

  // Set evolving variables
  
  bout_solve(N, F_N, "density");
  bout_solve(P, F_P, "pressure");
  bout_solve(V, F_V, "v");

  if(!restarting) {
    // Apply boundary conditions
    apply_boundary(N, "density");
    apply_boundary(P, "pressure");
    V.to_contravariant();
    apply_boundary(V, "v");

    // Set variables to these values (+ the initial perturbation)
    // NOTE: This must be after the calls to bout_solve
    N += N0;
    P += P0;
    V += V0;

  }

  // set communications
  comms.add(N);
  comms.add(P);
  comms.add(V);
  
  return 0;
}
开发者ID:bendudson,项目名称:BOUT-0.8,代码行数:54,代码来源:gas_compress.cpp

示例3: physics_init


//.........这里部分代码省略.........
  lambda_ii = 23.-log(ZZ*ZZ*ZZ*sqrt(2.*Ni_x)/pow(Ti_x, 1.5));
  wci       = 9.58e3*ZZ*bmag/AA;
  nueix     = 2.91e-6*Ni_x*lambda_ei/pow(Te_x, 1.5);
  nuiix     = 4.78e-8*pow(ZZ,4.)*Ni_x*lambda_ii/pow(Ti_x, 1.5)/sqrt(AA);

  Vi_x = wci * rho_s;

  /************** PRINT Z INFORMATION ******************/
  
  real hthe0;
  if(GRID_LOAD(hthe0) == 0) {
    output.write("    ****NOTE: input from BOUT, Z length needs to be divided by %e\n", hthe0/rho_s);
  }

  /************** NORMALISE QUANTITIES *****************/

  output.write("\tNormalising to rho_s = %e\n", rho_s);

  // Normalise profiles
  Ni0 /= Ni_x/1.0e14;
  Ti0 /= Te_x;
  Te0 /= Te_x;
  Vi0 /= Vi_x;

   // Normalise geometry 
  Rxy /= rho_s;
  hthe /= rho_s;
  dx /= rho_s*rho_s*(bmag/1e4);

  // Normalise magnetic field
  Bpxy /= (bmag/1e4);
  Btxy /= (bmag/1e4);
  Bxy  /= (bmag/1e4);

  // calculate pressures
  pei0 = (Ti0 + Te0)*Ni0;
  pe0 = Te0*Ni0;

  // Normalise coefficients
  chi_perp /= rho_s*rho_s*wci;
  D_perp   /= rho_s*rho_s*wci;
  mu_perp  /= rho_s*rho_s*wci;

  chi_perp = 0.1;
  D_perp = 0.1;
  mu_perp = 0.1;
  
  output.write("Diffusion coefficients: chi %e D %e Mu %e\n",
	       chi_perp, D_perp, mu_perp);

  /**************** CALCULATE METRICS ******************/

  g11 = (Rxy*Bpxy)^2;
  g22 = 1.0 / (hthe^2);
  g33 = (Bxy^2)/g11;
  g12 = 0.0;
  g13 = 0.0;
  g23 = -Btxy/(hthe*Bpxy*Rxy);
  
  J = hthe / Bpxy;
  
  g_11 = 1.0/g11;
  g_22 = (Bxy*hthe/Bpxy)^2;
  g_33 = Rxy*Rxy;
  g_12 = 0.0;
  g_13 = 0.0;
  g_23 = Btxy*hthe*Rxy/Bpxy;


  /**************** SET EVOLVING VARIABLES *************/

  // Tell BOUT++ which variables to evolve
  // add evolving variables to the communication object

  Ni = Vi = Te = Ti = 0.0;
  bout_solve(Ni,    F_Ni,    "Ni");
  bout_solve(Vi,    F_Vi,    "Vi");
  bout_solve(Te,    F_Te,    "Te");
  bout_solve(Ti,    F_Ti,    "Ti");

  comms.add(Ni);
  comms.add(Vi);
  comms.add(Te);
  comms.add(Ti);

  /************** SETUP COMMUNICATIONS **************/
  
  // Add any other variables to be dumped to file
  dump.add(Ni0, "Ni0", 0);
  dump.add(Te0, "Te0", 0);
  dump.add(Ti0, "Ti0", 0);

  dump.add(Te_x,  "Te_x", 0);
  dump.add(Ti_x,  "Ti_x", 0);
  dump.add(Ni_x,  "Ni_x", 0);
  dump.add(rho_s, "rho_s", 0);
  dump.add(wci,   "wci", 0);

  return(0);
}
开发者ID:bendudson,项目名称:BOUT-0.8,代码行数:101,代码来源:ue_bmark.cpp


注:本文中的Communicator::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。