/* ************************************************************************ * laplace.c: Solution of Laplace equation with finite differences * * * * comment: Output data is saved in 3D grid format used by gnuplot * ************************************************************************ */ #include #include #define maxx 40 /* number of grid points */ #define maxy 40 /* number of grid points */ main() { double p[maxx][maxy], pnew, dp, dpmax, omega; int i, j, iter; FILE *output; /* save data in laplace.dat */ FILE *file; /* save data in laplace_dp.dat */ output = fopen("laplace.dat","w"); file = fopen("laplace_dp.dat","w"); for(i=0; i dpmax) dpmax=fabs(dp); p[i][j] = pnew; } } fprintf(file, "%d\t%f\n",iter,dpmax); } for (i=0; i