1433 *
catch (std::exception &exc)
1435 * std::cerr << std::endl
1437 * <<
"----------------------------------------------------"
1439 * std::cerr <<
"Exception on processing: " << std::endl
1440 * << exc.what() << std::endl
1441 * <<
"Aborting!" << std::endl
1442 * <<
"----------------------------------------------------"
1448 * std::cerr << std::endl
1450 * <<
"----------------------------------------------------"
1452 * std::cerr <<
"Unknown exception!" << std::endl
1453 * <<
"Aborting!" << std::endl
1454 * <<
"----------------------------------------------------"
1461<a name=
"step_57-Results"></a><h1>Results</h1>
1464Now we use the method we discussed above to solve Navier Stokes equations with
1465viscosity @f$1/400@f$ and @f$1/7500@f$.
1467<a name=
"step_57-Testcase1LowReynoldsNumber"></a><h3> Test
case 1: Low Reynolds Number </h3>
1470In the
first test
case the viscosity is
set to be @f$1/400@f$. As we discussed in the
1471introduction, the
initial guess is the solution to the corresponding Stokes
1472problem. In the following table, the residuals at each Newton
's iteration on
1473every mesh is shown. The data in the table shows that Newton's iteration
1474converges quadratically.
1476<table align=
"center" class=
"doxtable">
1478 <th>@f$\mathrm{Re}=400@f$</th>
1479 <th colspan=
"2">Mesh0</th>
1480 <th colspan=
"2">Mesh1</th>
1481 <th colspan=
"2">Mesh2</th>
1482 <th colspan=
"2">Mesh3</th>
1483 <th colspan=
"2">Mesh4</th>
1486 <th>Newton iter </th>
1583The following figures show the sequence of generated grids. For the
case
1584of @f$\mathrm{Re}=400@f$, the
initial guess is obtained by solving Stokes on an
1585@f$8 \times 8@f$ mesh, and the mesh is refined adaptively. Between meshes, the
1586solution from the coarse mesh is interpolated to the fine mesh to be used as an
1589<table align=
"center">
1592 <img src=
"https://www.dealii.org/images/steps/developer/step-57.Re400_Mesh0.png" width=
"232px" alt=
"">
1595 <img src=
"https://www.dealii.org/images/steps/developer/step-57.Re400_Mesh1.png" width=
"232px" alt=
"">
1598 <img src=
"https://www.dealii.org/images/steps/developer/step-57.Re400_Mesh2.png" width=
"232px" alt=
"">
1603 <img src=
"https://www.dealii.org/images/steps/developer/step-57.Re400_Mesh3.png" width=
"232px" alt=
"">
1606 <img src=
"https://www.dealii.org/images/steps/developer/step-57.Re400_Mesh4.png" width=
"232px" alt=
"">
1611This picture is the graphical streamline result of lid-driven cavity with
1612@f$\mathrm{Re}=400@f$.
1613<img src=
"https://www.dealii.org/images/steps/developer/step-57.Re400_Streamline.png" alt=
"">
1615Then the solution is compared with a reference solution
1616from @cite Ghia1982 and the reference solution data can be found in the file
"ref_2d_ghia_u.txt".
1618<img src=
"https://www.dealii.org/images/steps/developer/step-57.compare-Re400.svg" style=
"width:50%" alt=
"">
1622<a name=
"step_57-Testcase2HighReynoldsNumber"></a><h3> Test
case 2: High Reynolds Number </h3>
1625Newton
's iteration requires a good initial guess. However, the nonlinear term
1626dominates when the Reynolds number is large, so that the solution to the Stokes
1627equations may be far away from the exact solution. If the Stokes solution acts
1628as the initial guess, the convergence will be lost. The following picture
1629shows that the nonlinear iteration gets stuck and the residual no longer decreases
1630in further iterations.
1632<img src="https://www.dealii.org/images/steps/developer/step-57.Re7500_loss_convergence.svg" style="width:50%" alt="">
1634The initial guess, therefore, has to be obtained via a continuation method
1635which 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
1636mesh is of size @f$32 \times 32@f$. After obtaining an initial guess, the mesh is
1637refined as in the previous test case. The following picture shows that at each
1638refinement Newton's iteration has quadratic convergence. 52 steps of Newton
's
1639iterations are executed for solving this test case.
1641<img src="https://www.dealii.org/images/steps/developer/step-57.Re7500_get_convergence.svg" style="width:50%" alt="">
1643We also show the residual from each step of Newton's iteration on every
1644mesh. The quadratic convergence is clearly visible in the table.
1646<table align=
"center" class=
"doxtable">
1648 <th>@f$\mathrm{Re}=7500@f$</th>
1649 <th colspan=
"2">Mesh0</th>
1650 <th colspan=
"2">Mesh1</th>
1651 <th colspan=
"2">Mesh2</th>
1652 <th colspan=
"2">Mesh3</th>
1653 <th colspan=
"2">Mesh4</th>
1656 <th>Newton iter </th>
1766The sequence of generated grids looks like
this:
1767<table align=
"center">
1770 <img src=
"https://www.dealii.org/images/steps/developer/step-57.Re7500_Mesh0.png" width=
"232px" alt=
"">
1773 <img src=
"https://www.dealii.org/images/steps/developer/step-57.Re7500_Mesh1.png" width=
"232px" alt=
"">
1776 <img src=
"https://www.dealii.org/images/steps/developer/step-57.Re7500_Mesh2.png" width=
"232px" alt=
"">
1781 <img src=
"https://www.dealii.org/images/steps/developer/step-57.Re7500_Mesh3.png" width=
"232px" alt=
"">
1784 <img src=
"https://www.dealii.org/images/steps/developer/step-57.Re7500_Mesh4.png" width=
"232px" alt=
"">
1788We compare our solution with the reference solution from @cite Erturk2005 .
1789<img src=
"https://www.dealii.org/images/steps/developer/step-57.compare-Re7500.svg" style=
"width:50%" alt=
"">
1790The following picture presents the graphical result.
1791<img src=
"https://www.dealii.org/images/steps/developer/step-57.Re7500_Streamline.png" alt=
"">
1793Furthermore, the error consists of the nonlinear error,
1794which decreases as we perform Newton iterations, and the discretization error,
1795which depends on the mesh size. That is why we have to
refine the
1796mesh and repeat Newton
's iteration on the next finer mesh. From the table above, we can
1797see that the final residual (nonlinear error) is below @f$10^{-12}@f$ on each mesh, but the
1798following picture shows us the difference between solutions on subsequently finer
1801<img src="https://www.dealii.org/images/steps/developer/step-57.converge-Re7500.svg" style="width:50%" alt="">
1804<a name="step-57-extensions"></a>
1806<a name="step_57-Possibilitiesforextensions"></a><h3>Possibilities for extensions</h3>
1809<a name="step_57-Comparetoothersolvers"></a><h4>Compare to other solvers</h4>
1812It is easy to compare the currently implemented linear solver to just using
1813UMFPACK for the whole linear system. You need to remove the nullspace
1814containing the constant pressures and it is done in @ref step_56 "step-56". More interesting
1815is the comparison to other state of the art preconditioners like PCD. It turns
1816out that the preconditioner here is very competitive, as can be seen in the
1817paper @cite HeisterRapin2013.
1819The following table shows the timing results between our iterative approach
1820(FGMRES) compared to a direct solver (UMFPACK) for the whole system
1821with viscosity set to 1/400. Even though we use the same direct solver for
1822the velocity block in the iterative solver, it is considerably faster and
1823consumes less memory. This will be even more pronounced in 3d.
1825<table align="center" class="doxtable">
1827 <th>Refinement Cycle</th>
1829 <th>Iterative: Total/s (Setup/s)</th>
1830 <th>Direct: Total/s (Setup/s)</th>
1835 <td>0.10 (0.06)</td>
1836 <td>0.13 (0.12)</td>
1841 <td>0.58 (0.37)</td>
1842 <td>1.03 (0.97)</td>
1847 <td>3.59 (2.73)</td>
1848 <td>7.78 (7.53)</td>
1853 <td>29.17 (24.94)</td>
1859<a name="step_57-3dcomputations"></a><h4>3d computations</h4>
1862The code is set up to also run in 3d. Of course the reference values are
1863different, see @cite Yang1998 for example. High resolution computations are not doable
1864with this example as is, because a direct solver for the velocity block does
1865not work well in 3d. Rather, a parallel solver based on algebraic or geometric
1866multigrid is needed -- see below.
1868<a name="step_57-Parallelization"></a><h4>Parallelization</h4>
1871For larger computations, especially in 3d, it is necessary to implement MPI
1872parallel solvers and preconditioners. A good starting point would be @ref step_55 "step-55",
1873which uses algebraic multigrid for the velocity block for the Stokes
1874equations. Another option would be to take a look at the list of codes
1875in the <a href="https://www.dealii.org/code-gallery.html">deal.II code
1876gallery</a>, which already contains parallel Navier-Stokes solvers.
1879<a name="step_57-PlainProg"></a>
1880<h1> The plain program</h1>
1881@include "step-57.cc"
__global__ void set(Number *val, const Number s, const size_type N)
void refine(Triangulation< dim, spacedim > &tria, const Vector< Number > &criteria, const double threshold, const unsigned int max_to_mark=numbers::invalid_unsigned_int)