src/test/refine-axi.c

Checks that refinement of axisymmetric metric and face fields behaves properly.

#include "axi.h"
  #include "run.h"
  
  double R0 = 0.1;
  int LEVEL = 6;
  
  face vector uf[];
  
  uf.t[top] = dirichlet(0);
  
  uf.t[bottom] = dirichlet(0); // since uf is multiplied by the metric which
                               // is zero on the axis of symmetry  
  
  int main()
  {
    L0 = 2;
    N = 16;
    run();
  }
  
  event init (t = 0)
  {
    uf.x.refine = refine_face_solenoidal;
  
    foreach_face()
      uf.x[] = 0.;
    foreach_face (x)
      uf.x[] = fm.x[]*(sq(L0) - y*y);
    boundary ((scalar *){uf});
    
    refine (level < LEVEL && sq(x - 2.) + sq(y) < sq(1.5*R0));
  
    output_cells (stdout);
    
    foreach()
      assert (fabs (cm[] - y) <= 1e-20);
    
    foreach_face(y) {    
      // fprintf (stderr, "%g %g %g %g\n", x, y, fm.y[], fm.y[] - y);
      assert (fabs (fm.y[] - y) <= 1e-20);
    }
    
    foreach_face(x) {
      // fprintf (stderr, "%g %g %g %g\n", x, y, fm.x[], fm.x[] - y);
      assert (fabs (fm.x[] - y) <= 1e-20);
    }
  
    foreach_face (x)
      fprintf (stderr, "%g %g %g %g\n", y, uf.x[], cm[], uf.x[]/cm[]);
  }
Exact and approximate solutions after refinement.

Exact and approximate solutions after refinement.