1432 *
catch (std::exception &exc)
1434 * std::cerr << std::endl
1436 * <<
"----------------------------------------------------"
1438 * std::cerr <<
"Exception on processing: " << std::endl
1439 * << exc.what() << std::endl
1440 * <<
"Aborting!" << std::endl
1441 * <<
"----------------------------------------------------"
1447 * std::cerr << std::endl
1449 * <<
"----------------------------------------------------"
1451 * std::cerr <<
"Unknown exception!" << std::endl
1452 * <<
"Aborting!" << std::endl
1453 * <<
"----------------------------------------------------"
1460<a name=
"step_57-Results"></a><h1>Results</h1>
1463Now we use the method we discussed above to solve Navier Stokes equations with
1464viscosity @f$1/400@f$ and @f$1/7500@f$.
1466<a name=
"step_57-Testcase1LowReynoldsNumber"></a><h3> Test
case 1: Low Reynolds Number </h3>
1469In the
first test
case the viscosity is set to be @f$1/400@f$. As we discussed in the
1470introduction, the
initial guess is the solution to the corresponding Stokes
1471problem. In the following table, the residuals at each Newton
's iteration on
1472every mesh is shown. The data in the table shows that Newton's iteration
1473converges quadratically.
1475<table align=
"center" class=
"doxtable">
1477 <th>@f$\mathrm{Re}=400@f$</th>
1478 <th colspan=
"2">Mesh0</th>
1479 <th colspan=
"2">Mesh1</th>
1480 <th colspan=
"2">Mesh2</th>
1481 <th colspan=
"2">Mesh3</th>
1482 <th colspan=
"2">Mesh4</th>
1485 <th>Newton iter </th>
1582The following figures show the sequence of generated grids. For the
case
1583of @f$\mathrm{Re}=400@f$, the
initial guess is obtained by solving Stokes on an
1584@f$8 \times 8@f$ mesh, and the mesh is refined adaptively. Between meshes, the
1585solution from the coarse mesh is interpolated to the fine mesh to be used as an
1588<table align=
"center">
1591 <img src=
"https://www.dealii.org/images/steps/developer/step-57.Re400_Mesh0.png" width=
"232px" alt=
"">
1594 <img src=
"https://www.dealii.org/images/steps/developer/step-57.Re400_Mesh1.png" width=
"232px" alt=
"">
1597 <img src=
"https://www.dealii.org/images/steps/developer/step-57.Re400_Mesh2.png" width=
"232px" alt=
"">
1602 <img src=
"https://www.dealii.org/images/steps/developer/step-57.Re400_Mesh3.png" width=
"232px" alt=
"">
1605 <img src=
"https://www.dealii.org/images/steps/developer/step-57.Re400_Mesh4.png" width=
"232px" alt=
"">
1610This picture is the graphical streamline result of lid-driven cavity with
1611@f$\mathrm{Re}=400@f$.
1612<img src=
"https://www.dealii.org/images/steps/developer/step-57.Re400_Streamline.png" alt=
"">
1614Then the solution is compared with a reference solution
1615from @cite Ghia1982 and the reference solution data can be found in the file
"ref_2d_ghia_u.txt".
1617<img src=
"https://www.dealii.org/images/steps/developer/step-57.compare-Re400.svg" style=
"width:50%" alt=
"">
1621<a name=
"step_57-Testcase2HighReynoldsNumber"></a><h3> Test
case 2: High Reynolds Number </h3>
1624Newton
's iteration requires a good initial guess. However, the nonlinear term
1625dominates when the Reynolds number is large, so that the solution to the Stokes
1626equations may be far away from the exact solution. If the Stokes solution acts
1627as the initial guess, the convergence will be lost. The following picture
1628shows that the nonlinear iteration gets stuck and the residual no longer decreases
1629in further iterations.
1631<img src="https://www.dealii.org/images/steps/developer/step-57.Re7500_loss_convergence.svg" style="width:50%" alt="">
1633The initial guess, therefore, has to be obtained via a continuation method
1634which has been discussed in the introduction. Here the step size in the continuation method, that is @f$|\nu_{i}-\nu_{i+1}|@f$, is 2000 and the initial
1635mesh is of size @f$32 \times 32@f$. After obtaining an initial guess, the mesh is
1636refined as in the previous test case. The following picture shows that at each
1637refinement Newton's iteration has quadratic convergence. 52 steps of Newton
's
1638iterations are executed for solving this test case.
1640<img src="https://www.dealii.org/images/steps/developer/step-57.Re7500_get_convergence.svg" style="width:50%" alt="">
1642We also show the residual from each step of Newton's iteration on every
1643mesh. The quadratic convergence is clearly visible in the table.
1645<table align=
"center" class=
"doxtable">
1647 <th>@f$\mathrm{Re}=7500@f$</th>
1648 <th colspan=
"2">Mesh0</th>
1649 <th colspan=
"2">Mesh1</th>
1650 <th colspan=
"2">Mesh2</th>
1651 <th colspan=
"2">Mesh3</th>
1652 <th colspan=
"2">Mesh4</th>
1655 <th>Newton iter </th>
1765The sequence of generated grids looks like
this:
1766<table align=
"center">
1769 <img src=
"https://www.dealii.org/images/steps/developer/step-57.Re7500_Mesh0.png" width=
"232px" alt=
"">
1772 <img src=
"https://www.dealii.org/images/steps/developer/step-57.Re7500_Mesh1.png" width=
"232px" alt=
"">
1775 <img src=
"https://www.dealii.org/images/steps/developer/step-57.Re7500_Mesh2.png" width=
"232px" alt=
"">
1780 <img src=
"https://www.dealii.org/images/steps/developer/step-57.Re7500_Mesh3.png" width=
"232px" alt=
"">
1783 <img src=
"https://www.dealii.org/images/steps/developer/step-57.Re7500_Mesh4.png" width=
"232px" alt=
"">
1787We compare our solution with the reference solution from @cite Erturk2005 .
1788<img src=
"https://www.dealii.org/images/steps/developer/step-57.compare-Re7500.svg" style=
"width:50%" alt=
"">
1789The following picture presents the graphical result.
1790<img src=
"https://www.dealii.org/images/steps/developer/step-57.Re7500_Streamline.png" alt=
"">
1792Furthermore, the error consists of the nonlinear error,
1793which decreases as we perform Newton iterations, and the discretization error,
1794which depends on the mesh size. That is why we have to
refine the
1795mesh and repeat Newton
's iteration on the next finer mesh. From the table above, we can
1796see that the final residual (nonlinear error) is below @f$10^{-12}@f$ on each mesh, but the
1797following picture shows us the difference between solutions on subsequently finer
1800<img src="https://www.dealii.org/images/steps/developer/step-57.converge-Re7500.svg" style="width:50%" alt="">
1803<a name="step-57-extensions"></a>
1805<a name="step_57-Possibilitiesforextensions"></a><h3>Possibilities for extensions</h3>
1808<a name="step_57-Comparetoothersolvers"></a><h4>Compare to other solvers</h4>
1811It is easy to compare the currently implemented linear solver to just using
1812UMFPACK for the whole linear system. You need to remove the nullspace
1813containing the constant pressures and it is done in @ref step_56 "step-56". More interesting
1814is the comparison to other state of the art preconditioners like PCD. It turns
1815out that the preconditioner here is very competitive, as can be seen in the
1816paper @cite HeisterRapin2013.
1818The following table shows the timing results between our iterative approach
1819(FGMRES) compared to a direct solver (UMFPACK) for the whole system
1820with viscosity set to 1/400. Even though we use the same direct solver for
1821the velocity block in the iterative solver, it is considerably faster and
1822consumes less memory. This will be even more pronounced in 3d.
1824<table align="center" class="doxtable">
1826 <th>Refinement Cycle</th>
1828 <th>Iterative: Total/s (Setup/s)</th>
1829 <th>Direct: Total/s (Setup/s)</th>
1834 <td>0.10 (0.06)</td>
1835 <td>0.13 (0.12)</td>
1840 <td>0.58 (0.37)</td>
1841 <td>1.03 (0.97)</td>
1846 <td>3.59 (2.73)</td>
1847 <td>7.78 (7.53)</td>
1852 <td>29.17 (24.94)</td>
1858<a name="step_57-3dcomputations"></a><h4>3d computations</h4>
1861The code is set up to also run in 3d. Of course the reference values are
1862different, see @cite Yang1998 for example. High resolution computations are not doable
1863with this example as is, because a direct solver for the velocity block does
1864not work well in 3d. Rather, a parallel solver based on algebraic or geometric
1865multigrid is needed -- see below.
1867<a name="step_57-Parallelization"></a><h4>Parallelization</h4>
1870For larger computations, especially in 3d, it is necessary to implement MPI
1871parallel solvers and preconditioners. A good starting point would be @ref step_55 "step-55",
1872which uses algebraic multigrid for the velocity block for the Stokes
1873equations. Another option would be to take a look at the list of codes
1874in the <a href="https://www.dealii.org/code-gallery.html">deal.II code
1875gallery</a>, which already contains parallel Navier-Stokes solvers.
1878<a name="step_57-PlainProg"></a>
1879<h1> The plain program</h1>
1880@include "step-57.cc"
void refine(Triangulation< dim, spacedim > &tria, const Vector< Number > &criteria, const double threshold, const unsigned int max_to_mark=numbers::invalid_unsigned_int)