StokesEquation

What's new?

Prerequisites

Problem statement

The Stokes-equation is given as

$$ -\frac{1}{Re} \Delta \vec{u} + \nabla p \ = \vec{g} $$$$ \text{div} (\vec{u}) = 0 $$

Where $Re \in \mathbb{R} $ denotes the Reynolds number. We consider two types of boundary conditions for the Stokes equation, Dirichlet (on $\Gamma_D \subset \Omega$) and Neumman (on $\Gamma_N \subset \Omega$). Those are defined as $$ \vec{u} =\vec{u}_D \ \text{ on } \Gamma_D\ \text{ (Dirichlet)}, \\ % \left( -\frac{1}{Re}\ \nabla \vec{u} + I_p \psi \right) \vec{n}\vert_{\delta \Omega} = 0 \ \text{ on } \Gamma_N\ \text{ (Neumann) } . $$

Solution within the BoSSS framework

First, we initialize the new worksheet; Note:

  1. This tutorial can be found in the source code repository as as StokesEq.ipynb. One can directly load this into Jupyter to interactively work with the following code examples.
  2. In the following line, the reference to BoSSSpad.dll is required. You must either set #r "BoSSSpad.dll" to something which is appropirate for your computer (e.g. C:\Program Files (x86)\FDY\BoSSS\bin\Release\net5.0\BoSSSpad.dll if you installed the binary distribution), or, if you are working with the source code, you must compile BoSSSpad and put it side-by-side to this worksheet file (from the original location in the repository, you can use the scripts getbossspad.sh, resp. getbossspad.bat).

To inicate at which point of the boundary which condition is valid, i.e. wether a certain point is eiter Dirichlet or Neumann we define IsDirichletBndy which defines a mapping $$ \vec{x} \mapsto \{ \text{true}, \text{false} \}, $$ where true actually indicates a Dirichlet boundary. Since this function is defined as a global delegate, it can be altered later on. In the same manner, the function UDiri defines the Dirichlet-value for the velocity at the boundary.

Velocity divergence and pressure gradient

At first, we implement the velocity divergence, i.e. the continuity equation. We use the strong form, i.e. $$ b(\vec{u},v) = \oint_{\Gamma \backslash \GammaD} \bar{v} \quad \lbrack \lbrack {\vec{u}}\rbrack\rbrack \cdot \vec{n}\Gamma

 dA 
 -
 \int_{\Omega} \text{div}(\vec{u}) v ~ dV.

$$

The gradient-operator

We use the variational formulation of the gradient operator, as it is explained in the section concerning the Poisson System

Tests on pressure gradient and velocity divergence

If our implementation is correct, we created a discretization of $$ \left[ \begin{array}{cc} 0 & \nabla \\ -\operatorname{div} & 0 \\ \end{array} \right] $$ so the matrix should have the form $$ \left[ \begin{array}{cc} 0 & B \\ B^T & 0 \\ \end{array} \right] =: M, $$ i.e. $M$ should be symmetric. We are testing this using a channel flow configuration using an equidistant grid.

We create a grid, a DG basis for velocity and pressure and a variable mapping:

We specify the boundary conditions as delegates:

Let's create the operator which contains only the pressure gradient and velocity divergence:

We create the matrix of the GradDiv-operator for the channel configuration. Before that, we have to set values for the global IsDirichletBndy and UDiri-variables.

Finally, we can test the symmetry of the matrix:

Adding the viscous operator, forming the Stokes operator

We use the SIP-operator from chapter SIP to model the viscous terms:

Finally, we are ready to implement the Stokes operator:

Again, we create the matrix (now, for the Stokes operator) and check its symmetry;

we also have to set the Reynolds number and the polynomial degree before calling ComputeMatrix (since we are doing a rather dirty trick by using global variables).

Testing the symmetry:

We also verify that our Stokes-matrix has full rank, i.e. we show that matrix size and rank are equal:

Solving the Stokes equation in the channel

We set the parameters and see whether we actually obtain the correct solution; the exact solution of our problem is $$ \vec{u}_{\text{ex}} = (1 - y^2, 0 )^T, \quad p_{\text{ex}} = \frac{200}{\text{Re}} - x \frac{2}{\text{Re}} $$ and since it is polynomial we should be able to obtain it \emph{exactly} in our velocity-pressure-space of degrees $(2,1)$.

Now, we are ready to solve the stokes equation. \BoSSS\ provides us with a system $$ \texttt{StokesMatrix Channel} \cdot (u,v,\psi)

In order to store our solution, we have to create DG fields:

Solve the linear system using a direct method:

We export the solution to a Tecplot file, use Visit (or any other visualization software) to inspect the solution:

Advanced topics

Stokes flow behind a grid

We use the following setting:

So, the boundary functions are:

TODO:

the rest is for you! One hint: in $y$-direction, use some spacing so that you have cell boundaries at (least at) $y \in \{ -1, 0, 1 \}$.