Ye 2017
Ye 2017
121
GMRES is used as the iterative method to solve this coupled Here, Tadmor is the flux scheme. In rhoCentralFoam, the three
linear system. The library of Hypre is called in the solving variables, i.e. rho, rhoU, rhoE, are discretized separately to obtain
procedure. The main contributions of this paper are: three linear systems. Each linear system are independent of others,
these linear systems can be solved separately.
The CSR data structure is designed in OpenFOAM to
store the coupled matrix, the interface between 2.2 Implicit coupled discretization
OpenFOAM and Hypre is designed and implemented to Considering the following two-dimensional Euler equations:
support the calling of BoomerAMG and GMRES in
Hypre. ρ ρu ρv
ρu ρu 2 p ρuv
t div
A coupled implicit density-based solver, coupledFoam, is
0. (1)
implemented in the framework of OpenFOAM. The ρv ρuv ρv 2 p
Steger-Warming flux vector splitting method is used to
capture shocks in discontinuous problems. E u( E p ) v( E p )
Where ρ is the density, u, v are the velocity components in x and y
Experiments are designed to verify and validate directions, p is the pressure, and E is the total energy. The first
coupledFoam. The steady-state oblique shock and term in the equations is called transient term, and the second is
unsteady-state forward step are tested. Compared with called convective term. After changing Euler equations into a
rhoCentralFoam, the flow field characteristics of conservation equation of the form, we will have:
coupledFoam is smoother. Specially, the residual of
coupledFoam in oblique shock case is smaller than t u( x, t ) divF ( u( x, t )) 0 . (2)
rhoCentralFoam.
In the process of the numerical discretization, the computational
The rest of the paper is organized as follows: Section 2 introduces domain Ω is partitioned into multiple computational domains j .
some related work and background, including the procedure of a
standard solver in OpenFOAM and implicit coupled discretization After discretization in each domain, we obtain the following
method. Section 3 introduces the design and implementation of formulation:
coupledFoa, followed by the experiments in section 4, which
Ωi Rin
shows the comparison of the results. Finally, Section 5 concludes
I Ui Ri .
n n
(3)
the paper. t U i
1 1
A Ac (| V | c ) I . (7)
2 2
Where V is the velocity flux flowing through Sij , |V|+c is the
spectral radius of the convective flux Jacobian. For the details, we
refer the readers to the reference [13]. To obtain Ac , which is the
Figure 1: The procedure of rhoCentralFoam
convective flux Jacobian, we refer the reader to reference [14].
122
Put all the cells together, we can get the following equation at n-th When the two-dimensional Euler equation is solved, the number
time step: of unknown variables is 4. According to equation (6), the variable
Uin of every cell is a vector of length 4,and Jacobian matrix A
AU Rn . (8)
is a 4×4 matrix. Thus, the discrete matrix A in coupledFoam is a
It is important to note that the A here is a large matrix of all the
sparse block matrix, which need to be stored in other data
computing cells, and U is the vector of all unknown variables.
structures.
That is, all the equations are discretized into a coupled matrix, and
all variables are solved in a coupled linear system. Fig.4 is a structured mesh with a simple cell number of 4. Fig.5
shows the data structure of the matrix A under the grid and the
3. THE DESIGN AND IMPLEMENTATION data structure of the block matrix . Block coefficients
OF COUPLEDFOAM corresponding to the cell 1 will be located from the fourth row to
3.1 The procedure of coupledFoam seventh row in the matrix A. The corresponding block coordinates
for are (1, 0).
The procedure of coupledFoam is different from that of the
standard solver in OpenFOAM. As is shown in fig.2. In
coupledFoam, the discretization of the DSL language and the 2 3
solving of the linear system are replaced by the procedure of
0 1
coupled discretization. In addition, there is an assembly of the
coupled equations and a matrix format conversion process before
Figure 4: A simple mesh with four cells
solving the linear system in coupledFoam. CoupledFoam uses
Hypre’s library to solve the linear system instead of using the 0 1 2 3
OpenFOAM’s library.
0 A00 A01 A02
col 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3
rhoCentralFoam coupledFoam
val x00 x0 1 x02 x03 x10 x1 1 x12 x13 x20 x21 x22 x23 x30 x31 x3 2 x33
Figure 2: The difference of procedures between
rhoCentralFoam and coupledFoam Figure 5: The data structure of the coupled matrix
When the matrix of Hypre is set, the matrix insert operation is
3.2 Data structure in coupledFoam performed using the data structure mentioned above and the
In OpenFOAM, the cell is numbered sequentially, the following interface.
discretization of each cell is only related to its adjacent cells, so
the obtained matrix is usually sparse. Compressed Sparse Row HY PRE IJM atrixSetValues(A,rownum,
format (CSR) is usually used to store such a sparse matrix. CSR
can save storage space since it stores only nonzero elements in the &ncol, &rows, &cols, &vals);
matrix.
Where rownum represents the number of rows to insert, ncol
Specifically, the CSR structure has three arrays of row, col, and represents the number of elements to be inserted, and rows
val, where row represents the row number of the matrix, col represents the corresponding row number. Cols represents the
represents the column number, and val represents the column number of the corresponding element, and vals indicates
corresponding element value in the matrix. Fig.3 is an example of the value of the element to insert. For specific use of related
a simple CSR structure. Hypre functions, see [15].
0 1 2 3
3.3 Coupled algorithm
0 1 2 0 0 According to formula (6), the flux on each surface of can be
row 0 1 2 3 divided into two parts, and . Such that the equation (5)
1 0 3 0 4
col 0 1 1 3 2 3 3
can be written as:
2 0 0 5 6
i 1
3 0 0 0 7
val 1 2 3 4 5 6 7 [ (| V | c)]I U i
ti 2
j neighbor
Ac, j Sij U j
(9)
Figure 3: The data structure CSR of an example sparse
j owner
Ac, j Sij U j Ri
matrix
123
In OpenFOAM, each surface on the grid unit is shared by two cell,
which are labeled as the owner and neighbor of the face. The
owner of a face is always the smaller label in the two shared cell,
and the neighbor is the other larger label. The symbols of Sij are
different in owner and neighbor, thus it is important to pay
attention to the symbols in the formula. In formula (9), the Figure 7: The grid of forward step
coefficient of U i will be located in the matrix A with block id of We use the Euler equation introduced in section 2.2 as the
mathematical solution Model.
(i, i). The coefficient block Ac , j will be located in A with block
id of (i, j). The coupled algorithm is shown in algorithm 1. 4.2 Methodology
To illustrate the correctness of coupledFoam, we firstly simulate
the oblique shock test case and forward step with rhoCentralFoam,
which is the official solver in OpenFOAM. The results of these
Algorithm 1: Procedure of coupled matrix discretization and cases using rhoCentralFoam are compared with the results using
assemble coupledFoam. The shock positions in these results should be
consistent. In our experiments, we focus on the convergence rate
1: for all patchi mesh.boundary() do in these two cases. We define the relative L2 normal of residual
2: pFaceCells= mesh.boundary()[patchi].faceCells(); Res in time step n as follows:
3: for all facei mesh.boundary()[patchi] do
4: calculate Ac , o ; ρin ρin 1 2
N
( ) /N
5: ownerLabel=pFaceCells[facei];
Res n
i 0
t
6: rhs[4*ownerLabel] -= Ac U ; Res 0
7: end for All the courant number is set 0.5 in these cases.
8: end for 4.3 Experimental Results
9: for all facei internal faces do
10: label ownerLabel = faceOwner()[facei]; 4.3.1 Oblique shock
11: label neighbour = faceNeighbor()[facei]; The contour lines of the ρ field is shown in Fig.8. Notice the
positions of the shocks are consistent. Also notice that the result
12: calculate Ac , o ; of coupledFoam is more stable than rhoCentralFoam. The
13: set block id (o,n); consistent in these results show the correctness of coupledFoam.
The convergence histories of residual in terms of iteration number
14: set A[offset(o,n)] += Ac, o .
is shown in Fig.9. The number of iterations here is the number of
15: calculate Ac , n ; steps in time marching. It can be seen that coupledFoam can
converge to smaller residuals than rhoCentralFoam.
16: set block id (n,o);
17: set A[offset(n,o)] -= Ac, n .
18: end for
4. EXPERIMENT
(a) The result of rhoCentralFoam
4.1 Experiment set up
The operating system of the computer we use in this experiment is
Red Hat Enterprise Linux Server 6.5, with OpenFOAM version
4.0 installed on it. In this experiment, we have tested two cases.
124
4.3.2 Forward step 6. ACKNOWLEDGMENTS
The contour lines of the flow’s density at specific time are shown The authors would like to thank the Science Challenge Project
in fig.10. Both these two solvers are able to capture shock wave in (No.TZ2016002), the National Key Research and Development
the flow field. These results also verify the correctness of the Program of China (No. 2016YFB0201301).
coupledFoam. By looking closely at the contours of density, it is
found that the contour lines obtained by rhoCentralFoam 7. REFERENCES
[1] M. Safinowski, M. Szudarek, R. Szewczyk, and W.
t=0.5s t=0.5s Winiarski, Capabili- ties of an Open-Source Software, Elmer
FEM, in Finite Element Analysis of Fluid Flow. Cham:
Springer International Publishing, 2017, pp. 118– 126.
t=1s t=1s [2] Blazek J. Computational fluid dynamics: principles and
applications[M]. Butterworth-Heinemann, 2015.
[3] Biswas G. Computational fluid dynamics[M]. Alpha Science
t=2s t=2s Intl Ltd, 2013.
[4] Jeong W, Seong J. Comparison of effects on technical
variances of computational fluid dynamics (CFD) software
t=4s based on finite element and finite volume methods[J].
t=4s
International Journal of Mechanical Sciences, 2014, 78: 19-
26..
[5] Moukalled F, Mangani L, Darwish M. The finite volume
rhoCentralFoam coupledFoam method in computational fluid dynamics[J]. 2016.
Figure 10. The comparison of contour lines of density in [6] H. Jasak, A. Jemcov, Z. Tukovic et al., “Openfoam: A c++
forward step in different time. library for complex physics simulations,” in International
workshop on coupled methods in numerical dynamics, vol.
1000. IUC Dubrovnik, Croatia, 2007, pp. 1–20.
[7] Q. Wang, X.-G. Ren, X.-H. Xu, C. Li, H.-Y. Ji, and X.-J.
Yang, “Coupling strategies investigation of hybrid atomistic-
continuum method based on state variable coupling,”
Advances in Materials Science and Engineering, vol. 2017,
2017.
[8] T. T. Zhang, W. J. Yang, Y. F. Lin, Y. Cao, M. Wang, Q.
Wang, and Y. X. Wei, “Numerical study on flow rate
limitation of open capillary channel flow through a wedge,”
Advances in Mechanical Engineering, vol. 8, no. 4, 2016.
[9] S. Yoon and A. Jameson, “Lower-upper symmetric-gauss-
seidel method for the euler and navier-stokes equations,”
Figure 11. The residuals of forward step with
Aiaa Journal, vol. 26, no. 9, p. 1025, 1988.
rhoCentralFoam and coupledFoam.
[10] R. F. Chen and Z. J. Wang, “Fast, Block Lower-Upper
contain more oscillations, while the results obtained by
Symmetric Gauss-Seidel Scheme Introduction,” 2000.
coupledFoam are smoother. The convergence histories of residual
in terms of iteration number is shown in Fig.11. The residual [11] C. Shen, X. L. Xia, Y. Z. Wang, F. Yu, and Z. W. Jiao,
convergence of coupledFoam is almost consistent with that of “Implementation of density-based implicit lu-sgs solver in
rhoCentralFoam. the framework of openfoam,” Advances in Engineering
Software, vol. 91, pp. 80–88, 2016.
5. CONCLUSION [12] J. Kim and K. Kim, “A development and verification of
We have developed a coupled implicit density-based solver, density based solver using lu-sgs algorithm in openfoam,”
coupledFoam, in the framework of OpenFOAM. The correctness 2014.
of coupledFoam is verified by the both the steady-state oblique
shock case and the unsteady-state forward step case. The [13] C. Shen, F. Sun, and X. Xia, “Analysis on capabilities of
comparisons of the results obtained by coupledFoam and density-based solvers within openfoam to distinguish
rhoCentralFoam respectively show that, coupledFoam can obtain aerothermal variables in difusion boundary layer,” Chinese
a smoother flow field. Especially in the oblique shock case, Journal of Aeronautics, vol. 26, no. 6, pp. 1370–1379, 2013.
coupledFoam can converge to lower residuals. This paper has [14] A. Rohde, “Eigenvalues and eigenvectors of the euler
some limitations since coupledFoam has a high time and space equations in general geometries,” Aiaa Journal, 2001.
overhead, we will focus on the memory and performance
optimization in the future. [15] R. Falgout and U. Yang, “Hypre user’s manual,” Revision
2.8. Technical Report, Lawrence Livermore National
Laboratory. Available at: http://www. llnl. gov/CASC/hypre,
Tech. Rep., 2011.
125