// cylinder_flow.c cylinder in wind tunnel, uniform grid // hard coded circle, two D view of cylinder #include #include #include #include "simeq_newton3.h" #include "deriv.h" static char fname[] = "cylinder"; //static const int order = 5; // 5th order approximation of derivatives #define order 5 static double cx[order][order]; // for rderiv static double cxx[order][order]; // first subscript is index static double cy[order][order]; static double cyy[order][order]; static double xmin = -2.0; // bounds for wind tunnel static double xmax = 2.0; static double ymin = -1.0; static double ymax = 1.0; static double xoff = 50.0; static double yoff = 50.0; static double scale = 100.0; // for plotting // static const int nxg = 61; // 4.0 in X #define nxg 61 // static const int nyg = 29; // 11 each side of 7 for cylinder, 2.0 in Y #define nyg 29 // static const int ncyl = 37; // grid points in cylinder 2*3+2*5+3*7 #define ncyl 37 static double hx = 4.0/60.0; // 61-1, x grid spacing static double hy = 2.0/28.0; // 29-1, y grid spacing static double xg[nxg]; // output grid static double yg[nyg]; static double u[nxg][nyg]; // velocity +X direction static double v[nxg][nyg]; // velocity +Y direction static double p[nxg][nyg]; // pressure static 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}; static 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}; // static const int nDOF = (nxg-2)*(nyg-2)-ncyl; // inside boundary, not in cylinder // number of degrees of freedom, u,v,p independent variable each #define nDOF (nxg-2)*(nyg-2)-ncyl // static const int neqn = 3*nDOF; // number of equations 3*nDOF = number of variables #define neqn 3*nDOF // static const int nlin = 3*order*order*nDOF; guess ??? // maximum number of nonlinear terms uu for some uv, some vv #define nlin nDOF // static const int ntot = neqn+nlin; // max independent plus product variables neqn+nlin #define ntot neqn+nlin static double A[neqn][ntot]; // A Y = X system of non linear equations static double Y[neqn]; // RHS right hand side of equations static double X[ntot]; // initial guess and solution of non linear equations static int var1[ntot]; // variable number for non linear equations static int var2[ntot]; // variable number for non linear equations static int var3[ntot]; // variable number for non linear equations static int iju[nxg][nyg]; static int ixpt[nDOF]; // inverse of iju static int jypt[nDOF]; static double u0 = 88.0; // u velocity, uniform at input, output, top, bottom static double v0 = 0.0; // v velocity is zero at these boundaries static double rho = 1.223; // density static double mu = 182.0E-6; // viscosity static double p0 = 0.100; // pressure at input and output, Pa about 14.5 psi // 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 // static void build_vert(); static int incyl(int i, int j); // return 1 if in airfoil cylinder static int bound(int i, int j); // 0 for not boundary, // 1 for external, 2 for airfoil static int su(int i, int j); // subscript, index in A for u(x[i],y[j]) // -1 for none static int sv(int i, int j); // subscript, index in A for v(x[i],y[j]) // -1 for none static int sp(int i, int j); // subscript, index in A for p(x[i],y[j]) // -1 for none static void build_equations(); int main(int argc, char *argv[]) { int i; long long int alen; printf("cylinder_flow.c running \n"); printf("%s order=%d \n", fname, order); printf("including boundary nxg=%d, nyg=%d \n", nxg, nyg); printf("nDOF=%d, neqn=%d, nlin=%d, ntot=%d \n", nDOF, neqn, nlin, ntot); alen = (long long)8*(long long)neqn*(long long)ntot; printf("A = %lld bytes \n", alen); printf("xmin=%f, xmax=%f ymin=%f, ymax=%f \n", xmin, xmax, ymin, ymax); printf("hx=%f, hy=%f \n", hx, hy); build_vert(); build_equations(); printf("starting to solve non-linear system of equations %d by %d \n", neqn, ntot-neqn); fflush(stdout); // solve nonlinear equations, use results u, v, p //?? simeq_newton3(neqn, ntot-neqn, A, Y, var1, var2, var3, X, //?? 6, 1.0e-6, 0); // print results from X printf(" ix jy u v p \n"); for(i=0; ineqn) var1[i] = -1; } printf("check nDOF=%d = %d ixnum \n", nDOF, ixnum); } // end build_vert static int incyl(int i, int j) // return 1 if in airfoil cylinder { int k; for(k=0; k