00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "utilf.h"
00012 #include "stypes.h"
00013 #include "markers.h"
00014 #include "extra.h"
00015 #include "extra1.h"
00016 #include "make_bc.h"
00017 #include "make_bc_periodic.h"
00018 #include "inout.h"
00019
00020 #define WALL_LEFT
00021
00022 #define WALL_TOP
00023
00024
00025 static real rp_pressure(real pe, real R, real x, real y, int nx, int ny)
00026 {
00027 real r = sqrt(sq(x - 0.5*nx - 1.0) + sq(y - 2.0));
00028 #if 1
00029 return pe;
00030 #else
00031 return pe*(1. - R/r);
00032 #endif
00033 }
00034
00035
00036 void bc_vector_bound(real2D u, real2D v, int nx, int ny)
00037 {
00038 int i, j;
00039
00040 for (i = 1; i <= nx; i++) {
00041 u[i][1] = u[i][2];
00042 v[i][2] = 0.0;
00043 u[i][ny] = u[i][ny-1];
00044 #ifdef WALL_TOP
00045 v[i][ny] = 0.0;
00046 #else
00047 v[i][ny+1] = v[i][ny];
00048 #endif
00049 }
00050
00051 for (j = 1; j <= ny; j++) {
00052 #ifdef WALL_LEFT
00053 u[2][j] = 0.0;
00054 #else
00055 u[1][j] = u[2][j];
00056 #endif
00057 #ifdef WALL_RIGHT
00058 u[nx][j] = 0.0;
00059 #else
00060 u[nx+1][j] = u[nx][j];
00061 #endif
00062 v[1][j] = v[2][j];
00063 v[nx][j] = v[nx-1][j];
00064 }
00065 }
00066
00067
00068 void bc_vector_div(real2D u, real2D v, real2D ap,
00069 interface in,
00070 int nx, int ny)
00071 {
00072 int i, j;
00073 real eu, ev;
00074
00075
00076 for (i = 3; i < nx; i++) {
00077 for (j = 2; j < ny; j++)
00078 if (!INU(i,j) && BU(i,j)) {
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090 #ifdef EXTRA_LINEAR
00091 extra_velocity((real)i, (real)j + 0.5, u, v, ap, in,
00092 &eu, &ev, nx, ny);
00093 #else
00094 extra_velocity2((real)i, (real)j + 0.5, u, v, ap, in,
00095 &eu, &ev, nx, ny);
00096 #endif
00097 u[i][j] = eu;
00098
00099 }
00100 else if (!INU(i,j))
00101 u[i][j] = UNDEFINED;
00102 for (j = 3; j < ny; j++)
00103 if (!INV(i,j) && BV(i,j)) {
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115 #ifdef EXTRA_LINEAR
00116 extra_velocity((real)i + 0.5, (real)j, u, v, ap, in,
00117 &eu, &ev, nx, ny);
00118 #else
00119 extra_velocity2((real)i + 0.5, (real)j, u, v, ap, in,
00120 &eu, &ev, nx, ny);
00121 #endif
00122 v[i][j] = ev;
00123
00124 }
00125 else if (!INV(i,j))
00126 v[i][j] = UNDEFINED;
00127 }
00128 bc_vector_bound(u, v, nx, ny);
00129 }
00130
00131
00132 void bc_pressure_inside(real2D p, real2D ap, int nx, int ny)
00133 {
00134 int i, j;
00135
00136 for (i = 2; i < nx; i++)
00137 for (j = 2; j < ny; j++)
00138 if (!INP(i,j))
00139 p[i][j] = 0.0;
00140 }
00141
00142
00143 void bc_pressure(real2D p, real2D ap, real pe,
00144 real R,
00145 int nx, int ny)
00146 {
00147 int i, j;
00148
00149 bc_pressure_inside(p, ap, nx, ny);
00150 for (i = 2; i < nx; i++) {
00151 #ifdef WALL_TOP
00152 p[i][ny] = p[i][ny-1];
00153 #else
00154 p[i][ny] = rp_pressure(pe, R, (real)i + 0.5, (real)ny + 0.5, nx, ny);
00155 #endif
00156 p[i][1] = p[i][2];
00157 }
00158 for (j = 2; j < ny; j++) {
00159 #ifdef WALL_LEFT
00160 p[1][j] = p[2][j];
00161 #else
00162 p[1][j] = rp_pressure(pe, R, 1.5, (real)j + 0.5, nx, ny);
00163 #endif
00164 #ifdef WALL_RIGHT
00165 p[nx][j] = p[nx-1][j];
00166 #else
00167 p[nx][j] = rp_pressure(pe, R, (real)nx + 0.5, (real)j + 0.5, nx, ny);
00168 #endif
00169 }
00170 }
00171
00172
00173 void bc_scalar(real2D scal, int nx, int ny, char sw)
00174 {
00175 int i, j;
00176
00177
00178 switch(sw) {
00179 case NULGRAD:
00180 for (i = 1; i <= nx; i++) {
00181 scal[i][1] = scal[i][2];
00182 scal[i][ny] = scal[i][ny - 1];
00183 }
00184 for (j = 1; j <= ny; j++) {
00185 scal[1][j] = scal[2][j];
00186 scal[nx][j] = scal[nx-1][j];
00187 }
00188 break;
00189 case NULGRAD2:
00190 for (i = 1; i <= nx; i++)
00191 scal[i][1] = scal[i][2];
00192 #ifdef WALL_LEFT
00193 for (j = 1; j <= ny; j++)
00194 scal[1][j] = scal[2][j];
00195 #endif
00196 #ifdef WALL_RIGHT
00197 for (j = 1; j <= ny; j++)
00198 scal[nx][j] = scal[nx-1][j];
00199 #endif
00200 #ifdef WALL_TOP
00201 for (i = 1; i <= nx; i++)
00202 scal[i][ny] = scal[i][ny-1];
00203 #endif
00204 break;
00205 case NUL:
00206
00207 for (i = 1; i <= nx; i++) {
00208 scal[i][1] = 0.0;
00209 scal[i][ny] = 0.0;
00210 }
00211 for (j = 1; j <= ny; j++)
00212 scal[1][j] = scal[nx][j] = 0.0;
00213 break;
00214 default:
00215 printf("illegal switch value for a scalar field\n");
00216 exit(1);
00217 }
00218 }
00219
00220
00221 int bc_xcoord(int i, int nx)
00222 {
00223
00224 if (i <= 1)
00225 return 3 - i;
00226 if (i >= nx)
00227 return 2*nx - i - 1;
00228 return i;
00229 }
00230
00231
00232 int bc_ycoord(int j, int ny)
00233 {
00234
00235 if (j <= 1)
00236 return 3 - j;
00237 if (j >= ny)
00238 return 2*ny - j - 1;
00239 return j;
00240 }
00241
00242
00243
00244
00245
00246
00247
00248