Reference documentation for deal.II version 9.5.0
\(\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);
1432 *   flow.run(4);
1433 *   }
1434 *   catch (std::exception &exc)
1435 *   {
1436 *   std::cerr << std::endl
1437 *   << std::endl
1438 *   << "----------------------------------------------------"
1439 *   << std::endl;
1440 *   std::cerr << "Exception on processing: " << std::endl
1441 *   << exc.what() << std::endl
1442 *   << "Aborting!" << std::endl
1443 *   << "----------------------------------------------------"
1444 *   << std::endl;
1445 *   return 1;
1446 *   }
1447 *   catch (...)
1448 *   {
1449 *   std::cerr << std::endl
1450 *   << std::endl
1451 *   << "----------------------------------------------------"
1452 *   << std::endl;
1453 *   std::cerr << "Unknown exception!" << std::endl
1454 *   << "Aborting!" << std::endl
1455 *   << "----------------------------------------------------"
1456 *   << std::endl;
1457 *   return 1;
1458 *   }
1459 *   return 0;
1460 *   }
1461 * @endcode
1462<a name="Results"></a><h1>Results</h1>
1463
1464
1465Now we use the method we discussed above to solve Navier Stokes equations with
1466viscosity @f$1/400@f$ and @f$1/7500@f$.
1467
1468<a name="Testcase1LowReynoldsNumber"></a><h3> Test case 1: Low Reynolds Number </h3>
1469
1470
1471In the first test case the viscosity is set to be @f$1/400@f$. As we discussed in the
1472introduction, the initial guess is the solution to the corresponding Stokes
1473problem. In the following table, the residuals at each Newton's iteration on
1474every mesh is shown. The data in the table shows that Newton's iteration
1475converges quadratically.
1476
1477<table align="center" class="doxtable">
1478<tr>
1479 <th>@f$\mathrm{Re}=400@f$</th>
1480 <th colspan="2">Mesh0</th>
1481 <th colspan="2">Mesh1</th>
1482 <th colspan="2">Mesh2</th>
1483 <th colspan="2">Mesh3</th>
1484 <th colspan="2">Mesh4</th>
1485</tr>
1486<tr>
1487 <th>Newton iter </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 <th>Residual </th>
1497 <th>FGMRES </th>
1498</tr>
1499<tr>
1500 <td>1</td>
1501 <td>3.7112e-03</td>
1502 <td>5</td>
1503 <td>6.4189e-03</td>
1504 <td>3</td>
1505 <td>2.4338e-03</td>
1506 <td>3</td>
1507 <td>1.0570e-03</td>
1508 <td>3</td>
1509 <td>4.9499e-04</td>
1510 <td>3</td>
1511</tr>
1512<tr>
1513 <td>2</td>
1514 <td>7.0849e-04</td>
1515 <td>5</td>
1516 <td>9.9458e-04</td>
1517 <td>5</td>
1518 <td>1.1409e-04</td>
1519 <td>6</td>
1520 <td>1.3544e-05</td>
1521 <td>6</td>
1522 <td>1.4171e-06</td>
1523 <td>6</td>
1524</tr>
1525<tr>
1526 <td>3</td>
1527 <td>1.9980e-05</td>
1528 <td>5</td>
1529 <td>4.5007e-05</td>
1530 <td>5</td>
1531 <td>2.9020e-08</td>
1532 <td>5</td>
1533 <td>4.4021e-10</td>
1534 <td>6</td>
1535 <td>6.3435e-11</td>
1536 <td>6</td>
1537</tr>
1538<tr>
1539 <td>4</td>
1540 <td>2.3165e-09</td>
1541 <td>6</td>
1542 <td>1.6891e-07</td>
1543 <td>5</td>
1544 <td>1.2338e-14</td>
1545 <td>7</td>
1546 <td>1.8506e-14</td>
1547 <td>8</td>
1548 <td>8.8563e-15</td>
1549 <td>8</td>
1550</tr>
1551<tr>
1552 <td>5</td>
1553 <td>1.2585e-13</td>
1554 <td>7</td>
1555 <td>1.4520e-11</td>
1556 <td>6</td>
1557 <td>1.9044e-13</td>
1558 <td>8</td>
1559 <td></td>
1560 <td></td>
1561 <td></td>
1562 <td></td>
1563</tr>
1564<tr>
1565 <td>6</td>
1566 <td></td>
1567 <td></td>
1568 <td>1.3998e-15</td>
1569 <td>8</td>
1570 <td></td>
1571 <td></td>
1572 <td></td>
1573 <td></td>
1574 <td></td>
1575 <td></td>
1576</tr>
1577</table>
1578
1579
1580
1581
1582
1583
1584The following figures show the sequence of generated grids. For the case
1585of @f$\mathrm{Re}=400@f$, the initial guess is obtained by solving Stokes on an
1586@f$8 \times 8@f$ mesh, and the mesh is refined adaptively. Between meshes, the
1587solution from the coarse mesh is interpolated to the fine mesh to be used as an
1588initial guess.
1589
1590<table align="center">
1591 <tr>
1592 <td align="center">
1593 <img src="https://www.dealii.org/images/steps/developer/step-57.Re400_Mesh0.png" width="232px" alt="">
1594 </td>
1595 <td align="center">
1596 <img src="https://www.dealii.org/images/steps/developer/step-57.Re400_Mesh1.png" width="232px" alt="">
1597 </td>
1598 <td align="center">
1599 <img src="https://www.dealii.org/images/steps/developer/step-57.Re400_Mesh2.png" width="232px" alt="">
1600 </td>
1601 </tr>
1602 <tr>
1603 <td align="center">
1604 <img src="https://www.dealii.org/images/steps/developer/step-57.Re400_Mesh3.png" width="232px" alt="">
1605 </td>
1606 <td align="center">
1607 <img src="https://www.dealii.org/images/steps/developer/step-57.Re400_Mesh4.png" width="232px" alt="">
1608 </td>
1609 </tr>
1610</table>
1611
1612This picture is the graphical streamline result of lid-driven cavity with
1613@f$\mathrm{Re}=400@f$.
1614<img src="https://www.dealii.org/images/steps/developer/step-57.Re400_Streamline.png" alt="">
1615
1616Then the solution is compared with a reference solution
1617from @cite Ghia1982 and the reference solution data can be found in the file "ref_2d_ghia_u.txt".
1618
1619<img src="https://www.dealii.org/images/steps/developer/step-57.compare-Re400.svg" style="width:50%" alt="">
1620
1621
1622
1623<a name="Testcase2HighReynoldsNumber"></a><h3> Test case 2: High Reynolds Number </h3>
1624
1625
1626Newton's iteration requires a good initial guess. However, the nonlinear term
1627dominates when the Reynolds number is large, so that the solution to the Stokes
1628equations may be far away from the exact solution. If the Stokes solution acts
1629as the initial guess, the convergence will be lost. The following picture
1630shows that the nonlinear iteration gets stuck and the residual no longer decreases
1631in further iterations.
1632
1633<img src="https://www.dealii.org/images/steps/developer/step-57.Re7500_loss_convergence.svg" style="width:50%" alt="">
1634
1635The initial guess, therefore, has to be obtained via a continuation method
1636which 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
1637mesh is of size @f$32 \times 32@f$. After obtaining an initial guess, the mesh is
1638refined as in the previous test case. The following picture shows that at each
1639refinement Newton's iteration has quadratic convergence. 52 steps of Newton's
1640iterations are executed for solving this test case.
1641
1642<img src="https://www.dealii.org/images/steps/developer/step-57.Re7500_get_convergence.svg" style="width:50%" alt="">
1643
1644We also show the residual from each step of Newton's iteration on every
1645mesh. The quadratic convergence is clearly visible in the table.
1646
1647<table align="center" class="doxtable">
1648 <tr>
1649 <th>@f$\mathrm{Re}=7500@f$</th>
1650 <th colspan="2">Mesh0</th>
1651 <th colspan="2">Mesh1</th>
1652 <th colspan="2">Mesh2</th>
1653 <th colspan="2">Mesh3</th>
1654 <th colspan="2">Mesh4</th>
1655 </tr>
1656 <tr>
1657 <th>Newton iter </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 <th>Residual </th>
1667 <th>FGMRES </th>
1668 </tr>
1669<tr>
1670 <td>1</td>
1671 <td>1.8922e-06</td>
1672 <td>6</td>
1673 <td>4.2506e-03</td>
1674 <td>3</td>
1675 <td>1.4299e-03</td>
1676 <td>3</td>
1677 <td>4.8793e-04</td>
1678 <td>2</td>
1679 <td>1.8998e-04</td>
1680 <td>2</td>
1681</tr>
1682<tr>
1683 <td>2</td>
1684 <td>3.1644e-09</td>
1685 <td>8</td>
1686 <td>1.3732e-03</td>
1687 <td>7</td>
1688 <td>4.1506e-04</td>
1689 <td>7</td>
1690 <td>9.1119e-05</td>
1691 <td>8</td>
1692 <td>1.3555e-05</td>
1693 <td>8</td>
1694</tr>
1695<tr>
1696 <td>3</td>
1697 <td>1.7611e-14</td>
1698 <td>9</td>
1699 <td>2.1946e-04</td>
1700 <td>6</td>
1701 <td>1.7881e-05</td>
1702 <td>6</td>
1703 <td>5.2678e-07</td>
1704 <td>7</td>
1705 <td>9.3739e-09</td>
1706 <td>7</td>
1707</tr>
1708<tr>
1709 <td>4</td>
1710 <td></td>
1711 <td></td>
1712 <td>8.8269e-06</td>
1713 <td>6</td>
1714 <td>6.8210e-09</td>
1715 <td>7</td>
1716 <td>2.2770e-11</td>
1717 <td>8</td>
1718 <td>1.2588e-13</td>
1719 <td>9</td>
1720</tr>
1721<tr>
1722 <td>5</td>
1723 <td></td>
1724 <td></td>
1725 <td>1.2974e-07</td>
1726 <td>7</td>
1727 <td>1.2515e-13</td>
1728 <td>9</td>
1729 <td>1.7801e-14</td>
1730 <td>1</td>
1731 <td></td>
1732 <td></td>
1733</tr>
1734<tr>
1735 <td>6</td>
1736 <td></td>
1737 <td></td>
1738 <td>4.4352e-11</td>
1739 <td>7</td>
1740 <td></td>
1741 <td></td>
1742 <td></td>
1743 <td></td>
1744 <td></td>
1745 <td></td>
1746</tr>
1747<tr>
1748 <td>7</td>
1749 <td></td>
1750 <td></td>
1751 <td>6.2863e-15</td>
1752 <td>9</td>
1753 <td></td>
1754 <td></td>
1755 <td></td>
1756 <td></td>
1757 <td></td>
1758 <td></td>
1759</tr>
1760</table>
1761
1762
1763
1764
1765
1766
1767The sequence of generated grids looks like this:
1768<table align="center">
1769 <tr>
1770 <td align="center">
1771 <img src="https://www.dealii.org/images/steps/developer/step-57.Re7500_Mesh0.png" width="232px" alt="">
1772 </td>
1773 <td align="center">
1774 <img src="https://www.dealii.org/images/steps/developer/step-57.Re7500_Mesh1.png" width="232px" alt="">
1775 </td>
1776 <td align="center">
1777 <img src="https://www.dealii.org/images/steps/developer/step-57.Re7500_Mesh2.png" width="232px" alt="">
1778 </td>
1779 </tr>
1780 <tr>
1781 <td align="center">
1782 <img src="https://www.dealii.org/images/steps/developer/step-57.Re7500_Mesh3.png" width="232px" alt="">
1783 </td>
1784 <td align="center">
1785 <img src="https://www.dealii.org/images/steps/developer/step-57.Re7500_Mesh4.png" width="232px" alt="">
1786 </td>
1787 </tr>
1788</table>
1789We compare our solution with the reference solution from @cite Erturk2005 .
1790<img src="https://www.dealii.org/images/steps/developer/step-57.compare-Re7500.svg" style="width:50%" alt="">
1791The following picture presents the graphical result.
1792<img src="https://www.dealii.org/images/steps/developer/step-57.Re7500_Streamline.png" alt="">
1793
1794Furthermore, the error consists of the nonlinear error,
1795which decreases as we perform Newton iterations, and the discretization error,
1796which depends on the mesh size. That is why we have to refine the
1797mesh and repeat Newton's iteration on the next finer mesh. From the table above, we can
1798see that the final residual (nonlinear error) is below @f$10^{-12}@f$ on each mesh, but the
1799following picture shows us the difference between solutions on subsequently finer
1800meshes:
1801
1802<img src="https://www.dealii.org/images/steps/developer/step-57.converge-Re7500.svg" style="width:50%" alt="">
1803
1804
1805<a name="extensions"></a>
1806
1807<a name="Possibilitiesforextensions"></a><h3>Possibilities for extensions</h3>
1808
1809
1810<a name="Comparetoothersolvers"></a><h4>Compare to other solvers</h4>
1811
1812
1813It is easy to compare the currently implemented linear solver to just using
1814UMFPACK for the whole linear system. You need to remove the nullspace
1815containing the constant pressures and it is done in @ref step_56 "step-56". More interesting
1816is the comparison to other state of the art preconditioners like PCD. It turns
1817out that the preconditioner here is very competitive, as can be seen in the
1818paper @cite HeisterRapin2013.
1819
1820The following table shows the timing results between our iterative approach
1821(FGMRES) compared to a direct solver (UMFPACK) for the whole system
1822with viscosity set to 1/400. Even though we use the same direct solver for
1823the velocity block in the iterative solver, it is considerably faster and
1824consumes less memory. This will be even more pronounced in 3d.
1825
1826<table align="center" class="doxtable">
1827<tr>
1828 <th>Refinement Cycle</th>
1829 <th>DoFs</th>
1830 <th>Iterative: Total/s (Setup/s)</th>
1831 <th>Direct: Total/s (Setup/s)</th>
1832</tr>
1833<tr>
1834 <td>5</td>
1835 <td>9539</td>
1836 <td>0.10 (0.06)</td>
1837 <td>0.13 (0.12)</td>
1838</tr>
1839<tr>
1840 <td>6</td>
1841 <td>37507</td>
1842 <td>0.58 (0.37)</td>
1843 <td>1.03 (0.97)</td>
1844</tr>
1845<tr>
1846 <td>7</td>
1847 <td>148739</td>
1848 <td>3.59 (2.73)</td>
1849 <td>7.78 (7.53)</td>
1850</tr>
1851<tr>
1852 <td>8</td>
1853 <td>592387</td>
1854 <td>29.17 (24.94)</td>
1855 <td>(>4GB RAM)</td>
1856</tr>
1857</table>
1858
1859
1860<a name="3dcomputations"></a><h4>3d computations</h4>
1861
1862
1863The code is set up to also run in 3d. Of course the reference values are
1864different, see @cite Yang1998 for example. High resolution computations are not doable
1865with this example as is, because a direct solver for the velocity block does
1866not work well in 3d. Rather, a parallel solver based on algebraic or geometric
1867multigrid is needed -- see below.
1868
1869<a name="Parallelization"></a><h4>Parallelization</h4>
1870
1871
1872For larger computations, especially in 3d, it is necessary to implement MPI
1873parallel solvers and preconditioners. A good starting point would be @ref step_55 "step-55",
1874which uses algebraic multigrid for the velocity block for the Stokes
1875equations. Another option would be to take a look at the list of codes
1876in the <a href="https://www.dealii.org/code-gallery.html">deal.II code
1877gallery</a>, which already contains parallel Navier-Stokes solvers.
1878 *
1879 *
1880<a name="PlainProg"></a>
1881<h1> The plain program</h1>
1882@include "step-57.cc"
1883*/
Point< 2 > first
Definition grid_out.cc:4615
__global__ void set(Number *val, const Number s, const size_type N)
const Event initial
Definition event.cc:65
void refine(Triangulation< dim, spacedim > &tria, const Vector< Number > &criteria, const double threshold, const unsigned int max_to_mark=numbers::invalid_unsigned_int)