Main Page   Data Structures   File List   Data Fields   Globals  

make_bc.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    periodic in x direction. 
00007    slip velocity           on y=0,1
00008    V.C = 0                 on y=0,1 
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 
00021 void bc_vector_bound(real2D u, real2D v, int nx, int ny)
00022 {
00023   int i, j;
00024   /* top and bottom walls */
00025   for (i = 1; i <= nx; i++) {
00026     u[i][1] = u[i][2]; /* axisymmetric */
00027     v[i][2] = 0.0;     /* axisymmetric */
00028     u[i][ny] = u[i][ny-1];
00029     v[i][ny] = 0.0;
00030   }
00031   /* left and right walls */
00032   for (j = 1; j <= ny; j++) {
00033     u[2][j] = 0.0;
00034     v[1][j] = v[2][j];
00035     u[nx][j] = 0.0;
00036     v[nx][j] = v[nx-1][j];
00037   }
00038 #ifdef CENTRAL_SYMMETRY
00039   i = nx/2 + 1;
00040   for (j = 1; j <= ny; j++)
00041     u[i][j] = 0.0;
00042 #endif
00043 }
00044 
00045 
00046 void bc_vector_div(real2D u, real2D v, real2D ap,
00047                    interface in,
00048                    int nx, int ny)
00049 {
00050   int i, j;
00051   real eu, ev;
00052 
00053   /* extrapolate the interfacial cells */
00054   for (i = 3; i < nx - 1; i++) { /* don't solve the first and last columns */
00055     for (j = 2; j < ny; j++)
00056       if (!INU(i,j) && BU(i,j)) {
00057 #ifdef EXTRA_LINEAR
00058         extra_velocity((real)i, (real)j + 0.5, u, v, ap, in, 
00059                        &eu, &ev, nx, ny);
00060 #else
00061         extra_velocity2((real)i, (real)j + 0.5, u, v, ap, in, 
00062                         &eu, &ev, nx, ny);
00063 #endif
00064         u[i][j] = eu;
00065       }
00066       else if (!INU(i,j))
00067         u[i][j] = UNDEFINED;
00068     for (j = 3; j < ny; j++)
00069       if (!INV(i,j) && BV(i,j)) {
00070 #ifdef EXTRA_LINEAR
00071         extra_velocity((real)i + 0.5, (real)j, u, v, ap, in, 
00072                        &eu, &ev, nx, ny);
00073 #else
00074         extra_velocity2((real)i + 0.5, (real)j, u, v, ap, in, 
00075                         &eu, &ev, nx, ny);
00076 #endif
00077         v[i][j] = ev;
00078       }
00079       else if (!INV(i,j))
00080         v[i][j] = UNDEFINED;
00081   }
00082   bc_vector_bound(u, v, nx, ny);
00083 }
00084 
00085 
00086 void bc_pressure_inside(real2D p, real2D ap, int nx, int ny)
00087 {
00088   int i, j;
00089   
00090   for (i = 2; i < nx; i++)
00091     for (j = 2; j < ny; j++)
00092       if (!INP(i,j))
00093         p[i][j] = 0.0;
00094 }
00095 
00096 
00097 void bc_pressure(real2D p, real2D ap, real pe, 
00098                  real R,
00099                  int nx, int ny)
00100 {
00101   bc_pressure_inside(p, ap, nx, ny);
00102   bc_scalar(p, nx, ny, NULGRAD);
00103 }
00104 
00105 
00106 void bc_scalar(real2D scal, int nx, int ny, char sw)
00107 {
00108   int i, j;
00109   
00110   /*  div: gradient equal to zero on y=0,1 planes  */
00111   switch(sw) {  
00112   case NULGRAD: case NULGRAD2:
00113     for (i = 1; i <= nx; i++) {
00114       scal[i][1] = scal[i][2]; /* axisymmetric */
00115       scal[i][ny] = scal[i][ny - 1];
00116     }     
00117     for (j = 1; j <= ny; j++) {
00118       scal[1][j] = scal[2][j];
00119       scal[nx][j] = scal[nx-1][j];
00120     }
00121     break;
00122   case NUL:
00123     /*  residue equal to zero on the walls  */ 
00124     for (i = 1; i <= nx; i++) {
00125       scal[i][1] = 0.0; /* axisymmetric */
00126       scal[i][ny] = 0.0;
00127     }
00128     for (j = 1; j <= ny; j++)
00129       scal[1][j] = scal[nx][j] = 0.0;
00130     break;
00131   default:
00132     printf("illegal switch value for a scalar field\n");
00133     exit(1);
00134   }
00135 }
00136 
00137 
00138 int bc_xcoord(int i, int nx)
00139 {
00140   /* mirror symmetric boundary conditions */
00141   if (i <= 1)
00142     return 3 - i;
00143   if (i >= nx)
00144     return 2*nx - i - 1;
00145   return i;
00146 }
00147 
00148 
00149 int bc_ycoord(int j, int ny)
00150 {
00151   /* mirror symmetric boundary conditions */
00152   if (j <= 1)
00153     return 3 - j;
00154   if (j >= ny)
00155     return 2*ny - j - 1;
00156   return j;
00157 }
00158 
00159 
00160 
00161 
00162 
00163 
00164 
00165 
00166 
00167 
00168 

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