# Defining a Good Grid for Solution Accuracy

Computational fluid dynamics (CFD) is essentially a series of approximations, and a CFD practitioner’s role is to manage the magnitude of errors in these approximations. One of the most basic approximations lies in the type of cells used for the simulation. Approximations can be good (the earth is spherical) or bad (the earth is flat). Both can serve a purpose depending on the user’s perspective and goal. A CFD practitioner must decide on several simulation aspects, such as solution algorithms, turbulence models, and convergence schemes. Simultaneously, understanding the consequences of their choices regarding the computational mesh is essential for generating high-fidelity simulation results.

Before CFD even enters the picture, there is the choice of the discretization scheme. Decisions regarding the computational grid require good knowledge of the solver – What type of cells does it support? How susceptible is it to grid-related errors? – and its control over the computational mesh. Ideally, grids would consist of only flow-aligned, orthogonal hexahedral cells, but this approach would not suffice for complex geometries. Further, a grid that is insufficiently refined in areas of high gradients can adversely affect the solution by under-representing the shear present in the flow. Along those lines, the choices made in a CFD workflow will ultimately determine both the solution's applicability and credibility.

**Assessing Grid-Induced Error**

It is challenging to assess the error introduced by the grid for an arbitrary case because of the complexity of the dynamics inherent in solutions to the Navier-Stokes equations. The convective derivative in the Navier-Stokes equations seems a fitting candidate to begin with when examining the effects of the grid (due to its non-linear nature).

For this study, a passive scalar advection case is considered, and an advection-only solver is employed. This work demonstrates baseline discrepancies between grid types for a given solver, with the understanding that more sophisticated algorithms may improve the quality of the solution, but the trends will remain the same.

**Figure 1.** *In the presence of a vertical gradient, the offset δ between the face center and the line connecting cell centers (cell skewness) can affect the accuracy of the computed flux for the shared face, introducing numerical errors.*

This type of error predominantly affects advective terms, such as the convective derivative in the Navier-Stokes equation. This term drives many of the non-linearities present in turbulent flow, and any misrepresentation can adversely affect the simulation accuracy, particularly for separated flows with off-body gradients.

**Advection of Thermal Gradient in 2D**

Figure 2 illustrates a simple 2D case in which a thermal profile is advected across a simulation domain.

**Figure 2.** *This illustration showed the test case consisting of a rectangular domain and imposed thermal gradient to be advected across the simulation volume.*

Here the error is considered from a purely quadrilateral grid. The small error present in the solution is simply the baseline interpolation error resulting from the finite discretization size. That is, the error present in the solution is wholly due to grid resolution limitations, not a result of poor cell quality.

**Figure 3.** *The baseline error in the solution computed on an orthogonal grid with quadrilateral elements shows errors due entirely to the limit in resolution*.

These results can then be compared to the computed solutions from two unstructured grids with triangular elements. The first, generated with a Delaunay algorithm, has a distribution of cells with non-zero skewness, as shown in Figure 4, and the effect of skewness on the accuracy of the solution is clearly seen. The second unstructured grid, generated using an Advancing Front algorithm, contains equilateral triangles with zero skewness in the majority of the computational domain.

**Figure 4.** *The error in the solution computed on a Delaunay triangular grid is considerably higher than the error from the structured grid.*

**Figure 5.** *Close examination of Delaunay (a) and Advancing Front (b) triangular meshes highlights the source of the non-zero skewness for Delaunay meshes.*

Non-zero skewness is likely an unavoidable consequence of modeling any geometry of useful purpose. Yet, this study aims to incentivize researchers wishing to minimize grid-related errors. Intuitive foresight into the anticipated flow field directs an experienced CFD practitioner to isolate critical regions of interest and maximize the quality of the cells in that area.

**Advection in 3D**

These simplistic two-dimensional examples can be extended to three dimensions, as shown in Figure 6. As in the structured case shown in Figure 3, the resulting error is solely due to the limit in resolution.

**Figure 6.** *The cubic domain with imposed Gaussian temperature profile extended the simple problem to three dimensions.*

**Figure 7.** *The error in the solution computed on a grid consisting of 6.5M tetrahedral cells showed a considerable cumulative error as before in two dimensions, despite a significantly large number of elements.*

These results do not state that unstructured grids are to be avoided. Instead, these results are from an isolated test case specifically designed to highlight the effects of the grid on the solution.

Modern CFD solvers can produce robust solutions on both hexahedral and tetrahedral grids (depending on the solver, of course). Further, the simplistic algorithm used in computing these results lacks many existing techniques for mitigating the effects of poor cell quality that may be present in the solver. Lastly, the errors being discussed are generally diminished with increasing grid resolution. Therefore, if the mesh is sufficiently refined, these errors are inconsequential.

**References**

- “How grid quality affects solution accuracy,” J. Rhoads and T. Carrigan, 9th Annual OpenFOAM Workshop.
- “How grid quality affects solution accuracy,” J. Rhoads, 67th Annual American Physical Society Division of Fluid Dynamics Meeting.

If you want to see what else Fidelity Pointwise can do to help improve your preprocessing workflow, request a demo today!