# 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:

• ${f}_{x}$ corresponding to the Level Set function $x$;
• ${f}_{y}$ corresponding to the Level Set function $y$;
• ${f}_{-x}$ corresponding to the Level Set function $-x$;
• ${f}_{-y}$ 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[]);
}