void hook_ante_loop(const int nt)
  {
    parent_t::hook_ante_loop(nt);
    if (this->rank != 0) return;

    //checking what are the MPDATA options of each test simulation (fct / iga / ...) 
    //basing on gnuplot output filename ...
    std::string gnuplot_name = this->p.gnuplot_output;
    std::string name;
    char delimeter('%');
    std::istringstream iss(gnuplot_name);
    getline(iss, name, delimeter);
    // ... and naming output stats file accordingly
    if(!ofs.is_open())
      ofs.open("stats_"+name+".txt", std::ofstream::out);

    last_timestep = nt;

    true_solution.resize(this->mem->advectee().shape());
    error_2.resize(this->mem->advectee().shape());

    //after one full rotation true solution is equal to the inital state
    true_solution = this->mem->advectee();
    ofs << std::fixed << std::setprecision(8) << std::endl;
    ofs << "timestep      = 0"     << std::endl;
    ofs << "min(solution) = " << min(true_solution) <<std::endl;
    ofs << "max(solution) = " << max(true_solution) <<std::endl;
    ofs << " " <<std::endl;
  }
 libcloudphxx::lgrngn::arrinfo_t<real_t> make_arrinfo(
   typename parent_t::arr_t arr
 ) {
   return libcloudphxx::lgrngn::arrinfo_t<real_t>(
     arr.dataZero(), 
     arr.stride().data()
   );
 }
Example #3
0
 ll::arrinfo_t<real_t> make_arrinfo(
   typename parent_t::arr_t arr
 ) {
   return ll::arrinfo_t<real_t>(
     arr.dataZero(), 
     arr.stride().data()
   );
 }
  void hook_ante_loop(const int nt)
  {
    parent_t::hook_ante_loop(nt);
    if (this->rank != 0) return;

    //checking what are the MPDATA options of each test simulation (default / best) 
    //basing on hdf outdir name and naming output stats file accordingly
    if(!ofs.is_open())
      ofs.open("stats_" + this->outdir + ".txt", std::ofstream::out);

    last_timestep = nt;
                                    //nlon
    ii = blitz::Range(0, this->mem->grid_size[0].length() - 2);  // due to boundary condition type not all points should be evaluated
    jj = blitz::Range(0, this->mem->grid_size[1].length() - 1);  // when calculating errors
                                    //nlat

    ic.resize(ii, jj);
    ic = this->mem->advectee()(ii, jj);

    // at the end of the test true solution is equal to the inital state
    ofs << std::endl;
    write_stat("timestep      = ", 0);
    write_stat("min(solution) = ", min(ic), false);
    write_stat("max(solution) = ", max(ic));
    ofs << " " << std::endl;
  }
  void hook_post_step()
  {
    parent_t::hook_post_step();
    this->mem->barrier();
    if (this->rank != 0) return;
    if (this->timestep == last_timestep) 
    { 
      // final condition
      fc.resize(ii, jj);
      fc = this->mem->advectee()(ii, jj);
      gf.resize(ii, jj);
      gf = this->mem->g_factor()(ii, jj);

      //output stats
      write_stat("timestep = ", this->timestep);
      write_stat("emin = ", (min(fc) - min(ic)) / max(ic));
      write_stat("emax = ", (max(fc) - max(ic)) / max(ic));
      write_stat("err0 = ", sqrt(sum(pow2(fc - ic) * gf)) / max(ic));
      write_stat("err1 = ", sum(gf * fc) / sum(gf * ic) - 1);
      write_stat("err2 = ", sum(gf * pow2(fc)) / sum(gf * pow2(ic)) - 1);
    }
  }