<br>

<i>
This program grew out of a student project by Abner Salgado at Texas A&M
University. Most of the work for this program is by him.
</i>

<a name="Intro"></a>
<h1> Introduction </h1>

<a name="Motivation"></a>
<h3> Motivation </h3>
The purpose of this program is to show how to effectively solve the incompressible time-dependent
Navier-Stokes equations. These equations describe the flow of a viscous incompressible fluid and read
@f{align*}
  u_t + u \cdot \nabla u - \nu \Delta u + \nabla p = f, \\
  \nabla \cdot u = 0,
@f}
where $u$ represents the velocity of the flow and $p$ the pressure. This system of equations is supplemented by
the initial condition
@f[
  u |_{t=0} = u_0,
@f]
with $u_0$ sufficiently smooth and solenoidal, and suitable boundary conditions. For instance, an admissible boundary
condition, is
@f[
  u|_{\partial\Omega} = u_b.
@f]
It is possible to prescribe other boundary conditions as well. In the test case that we solve here the boundary
is partitioned into two disjoint subsets $\partial\Omega = \Gamma_1 \cup \Gamma_2$ and we have
@f[
  u|_{\Gamma_1} = u_b,
@f]
and
@f[
 u\times n|_{\Gamma_2} = 0, \quad p|_{\Gamma_2} = 0
@f]
where $n$ is the outer unit normal. The boundary conditions on $\Gamma_2$ are often
used to model outflow conditions.

In previous tutorial programs (see for instance step-20 and
step-22) we have seen
how to solve the time-independent Stokes equations using a Schur complement approach. For the
time-dependent case, after time discretization, we would arrive at a system like
@f{align*}
  \frac1\tau u^k - \nu \Delta u^k + \nabla p^k = F^k, \\
  \nabla \cdot u^k = 0,
@f}
where $\tau$ is the time-step. Although the structure of this system is similar to the Stokes system and thus
it could be solved using a Schur complement approach, it turns out that the condition number of the
Schur complement is proportional to $\tau^{-2}$. This makes the system very
difficult to solve, and means that for the Navier-Stokes equations, this is
not a useful avenue to the solution.

<a name="Projection"></a>
<h3> Projection methods </h3>

Rather, we need to come up with a different approach to solve the time-dependent Navier-Stokes
equations. The difficulty in their solution comes from the fact that the velocity and the pressure are coupled
through the constraint
@f[
  \nabla \cdot u = 0,
@f]
for which the pressure is the Lagrange multiplier.
Projection methods aim at decoupling this constraint from the diffusion (Laplace) operator.

Let us shortly describe how the projection methods look like in a semi-discrete setting. The objective is to
obtain a sequence of velocities $\{u^k\}$ and pressures $\{p^k\}$. We will
also obtain a sequence $\{\phi^k\}$ of auxiliary variables.
Suppose that from the initial conditions, and an application of a first order method we have found
$(u^0,p^0,\phi^0=0)$ and $(u^1,p^1,\phi^1=p^1-p^0)$. Then the projection method consists of the following steps:
<ul>
  <li> <b>Step 0</b>: Extrapolation. Define:
  @f[
    u^\star = 2u^k - u^{k-1}, \quad p^\sharp = p^k + \frac43 \phi^k - \frac13 \phi^{k-1}.
  @f]
  <li> <b>Step 1</b>: Diffusion step. We find $u^{k+1}$ that solves the single
  linear equation
  @f[
    \frac1{2\tau}\left( 3u^{k+1} - 4u^k + u^{k-1} \right)
    + u^\star \cdot\nabla u^{k+1} + \frac12 \left( \nabla \cdot u^\star \right) u^{k+1}
    -\nu \Delta u^{k+1} + \nabla p^\sharp
    = f^{k+1},
    \quad
    u^{k+1}|_{\Gamma_1} = u_b,
    \quad
    u^{k+1} \times n|_{\Gamma_2} = 0.
  @f]

  <li> <b>Step 2</b>: Projection. Find $\phi^{k+1}$ that solves
  @f[
    \Delta \phi^{k+1} = \frac3{2\tau} \nabla \cdot u^{k+1},
    \quad
    \partial_n \phi^{k+1}|_{\Gamma_1} = 0,
    \quad
    \phi^{k+1}|_{\Gamma_2} = 0
  @f]
  <li> <b>Step 3</b>: Pressure correction. Here we have two options:
    <ul>
      <li> <i>Incremental Method in Standard Form</i>. The pressure is updated by:
      @f[
        p^{k+1} = p^k + \phi^{k+1}.
      @f]
      <li> <i>Incremental Method in Rotational Form</i>. In this case
      @f[
        p^{k+1} = p^k + \phi^{k+1} - \nu \nabla \cdot u^{k+1}.
      @f]
    </ul>
