From d3ae9cb57a78bca4098f2e970caa74108cbc6c7c Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Tue, 9 Nov 2010 11:23:38 -0500 Subject: [PATCH] Remove src/poisson_2d/P_2d.c (duplicated poisson_2d.c). --- src/poisson_2d/P_2d.c | 223 ------------------------------------------ 1 file changed, 223 deletions(-) delete mode 100644 src/poisson_2d/P_2d.c diff --git a/src/poisson_2d/P_2d.c b/src/poisson_2d/P_2d.c deleted file mode 100644 index e16928b..0000000 --- a/src/poisson_2d/P_2d.c +++ /dev/null @@ -1,223 +0,0 @@ -/* - Over-relaxation solution to Poisson equation - - Syntax - Poisson N N_x N_y - ( Max # iteration, grid in x, grid in y ) - - Note: only written for equal x and y meshes -- N_x = N_y - - IBOUND: positions on grid corresponding to boundaries - - Modular code - simple main code - logical functions - - - Build & use of code - -gcc poisson_2d.c -lm -o poisson_2d - -./poisson_2d N N_x N_y | plot_image.py -s N_x,N_y -t "2d Poisson" - -*/ - -#include -#include -#include -#include - -#define MAX_x 350 /* maximum dimensions */ -#define MAX_y 350 - -#define EPS 1.0e-7 /* tolerance in solution */ - -#define IMAGE 1 /* image - yes (1) - no (0) */ - - /* global array & file to record solution */ -int ibound[MAX_x][MAX_y]; -double phi[MAX_x][MAX_y], ff[MAX_x][MAX_y]; - - -/* lattice definition & iteration number */ -void set_grid ( int argc, char *argv[], int *N_iterations, - int *NI, int *NJ, double *h ) -{ - if ( argc != 4 ) - { - printf( " Syntax: poisson N N_x N_y ( where N_x = N_y ) \n" ); - exit(1); - } - *N_iterations = atoi(argv[1]); - *NI = atoi(argv[2]); - *NJ = atoi(argv[3]); - - if ( *NI != *NJ ) - { - fprintf( stderr, " Code only setup for N_x = N_y \n"); - exit(1); - } - - if ( *NI > MAX_x || *NJ > MAX_y) - { - fprintf( stderr, " Grid dimensions too large \n"); - exit(1); - } - - *h = 1.0/(double)(*NI-1); -} - - -/* initial phi values, source & boundary conditions */ -void initial_source_and_boundary ( int NI, int NJ ) -{ - int i, j, i_s; - double r2; - /* initial fields & source*/ - for ( i=0 ; i phi_max ) phi_max = phi[i][j]; - - if ( ibound[i][j] == 0 ) - { - residual = phi[i+1][j] + phi[i-1][j] + - phi[i][j+1] + phi[i][j-1] - - 4.0 * phi[i][j] - h * h * ff[i][j]; - } - else - { - residual = 0.0; - } - if( fabs( residual ) > largest_residual ) - largest_residual = fabs( residual ); - } - } - - fprintf( stderr, "largest residual : %e \n", largest_residual ); - - /* output phi for image */ - if ( IMAGE == 1 ) - { - aux = 255.0 / ( phi_max - phi_min ); - for ( i=0 ; i 30 ) chi = 1.2; - if ( iter > 50 ) chi = 1.8; - /* Gauss-Siedel update */ - difference = 0.0; - for ( i=0 ; i