src/test/fractions2.c

Fractions in marginal cases

This checks that straight interfaces falling exactly on grid lines give the correct fractions.

#include "fractions.h"

int main() {

The origin is set at the center of the domain.

  origin (- 0.5, - 0.5);
  init_grid (4);

Four fractions are defined:

  • fx corresponding to the Level Set function x;
  • fy corresponding to the Level Set function y;
  • fx corresponding to the Level Set function x;
  • fy corresponding to the Level Set function y.

All four should correspond to an half space.

  scalar fx[], f_x[], fy[], f_y[];

  fraction (fx, x);
  fraction (fy, y);
  fraction (f_x, -x);
  fraction (f_y, -y);

The cell grid and values of the fractions are saved.

  output_cells (stdout);

  foreach()
    fprintf (stderr, "%g %g %g %g %g %g \n", x, y, fx[], fy[], f_x[], f_y[]);
}

Ouputs

Reconstruction of \phi(x, y) = x

Reconstruction of ϕ(x,y)=x

Reconstruction of \phi(x, y) = y

Reconstruction of ϕ(x,y)=y

Reconstruction of \phi(x, y) = -x

Reconstruction of ϕ(x,y)=x

Reconstruction of \phi(x, y) = -y

Reconstruction of ϕ(x,y)=y