#include #include #include #include #include #include "mpe_graphics.h" #include "mpe.h" /******** #3D graphical library *********/ #include "threed.c" /* two values converge if their difference is less than EPSILON: */ // #define EPSILON 1e-5 #define EPSILON 1e-5 #define PI 3.1415927 /* N is size of NxN matrix, M is size of MxM quadrant, P is P*P workers */ #define N 288 #define M (2+N/2) #define P 2 /**** for dynamically allocated, large contiguous arrays ****/ typedef double NROW[N+2]; NROW *Data; /* main data matrix - exists only on root process */ typedef double QROW[M]; QROW *Q; /* one quadrant - needed by every process */ QROW *R; /* swap buffer */ /* macro to compute start address of quadrant in mesh */ /* These quadrants will overlap (2x2 mesh assumed) */ #define QUADRANT(DD,y,x) (DD[y*(N/2)]+(x*(N/2))) int mycoord[2]; /* stores mesh coordinates */ int locate[P][P]; /* used by master to locate workers in mesh */ #define YCORD mycoord[0] #define XCORD mycoord[1] #define NORTH 0 #define SOUTH 1 #define EAST 2 #define WEST 3 #define SND 0 #define RCV 1 MPI_Comm WORKERS, MESH; MPI_Datatype QUAD; // quadrant submatrix MPI_Datatype COLUMN; // one column in quadrant void master(); void worker(); void registerworkers(); /* used by master */ void registercoord(int,int); /* used by worker */ void setup(); // for graphics void visualize(NROW *); // for graphics // number of iterations before a convergence vote and display update: int CVN = 40; /* For graphics */ #define GRAPHICS 1 MPE_XGraph graph; MPE_Color mcolor[9] = {MPE_RED,MPE_BLUE,MPE_GREEN,MPE_YELLOW,MPE_BROWN,MPE_ORANGE,MPE_GRAY,MPE_PINK,MPE_BLACK}; int rotation = 220; // 220 for front view, 140 for rear view int mousesynch = 0; // mouse click between frames flag