涡格法代码及解释
#include “iostream.h“ #include “stdio.h“ #include “math.h“ #define PI 3.1415926 class AIRFOIL //用来存放翼型的信息 { public: double L,Bg,S; double Xo,Xc; double Y,Cy; AIRFOIL(){Y=0.0f,S=0.0f,L=0.0f,Bg=0.0f,Xo=0.0f,Xc=0.0f;} }; class GIRD//网格信息 { public: double x1,z1,x2,z2;//左右自由涡的坐标 double x3,z3,x4,z4;//3/4 弦线处的坐标 double x,z;//控制点的坐标,3/4 弦线中点 GIRD(){x1=0.0f,x2=0.0f,z1=0.0f,z2=0.0f,x3=0.0f,x4=0.0f,z3=0.0f,z4=0.0f,x=0.0f,z=0.0f;} }; double vec(double x,double z,double x1,double z1,double x2,double z2 ) { double a,b,c,d,e; a=1/((x2-x)*(z1-z)-(x1-x)*(z2-z)); b=((x2-x1)*(x1-x)+(z2-z1)*(z1-z))/sqrt(pow((x1-x),2)+pow((z1-z),2)); c=((x2-x1)*(x2-x)+(z2-z1)*(z2-z))/sqrt(pow((x2-x),2)+pow((z2-z),2)); d=(1-(x1-x)/sqrt(pow((x1-x),2)+pow((z1-z),2)))/(z1-z); e=(1-(x2-x)/sqrt(pow((x2-x),2)+pow((z2-z),2)))/(z2-z); return (a*(b-c)+d-e)/4/PI; } void Gaussseidel(int n,double *M,double **a,double *x,double *b)//高斯--塞得尔迭带法 { int t=0,i,j;//迭代次数 while(tairfoil.Lairfoil.Bgairfoil.Xoairfoil.Xc; if(airfoil.Bg-airfoil.L*(tan(airfoil.Xo*PI/180)+tan(airfoil.Xc*PI/180))/20) { coutMa; a=a*PI/180; coutNgNq; coutNg““Nq““endl; Nq--;Ng--;//变成分多少块 double *baseq=new double[Nq+1]; double *baseB=new double[Nq+1]; double *result=new double[2*Nq*Ng]; double *b=new double[2*Nq*Ng]; double *M1=new double[2*Nq*Ng]; GIRD **girdleft,**girdright;//左半边机翼,右半边机翼 girdleft=new GIRD*[Ng]; for(i=0;iNg;i++) { girdleft[i]=new GIRD[Nq]; } girdright=new GIRD*[Ng]; for(i=0;iNg;i++) { girdright[i]=new GIRD[Nq]; } double width=airfoil.L/Nq/2;//展长每个分块的长度 //前缘节点的 x 坐标 cout“前缘节点处的 x 坐标“endl; for(i=0;iNq+1;i++) { baseq[i]=0+i*width*tan(airfoil.Xo*PI/180); coutbaseq[i]““endl; } //每一条平行于根弦的弦的长度 cout“每一条平行于根弦的弦的长度“endl; for(i=0;iNq+1;i++) { baseB[i]=airfoil.Bg-i*(tan(airfoil.Xo*PI/180)+tan(airfoil.Xc*PI/180))*width; coutbaseB[i]““endl; } for(i=0;iNg;i++) { for(j=0;jNq;j++) { girdleft[i][j].x1=baseq[j]+baseB[j]/4/Ng+i*baseB[j]/Ng; girdright[i][j].x1=girdleft[i][j].x1; cout“(x2,z2):““(“girdright[i][j].x2“,“girdright[i][j].z2“)“endl; cout“(x3,z3):““(“girdright[i][j].x3“,“girdright[i][j].z3“)“““; cout“(x4,z4):““(“girdright[i][j].x4“,“girdright[i][j].z4“)“““; cout“(x,z):““(“girdright[i][j].x“,“girdright[i][j].z“)“endl; } } //存储系数矩阵 double **array; array=new double*[2*Ng*Nq]; for(i=0;i2*Ng*Nq;i++) { array[i]=new double[2*Ng*Nq]; } for(i=0;iNq*Ng;i++) 出 打出 girdleft[i][j].x3=girdleft[i][j].x1+baseB[j]/2/Ng; girdright[i][j].x3=girdleft[i][j].x3; girdleft[i][j].z1=0+j*width; girdright[i][j].z1=-1*girdleft[i][j].z1; girdleft[i][j].z3=girdleft[i][j].z1; girdright[i][j].z3=-1*girdleft[i][j].z3; girdleft[i][j].z2=girdleft[i][j].z1+width; girdright[i][j].z2=-1*girdleft[i][j].z2; girdleft[i][j].z4=girdleft[i][j].z2; girdright[i][j].z4=-1*girdleft[i][j].z4; girdleft[i][j].x2=baseq[j+1]+baseB[j+1]/4/Ng+i*baseB[j+1]/Ng; girdright[i][j].x2=girdleft[i][j].x2; girdleft[i][j].x4=girdleft[i][j].x2+baseB[j+1]/2/Ng; girdright[i][j].x4=girdleft[i][j].x4; girdleft[i][j].x=(girdleft[i][j].x3+girdleft[i][j].x4)/2; girdright[i][j].x=girdleft[i][j].x; gi