// cylinder_flow.java cylinder in wind tunnel, uniform grid // hard coded circle, two D view of cylinder import java.awt.*; import java.awt.event.*; import java.io.*; public class cylinder_flow extends Frame { int order = 7; // 7th order approximation of derivatives double cx[] = new double[order]; // for rderiv double cxx[] = new double[order]; double cy[] = new double[order]; double cyy[] = new double[order]; double xmin = -3.0; // bounds for wind tunnel double xmax = 3.0; double ymin = -1.0; double ymax = 1.0; double xoff = 50.0; double yoff = 50.0; double scale = 100.0; // for plotting int nxg = 87; // 6.0 in X int nyg = 29; // 11 each side of 7 for cylinder, 2.0 in Y int ncyl = 37; // grid points in cylinder 2*3+2*5+3*7 double hx = 6.0/86.0; // 87-1, x grid spacing double hy = 2.0/28.0; // 29-1, y grid spacing double xg[] = new double[nxg]; // output grid double yg[] = new double[nyg]; double u[][] = new double[nxg][nyg]; // velocity +X direction double v[][] = new double[nxg][nyg]; // velocity +Y direction double p[][] = new double[nxg][nyg]; // pressure int ixcyl[] = {40, 40, 40, 41, 41, 41, 41, 41, 42, 42, 42, 42, 42, 42, 42, 43, 43, 43, 43, 43, 43, 43, 44, 44, 44, 44, 44, 44, 44, 45, 45, 45, 45, 45, 46, 46, 46}; int jxcyl[] = {13, 14, 15, 12, 13, 14, 15, 16, 11, 12, 13, 14, 15, 16, 17, 11, 12, 13, 14, 15, 16, 17, 11, 12, 13, 14, 15, 16, 17, 12, 13, 14, 15, 16, 13, 14, 15}; int nDOF = (nxg-2)*(nyg-2)-ncyl; // inside boundary, not in cylinder // number of degrees of freedom, u,v,p independent variable each int neqn = 3*nDOF; // number of equations 3*nDOF = number of variables int nlin = nDOF; //?? 3*order*order*nDOF; // maximum number of nonlinear terms // uu for some uv, some vv int ntot= neqn+nlin; // max independent plus product variables neqn+nlin double A[][] = new double[neqn][ntot]; // A Y = X system of non linear equations double Y[] = new double[neqn]; // RHS right hand side of equations double X[] = new double[ntot]; // initial guess and solution of non linear equations int var1[] = new int[ntot]; // variable number for non linear equations int var2[] = new int[ntot]; // variable number for non linear equations int var3[] = new int[ntot]; // variable number for non linear equations int iju[][] = new int[nxg][nyg]; int ixpt[] = new int[nDOF]; // inverse of iju int jypt[] = new int[nDOF]; int width = 700; // window int height = 500; // upper part for title double xx[]; double yy[]; int iu[]; // x index is u position int jv[]; // y index+nDOF is v position int eqn = 0; // equation being built int nl; // available non linear term in var1, var2 // v is offset, nDOF+j double u0 = 88.0; // u velocity, uniform at input, output, top, bottom double v0 = 0.0; // v velocity is zero at these boundaries double rho = 1.223; // density double mu = 182.0E-6; // viscosity double p0 = 0.100; // pressure at input and output, Pa about 14.5 psi String fname; // Non linear equations in A nDOF u, v, p unknowns // 0..nDOF-1 3nDOF-1 nlin ntot = 3*nDOF+nlin // |---u---|---v---|---p---|---uu, uv, vv---| // |---var1[i]=i unknowns--|--var1, var2 ---| // var2, var3 = -1 variable index // neqn rows ? may add continuity equations // A*X=Y Y is RHS // function incyl(i,j) = true for in cylinder, else false // function bound(i,j) = 0 for not boundary, 1 for external, 2 for cylinder // function su(i,j) = subscript, index in A for u(x[i],y[j]) -1 for none // function sv(i,j) = subscript, index in A for v(x[i],y[j]) -1 for none // function sp(i,j) = subscript. index in A for p(x[i],y[j]) -1 for none // cylinder_flow(String gname) { System.out.println("cylinder_flow.java running"); fname = gname; System.out.println("using "+fname+", order="+order); build_vert(); setTitle(fname+" "); setSize(width,height); setBackground(Color.white); setForeground(Color.black); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); setVisible(true); this.addMouseListener (new mousePressHandler()); build_equations(); } // end constructor cylinder_flow void build_vert() { double x, y; int ixnum = 0; // set up circle, 2D cylinder // xmin, xmax, ymin, ymax set manually for now System.out.println("xmin="+xmin+", xmax="+xmax+ ", ymin="+ymin+", ymax="+ymax); System.out.println("including boundary nxg="+nxg+ ", hx="+hx+", nyg="+nyg+", hy="+hy); // insert boundary and initial "guess" for(int i=0; i