// pde23_eqn2.c 3D uniform grid boundary value PDE // user defined via web using pdedef232.h pdedef232.c // set up and solve system of linear equations // create two dimensional array with // (nx-2)*(ny-2)*(nz-2) rows, one for each equation #include "nuderiv.h" #include #include #include #include "pdedef232.h" // defines nx, ny, nz #undef abs #define abs(a) ((a)<0.0?(-(a)):(a)) #undef min #define min(a,b) ((a)<(b)?(a):(b)) #undef max #define max(a,b) ((a)>(b)?(a):(b)) // not including boundary #define nxyz (nx-2)*(ny-2)*(nz-2) static double xg[nx]; static double yg[ny]; static double zg[nz]; // nx-2 by ny-2 by nz-2 internal, non boundary cells static double cxx[nx]; // nuderiv coefficients static double cyy[ny]; static double czz[nz]; static double cxy[nx][ny]; static double cxz[nx][nz]; static double cyz[ny][nz]; static double cx[nx]; static double cy[ny]; static double cz[nz]; static double coefdxx, coefdyy, coefdzz, coefdxdy, coefdxdz, coefdydz, coefdx, coefdy, coefdz, coefu; static double us[nxyz]; // solution being computed 9*8*7 static double ut[nxyz][nxyz+1]; // temporary equations static double error; // sum of absolute exact-computed static double avgerror; // average error static double maxerror; // maximum cell error int S(int i, int j, int k) // index into us and row into ut { return (i-1)+(nx-2)*(j-1)+(nx-2)*(ny-2)*(k-1); } // end S static void check() // typically not known, instrumentation { int i, j, k; double uexact, err; error = 0.0; maxerror = 0.0; for(i=1; imaxerror) maxerror=err; } } } } // end check static void printdiff() { int i, j, k; printf("difference exact-computed solution, partial\n"); k = 1; for(i=1; i abs_pivot) { i_pivot = i; pivot = B[row[i]][k]; abs_pivot = abs ( pivot ); } } // have pivot, interchange row pointers hold = row[k]; row[k] = row[i_pivot]; row[i_pivot] = hold; // check for near singular if( abs_pivot < 1.0E-10 ) { for(j=k+1; j