deal.II version GIT relicensing-1721-g8100761196 2024-08-31 12:30:00+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
step-57.h
Go to the documentation of this file.
1 1);
1430 *   flow.run(4);
1431 *   }
1432 *   catch (std::exception &exc)
1433 *   {
1434 *   std::cerr << std::endl
1435 *   << std::endl
1436 *   << "----------------------------------------------------"
1437 *   << std::endl;
1438 *   std::cerr << "Exception on processing: " << std::endl
1439 *   << exc.what() << std::endl
1440 *   << "Aborting!" << std::endl
1441 *   << "----------------------------------------------------"
1442 *   << std::endl;
1443 *   return 1;
1444 *   }
1445 *   catch (...)
1446 *   {
1447 *   std::cerr << std::endl
1448 *   << std::endl
1449 *   << "----------------------------------------------------"
1450 *   << std::endl;
1451 *   std::cerr << "Unknown exception!" << std::endl
1452 *   << "Aborting!" << std::endl
1453 *   << "----------------------------------------------------"
1454 *   << std::endl;
1455 *   return 1;
1456 *   }
1457 *   return 0;
1458 *   }
1459 * @endcode
1460<a name="step_57-Results"></a><h1>Results</h1>
1461
1462
1463Now we use the method we discussed above to solve Navier Stokes equations with
1464viscosity @f$1/400@f$ and @f$1/7500@f$.
1465
1466<a name="step_57-Testcase1LowReynoldsNumber"></a><h3> Test case 1: Low Reynolds Number </h3>
1467
1468
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.
1474
1475<table align="center" class="doxtable">
1476<tr>
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>
1483</tr>
1484<tr>
1485 <th>Newton iter </th>
1486 <th>Residual </th>
1487 <th>FGMRES </th>
1488 <th>Residual </th>
1489 <th>FGMRES </th>
1490 <th>Residual </th>
1491 <th>FGMRES </th>
1492 <th>Residual </th>
1493 <th>FGMRES </th>
1494 <th>Residual </th>
1495 <th>FGMRES </th>
1496</tr>
1497<tr>
1498 <td>1</td>
1499 <td>3.7112e-03</td>
1500 <td>5</td>
1501 <td>6.4189e-03</td>
1502 <td>3</td>
1503 <td>2.4338e-03</td>
1504 <td>3</td>
1505 <td>1.0570e-03</td>
1506 <td>3</td>
1507 <td>4.9499e-04</td>
1508 <td>3</td>
1509</tr>
1510<tr>
1511 <td>2</td>
1512 <td>7.0849e-04</td>
1513 <td>5</td>
1514 <td>9.9458e-04</td>
1515 <td>5</td>
1516 <td>1.1409e-04</td>
1517 <td>6</td>
1518 <td>1.3544e-05</td>
1519 <td>6</td>
1520 <td>1.4171e-06</td>
1521 <td>6</td>
1522</tr>
1523<tr>
1524 <td>3</td>
1525 <td>1.9980e-05</td>
1526 <td>5</td>
1527 <td>4.5007e-05</td>
1528 <td>5</td>
1529 <td>2.9020e-08</td>
1530 <td>5</td>
1531 <td>4.4021e-10</td>
1532 <td>6</td>
1533 <td>6.3435e-11</td>
1534 <td>6</td>
1535</tr>
1536<tr>
1537 <td>4</td>
1538 <td>2.3165e-09</td>
1539 <td>6</td>
1540 <td>1.6891e-07</td>
1541 <td>5</td>
1542 <td>1.2338e-14</td>
1543 <td>7</td>
1544 <td>1.8506e-14</td>
1545 <td>8</td>
1546 <td>8.8563e-15</td>
1547 <td>8</td>
1548</tr>
1549<tr>
1550 <td>5</td>
1551 <td>1.2585e-13</td>
1552 <td>7</td>
1553 <td>1.4520e-11</td>
1554 <td>6</td>
1555 <td>1.9044e-13</td>
1556 <td>8</td>
1557 <td></td>
1558 <td></td>
1559 <td></td>
1560 <td></td>
1561</tr>
1562<tr>
1563 <td>6</td>
1564 <td></td>
1565 <td></td>
1566 <td>1.3998e-15</td>
1567 <td>8</td>
1568 <td></td>
1569 <td></td>
1570 <td></td>
1571 <td></td>
1572 <td></td>
1573 <td></td>
1574</tr>
1575</table>
1576
1577
1578
1579
1580
1581
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
1586initial guess.
1587
1588<table align="center">
1589 <tr>
1590 <td align="center">
1591 <img src="https://www.dealii.org/images/steps/developer/step-57.Re400_Mesh0.png" width="232px" alt="">
1592 </td>
1593 <td align="center">
1594 <img src="https://www.dealii.org/images/steps/developer/step-57.Re400_Mesh1.png" width="232px" alt="">
1595 </td>
1596 <td align="center">
1597 <img src="https://www.dealii.org/images/steps/developer/step-57.Re400_Mesh2.png" width="232px" alt="">
1598 </td>
1599 </tr>
1600 <tr>
1601 <td align="center">
1602 <img src="https://www.dealii.org/images/steps/developer/step-57.Re400_Mesh3.png" width="232px" alt="">
1603 </td>
1604 <td align="center">
1605 <img src="https://www.dealii.org/images/steps/developer/step-57.Re400_Mesh4.png" width="232px" alt="">
1606 </td>
1607 </tr>
1608</table>
1609
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="">
1613
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".
1616
1617<img src="https://www.dealii.org/images/steps/developer/step-57.compare-Re400.svg" style="width:50%" alt="">
1618
1619
1620
1621<a name="step_57-Testcase2HighReynoldsNumber"></a><h3> Test case 2: High Reynolds Number </h3>
1622
1623
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.
1630
1631<img src="https://www.dealii.org/images/steps/developer/step-57.Re7500_loss_convergence.svg" style="width:50%" alt="">
1632
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.
1639
1640<img src="https://www.dealii.org/images/steps/developer/step-57.Re7500_get_convergence.svg" style="width:50%" alt="">
1641
1642We also show the residual from each step of Newton's iteration on every
1643mesh. The quadratic convergence is clearly visible in the table.
1644
1645<table align="center" class="doxtable">
1646 <tr>
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>
1653 </tr>
1654 <tr>
1655 <th>Newton iter </th>
1656 <th>Residual </th>
1657 <th>FGMRES </th>
1658 <th>Residual </th>
1659 <th>FGMRES </th>
1660 <th>Residual </th>
1661 <th>FGMRES </th>
1662 <th>Residual </th>
1663 <th>FGMRES </th>
1664 <th>Residual </th>
1665 <th>FGMRES </th>
1666 </tr>
1667<tr>
1668 <td>1</td>
1669 <td>1.8922e-06</td>
1670 <td>6</td>
1671 <td>4.2506e-03</td>
1672 <td>3</td>
1673 <td>1.4299e-03</td>
1674 <td>3</td>
1675 <td>4.8793e-04</td>
1676 <td>2</td>
1677 <td>1.8998e-04</td>
1678 <td>2</td>
1679</tr>
1680<tr>
1681 <td>2</td>
1682 <td>3.1644e-09</td>
1683 <td>8</td>
1684 <td>1.3732e-03</td>
1685 <td>7</td>
1686 <td>4.1506e-04</td>
1687 <td>7</td>
1688 <td>9.1119e-05</td>
1689 <td>8</td>
1690 <td>1.3555e-05</td>
1691 <td>8</td>
1692</tr>
1693<tr>
1694 <td>3</td>
1695 <td>1.7611e-14</td>
1696 <td>9</td>
1697 <td>2.1946e-04</td>
1698 <td>6</td>
1699 <td>1.7881e-05</td>
1700 <td>6</td>
1701 <td>5.2678e-07</td>
1702 <td>7</td>
1703 <td>9.3739e-09</td>
1704 <td>7</td>
1705</tr>
1706<tr>
1707 <td>4</td>
1708 <td></td>
1709 <td></td>
1710 <td>8.8269e-06</td>
1711 <td>6</td>
1712 <td>6.8210e-09</td>
1713 <td>7</td>
1714 <td>2.2770e-11</td>
1715 <td>8</td>
1716 <td>1.2588e-13</td>
1717 <td>9</td>
1718</tr>
1719<tr>
1720 <td>5</td>
1721 <td></td>
1722 <td></td>
1723 <td>1.2974e-07</td>
1724 <td>7</td>
1725 <td>1.2515e-13</td>
1726 <td>9</td>
1727 <td>1.7801e-14</td>
1728 <td>1</td>
1729 <td></td>
1730 <td></td>
1731</tr>
1732<tr>
1733 <td>6</td>
1734 <td></td>
1735 <td></td>
1736 <td>4.4352e-11</td>
1737 <td>7</td>
1738 <td></td>
1739 <td></td>
1740 <td></td>
1741 <td></td>
1742 <td></td>
1743 <td></td>
1744</tr>
1745<tr>
1746 <td>7</td>
1747 <td></td>
1748 <td></td>
1749 <td>6.2863e-15</td>
1750 <td>9</td>
1751 <td></td>
1752 <td></td>
1753 <td></td>
1754 <td></td>
1755 <td></td>
1756 <td></td>
1757</tr>
1758</table>
1759
1760
1761
1762
1763
1764
1765The sequence of generated grids looks like this:
1766<table align="center">
1767 <tr>
1768 <td align="center">
1769 <img src="https://www.dealii.org/images/steps/developer/step-57.Re7500_Mesh0.png" width="232px" alt="">
1770 </td>
1771 <td align="center">
1772 <img src="https://www.dealii.org/images/steps/developer/step-57.Re7500_Mesh1.png" width="232px" alt="">
1773 </td>
1774 <td align="center">
1775 <img src="https://www.dealii.org/images/steps/developer/step-57.Re7500_Mesh2.png" width="232px" alt="">
1776 </td>
1777 </tr>
1778 <tr>
1779 <td align="center">
1780 <img src="https://www.dealii.org/images/steps/developer/step-57.Re7500_Mesh3.png" width="232px" alt="">
1781 </td>
1782 <td align="center">
1783 <img src="https://www.dealii.org/images/steps/developer/step-57.Re7500_Mesh4.png" width="232px" alt="">
1784 </td>
1785 </tr>
1786</table>
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="">
1791
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
1798meshes:
1799
1800<img src="https://www.dealii.org/images/steps/developer/step-57.converge-Re7500.svg" style="width:50%" alt="">
1801
1802
1803<a name="step-57-extensions"></a>
1804
1805<a name="step_57-Possibilitiesforextensions"></a><h3>Possibilities for extensions</h3>
1806
1807
1808<a name="step_57-Comparetoothersolvers"></a><h4>Compare to other solvers</h4>
1809
1810
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.
1817
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.
1823
1824<table align="center" class="doxtable">
1825<tr>
1826 <th>Refinement Cycle</th>
1827 <th>DoFs</th>
1828 <th>Iterative: Total/s (Setup/s)</th>
1829 <th>Direct: Total/s (Setup/s)</th>
1830</tr>
1831<tr>
1832 <td>5</td>
1833 <td>9539</td>
1834 <td>0.10 (0.06)</td>
1835 <td>0.13 (0.12)</td>
1836</tr>
1837<tr>
1838 <td>6</td>
1839 <td>37507</td>
1840 <td>0.58 (0.37)</td>
1841 <td>1.03 (0.97)</td>
1842</tr>
1843<tr>
1844 <td>7</td>
1845 <td>148739</td>
1846 <td>3.59 (2.73)</td>
1847 <td>7.78 (7.53)</td>
1848</tr>
1849<tr>
1850 <td>8</td>
1851 <td>592387</td>
1852 <td>29.17 (24.94)</td>
1853 <td>(>4GB RAM)</td>
1854</tr>
1855</table>
1856
1857
1858<a name="step_57-3dcomputations"></a><h4>3d computations</h4>
1859
1860
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.
1866
1867<a name="step_57-Parallelization"></a><h4>Parallelization</h4>
1868
1869
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.
1876 *
1877 *
1878<a name="step_57-PlainProg"></a>
1879<h1> The plain program</h1>
1880@include "step-57.cc"
1881*/
Point< 2 > first
Definition grid_out.cc:4623
const Event initial
Definition event.cc:64
void refine(Triangulation< dim, spacedim > &tria, const Vector< Number > &criteria, const double threshold, const unsigned int max_to_mark=numbers::invalid_unsigned_int)