示例#1
0
文件: uvp.c 项目: huhulala/cdf3_final
void calculate_fg(double Re, double GX, double GY,double alpha, double dt,double dx,double dy, int imax, int jmax,
		double **U,double **V,double **F,double **G, int **Flag)
{
	/* see formulas 9 and 10 in combination with formulas 4 and 5 */
	int i;
	int j;

	for (j = 1; j <= jmax; j++)
	for (i = 1; i <= imax; i++)
	{
		/********** calculate F **********/
		/* calculate f and g only between two fluid cells */
		if ((i <= imax - 1) && (Flag[i+1][j] == C_F && Flag[i][j] == C_F))
		{
				F[i][j] = U[i][j] + dt * (
				/* 1/Re * (d²u/dx² + d²u/dy²) */
				1 / Re * (d2udx2(i, j, U, dx) + d2udy2(i, j, U, dy))
				/* - du²/dx */
				- du2dx(i, j, U, dx, alpha)
				/* - duv/dy */
				- duvdy(i, j, U, V, dy, alpha) + GX);
		}
		else
			/* F aus 1.4 bis 1.6  */
			F[i][j] = U[i][j];
		/********** calculate G **********/
		if ((j <= jmax - 1) && (Flag[i][j+1] == C_F && Flag[i][j] == C_F))
		{
				G[i][j] = V[i][j] + dt * (
				/* 1/Re * (d²v/dx² + d²v/dy²) */
				1 / Re * (d2vdx2(i, j, V, dx) + d2vdy2(i, j, V, dy))
				/* - duv/dx */
				- duvdx(i, j, U, V, dx, alpha)
				/* - dv²/dy */
				- dv2dy(i, j, V, dy, alpha) + GY);
		}
		/* G aus 1.4 bis 1.6  */
		else
			G[i][j] = V[i][j];
	}

	/* calculate boundary values -  see formula 17 */
	for (j = 1; j <= jmax; j++)
	{
		F[0][j] = U[0][j];
		F[imax][j] = U[imax][j];
	}
	for (i = 1; i <= imax; i++)
	{
		G[i][0] = V[i][0];
		G[i][jmax] = V[i][jmax];
	}
}
示例#2
0
文件: uvp.c 项目: apachalieva/GPU
void calculate_fg(
  double Re,
  double GX,
  double GY,
  double alpha,
  double dt,
  double dx,
  double dy,
  int imax,
  int jmax,
  double **U,
  double **V,
  double **F,
  double **G, 
  int **Flag
){
	int i,j;
	
	/* boundary conditions */
	for(j=1; j<=jmax; j++){
		F[ 0 ][ j ] = U[ 0 ][ j ];
		F[ imax ][ j ] = U[ imax ][ j ];
	}

	for(i=1; i<=imax; i++){
		G[i][0] = V[i][0];
		G[i][jmax] = V[i][jmax];
	}
	
	/* inner values */
	for(i=1; i<=imax-1; i++)
		for(j=1; j<=jmax; j++)
			if(Flag[i][j]==C_F && Flag[i+1][j]==C_F)
				F[i][j] = U[i][j] + dt * (
						(d2dx(U,i,j,dx) + d2dy(U,i,j,dy))/Re - du2dx(U, i, j, dx, alpha) - duvdy(U,V,i,j,dy, alpha) + GX
						);

	for(i=1; i<=imax; i++)
		for(j=1; j<=jmax-1; j++)
			if(Flag[i][j]==C_F && Flag[i][j+1]==C_F)
				G[i][j] = V[i][j] + dt * (
						(d2dx(V,i,j,dx) + d2dy(V,i,j,dy))/Re - duvdx(U, V, i, j, dx, alpha) - dv2dy(V,i,j,dy, alpha) + GY
						);

}