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