Code Verification

The goal of Code Verification is to check that a computer code that embeds the algorithm for the numerical solution of a given mathematical model is correct, i.e. that the program has no bugs.  It is not a Software Quality Assurance exercise (it does not check the quality of the programmer) since the objective is to guarantee that the code executes the correct algorithm independently of its efficiency. However, Code Verification is an activity that is only required when a code is changed. Therefore, once it is properly done it does not have to be repeated until the code is modified.

In Computational Fluid Dynamics (CFD), the correctness of the code is typically demonstrated by showing that the numerical solution converges to the exact solution of the mathematical model with the increase of the number of degrees of freedom (grid/time refinement). Furthermore, it is also required to check that the observed orders of grid and time convergence of the numerical error correspond to the expected (formal) orders of convergence of the discretization techniques adopted in the solution algorithm. Therefore, performing Code Verification requires error evaluation and so the exact solution must be known.

The requirement of the knowledge of the exact solution leads to two alternatives for Code Verification of CFD solvers:

  1. Analytical Solutions.
  1. Method of Manufactured Solutions (MMS).

The first option is restricted to a relatively small number of existing solutions, which often do not exercise all the terms and/or boundary conditions of the Navier-Stokes equations. The second alternative is more general and it can be applied to any set of partial differential equations enabling Code Verification for any type of mathematical model including the Reynolds-Averaged Navier-Stokes equations. MMS includes three steps:

  1. Write the solution and boundary conditions of all dependent variables of the mathematical model in the selected domain.
  1. Introduce the manufactured solution in the system of equations included in the mathematical model to determine the unbalance of the equations.
  1. Insert the terms determined in the previous step as source terms of the original system of equations to guarantee that the solutions chosen in the first step become and exact solution of the mathematical model.

For example, in the Navier-Stokes equations the source determined in third step of MMS correspond to the force field that makes the chosen solution in step 1 respect the momentum balance.


Solution Verification

The goal of Solution Verification is to estimate the numerical uncertainty U(Φ) of an approximate solution Φnum of a mathematical solution for which the exact solution Φexact is unknown, i.e. to define an interval that contains Φexact typically 95 out of 100 cases, Φnum-U(Φ) ≤ Φexact ≤ Φnum-U(Φ) . The determination of the numerical uncertainty requires the definition of the quantities of interest Φ and the estimation of the numerical error δnum(Φ) . The most usual way to convert the estimated numerical error into an uncertainty is to use a safety factor, U(Φ)=Fsδ(Φ).

The numerical error has several contributions, but in carefully done simulations it is should be dominated by the contribution of the discretization error, i.e. round-off, iterative and statistical errors (if they exist) are negligible when compared to the discretization error. There are several techniques proposed in the open literature for the estimation of the discretization error. Procedures (tools) for the estimation of the numerical uncertainty of steady and unsteady flow simulations based on grid/time refinement studies are available in the page of Utilities/V&V Tools.