Exemple #1
0
//===================================================================//
		//START FlexWingVortDist
//===================================================================//
void FlexWingVortDist(const GENERAL info,const PANEL *panelPtr,\
					DVE *surfacePtr,DVE **wakePtr,double **D,\
					double *R,int timestep)
{
//Solves equation system Dx=R using a Gaussian algorithm
//input
//info			general information
//panelPtr		panel information
//surfacePtr	surface DVEs
//walePtr		wake DVEs
//D				D matrix 3nx3n, n = no. of surface DVEs
//R				right hand side vector
//timestep		current timestep
//
//
//output
//Surface DVEs vorticity coefficients A, B, and C
void DVE_Resultant(const GENERAL,const PANEL *,const DVE *,DVE **,\
				   const int,double *);

	double *x;
	int m,n;

	//computes resultant vector.
	DVE_Resultant(info,panelPtr,surfacePtr,wakePtr,timestep,R);

	ALLOC1D(&x,(info.Dsize));		//frees memory allocated for A

	GaussSolve(D,R,info.Dsize,x);	//subroutine in gauss.cpp

	//assigns circulation coefficients A, B, and C
	for(n=0;n<info.noelement;n++)
	{
		m=n*3;
		surfacePtr[n].A=x[m];
		surfacePtr[n].B=x[m+1];
		surfacePtr[n].C=x[m+2];
//#printf("A= %lf\tB= %lf\tC= %lf\n",x[m],x[m+1],x[m+2]);//##
	}
	FREE1D(&x,(info.Dsize));		//frees memory allocated for A
}
Exemple #2
0
/*!
 */
void polynomial::Solve()
{
    int O;

    O = GlobalO;
    if (XYCount() <= O)
        O = XYCount() - 1;

    if (O >= 0)
    {
        BuildMatrix(O);

		GaussSolve(O);
		while (1 < O)
		{
			C[0] = 0.0f;
			O = O - 1;
			FinalizeMatrix(O);
		}
    }
}
Exemple #3
0
	//Assembly of equation system that defines vorticity distribution
	//across each elementary wing.  Equation system has the form :
	//				D A = R
	//			D  	matrix with (3n)^2 elements, where n is the number
	//				of elementary wings
	//			A   3n vector with the A, B, and C coefficients of the
	//				vorticity distribution across each elementary wing.
	//			R	3n resultant vector, equal zero except for Part 3.
	//				R and D consist of three major parts:
	//					Part 1: Boundary cond. between elem. wings due
	//							of the same panel.  Magnitude and slope
	//							of the vorticity is preserved across the
	//							boundaries
	//					Part 2: Boundary cond. between elem. wings of
	//							neighboring panels (including free ends).
	//							possible conditions are preservation of
	//							vorticity (or 0 at free end), slope, or
	//							curvature.
	//					Part 3: Kinematic condition in the ctrl. point.
	//
	//The function also solves the equation system for the vorticity
	//coefficients, A, B, and C, of each elementary wing by applying a
	//Gaussian elimination.
void Vorticity_Distribution(const GENERAL info, const PANEL *panelPtr, \
							BOUND_VORTEX *elementPtr, double **D, double *R)
{
//assembles boundary conditions between panels
void BoundaryCond(const BOUND_VORTEX *,const PANEL *,const GENERAL,double **);
void Resultant(const BOUND_VORTEX *, const GENERAL, double *);
void KinematicCond(const BOUND_VORTEX *,const GENERAL,const PANEL *,double **);

int n, m;					//counter
int Dsize=info.Dsize;		//size of matrix D
double *x;					//temporary vector with Vorticity coefficients A,B,C

	//assmebly of resultant vector R
	Resultant(elementPtr,info,R);
						//subroutine in equ_system.cpp

	//assembly of first part of D, boundary cond. of
	//elementary wings within each panel
	BoundaryCond(elementPtr,panelPtr,info,D);
						//subroutine in equ_system.cpp

	//assembles second part of D that deals with
	//the kinematic condition of the elementary wing
	KinematicCond(elementPtr,info,panelPtr,D);
						//subroutine in equ_system.cpp
	//Solves D x = R equation system with Gaussian elimination
	ALLOC1D(&x,(Dsize)); //allocates memory for x

 /*  ###########################################################
 //save D matrix and resultant vector R in file D_matrix.txt
 FILE *fp;
 fp = fopen("D_matrix.txt", "w");
 //writes header line
 fprintf(fp, "\t");
 for(m=0; m<Dsize; m++)
 fprintf(fp, "%ld\t",m);
 fprintf(fp, "\t\tR");
 for(n=0; n<Dsize; n++)
 {
	 //row number
 	fprintf(fp, "\n%d\t",n);
 	//n-th row of D
 	for(m=0; m<Dsize; m++)
 	fprintf(fp, "%lf\t",D[n][m]);
 	//n-th element of R
	fprintf(fp, "\t\t%lf",R[n]);
 }
 fclose(fp);
 //###########################################################//*/

	GaussSolve(D,R,Dsize,x);
						//subroutine in gauss.cpp

	//assigns circulation coefficients A, B, and C
	for(n=0;n<info.noelement;n++)
	{
		m=n*3;
		elementPtr[n].A=x[m];
		elementPtr[n].B=x[m+1];
		elementPtr[n].C=x[m+2];
//#printf("A= %lf\tB= %lf\tC= %lf\n",x[m],x[m+1],x[m+2]);//##
	}
	FREE1D(&x,(Dsize));		//frees memory allocated for A
}