</ul>

Without going into details, let us remark a few things about the projection methods that we have just described:
<ul>
  <li> The advection term $u\cdot\nabla u$ is replaced by its <i>skew symmetric form</i>
  @f[
    u \cdot \nabla u + \frac12 \left( \nabla\cdot u \right) u.
  @f]
  This is consistent with the continuous equation (because $\nabla\cdot u = 0$,
  though this is not true pointwise for the discrete solution) and it is needed to
  guarantee unconditional stability of the
  time-stepping scheme. Moreover, to linearize the term we use the second order extrapolation $u^\star$ of
  $u^{k+1}$.
  <li> The projection step is a realization of the Helmholtz decomposition
  @f[
    L^2(\Omega)^d = H \oplus \nabla H^1_{\Gamma_2}(\Omega),
  @f]
  where
  @f[
    H = \left\{ v \in L^2(\Omega)^d:\  \nabla\cdot v =0, \  v\cdot n|_{\Gamma_1} = 0 \right\},
  @f]
  and
  @f[
    H^1_{\Gamma_2}(\Omega) = \left\{ q \in H^1(\Omega):\ q|_{\Gamma_2} = 0 \right\}.
  @f]
  Indeed, if we use this decomposition on $u^{k+1}$ we obtain
  @f[
    u^{k+1} = v^{k+1} + \nabla \left( \frac{2\tau}{3}  \phi^{k+1} \right),
  @f]
  with $v^{k+1}\in H$. Taking the divergence of this equation we arrive at the projection equation.
  <li> The more accurate of the two variants outlined above is the rotational
  one. However, the program below implements both variants. Moreover, in the author's experience,
  the standard form is the one that should be used if, for instance, the viscosity $\nu$ is variable.
</ul>


<p>
The standard incremental scheme and the rotational incremental scheme were first considered by van Kan in
<ul>
  <li> J. van Kan, "A second-order accurate pressure-correction scheme for viscous incompressible flow",
       SIAM Journal on Scientific and Statistical Computing, vol. 7, no. 3, pp. 870–891, 1986
</ul>
and is analyzed by Guermond in
<ul>
  <li> J.-L. Guermond, "Un résultat de convergence d’ordre deux en temps pour
                        l’approximation des équations de Navier–Stokes par une technique de projection incrémentale",
       ESAIM: Mathematical Modelling and Numerical Analysis, vol. 33, no. 1, pp. 169–189, 1999
</ul>
for the case $\nu = 1$.
It turns out that this technique suffers from unphysical boundary conditions for the kinematic pressure that
lead to reduced rates of convergence. To prevent this, Timmermans et al. proposed in
<ul>
  <li> L. Timmermans, P. Minev, and F. Van De Vosse,
       "An approximate projection scheme for incompressible flow using spectral elements",
       International Journal for Numerical Methods in Fluids, vol. 22, no. 7, pp. 673–688, 1996
</ul>
the rotational pressure-correction projection method that uses a divergence correction for the kinematic pressure.
A thorough analysis for scheme has first been performed in
<ul>
  <li> J.-L. Guermond and J. Shen, "On the error estimates for the rotational pressure-correction projection methods",
       Mathematics of Computation, vol. 73, no. 248, pp. 1719–1737, 2004
</ul>
for the Stokes problem.
</p>

