src/test/bump2Dc.c

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    
    // same as bump2D.c but with "inner" boundaries
    
    #include "saint-venant.h"
    
    int LEVEL = 8;
    
    int main (int argc, char * argv[])
    {
      if (argc > 1)
        LEVEL = atoi (argv[1]);
      size (2.);
      origin (-L0/2., -L0/2.);
      init_grid (1 << LEVEL);
      run();
    }
    
    bid inner;
    
    event init (i = 0)
    {
      mask (fabs(x) > 0.5 || fabs(y) > 0.5 ? inner : none);
      foreach()
        h[] = 0.1 + 1.*exp(-200.*(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) {
      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);
      }
    }
    
    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);
    }