src/test/hydrostatic1.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
    
    // similar to hydrostatic.c but with a linear density profile
    // (i.e. a quadratic pressure profile).
    
    #include "navier-stokes/centered.h"
    
    int main() {
      origin (-0.5, -0.5);
      init_grid (8);
      DT = 1.;
      TOLERANCE = 1e-6;
      stokes = true;
      run();
    }
    
    p[top] = dirichlet(0);
    
    event init (i = 0) {
      refine (level == 3 && sq(x) + sq(y) < sq(0.25));
      const face vector g[] = {0,-1.};
      a = g;
      alpha = new face vector;
      foreach_face()
        alpha.x[] = 1./(0.51 - y);
    }
    
    event check (i = 1) {
      output_cells (stdout);
    #if 1
      foreach()
        fprintf (stderr, "%g %g %g %.6f %.6f\n", x, y, p[], u.x[], u.y[]);
    #else
      foreach_face(y)
        fprintf (stderr, "%g %g %g\n", x, y, uf.y[]);
    #endif
    }