00001
00002
00003
00004 #include <stdio.h>
00005 #include <stdlib.h>
00006 #include <math.h>
00007 #include "utilf.h"
00008 #include "markers.h"
00009 #include "xfig.h"
00010 #include "printfree.h"
00011 #include "inout.h"
00012
00013
00014 #define SCALE 100.0
00015 #define XFIG(x) (SCALE*(x) + 100.)
00016 #define YFIG(y) (SCALE*(y) + 100.)
00017
00018 void printfree(FILE *fptr,
00019 real2D u, real2D v, real2D ap,
00020 interface in,
00021 int nx, int ny)
00022 {
00023 int i, j, *x, *y;
00024 real maxu, maxv;
00025 char s[256];
00026 int xs = 2, xe = nx - 1, ys = 2, ye = ny - 1;
00027
00028 fprintf(fptr, "#FIG 2.1\n80 1\n");
00029 for (i = xs; i <= xe; i++) {
00030 XfigLine(fptr, XFIG((real)i), YFIG(ys), XFIG((real)i), YFIG(ye),
00031 XFIG_SOLID, 1, XFIG_BLACK);
00032 sprintf(s, "%d", i);
00033 XfigText(fptr, XFIG((real)i + 0.5), YFIG((real)ys - 0.2),
00034 XFIG_CENTER, XFIG_TIMES_ROMAN, 24,
00035 XFIG_BLACK, 0.0, s);
00036 }
00037 for (j = ys; j <= ye; j++) {
00038 XfigLine(fptr, XFIG(xs), YFIG((real)j), XFIG(xe), YFIG((real)j),
00039 XFIG_SOLID, 1, XFIG_BLACK);
00040 sprintf(s, "%d", j);
00041 XfigText(fptr, XFIG((real)xs - 0.5), YFIG((real)j + 0.75),
00042 XFIG_CENTER, XFIG_TIMES_ROMAN, 24,
00043 XFIG_BLACK, 0.0, s);
00044 }
00045
00046 maxu = fmodmax(u, nx, ny, &i, &j);
00047 maxv = fmodmax(v, nx, ny, &i, &j);
00048 maxu = maxv > maxu ? maxv : maxu;
00049 maxu = maxu == 0.0 ? 1.0 : maxu;
00050
00051
00052
00053 for (i = xs; i <= xe; i++)
00054 for (j = ys; j <= ye; j++) {
00055 if (!INU(i,j) && BU(i,j))
00056 XfigVector(fptr, XFIG((real)i), YFIG(0.5 + (real)j),
00057 SCALE*u[i][j]/maxu, 0.0,
00058 XFIG_SOLID, 1, XFIG_BLUE);
00059 else if (INU(i,j))
00060 XfigVector(fptr, XFIG((real)i), YFIG(0.5 + (real)j),
00061 SCALE*u[i][j]/maxu, 0.0,
00062 XFIG_SOLID, 1, XFIG_RED);
00063 if (!INV(i,j) && BV(i,j))
00064 XfigVector(fptr, XFIG(0.5 + (real)i), YFIG((real)j),
00065 0.0, SCALE*v[i][j]/maxu,
00066 XFIG_SOLID, 1, XFIG_GREEN);
00067 else if (INV(i,j))
00068 XfigVector(fptr, XFIG(0.5 + (real)i), YFIG((real)j),
00069 0.0, SCALE*v[i][j]/maxu,
00070 XFIG_SOLID, 1, XFIG_MAGENTA);
00071 if (INP(i,j))
00072 XfigBox(fptr, XFIG(0.5 + (real)i) - SCALE/20.,
00073 YFIG(0.5 + (real)j) - SCALE/20.,
00074 XFIG(0.5 + (real)i) + SCALE/20.,
00075 YFIG(0.5 + (real)j) + SCALE/20.,
00076 XFIG_SOLID, 2, XFIG_BLACK);
00077 }
00078
00079 x = (int *)malloc(in.n*sizeof(int));
00080 y = (int *)malloc(in.n*sizeof(int));
00081 for (i = 0; i < in.n; i++) {
00082 x[i] = XFIG(in.x[i]);
00083 y[i] = YFIG(in.y[i]);
00084 }
00085 XfigPolyLine(fptr, x, y, in.n, XFIG_SOLID, 1, XFIG_BLACK);
00086 for (i = 0; i < in.n; i++) {
00087 XfigCircle(fptr, x[i], y[i], SCALE/20.,
00088 XFIG_SOLID, 2, XFIG_BLACK);
00089 sprintf(s, "%d", i + 1);
00090 XfigText(fptr, x[i] + 12, y[i],
00091 XFIG_CENTER, XFIG_TIMES_ROMAN, 20,
00092 XFIG_BLACK, 0.0, s);
00093 }
00094 free(x); free(y);
00095
00096 }
00097
00098
00099
00100
00101
00102
00103