Пример #1
0
  void system::set_problem(const bool init) 
  {
    if (myproc == 0)
      fprintf(stderr, " ********* Setting up Orszag-Tang vortex ************* \n");

    const real b0 = 1.0/sqrt(4.0*M_PI);
    const real d0 = 25.0/(36.0*M_PI);
    const real v0 = 1.0;
    const real p0 = 5.0/(12*M_PI);
    gamma_gas = 5.0/3;
    courant_no = 0.8;

    if (!init) return;

    U_local.resize(local_n);
    dU_local.resize(local_n);
    Wrec_local.resize(local_n);

    const real adv = 0.0;
    double dt_min = HUGE;
    for (int i = 0; i < (int)local_n; i++) 
    {
      const Particle &pi = ptcl_local[i];

      real x = pi.pos.x;
      real y = pi.pos.y;


      real d, p, vx, vy, vz, bx, by, bz;

      vx = -v0 * sin(2.0*M_PI*y) + adv;
      vy = +v0 * sin(2.0*M_PI*x) + adv;
      vz =  0.0;

      bx = -b0*sin(2*M_PI*y);
      by = +b0*sin(4*M_PI*x);
      bz = 0.0;

      //			bx = by = bz= 0;

      //			bz = b0;

      d = d0;
      p = p0;
      real scal = 1;

#ifdef __ADVECT_PULSE_TEST__

      vx = 0;
      vy = 0;
      vz = 0;
      bx = by = bz = 0;
      p = 1.0;
      d = 1.0;
      //     vx = 1; vy = 0;
      //     if (x > 0.3 && x < 0.7) d = 2;

      vx = 0; vy = 1;
      if (y > 0.25 && y < 0.75) {
        d = 10;
        //				p = 1;
      }

#endif

#if 0
      bx = by = bz = 0;
#endif


      Fluid m;

      m[Fluid::DENS] = d ;
      m[Fluid::ETHM] = p/(gamma_gas - 1.0);
      m[Fluid::VELX] = vx;
      m[Fluid::VELY] = vy;
      m[Fluid::VELZ] = vz;
      m[Fluid::BX  ] = bx;
      m[Fluid::BY  ] = by;
      m[Fluid::BZ  ] = bz;
      m[Fluid::PSI ] = 0.0;
      m[Fluid::ENTR] = compute_entropy_from_ethm(m);
      for (int k = 0 ; k < Fluid::NSCALARS; k++)
        m.scal(k) = scal;

      Wrec_local[i]        = Fluid_rec(m);
      U_local  [i]       = m.to_conservative(cell_local[i].Volume);
      dU_local[i] = 0.0;
      ptcl_local[i].volume = cell_local[i].Volume;

      const double L      = std::pow(cell_local[i].Volume, 1.0/3);
      const double cs_est = std::sqrt((p*gamma_gas + (bx*bx+by*by+bz*bz))/d);
      const double v_est  = std::sqrt(vx*vx + vy*vy + vz*vz);
      const double dt_est = 0.1 * courant_no * L/(cs_est + v_est);

      ptcl_local[i].tlast = 0.0;
      ptcl_local[i].rung = scheduler.get_rung(dt_est);

      dt_min = std::min(dt_min, dt_est);

    }

    double dt_min_glob;
    MPI_Allreduce(&dt_min, &dt_min_glob, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD);

    MPI_Barrier(MPI_COMM_WORLD);
    if (myproc == 0)
      fprintf(stderr , " pvel ... \n");

    get_active_ptcl(true);

    MPI_Barrier(MPI_COMM_WORLD);
    if (myproc == 0)
      fprintf(stderr , " pvel ... \n");


    cell_list.swap(cell_local);
    ptcl_import.swap(ptcl_local);
    U_import.swap(U_local);
    site_active_list.swap(active_ptcl);


    compute_pvel();
    compute_timesteps(true);

    cell_list.swap(cell_local);
    ptcl_import.swap(ptcl_local);
    U_import.swap(U_local);
    site_active_list.swap(active_ptcl);

    for (int i = 0; i < (int)local_n; i++)
    {
      ptcl_local[i].rung += 1;
      ptcl_local[i].orig_vel = ptcl_local[i].vel;
    }
    all_active = true;
    scheduler.flush_list();
    for (int i = 0; i < (int)local_n; i++)
    {
      scheduler.push_particle(i, (int)ptcl_local[i].rung);
      ptcl_local[i].tend  = 0.0 + scheduler.get_dt(ptcl_local[i].rung);
    }
    boundary_n = 0;

    clear_mesh(true);

    MPI_Barrier(MPI_COMM_WORLD);
    if (myproc == 0) fprintf(stderr, " proc= %d: complete problem setup \n", myproc);
  }
Пример #2
0
  void System::Problem_generate_IC(const int param)
  {
    const real b0 = 1.0/sqrt(4.0*M_PI);
    const real d0 = 25.0/(36.0*M_PI);
    const real v0 = 1.0;
    const real p0 = 5.0/(12*M_PI);

    gamma_gas     = 5.0/3;
    courant_no    = 0.4;

    t_global  = 0;
    iteration = 0;

    real adv = 0.0;

    for (int i = 0; i < local_n; i++) 
    {
      const Particle &pi = ptcl_list[i];

      const real x = pi.get_pos().x;
      const real y = pi.get_pos().y;

      real d, p, vx, vy, vz, bx, by, bz;

      vx = -v0 * sin(2.0*M_PI*y) + adv;
      vy = +v0 * sin(2.0*M_PI*x) + adv;
      vz =  0.0;

      bx = -b0*sin(2*M_PI*y);
      by = +b0*sin(4*M_PI*x);
      bz = 0.0;

      d = d0;
      p = p0;
      real scal = 1;

#ifdef __ADVECT_PULSE_TEST__
      vx = 0;
      vy = 0;
      vz = 0;
      bx = by = bz = 0;
      p = 1.0;
      d = 1.0;

      vx = 0; vy = 1;
      if (y > 0.25 && y < 0.75) 
      {
        d = 10;
      }
#endif


      Fluid m;

      m[Fluid::DENS] = d ;
      m[Fluid::ETHM] = p/(gamma_gas - 1.0);
      m[Fluid::VELX] = vx;
      m[Fluid::VELY] = vy;
      m[Fluid::VELZ] = vz;
      m[Fluid::BX  ] = bx;
      m[Fluid::BY  ] = by;
      m[Fluid::BZ  ] = bz;
      m[Fluid::PSI ] = 0.0;
      m[Fluid::ENTR] = Problem_compute_entropy_from_ethm(m);
      for (int k = 0 ; k < Fluid::NSCALARS; k++)
        m.scal(k) = scal;

      Wrec_list[i] = Fluid_rec(m);
      
      mesh_pnts[i].idx      = thisIndex*(local_n << 1)+ i + 1;
      mesh_pnts[i].boundary = MeshPoint::NO_BOUNDARY;
      
    }
  }