{'fraction_non_alphanumeric': 0.03340954347665757, 'fraction_numerical': 0.005015119109078841, 'mean_word_length': 4.353335965258586, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
On Estimating Machine-Zero Residual

In this paper, we propose two techniques to estimate the magnitude of a machine-zero residual for a given problem, which is the smallest possible residual that can be achieved when we solve a system of discretized equations. We estimate the magnitude of the machine-zero residual by a norm of residuals computed with a randomly-perturbed approximate solution that is considered as close in magnitude to an exactly-converged solution. One method uses free-stream values as the approximate solution, and the other uses a current solution during an iterative solve as the approximate solution via the method of manufactured solutions. Numerical results show that these estimates predict the levels of machine-zero residuals very accurately for all equations of the Euler and Navier-Stokes equations in a transonic flow over an airfoil and viscous flows over a cylinder and a flat plate.


Introduction
A machine-zero residual is defined as a residual (e.g., a finite-volume discretization of the Euler equations) with a converged solution substituted having machine-zero-level perturbation. It is the smallest possible residual value that a solver can achieve; it is difficult to predict especially before a calculation. Also, it varies widely depending on the grid unit and the solution units especially when solving a dimensional form of flow equations. However, if it were possible to estimate a machine-zero residual before or during a calculation, then it would be very useful. For example, if an initial solution happens to be a converged solution (e.g., a restart) or close to it, then a machine-zero residual estimate would help us determine that the residual is well satisfied already and thus we would stop even before calling a solver. On the other hand, if there is no estimate available, we will find that a solver generates very small solution updates but cannot tell if the solution is already converged (it could be stalling). One can look at the corresponding residual level, but again one cannot tell whether it is the smallest possible value (it could be stalling). Note again that the machine-zero residual level depends on many different factors and thus it can be very small or very large: e.g., being 1.0e-09 does not necessarily mean a machine-zero residual.
In practical fluid-dynamics solvers, iterative convergence is checked based on the reduction of the residual or iterative-solution-difference from their initial values. This is a practical thing to do, but it can be inefficient. For example, if an initial solution is very close to a converged solution (e.g., a solution at a previous time step in an inner iteration of an implicit time-stepping scheme with a very small time step), then the residual is already very small at the beginning of an iteration. Reducing the residual by two or three orders of magnitude may be much more than necessary; one order of magnitude reduction may suffice. If an accurate estimate of a machine-zero residual is available, then we can determine how well the discrete equations are satisfied (e.g., five orders of magnitude above the machine-zero level) and stop the iteration earlier and could save computing time by a considerable amount over an entire unsteady simulation.
To the best of the author's knowledge at the time of writing this, no techniques are currently available for estimating a machine-zero residual level for a given flow problem. It is the objective of this paper to propose two such techniques and investigate how well they estimate machine-zero residual levels for inviscid and viscous flow problems in two dimensions.

Machine-Zero Residual
Consider a nonlinear system of equations, which arise from a finite-volume-type discretization of the dimensional Euler/Navier-Stokes equations, where R and U denote global vectors of residuals and numerical solutions in a given grid, which we solve by an iterative solver: where k is the iteration counter and ∆U k is a correction suggested by an iterative method (e.g., Newton's method). Let U be an exactly converged solution for a given problem with appropriate boundary conditions: In reality, the iteration will not find U exactly but converge to U with perturbation of the order of machine zero, U + U, where is a machine zero for a value of O(1) (e.g., 1.0E-16 in double precision). This is the best we can hope for. Then, the minimum residual that can be attained, which we call the machine-zero residual, would be which may be expanded as where ∂R ∂U is the residual Jacobian evaluated at U. It shows that the machine-zero residual depends on the magnitude of the solution as well as the Jacobian. Hence, there are various factors that affect the magnitude of the machine-zero residual: e.g., grid units and physical units. Therefore, it is not necessarily of the order of 1.0E-16.
At this point, it is clear that the machine-zero residual cannot be computed because the exactly-converged solution U is not known.

Estimates of Machine-Zero Residual
To estimate a machine-zero residual, we need to approximate the exactly-converged solution U. As our interest is only in estimating the magnitude of the machine-zero residual in some norm, the approximation just has to be close in magnitude to the exactly-converged solution U. There are two possibilities.

Free-stream estimate R c
One is a constant free-stream solution: where r is a random number (0 ≤ r ≤ 1) and U ∞ denotes a constant solution, which is an exact solution with a free-stream condition applied at all boundaries: R(U ∞ ) = 0. Note that in practice we apply different random numbers to solutions at different nodes (or cells) as we will show below. It is reasonable to set a free-stream condition at all boundaries, but we did not do so for the test cases shown in this paper. This estimate can be computed before a calculation and also separately for different equations in a target system. In our dimensional Euler/Navier-Stokes solver, we store the primitive variables w = (p , u, v, T ) at nodes, where u and v are velocity components, T is the temperature, and p is the gauge pressure p = p − p ∞ , where p ∞ is a free-stream pressure. Hence, the residual is a function of the primitive variables stored at nodes: R(U) = R([w 1 , w 2 , w 3 , · · · , w N ]), where N denotes the number of nodes in a grid. We define the perturbed free-stream solution at a node j as where r j is a random number defined at the node j and the maxmod function is defined by Note that the free-stream value of the gauge pressure p is zero. The velocity components u ∞ and v ∞ are computed for a given set of a free-stream Mach number and an angle of attack. It is emphasized again that the perturbed free-stream solution is different at different nodes.

Current solution as a manufactured solution R m
The other possibility is to use a current solution U k as an exact solution, which is possible by the method of manufactured solutions. Let S be a source term defined by Then, U k is an exact solution to the problem, which leads to the following estimate: This is a machine-zero residual for a slightly different problem, but expected to serve well as an estimate, at least in magnitude, for the original problem. In fact, if we expand it as we find that the estimate R m is an approximation to the machine-zero residual in the form (5). It would be an accurate estimate if the current solution is close to a converged solution in magnitude. In practice, we again apply different random numbers to solutions at different nodes. As in the previous case, this estimate can also be computed for each equation in a target system. It may be updated at every iteration if needed. Note that this technique is more general than the free-stream estimate R c ; it can be used with a free-stream solution by setting U k = U ∞ (then there is no need to specify a free-stream condition at all boundaries). In our dimensional solver, we define the perturbed solution in the primitive variables, at a node j, as where the variables (p j , u j , v j , T j ) are values at the k-th iteration.

Results
In this section, we will present numerical results for inviscid and viscous test cases. The Euler and Navier-Stokes equations are solved in the dimensional form. The discretization method is the edge-based method [1] with the Roe inviscid flux [2] and the alpha-damping viscous flux [3]: the residual is defined at a node j by where V j is the measure of a dual control volume around the node j, {k j } is a set of neighbor nodes of the node j, Φ jk is the sum of inviscid and viscous numerical fluxes, and n jk is the directed area vector along the edge. The system of residual equations are then solved by an implicit defect-correction solver. See Ref. [1] for further details. We store the primitive variables at nodes, reconstruct them to achieve second-order accuracy, and directly update them in a solver. For all problems, the free-stream pressure and temperature are defined by and the velocity will be determined for a given Mach number and an angle of attack. The machine-zero residual estimate R c is computed only once before a calculation and R m is computed at every iteration to see how it changes. The estimates and actual residual norms will be computed in the L 1 norm for all cases (i.e., the arithmetic average of the absolute value of a residual over all nodes in a grid). The machine zero is set to be = 1.0e-16 unless otherwise stated. We will show also the L 1 norm of the iterative solution error dw(i) defined for each primitive variable w i , i = 1, 2, 3, 4, at the k-th nonlinear iteration by This quantity is computed here only to confirm machine-zero convergence of the solution variables. We would not determine convergence based on it since a small iterative solution error does not necessarily mean convergence (e.g., it may be stalling). We wish to determine convergence by the residual norm, which tells us how well the discrete equations are satisfied.  Figure 1. As can be seen, the machine-zero residuals are accurately predicted by both estimates. It is seen also that the estimate R m does not change very much during the iteration. The iterative solution difference is also plotted. The results confirm that the solution is indeed converged to machine zero. This is a low-Mach viscous flow test case. The free-stream velocity is determined for the Mach number 0.001 and a zero angle of attack. The viscosity is a constant and determined from Re ∞ = 20. To overcome well-known low-Mach problems, we employed here a preconditioned technique of Weiss and Smith [4] and solved an preconditioned Navier-Stokes system. Results are shown in Figure 2. As can be seen, the estimates are very accurately predicted and the iterative solution difference has reached machine-zero convergence. We consider a viscous flow over a flat plate. We again solve the preconditioned Navier-Stokes equations in the dimensional form. The velocity and the viscosity are determined from M ∞ = 0.15 (zero angle of attack) and Re ∞ = 10 4 . The grid is a triangular grid with 274×194 nodes. Results are shown in Figure  3. It can be seen that the estimates very accurately predict the4 machine-zero residuals and the iterative solution difference has reached machine-zero convergence.
For this test case, we explored also the use of larger values of to see if these estimates can predict the residual level for partially converged solutions. Here, the solver is terminated when the iterative solution difference is less than a specified value of . Results are shown in Figure 4. As expected, the solver is terminated earlier for a larger value of . The solutions are very similar as shown in Figure 5, which are sampled along a vertical grid line at x = 0.9. Therefore, the residuals have been reduced sufficiently for producing accurate solutions. However, the residual estimates are not very accurate as can be seen in Figures  4(b) and 4 (c). In fact, we performed the same test for both the airfoil and cylinder cases and found similar results (not shown). One possible way to use them is to check first the iterative solution difference whether the solution is converged to a desired level and then use these estimates to confirm that the current residual is small enough (smaller than these estimates); if the residual is larger than the estimates, the solver may be stalling.

Conclusions
We have proposed and demonstrated two techniques to estimate the norm of machine-zero residuals for a given problem. Numerical results show that these estimates can predict machine-zero residual levels very accurately, at least for the inviscid and viscous flow problems considered. For practical applications, these estimates may be employed to check the convergence of an iterative solver. Focusing on how close the magnitude of a current residual is to a machine-zero-residual estimate (instead of how many orders of magnitude it is reduced from an initial residual), we may terminate the iteration when the residual norm is, say, five orders of magnitude larger than the machine-zero-residual estimate.   x-momentum, y-momentum, energy). R m was updated at every iteration. The actual residual norms, Res(1), Res(2), Res (3), and Res (4), stop going down nearly at the predicted levels.   Figure 5: A flat plate case with different . The vertical axis is η for all plots; η is the normalized coordinate defined by η = y √ Re x /x, where Re x is the Reynolds number based on the length x, i.e., the distance from the leading edge.