<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">\File{sor.c},{12:21},{May 15 1997}
\L{\LB{\C{}\/* Successive Over\-Relaxation solver *\/\CE{}}}
\L{\LB{}}
\L{\LB{\K{\#include} \S{}\"main.h\"\SE{}}}
\L{\LB{\K{\#include} \S{}\"xgraphics.h\"\SE{}}}
\L{\LB{\K{\#include} \S{}\"sor.h\"\SE{}}}
\L{\LB{}}
\L{\LB{\K{extern} NPTS;}}
\L{\LB{}}
\L{\LB{fpt}}
\L{\LB{\Proc{relax}relax(\K{double} alpha, fpt *field, \K{int} *bound) \{}}
\L{\LB{  \K{int} i, j, k;}}
\L{\LB{  fpt tmp, change, new, foo;}}
\L{\LB{  change = 0;}}
\L{\LB{}\Tab{8}{\K{for} (i = 1; i \&lt; NPTS\-1; ++i) \{}}
\L{\LB{}\Tab{8}{  \K{for} (j = 1; j \&lt; NPTS\-1; ++j) \{}}
\L{\LB{}\Tab{8}{    \K{for} (k = 1; k \&lt; NPTS\-1; ++k) \{}}
\L{\LB{}\Tab{8}{      \K{if}(F(bound,i,j,k) == \-1) \{}}
\L{\LB{}\Tab{16}{tmp = F(field,i,j,k);}}
\L{\LB{}\Tab{16}{new =}}
\L{\LB{}\Tab{16}{  (((1.0\-alpha)*}}
\L{\LB{}\Tab{16}{    ((fpt) F(field, i, j, k))));}}
\L{\LB{}\Tab{16}{foo = ((fpt) F(field,i,j\-1,k));}}
\L{\LB{}\Tab{16}{foo+= ((fpt) F(field,i\-1,j,k));}}
\L{\LB{}\Tab{16}{foo+= ((fpt) F(field,i+1,j,k));}}
\L{\LB{}\Tab{16}{foo+=((fpt) F(field,i,j+1,k));}}
\L{\LB{}\Tab{16}{foo+=((fpt) F(field,i,j,k\-1));}}
\L{\LB{}\Tab{16}{foo+=((fpt) F(field,i,j,k+1));}}
\L{\LB{}\Tab{16}{foo\/=6;}}
\L{\LB{}\Tab{16}{foo*=alpha;}}
\L{\LB{}\Tab{16}{new += foo;}}
\L{\LB{}\Tab{16}{(F(field,i,j,k)) = new;}}
\L{\LB{}\Tab{16}{tmp = (F(field,i,j,k)\-tmp);}}
\L{\LB{}\Tab{16}{change += (tmp*tmp);}}
\L{\LB{}\Tab{8}{      \}}}
\L{\LB{}\Tab{8}{      \K{else} \{}}
\L{\LB{}\Tab{24}{F(field, i, j, k) = (fpt) F(bound, i, j, k);}}
\L{\LB{}\Tab{16}{\}}}
\L{\LB{}\Tab{8}{    \}}}
\L{\LB{}\Tab{8}{  \}}}
\L{\LB{}\Tab{8}{\}}}
\L{\LB{}\Tab{8}{}}
\L{\LB{}\Tab{8}{\K{for}(i=0; i\&lt; NPTS; ++i)}}
\L{\LB{}\Tab{8}{  \K{for}(j=0;j \&lt; NPTS; ++j)\{}}
\L{\LB{}\Tab{8}{    F(field, i, j, 0) = F(field, i, j, 1);}}
\L{\LB{}\Tab{8}{    F(field, i, 0, j) = F(field, i, 1, j);}}
\L{\LB{}\Tab{8}{    F(field, 0, i, j) = F(field, 1, i, j);}}
\L{\LB{}\Tab{8}{    F(field, i, j, NPTS\-1) = F(field, i, j, NPTS\-2);}}
\L{\LB{}\Tab{8}{    F(field, i, NPTS\-1, j) = F(field, i, NPTS\-2, j);}}
\L{\LB{}\Tab{8}{    F(field, NPTS\-1, i, j) = F(field, NPTS\-2, i, j);}}
\L{\LB{}\Tab{8}{  \}}}
\L{\LB{}\Tab{8}{\K{return} change;}}
\L{\LB{\}}}
\L{\LB{}}
\L{\LB{fpt}}
\L{\LB{\Proc{charge}charge(fpt *field, \K{int} *bound, \K{int} objnum) \{}}
\L{\LB{  \K{int} i,j,k;}}
\L{\LB{  fpt chg=0.0;}}
\L{\LB{}}
\L{\LB{    \K{for} (i = 1; i \&lt; NPTS\-1; ++i)}}
\L{\LB{         \K{for} (j = 1; j \&lt; NPTS\-1; ++j)}}
\L{\LB{}\Tab{8}{    \K{for} (k = 1; k \&lt; NPTS\-1; ++k) \{}}
\L{\LB{}\Tab{8}{      \K{if}(F(bound,i,j,k) == objnum)\{}}
\L{\LB{}\Tab{16}{chg+= (F(field,i,j,k) \- F(field,i,j,k+1));}}
\L{\LB{}\Tab{16}{chg+= (F(field,i,j,k) \- F(field,i,j,k\-1));}}
\L{\LB{}\Tab{16}{chg+= (F(field,i,j,k) \- F(field,i+1,j,k));}}
\L{\LB{}\Tab{16}{chg+= (F(field,i,j,k) \- F(field,i\-1,j,k));}}
\L{\LB{}\Tab{16}{chg+= (F(field,i,j,k) \- F(field,i,j\-1,k));}}
\L{\LB{}\Tab{16}{chg+= (F(field,i,j,k) \- F(field,i,j+1,k));}}
\L{\LB{}\Tab{8}{      \}}}
\L{\LB{}\Tab{8}{    \}}}
\L{\LB{    \K{return} chg;}}
\L{\LB{\}}}
</pre></body></html>