src/test/bump2D.c

    #include "saint-venant.h"
    
    int LEVEL = 7;
    
    int main (int argc, char * argv[])
    {
      if (argc > 1)
        LEVEL = atoi (argv[1]);
      origin (-0.5, -0.5);
      init_grid (1 << LEVEL);
      run();
    }
    
    event init (i = 0)
    {
      double a = 1., b = 200.;
      foreach()
        h[] = 0.1 + a*exp(- b*(x*x + y*y));
    }
    
    event logfile (i++) {
      stats s = statsf (h);
      fprintf (stderr, "%g %d %g %g %.8f\n", t, i, s.min, s.max, s.sum);
    }
    
    event outputfile (t <= 2.5; t += 2.5/8) {
    #if !_MPI
      static int nf = 0;
      printf ("file: eta-%d\n", nf);
      output_field ({eta}, linear = true);
    
      scalar l[];
      foreach()
        l[] = level;
      printf ("file: level-%d\n", nf++);
      output_field ({l});
    
      /* check symmetry */
      foreach() {
        double h0 = h[];
        point = locate (-x, -y);
        //    printf ("%g %g %g %g %g\n", x, y, h0, h[], h0 - h[]);
        assert (fabs(h0 - h[]) < 1e-12);
        point = locate (-x, y);
        assert (fabs(h0 - h[]) < 1e-12);
        point = locate (x, -y);
        assert (fabs(h0 - h[]) < 1e-12);
      }
    #endif
    }
    
    #if _MPI
    event image(i++)
    {
      scalar pid[];
      foreach()
        pid[] = pid();
      static FILE * fp = fopen ("pid", "w");
      output_ppm (pid, fp, min = 0, max = npe() - 1);
    }
    #endif
    
    event adapt (i++) {
      astats s = adapt_wavelet ({h}, (double[]){1e-3}, LEVEL);
      fprintf (stderr, "# refined %d cells, coarsened %d cells\n", s.nf, s.nc);
    }

    See also

    Benchmark on GPUs