Main Page   Data Structures   File List   Data Fields   Globals  

make_bc_grad.c

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*/
00002 /* SCCS Information: @(#)make_bc.c      1.1    3/7/96 */
00003 /*---------------------------------------------------------------------------*/
00004 /* Implements the following boundary conditions
00005   
00006    Imposed pressure on x=0,1 and y=1 verifying the mass conservation and
00007    Bernouilli's equation
00008    Neuman conditions for velocity on x=0,1 and y=1
00009    axis of symmetry on y=0
00010  
00011 */   
00012 #include "utilf.h"
00013 #include "stypes.h"
00014 #include "markers.h"
00015 #include "extra.h"
00016 #include "make_bc.h"
00017 #include "make_bc_periodic.h"
00018 
00019 
00020 static real rp_pressure(real pe, real pg,
00021                         real R, real Rp, real x, real y, real xc)
00022 {
00023   real r = sqrt(sq(x - xc) + sq(y - 2.));
00024   return pe*(1. - R/r) + 
00025     (R*pg + 0.5*R*sq(Rp)*(1. - cube(R/r)))/r;
00026 }
00027 
00028 
00029 void bc_vector_bound(real2D u, real2D v, int nx, int ny)
00030 {
00031   int i, j;
00032   /* top and bottom walls */
00033   for (i = 1; i <= nx; i++) {
00034     u[i][1] = u[i][2];
00035     v[i][2] = 0.0;
00036     u[i][ny] = 2.*u[i][ny-1] - u[i][ny-2];
00037     v[i][ny] = 2.*v[i][ny-1] - v[i][ny-2];
00038   }
00039   /* left and right walls */
00040   for (j = 1; j <= ny; j++) {
00041     u[1][j] = 2.*u[2][j] - u[3][j];
00042     u[nx][j] = 2.*u[nx-1][j] - u[nx-2][j];
00043     v[1][j] = 2.*v[2][j] - v[3][j];
00044     v[nx][j] = 2.*v[nx-1][j] - v[nx-2][j];
00045   }
00046 }
00047 
00048 
00049 void bc_vector(real2D u, real2D a, real2D v, real2D c,
00050                interface in,
00051                int nx, int ny)
00052 {
00053   int i, j;
00054 
00055   /* extrapolate the interfacial cells */
00056   for (i = 2; i < nx; i++)
00057     for (j = 2; j < ny; j++) {
00058       if (a[i-1][j] > 0.0 && a[i-1][j] < 1.0)
00059         u[i][j] = interplate_u(u, a, NULL,
00060                                (real)i, 0.5 + (real)j, nx, ny, INTERPLATE_FULL);
00061       if (i != 2 && a[i-1][j] == 0.0)
00062         u[i][j] = 0.0;
00063       if (c[i][j-1] > 0.0 && c[i][j-1] < 1.0)
00064         v[i][j] = interplate_v(v, c, NULL, 
00065                                0.5 + (real)i, (real)j, nx, ny, INTERPLATE_FULL);
00066       if (c[i][j-1] == 0.0)
00067         v[i][j] = 0.0;
00068     }
00069 
00070   bc_vector_bound(u, v, nx, ny);
00071 }
00072 
00073 
00074 void bc_vector_div(real2D u, real2D a, real2D v, real2D c,
00075                    interface in,
00076                    int nx, int ny)
00077 {
00078   int i, j;
00079   real eu, ev, a11, a22, a12, a21;
00080 
00081   /* extrapolate the interfacial cells */
00082   for (i = 2; i < nx; i++)
00083     for (j = 2; j < ny; j++) {
00084       if (a[i-1][j] > 0.0 && a[i-1][j] < 1.0) {
00085         extra_velocity((real)i, 0.5 + (real)j, u, a, v, c, in, 
00086                        &eu, &ev, &a11, &a22, &a12, &a21, nx, ny);
00087         u[i][j] = eu;
00088       }
00089       if (i != 2 && a[i-1][j] == 0.0)
00090         u[i][j] = 0.0;
00091       if (c[i][j-1] > 0.0 && c[i][j-1] < 1.0) {
00092         extra_velocity(0.5+(real)i, (real)j, u, a, v, c, in, 
00093                        &eu, &ev, &a11, &a22, &a12, &a21, nx, ny);
00094         v[i][j] = ev;
00095       }
00096       if (c[i][j-1] == 0.0)
00097         v[i][j] = 0.0;
00098     }
00099 
00100   bc_vector_bound(u, v, nx, ny);
00101 }
00102 
00103 
00104 void bc_pressure(real2D p, real2D cc, interface in,
00105                  real pe, real pg, real R, real Rp,
00106                  int nx, int ny)
00107 {
00108   int i, j;
00109 
00110   /* extrapolate the interfacial cells */
00111   for (i = 2; i < nx; i++) {
00112     for (j = 2; j < ny; j++) {
00113       if (cc[i][j] > 0.0 && cc[i][j] < 1.0)
00114         p[i][j] = interplate_p(p, cc, in,
00115                                0.5 + (real)i, 0.5 + (real)j, nx, ny);
00116       if (cc[i][j] == 0.0)
00117         p[i][j] = 0.0;
00118     }
00119   }
00120 
00121   for (i = 1; i <= nx; i++)
00122     p[i][ny - 1] = rp_pressure(pe, pg, R, Rp, 
00123                                0.5 + (real)i, 0.5 + (real)(ny - 1), 
00124                                0.5*(nx - 2.) + 2.);
00125   for (j = 1; j <= ny; j++) {
00126     p[2][j] = rp_pressure(pe, pg, R, Rp, 
00127                           2.5, 0.5 + (real)j, 
00128                           0.5*(nx - 2.) + 2.);
00129     p[nx - 1][j] = rp_pressure(pe, pg, R, Rp, 
00130                                0.5 + (real)(nx - 1), 0.5 + (real)j,
00131                                0.5*(nx - 2.) + 2.);
00132   }
00133   bc_scalar(p, nx, ny, NULGRAD);
00134 }
00135 
00136 
00137 void bc_tensor(real2D S11, real2D S22, real2D S12, int nx, int ny)
00138 {
00139   int i, j;
00140   
00141   /*  slip conditions on the walls S12 = 0  */
00142   for (i = 2; i <= nx - 1; i++) {
00143     S12[i][2] = 0.0;
00144     S12[i][ny] = S12[i][ny-1];
00145   }
00146   for (j = 2; j <= ny - 1; j++) {
00147     S12[2][j] = S12[3][j];
00148     S12[nx][j] = S12[nx-1][j];
00149   }
00150 }
00151 
00152 
00153 void bc_scalar(real2D scal, int nx, int ny, char sw)
00154 {
00155   int i, j;
00156   
00157   /*  div: gradient equal to zero on y=0,1 planes  */
00158   switch(sw) {
00159     case NULGRAD:
00160       for (i = 1; i <= nx; i++)
00161         {
00162           scal[i][1] = scal[i][2];
00163           scal[i][ny] = scal[i][ny - 1];
00164         }
00165       for (j = 1; j <= ny; j++) {
00166         scal[1][j] = scal[2][j];
00167         scal[nx][j] = scal[nx-1][j];
00168       }
00169       break;
00170     case NULGRAD2:
00171       for (i = 1; i <= nx; i++)
00172         scal[i][1] = scal[i][2];
00173       break;
00174     case NUL:
00175       /*  residue equal to zero on the walls  */ 
00176       for (i = 1; i <= nx; i++)
00177         scal[i][1] = scal[i][ny] = 0.0;
00178       for (j = 1; j <= ny; j++)
00179         scal[1][j] = scal[nx][j] = 0.0;
00180       break;
00181     default:
00182       printf("illegal switch value for a scalar field\n");
00183       exit(1);
00184   }
00185 }
00186 
00187 
00188 int bc_xcoord(int i, int nx)
00189 {
00190   /* mirror symmetric boundary conditions */
00191   if (i <= 1)
00192     return 3 - i;
00193   if (i >= nx)
00194     return 2*nx - i - 1;
00195   return i;
00196 }
00197 
00198 
00199 int bc_ycoord(int j, int ny)
00200 {
00201   /* mirror symmetric boundary conditions */
00202   if (j <= 1)
00203     return 3 - j;
00204   if (j >= ny)
00205     return 2*ny - j - 1;
00206   return j;
00207 }
00208 
00209 
00210 
00211 
00212 
00213 
00214 
00215 

Generated on Wed Feb 19 22:26:49 2003 for Markers by doxygen1.2.18