Пример #1
0
void Computation::computeNewVelocities(GridFunction& u, GridFunction& v,
		GridFunction& f, GridFunction& g, GridFunction& p, RealType deltaT) {
	GridFunction branch_1(p.griddimension);
	MultiIndexType begin, end;
	begin[0] = 1;
	end[0] = u.griddimension[0] - 3;
	begin[1] = 1;
	end[1] = u.griddimension[1] - 2;
	// u Update
	PointType delta;
	delta[0] = SimIO.para.deltaX;
	delta[1] = SimIO.para.deltaY;
	Px(branch_1, p, delta);
	f.AddToGridFunction(begin, end, -1.0 * deltaT, branch_1);
	u.SetGridFunction(begin, end, 1.0, f);
	// v Update
	begin[0] = 1;
	end[0] = v.griddimension[0] - 2;
	begin[1] = 1;
	end[1] = v.griddimension[1] - 3;
	GridFunction branch_2(p.griddimension);
	Py(branch_2, p, delta);
	g.AddToGridFunction(begin, end, -1.0 * deltaT, branch_2);
	v.SetGridFunction(begin, end, 1.0, g);

}
Пример #2
0
void Computation::setBoundaryTN(GridFunction& T, RealType (*TO)(RealType),
		RealType (*TU)(RealType), RealType (*TL)(RealType),
		RealType (*TR)(RealType)) {
	MultiIndexType begin, end;
	// T_i,0

	begin[0] = 1;
	end[0] = T.griddimension[0] - 2;
	begin[1] = 0;
	end[1] = 0;
	MultiIndexType Offset;
	Offset[0] = 0;
	Offset[1] = 1;
	T.SetGridFunction(begin, end, TU, false, SimIO.para.deltaX);
	T.ScaleGridFunction(begin, end, SimIO.para.deltaY);
	T.AddToGridFunction(begin, end, 1.0, T, Offset);

	// T_i,jmax+1

	begin[0] = 1;
	end[0] = T.griddimension[0] - 2;
	begin[1] = T.griddimension[1] - 1;
	end[1] = T.griddimension[1] - 1;
	//MultiIndexType Offset;
	Offset[0] = 0;
	Offset[1] = -1;
	T.SetGridFunction(begin, end, TO, false, SimIO.para.deltaX);
	T.ScaleGridFunction(begin, end, SimIO.para.deltaY);
	T.AddToGridFunction(begin, end, 1.0, T, Offset);
}
Пример #3
0
void Computation::setBoundaryG(GridFunction& g, GridFunction& v) {

	MultiIndexType begin, end;
	begin[0] = 1;
	end[0] = g.griddimension[0] - 2;
	begin[1] = 0;
	end[1] = 0;
	g.SetGridFunction(begin, end, 1.0, v);

	begin[0] = 1;
	end[0] = g.griddimension[0] - 2;
	begin[1] = g.griddimension[1] - 2;
	end[1] = g.griddimension[1] - 2;
	g.SetGridFunction(begin, end, 1.0, v);
}
Пример #4
0
void Computation::setBoundaryF(GridFunction& f, GridFunction& u) {
	MultiIndexType begin, end;
	begin[0] = 0;
	end[0] = 0;
	begin[1] = 1;
	end[1] = f.griddimension[1] - 2;
	f.SetGridFunction(begin, end, 1.0, u);

// F_iMax,j=u_iMax+1,j
	begin[0] = f.griddimension[0] - 2;
	end[0] = f.griddimension[0] - 2;
	begin[1] = 1;
	end[1] = f.griddimension[1] - 2;
	f.SetGridFunction(begin, end, 1.0, u);
}
Пример #5
0
void Stencil::ApplyUVxStencilOperator(const MultiIndexType& gridreadbegin,
		const MultiIndexType& gridreadend,
		const MultiIndexType& gridwritebegin,
		const MultiIndexType& gridwriteend,
		const GridFunctionType& sourcegridfunctionU,
		const GridFunctionType& sourcegridfunctionV,
		GridFunction& imagegridfunction,
		RealType alpha){
	RealType tmp;
	for (IndexType i=gridwritebegin[0]; i<=gridwriteend[0]; i++){
		for (IndexType j=gridwritebegin[1]; j<=gridwriteend[1]; j++){
			tmp = 0.25*((sourcegridfunctionU[i][j]+sourcegridfunctionU[i][j+1])*
						(sourcegridfunctionV[i][j]+sourcegridfunctionV[i+1][j])-
						(sourcegridfunctionU[i-1][j]+sourcegridfunctionU[i-1][j+1])*
						(sourcegridfunctionV[i-1][j]+sourcegridfunctionV[i][j])
			)+
							  alpha*0.25*(abs(sourcegridfunctionU[i][j]+sourcegridfunctionU[i][j+1])*
									  (sourcegridfunctionV[i][j]-sourcegridfunctionV[i+1][j])-
									      abs(sourcegridfunctionU[i-1][j]+sourcegridfunctionU[i-1][j+1])*
									      (sourcegridfunctionV[i-1][j]-sourcegridfunctionV[i][j])
									  );

			imagegridfunction.SetGridFunction(i,j,tmp/h[0]);
		}
	}
}
Пример #6
0
void Computation::setBoundaryP(GridFunction& p) {
	MultiIndexType begin, end;

	if (SimIO.para.world_rank == 0) {
		// p_0,j = p_1,j
		begin[0] = 0;
		end[0] = 0;
		begin[1] = 1;
		end[1] = p.griddimension[1] - 2;
		MultiIndexType Offset;
		Offset[0] = 1;
		Offset[1] = 0;
		p.SetGridFunction(begin, end, 1.0, Offset);
	}

	if (SimIO.para.world_rank == 1) {
		// p_iMax+1,j = p_iMax,j
		begin[0] = p.griddimension[0] - 1;
		end[0] = p.griddimension[0] - 1;
		begin[1] = 1;
		end[1] = p.griddimension[1] - 2;
		MultiIndexType Offset;
		Offset[0] = -1;
		Offset[1] = 0;
		p.SetGridFunction(begin, end, 1.0, Offset);
	}
	// p_i,0 = p_i,1
	begin[0] = 1;
	end[0] = p.griddimension[0] - 2;
	begin[1] = 0;
	end[1] = 0;
	MultiIndexType Offset;
	Offset[0] = 0;
	Offset[1] = 1;
	p.SetGridFunction(begin, end, 1.0, Offset);

	// p_i,jMax+1 = p_i,jMax
	begin[0] = 1;
	end[0] = p.griddimension[0] - 2;
	begin[1] = p.griddimension[1] - 1;
	end[1] = p.griddimension[1] - 1;
	Offset[0] = 0;
	Offset[1] = -1;
	p.SetGridFunction(begin, end, 1.0, Offset);

}
Пример #7
0
void Computation::setBoundaryV(GridFunction& v) {
	MultiIndexType begin, end;

	// v_i,0 = 0
	begin[0] = 1;
	end[0] = v.griddimension[0] - 2;
	begin[1] = 0;
	end[1] = 0;
	v.SetGridFunction(begin, end, 0.0);

	// v_i,jMax =0
	begin[0] = 1;
	end[0] = v.griddimension[0] - 2;
	begin[1] = v.griddimension[1] - 2;
	end[1] = v.griddimension[1] - 2;
	v.SetGridFunction(begin, end, 0.0);
	if (SimIO.para.world_rank == 0) {
		// v_0,j = -v_1,j
		begin[0] = 0;
		end[0] = 0;
		begin[1] = 1;
		end[1] = v.griddimension[1] - 2;
		MultiIndexType Offset;
		Offset[0] = 1;
		Offset[1] = 0;
		v.SetGridFunction(begin, end, -1.0, Offset);
	}
	if (SimIO.para.world_rank == 1) {
		// v_iMax+1,j = -v_iMax,j
		begin[0] = v.griddimension[0] - 1;
		end[0] = v.griddimension[0] - 1;
		begin[1] = 1;
		end[1] = v.griddimension[1] - 2;
		MultiIndexType Offset;
		Offset[0] = -1;
		Offset[1] = 0;
		v.SetGridFunction(begin, end, -1.0, Offset);
	}
}
Пример #8
0
void Computation::setBoundaryU(GridFunction& u) {
	MultiIndexType begin, end;
	if (SimIO.para.world_rank == 0) {
		// u_0,j = 0
		begin[0] = 0;
		end[0] = 0;
		begin[1] = 1;
		end[1] = u.griddimension[1] - 2;
		u.SetGridFunction(begin, end, 0.0);
	}
	if (SimIO.para.world_rank == 1) {
		//u_iMax,j = 0
		begin[0] = u.griddimension[0] - 2;
		end[0] = u.griddimension[0] - 2;
		begin[1] = 1;
		end[1] = u.griddimension[1] - 2;
		u.SetGridFunction(begin, end, 0.0);
	}
	// u_i,0
	begin[0] = 1;
	end[0] = u.griddimension[0] - 2;
	begin[1] = 0;
	end[1] = 0;
	MultiIndexType Offset;
	Offset[0] = 0;
	Offset[1] = 1;
	u.SetGridFunction(begin, end, -1.0, Offset);

	// u_i,jMax+1
	begin[0] = 1;
	end[0] = u.griddimension[0] - 2;
	begin[1] = u.griddimension[1] - 1;
	end[1] = u.griddimension[1] - 1;
	Offset[0] = 0;
	Offset[1] = -1;
	u.SetGridFunction(begin, end, -1.0, Offset);
	//u.SetGridFunction(begin, end, -1.0, u, Offset, 2.0);

}
Пример #9
0
void Stencil::ApplyStencilOperator(const MultiIndexType& gridreadbegin,
		const MultiIndexType& gridreadend,
		const MultiIndexType& gridwritebegin,
		const MultiIndexType& gridwriteend,
		const GridFunctionType& sourcegridfunction,
		GridFunction& imagegridfunction){
	// Berechne die Ableitungen
	// (0,0) ist bei allen allen drei Matrtzen (Stencil, sourcegrid, imagegrid) oben links
	RealType tmp;
	for (IndexType i=gridwritebegin[0]; i<=gridwriteend[0]; i++){
		for (IndexType j=gridwritebegin[1]; j<=gridwriteend[1]; j++){
			tmp = 0.0;
			for(IndexType k=0; k<3; k++){
				for(IndexType l=0; l<3; l++){
					tmp = tmp + sourcegridfunction[i+k-1][j+l-1]*stencil[k][l];
				}
			}
			imagegridfunction.SetGridFunction(i,j,tmp);
	 	}
	}

}
Пример #10
0
void Computation::setBoundaryTD(GridFunction& T, RealType (*TO)(RealType),
		RealType (*TU)(RealType), RealType (*TL)(RealType),
		RealType (*TR)(RealType)) {
	MultiIndexType begin, end;
	if (SimIO.para.world_rank == 0) {
		// p_0,j = p_1,j
		begin[0] = 0;
		end[0] = 0;
		begin[1] = 1;
		end[1] = T.griddimension[1] - 2;

		T.SetGridFunction(begin, end, TL, true, SimIO.para.deltaY);
		T.ScaleGridFunction(begin, end, 2.0);
		MultiIndexType Offset;
		Offset[0] = 1;
		Offset[1] = 0;
		T.AddToGridFunction(begin, end, -1.0, T, Offset);

	}

	if (SimIO.para.world_rank == 1) {
		// T_imax+1,j
		begin[0] = T.griddimension[0] - 1;
		end[0] = T.griddimension[0] - 1;
		begin[1] = 1;
		end[1] = T.griddimension[1] - 2;
		MultiIndexType Offset;
		Offset[0] = -1;
		Offset[1] = 0;
		T.SetGridFunction(begin, end, TR, true, SimIO.para.deltaY);
		T.ScaleGridFunction(begin, end, 2.0);
		T.AddToGridFunction(begin, end, -1.0, T, Offset);
	}
/*
	// T_i,0

	begin[0] = 1;
	end[0] = T.griddimension[0] - 2;
	begin[1] = 0;
	end[1] = 0;
	MultiIndexType Offset;
	Offset[0] = 0;
	Offset[1] = 1;
	T.SetGridFunction(begin, end, TU, false, SimIO.para.deltaX);
	T.ScaleGridFunction(begin, end, 2.0);
	T.AddToGridFunction(begin, end, -1.0, T, Offset);

	// T_i,jmax+1

	begin[0] = 1;
	end[0] = T.griddimension[0] - 2;
	begin[1] = T.griddimension[1] - 1;
	end[1] = T.griddimension[1] - 1;
	MultiIndexType Offset;
	Offset[0] = 0;
	Offset[1] = -1;
	T.SetGridFunction(begin, end, TO, false, SimIO.para.deltaX);
	T.ScaleGridFunction(begin, end, 2.0);
	T.AddToGridFunction(begin, end, -1.0, T, Offset);*/

}