• Nem Talált Eredményt

Solving Partial Differential Equations on FPGA

3.1 Computational Fluid Dynamics (CFD)

3.1.2 Finite volume method solution of Euler equations

Finite Volume Method (FVM) is a frequently used discretization strategy to numeri-cally solve the hyperbolic conservation laws expressed by the Euler equations [22]. To illustrate a possible application, a simulation of the airflow inside a scramjet engine is presented in Figure 3.1. During the discretization, a mesh is introduced for the compu-tational domainwhere the PDE is studied. The idea behind the strategy is to integrate Equation 3.3 for each element (cell) of the mesh. Using the divergence theorem, the change of the quantity U inside each cell can be approximated via the fluxes going through the border of the cell:

Z

Figure 3.1: A simulation of the airflow inside a scramjet engine. Colors represent the value of the density (kg/m3) component of the state vector.

wherenTis the outward pointing unit normal field of the boundary of cellT. As numer-ical fluxes are locally conserved, flux computations can be reused in the neighboring cells.

The temporal derivative is discretized by the first-order forward Euler method:

∂U

∂t = Un+1−Un

∆t , (3.5)

whereUn is the known value of the state vector at time leveln, Un+1 is the unknown value of the state vector at time leveln+ 1, and∆tis the time step. In the current im-plementation, constant time steps are used, however, a variable time step modification of the framework is also possible.

In Chapter 4 the developed design methodology is presented via the solution of the Euler equations in case of structured and unstructured space discretization. In both cases the fluxes are computed similarly, however, in the unstructured case, extra rota-tions are needed which makes the numerical scheme more complex. In the following part both schemes are presented.

3.1.2.1 Structured mesh

Kocsardi et al. [23] showed that logically structured arrangement of data is a convenient choice for an efficient FPGA-based implementation. Hereby I am shortly reviewing the

numerical scheme because it is used as a test case to demonstrate the AU generation capabilities of the presented framework.

The computational domainΩis composed ofn×mlogically structured rectangles (cells). The area of a cell T is denoted by VT, while a face f is described by the vector nf which is normal to the face f and its size equals to the area of the face.

The flux tensor evaluated at a facef is denoted byFf. Using the cell centered FVM discretization, the governing equations (Equation 3.4) can be described as

∂UT

where the summation is meant for all four faces of cellT.

In order to stabilize the solution procedure, artificial dissipation has to be intro-duced into the scheme. According to the standard procedure, this is achieved by re-placing the physical flux tensor by a numerical flux functionF˜ containing a dissipative stabilization term. In the dissertation the simple and robust Lax-Friedrichs numerical flux function is used, which is defined as

F˜ = FL+FR

2 −(|¯u|+ ¯c)UR−UL

2 (3.7)

where FL(UL) and FR(UR) is the flux at the left and right side of the interface, respectively, |¯u| is the average value of the velocity, and |¯c| is the speed of sound at the interface.

Fixing the coordinate system for each cell in an east-south direction, the dot product with the normal vector can be simplified to a multiplication by the area of the face. In case of eastward and southward fluxes the first and second columns of the flux tensor can be used, respectively:

southρ = ρLvLRvR

where L indicates the cell where the state vector is updated, while R indicates the neighboring cell (e.g. east or south). In case of northward and westward fluxes, the flux has already been computed at one of the neighboring cells and can be reused with a minus sign. Applying time discretization and using the numerical fluxes the state vectors can be updated according to the following formula:

Un+1T =UnT − ∆t

Structured data representation is not flexible for the spatial discretization of complex geometries. One of the main innovative contributions of our paper [1] was that an unstructured, cell-centered representation of physical quantities was implemented on FPGA. In the following paragraphs the mesh geometry, the governing equations, and the main features of the numerical algorithm are presented.

The computational domainΩis composed of non-overlapping triangles. Each face f of a triangleT is associated with a normal vectornf which points outward T and is scaled by the length of the face. The volume of a triangle T is indicated by VT. Following the finite volume methodology, the state vectors are stored at the mass center of the triangles.

During flux computation the coordinate system is attached to the given facef such a way that axisxis normal tof(see Fig. 3.2). The benefit of this representation is that theFf·nf dot product equals to the first column ofFmultiplied by the area of the face.

The drawbacks of the representation are that the velocity vectors have to be rotated to this coordinate system before the flux computation and fluxes have to be rotated back to the global coordinate system before final summation.

Figure 3.2: Interface with the normal vector and the cells required in the computation

Similarly to the structured case, the Lax-Friedrichs numerical flux function (Equa-tion 3.7) is used to stabilize the solu(Equa-tion, however, in this case, the normal component of the numerical flux function has to be calculated for each interface:

fρ = ρLuLRuR

2 −(|¯u|+ ¯c)ρR−ρL

2 (3.11a)

fρu = (ρLu2L+pL) + (ρRu2R+pR)

2 −(|¯u|+ ¯c)ρRuR−ρLuL

2 (3.11b)

fρv = ρLuLvLRuRvR

2 −(|¯u|+ ¯c)ρRvR−ρLvL

2 (3.11c)

fE = (EL+pL)uL+ (ER+pR)uR

2 −(|¯u|+ ¯c)ER−EL

2 (3.11d)

where L indicates the cell where the state vector is updated and R indicates the neigh-boring cell.

Applying time discretization and using the numerical fluxes, the state vectors can be updated according to the following formula:

Un+1T =UnT − ∆t VT

X

f

nff|nf|, (3.12)

whereRˆnf is the rotation tensor describing the transformation from the face-attached coordinate system to the global one. Unfortunately, in the unstructured case, it is not

memory requirement of the implementation.

The AU is generated from Equations 3.11a to 3.11d and is designed to compute the normal component of the numerical flux function for a new interface in each clock cycle. Beside the AU an additional simple arithmetic unit is required to update conser-vative state variables (ρ, ρu, ρv, E) using the flux vectors. As a cell has three interfaces, three clock cycles are required for a complete cell update.