# Accelerating FVM-Based Parallel Fluid Simulations with Better Grid Renumbering Methods
## 2 Numerical Fluid Simulations Based on Finite Volume Method
### Matrix Assembly for Governing Equations  
Considering a simple case with a one-dimensional unstructured grid, the continuity equation, momentum equation, and energy equation can all be written in the following general formula:  
\[\underbrace{\frac{d(\rho u\phi)}{dx}}_{\text{convection term}}=\frac{d}{dx}( \underbrace{\Gamma\frac{d\phi}{dx}}_{\text{diffusion term}})+\underbrace{S}_{ \text{source term}} \tag{1}\]  
Figure 1: A schematic diagram of FVM. The control equations with boundary and mesh configurations are discretized into sparse linear systems by FVM. Figure 2: (a) Domain discretized using a uniform grid system, and (b) domain discretized using an unstructured grid system with triangular elements. Equation (1), which represents the diffusion equation for a single time step of FVM., contains the convection term, diffusion term, and source term. \(\phi\) in the equation is a generalized variable, which can be velocity, temperature or concentration, and other physical quantities to be obtained. \(\Gamma\) is the generalized diffusion coefficient corresponding to \(\phi\), and \(S\) is the generalized source term. The boundary condition values of the variable \(\phi\) at endpoints A and B are known. The above is the conserved form of the equation, which is necessary to establish the discrete equation using the finite volume method. The critical step of the finite volume method is to apply integration in the interval of control volume of the control equation, and one gets discrete equations on the control volume nodes. Next, taking the Equation (1) as an example to perform domain discretization:  
\[\int_{\Delta V}\frac{d(\rho u\phi)}{dx}dV=\int_{\Delta V}\frac{d}{dx}(\Gamma \frac{d\phi}{dx})dV+\int_{\Delta V}SdV \tag{2}\]  
Equation (2) represents the integration of the fluid domain over a single time step for the control unit after regional discretization. \(\Delta V\) is the volume value of the control volume. When the control volume is minimal, \(\Delta V\) can be expressed as \(\Delta\bullet AV\), where \(A\) is the area of the interface of the control volume. Both convection and diffusion terms have been transformed into values on the control volume interface. One of the most significant characteristics of the finite volume method is that the equation has explicit physical interpolation. Physical quantities at nodes represent physical quantities at the interface through interpolation. In order to calculate the physical parameters on the interface, it is necessary to carry out approximate distribution among nodes. It can be imagined that linear approximation is the most straightforward method to calculate the characteristic values, called the central difference. The conservation equation on a control volume can be expressed as the following:  
\[a_{P}\phi_{P}=a_{H}\phi_{H}+a_{E}\phi_{E}+b \tag{3}\]  
where \(a_{P}a_{H}a_{E}b\) are the unknown coefficient. For the one-dimensional problem, area A at the control volume interface e and w are both 1, namely unit area; consequently, \(\Delta V=\Delta X\). Equation (3) demonstrates the tight connection between the unit to be solved and the neighboring units, which also reflects the memory access order of the finite volume method. The discretized system of equations is stored in a numerical simulation framework in the form of a sparse matrix [8]. The rows represent the coefficients of the discretized equations, and the off-diagonal coefficients represent the interaction between adjacent elements. The number of non-zero elements in each row is the same as the number of elements associated with that row. The input of a linear solver is a system of equations generated by the discretization process, which can be written mathematically as:  
\[\mathbf{A}\phi=\mathbf{b} \tag{4}\]  
where \(\mathbf{A}\) is the matrix of the coefficients of the element \(a_{ij}\), \(\phi\) is the vector of unknown variables \(\phi_{i}\), and \(b\) is the vector of sources \(b_{i}\).