12.07.2015 Views

COPYRIGHT 2008, PRINCETON UNIVERSITY PRESS

COPYRIGHT 2008, PRINCETON UNIVERSITY PRESS

COPYRIGHT 2008, PRINCETON UNIVERSITY PRESS

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

536 chapter 19Because the current flows smoothly along the top of the beam, v y must alsovanish. In addition, since there is no x variation, we have∂v y∂x =0 ⇒ w = −∂v x∂y = −∂2 u∂y 2 . (19.77)After substituting these relations into the Taylor series (19.74), we can solvefor w and obtain the finite-difference version of the top boundary condition:u(x, y + h) − u(x, y)w ≃−2h 2⇒ w i,j = −2 u i,j+1 − u i,jh 2 (top). (19.78)Similar treatments applied to other surfaces yield the following boundaryconditions.u =0; w =0 Centerline EAu =0, w i,j = −2(u i+1,j − u i,j )/h 2 Beam back Bu =0, w i,j = −2(u i,j+1 − u i,j )/h 2 Beam top Cu =0, w i,j = −2(u i−1,j − u i,j )/h 2 Beam front D∂u/∂x =0, w =0 Inlet F∂u/∂y = V 0 , w =0 Surface G∂u/∂x =0, ∂w/∂x=0 Outlet H19.9.3 SOR on a Grid ImplementationBeam.java in Listing 19.3 is our solution of the vorticity form of the Navier–Stokesequation. You will notice that while the relaxation algorithm is rather simple, somecare is needed in implementing the many boundary conditions. Relaxation of thestream function and of the vorticity is done by separate methods, and the file outputformat is that for a Gnuplot surface plot.✞☎/ / Beam . java solves Navier−Stokes equations for flow over plateimport java . io .∗ ;import java . util .∗ ;public class Beam {static int Nxmax = 7 0 ; static int Nymax = 2 0 ; / / Grid parametersstatic double u[][] = new double [Nxmax + 1 ] [ Nymax + 1 ] ; / / Streamstatic double w[][] = new double [Nxmax + 1 ] [ Nymax + 1 ] ; // Vorticitystatic double V0 = 1.; static double R; // Initial v, Reynold ’ s #static double omega = 0.1; // Relaxation parameterstatic int IL = 10; static int H= 8; static int T = 8; / / Geometrystatic double h = 1.; static double nu = 1 . ; // h, viscositypublic static void main ( String [] argv ) throws IOException , FileNotFoundException {PrintWriter q = new PrintWriter (new FileOutputStream ("flow1 . dat . dat") , true );int i , j , iter ;iter = 0; / / Number of i t e rations−101<strong>COPYRIGHT</strong> <strong>2008</strong>, PRINCET O N UNIVE R S I T Y P R E S SEVALUATION COPY ONLY. NOT FOR USE IN COURSES.ALLpup_06.04 — <strong>2008</strong>/2/15 — Page 536

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!