/* prog1a.c -- Solve Poisson Equation Written Feb 25, 2003 by Eric Olson for Mathematics 484 For information about the five-point formula for solving the Poisson equation see Chapter 7 in A First Course in the Numerical Analysis of Differential Equations by Iserles. For information about the Gauss-Seidel iteration method used to solve the resulting system of finite differences see Chapter 10 in the same reference. */ #include #include #define N 10 const double h=8.0/N; const double eps=0.001; const double etol=0.001/N/N/N; double u[N][N],hhf[N][N]; int cmax=0; struct intpt { int i,j,n; } ipts[2*N]; /* Determine if a point (x,y) is an interior point in the domain. Returns 1 if an interior point 0 otherwise */ int isint(double x, double y){ if( (x>0.0+eps) && (y>0.0+eps) && (x+y<7.0-eps) ) return 1; else return 0; } /* Specify the Dirichlet condition at (x,y) on the boundary */ double psi(double x, double y){ return x-2.0*y; } /* Specify the forcing term at (x,y) in the domain */ double f(double x, double y){ return 0.0; } void printu(){ int i,j; /* Print the matrix u */ for(i=0;i