Main Page   Data Structures   File List   Data Fields   Globals  

make_bc_rad.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 pR,
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*pR + 0.5*R*sq(Rp)*(1. - cube(R/r)))/r;
00026     */
00027   return pe;
00028 }
00029 
00030 
00031 void bc_vector_bound(real2D u, real2D v, 
00032                      real R, real Rp, real xc,
00033                      int nx, int ny)
00034 {
00035   int i, j;
00036   real r;
00037 
00038   R *= R;
00039   /* top and bottom walls */
00040   for (i = 1; i <= nx; i++) {
00041     u[i][1] = u[i][2];
00042     v[i][2] = 0.0;
00043     r = sqrt(sq((real)i - xc) + sq((real)ny + 0.5 - 2.));
00044     u[i][ny] = R/cube(r)*Rp*((real)i - xc);
00045     r = sqrt(sq((real)i + 0.5 - xc) + sq((real)ny - 2.));
00046     v[i][ny] = R/cube(r)*Rp*((real)ny - 2.);
00047   }
00048   /* left and right walls */
00049   for (j = 1; j <= ny; j++) {
00050     r = sqrt(sq(2. - xc) + sq((real)j + 0.5 - 2.));
00051     u[2][j] = R/cube(r)*Rp*(2. - xc);
00052     r = sqrt(sq((real)nx - xc) + sq((real)j + 0.5 - 2.));
00053     u[nx][j] = R/cube(r)*Rp*((real)nx - xc);
00054     r = sqrt(sq(1.5 - xc) + sq((real)j - 2.));
00055     v[1][j] = R/cube(r)*Rp*((real)j - 2.);
00056     r = sqrt(sq((real)nx + 0.5 - xc) + sq((real)j - 2.));
00057     v[nx][j] = R/cube(r)*Rp*((real)j - 2.);
00058   }
00059 }
00060 
00061 
00062 void bc_vector(real2D u, real2D a, real2D v, real2D c,
00063                interface in,
00064                real R, real Rp,
00065                int nx, int ny)
00066 {
00067   int i, j;
00068 
00069   /* extrapolate the interfacial cells */
00070   for (i = 2; i < nx; i++)
00071     for (j = 2; j < ny; j++) {
00072       if (a[i-1][j] > 0.0 && a[i-1][j] < 1.0)
00073         u[i][j] = interplate_u(u, a, NULL,
00074                                (real)i, 0.5 + (real)j, nx, ny, INTERPLATE_FULL);
00075       if (i != 2 && a[i-1][j] == 0.0)
00076         u[i][j] = 0.0;
00077       if (c[i][j-1] > 0.0 && c[i][j-1] < 1.0)
00078         v[i][j] = interplate_v(v, c, NULL, 
00079                                0.5 + (real)i, (real)j, nx, ny, INTERPLATE_FULL);
00080       if (c[i][j-1] == 0.0)
00081         v[i][j] = 0.0;
00082     }
00083 
00084   bc_vector_bound(u, v, R, Rp, 0.5*(nx - 2.) + 2., nx, ny);
00085 }
00086 
00087 
00088 void bc_vector_div(real2D u, real2D a, real2D v, real2D c,
00089                    interface in,
00090                    real R, real Rp,
00091                    int nx, int ny)
00092 {
00093   int i, j;
00094   real eu, ev, a11, a22, a12, a21;
00095 
00096   /* extrapolate the interfacial cells */
00097   for (i = 2; i < nx; i++)
00098     for (j = 2; j < ny; j++) {
00099       if (a[i-1][j] > 0.0 && a[i-1][j] < 1.0) {
00100         extra_velocity((real)i, 0.5 + (real)j, u, a, v, c, in, 
00101                        &eu, &ev, &a11, &a22, &a12, &a21, nx, ny);
00102         u[i][j] = eu;
00103       }
00104       if (i != 2 && a[i-1][j] == 0.0)
00105         u[i][j] = 0.0;
00106       if (c[i][j-1] > 0.0 && c[i][j-1] < 1.0) {
00107         extra_velocity(0.5+(real)i, (real)j, u, a, v, c, in, 
00108                        &eu, &ev, &a11, &a22, &a12, &a21, nx, ny);
00109         v[i][j] = ev;
00110       }
00111       if (c[i][j-1] == 0.0)
00112         v[i][j] = 0.0;
00113     }
00114 
00115   bc_vector_bound(u, v, R, Rp, 0.5*(nx - 2.) + 2., nx, ny);
00116 }
00117 
00118 
00119 void bc_pressure(real2D p, real2D cc, interface in,
00120                  real pe, real pg, real pR, real R, real Rp,
00121                  int nx, int ny)
00122 {
00123   int i, j;
00124 
00125   /* extrapolate the interfacial cells */
00126   for (i = 2; i < nx; i++) {
00127     for (j = 2; j < ny; j++) {
00128       if (cc[i][j] > 0.0 && cc[i][j] < 1.0)
00129         p[i][j] = interplate_p(p, cc, in,
00130                                0.5 + (real)i, 0.5 + (real)j, nx, ny);
00131       if (cc[i][j] == 0.0)
00132         p[i][j] = pg;
00133     }
00134   }
00135 
00136   for (i = 1; i <= nx; i++)
00137     p[i][ny - 1] = rp_pressure(pe, pR, R, Rp, 
00138                                0.5 + (real)i, 0.5 + (real)(ny - 1), 
00139                                0.5*(nx - 2.) + 2.);
00140   for (j = 1; j <= ny; j++) {
00141     p[2][j] = rp_pressure(pe, pR, R, Rp, 
00142                           2.5, 0.5 + (real)j, 
00143                           0.5*(nx - 2.) + 2.);
00144     p[nx - 1][j] = rp_pressure(pe, pR, R, Rp, 
00145                                0.5 + (real)(nx - 1), 0.5 + (real)j,
00146                                0.5*(nx - 2.) + 2.);
00147   }
00148   bc_scalar(p, nx, ny, NULGRAD);
00149 }
00150 
00151 
00152 void bc_tensor(real2D S11, real2D S22, real2D S12, int nx, int ny)
00153 {
00154   int i, j;
00155   
00156   /*  slip conditions on the walls S12 = 0  */
00157   for (i = 2; i <= nx - 1; i++) {
00158     S12[i][2] = 0.0;
00159     S12[i][ny] = S12[i][ny-1];
00160   }
00161   for (j = 2; j <= ny - 1; j++) {
00162     S12[2][j] = S12[3][j];
00163     S12[nx][j] = S12[nx-1][j];
00164   }
00165 }
00166 
00167 
00168 void bc_scalar(real2D scal, int nx, int ny, char sw)
00169 {
00170   int i, j;
00171   
00172   /*  div: gradient equal to zero on y=0,1 planes  */
00173   switch(sw) {
00174     case NULGRAD:
00175       for (i = 1; i <= nx; i++)
00176         {
00177           scal[i][1] = scal[i][2];
00178           scal[i][ny] = scal[i][ny - 1];
00179         }
00180       for (j = 1; j <= ny; j++) {
00181         scal[1][j] = scal[2][j];
00182         scal[nx][j] = scal[nx-1][j];
00183       }
00184       break;
00185     case NULGRAD2:
00186       for (i = 1; i <= nx; i++)
00187         scal[i][1] = scal[i][2];
00188       break;
00189     case NUL:
00190       /*  residue equal to zero on the walls  */ 
00191       for (i = 1; i <= nx; i++)
00192         scal[i][1] = scal[i][ny] = 0.0;
00193       for (j = 1; j <= ny; j++)
00194         scal[1][j] = scal[nx][j] = 0.0;
00195       break;
00196     default:
00197       printf("illegal switch value for a scalar field\n");
00198       exit(1);
00199   }
00200 }
00201 
00202 
00203 int bc_xcoord(int i, int nx)
00204 {
00205   /* mirror symmetric boundary conditions */
00206   if (i <= 1)
00207     return 3 - i;
00208   if (i >= nx)
00209     return 2*nx - i - 1;
00210   return i;
00211 }
00212 
00213 
00214 int bc_ycoord(int j, int ny)
00215 {
00216   /* mirror symmetric boundary conditions */
00217   if (j <= 1)
00218     return 3 - j;
00219   if (j >= ny)
00220     return 2*ny - j - 1;
00221   return j;
00222 }
00223 
00224 
00225 
00226 
00227 
00228 
00229 
00230 

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