src/test/indexing.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
    
    /* parallel Z-indexing */
    
    #include "refine_unbalanced.h"
    
    int main (int argc, char ** argv)
    {
      int depth = 4;
      origin (-0.5, -0.5, -0.5);
      init_grid (1);
    
      foreach_cell() {
        cell.pid = pid();
        cell.flags |= active;
      }
      tree->dirty = true;
    
      refine_unbalanced (level < depth - 2 ||
    		     level <= depth*(1. - sqrt(x*x + y*y + z*z)),
    		     NULL);
    
      scalar reference[];
      int i = 0;
      foreach()
        reference[] = i++;
    
      mpi_partitioning();
    
      scalar index[];
      z_indexing (index, true);
    
      output_cells (stdout);
      foreach() {
        fprintf (stderr, "%g %g %g %g %g\n", x, y, z, index[], reference[]);
        assert (index[] == reference[]);
      }
    }