<a name ="fullydiscrete"></a>
<h3> The Fully Discrete Setting </h3>
To obtain a fully discrete setting of the method we, as always, need a variational formulation. There is one
subtle issue here given the nature of the boundary conditions. When we multiply the equation by a suitable test
function one of the term that arises is
@f[
  -\nu \int_\Omega \Delta u \cdot v.
@f]
If we, say, had Dirichlet boundary conditions on the whole boundary then after integration by parts we would
obtain
@f[
  -\nu \int_\Omega \Delta u \cdot v = \nu \int_\Omega \nabla u : \nabla v
                                    - \int_{\partial\Omega} \partial_n u \cdot v
                                    = \nu \int_\Omega \nabla u : \nabla v.
@f]
One of the advantages of this formulation is that it fully decouples the components of the velocity. Moreover,
they all share the same system matrix. This can be exploited in the program.

However, given the nonstandard boundary conditions, to be able to take them into account we need to use
the following %identity
@f[
  \Delta u = \nabla\nabla\cdot u - \nabla\times\nabla\times u,
@f]
so that when we integrate by parts and take into account the boundary conditions we obtain
@f[
  -\nu \int_\Omega \Delta u \cdot v = \nu \int_\Omega \left[ \nabla \cdot u \nabla \cdot v
                                    + \nabla \times u \nabla \times v \right],
@f]
which is the form that we would have to use. Notice that this couples the components of the velocity.
Moreover, to enforce the boundary condition on the pressure, we need to rewrite
@f[
  \int_\Omega \nabla p \cdot v = -\int_\Omega p \nabla \cdot v + \int_{\Gamma_1} p v\cdot n
                                + \int_{\Gamma_2} p v\cdot n
                               = -\int_\Omega p \nabla \cdot v,
@f]
where the boundary integral in $\Gamma_1$ equals zero given the boundary conditions for the velocity,
and the one in $\Gamma_2$ given the boundary conditions for the pressure.

In the simplified case where the boundary $\Gamma_2$ is %parallel to a coordinate axis, which holds for
the testcase that we carry out below, it can actually be shown that
@f[
  \nu \int_\Omega \nabla u : \nabla v = \nu \int_\Omega \left[ \nabla \cdot u \nabla \cdot v
                                    + \nabla \times u \nabla \times v \right].
@f]
This issue is not very often addressed in the literature. For more information the reader can consult, for
instance,
<ul>
  <li> J.-L. GUERMOND, L. QUARTAPELLE, On the approximation of the unsteady Navier-Stokes equations by
  finite element projection methods, Numer. Math., 80  (1998) 207-238
  <li> J.-L. GUERMOND, P. MINEV, J. SHEN, Error analysis of pressure-correction schemes for the
  Navier-Stokes equations with open boundary conditions, SIAM J. Numer. Anal., 43  1 (2005) 239--258.
</ul>



<a name = "implementation"></a>
<h3> Implementation </h3>

Our implementation of the projection methods follows <i>verbatim</i> the description given above. We must note,
however, that as opposed to most other problems that have several solution components, we do not use
vector-valued finite elements. Instead, we use separate finite elements the components of the velocity
and the pressure, respectively, and use different <code>DoFHandler</code>'s for those as well. The main
reason for doing this is that, as we see from the description of the scheme, the <code>dim</code> components
of the velocity and the pressure are decoupled. As a consequence, the equations for all the velocity components
look all the same, have the same system matrix, and can be solved in %parallel. Obviously, this approach
has also its disadvantages. For instance, we need to keep several <code>DoFHandler</code>s and iterators
synchronized when assembling matrices and right hand sides; obtaining quantities that are inherent to
vector-valued functions (e.g. divergences) becomes a little awkward, and others.

<a name ="testcase"></a>
<h3> The Testcase </h3>

The testcase that we use for this program consists of the flow around a square obstacle. The geometry is
as follows:

<img src="https://www.dealii.org/images/steps/developer/step-35.geometry.png" alt="">

with $H=4.1$, making the geometry slightly non-symmetric.

We impose no-slip boundary conditions on both the top and bottom walls and the obstacle. On the left side we
have the inflow boundary condition
@f[
  u =
  \left( \begin{array}{c} 4 U_m y (H-y)/H^2 \\ 0 \end{array} \right),
@f]
with $U_m = 1.5$, i.e. the inflow boundary conditions correspond to Poiseuille flow for this configuration.
Finally, on the right vertical wall we impose the condition that the vertical component of the velocity
and the pressure should both be zero.
The final time $T=10$.
