twophase

1. The program

This program solves the following two phase type free boundary problem

q:[-1,1] -> R with periodic boundary conditions
Laplacian q = -1 where q is positive and 1 where q is negative.
Moreover, q is cubically symmetric, meaning that q o R = q for any rotation R of the cube [-1,1]^3.

Once the solution is found, |Dq| is coumputed at the free boundary points (1/2,1/2,1/2) and (0,1,1/2). This is done to check if their values coincide. Apparently they don't.

You will see that two numbers are provided for each approximation of |Dq|. One is obtained by a plain difference between consecutive points in the grid divided by a suitable multiple of h. The other takes into account the value of the second derivative of q in the normal direction and subtracts it, so it should be an order of magnitude more accurate. This becomes apparent by comparing the values obtained for small grids (for example 21 points) with larger grids (for example 125 points).

If you look at the code you will notice a particularity of the implementation. Only a piece of the grid is stored in memory. It corresponds to the tetrahedron 0<=z<=y<=x<=1. The reason why this is done is because q is a cubically symetric function and every point in the cube [-1,1] can be mapped to one point in that tetrahedron by some symmetry. In this way there is an obvious efficiency gain since the number of grid points is reduced by a factor of 48.

2. Compiling

If you have a c++ compiler properly installed in your system, just type make and an executable file will be created.

The program was only tested under Linux, but there is no reason why it wouldn't work in other platforms.