sandbox/Antoonvh/restrictiontest.c

    Does restriction work on trees?

    #include "grid/bitree.h" //May be a quadtree or octree.
    scalar s[];
    
    int main() {
      init_grid (16);
      unrefine (x < 0.5);
      foreach()
        s[] = 1.;
      restriction ({s});
      foreach_cell()
        printf ("%g %d %g\n",x, level, s[]);
      
      FILE * fp = fopen("boundary", "w");
      boundary ({s});  
      foreach_cell()
        fprintf (fp, "%g %d %g\n",x, level, s[]);
    }
    reset
    set yr [-0.5:4.5]
    set xr [-0.1:1.1]
    set key off
    set size square
    set xlabel 'x'
    set ylabel 'level'
    set size ratio 1
    plot 'out' using 1:2 , \
         '' using 1:2:(sprintf("    %.0f",$3)) with labels
    No, it does not (script)

    No, it does not (script)

    reset
    set yr [-0.5:4.5]
    set xr [-0.1:1.1]
    set xlabel 'x'
    set ylabel 'level'
    set key off
    set size square
    set size ratio 1
    plot 'boundary' using 1:2 , \
         '' using 1:2:(sprintf("    %.0f",$3)) with labels
    boundary behaves as intended (script)

    boundary behaves as intended (script)