Steady Navier-Stokes

class flatiron_tk.physics.steady_navier_stokes.SteadyNavierStokes(mesh)[source]

Bases: SteadyStokes

A class to represent the steady Navier-Stokes equations. This class extends the SteadyStokes class to include the convective term in the momentum equation.

add_stab()[source]

Add stabilization terms to the weak form for the steady Navier-Stokes problem.

get_residual(u, p)[source]

Compute the residual for the steady Navier-Stokes problem.

Parameters:

u: The velocity field. p: The pressure field.

Returns:

The residual of the steady Navier-Stokes equations.

get_stab_constant(u, h, alpha, beta)[source]

Compute the stabilization constants for the steady Navier-Stokes problem.

Parameters:

u: The velocity field. h: The cell diameter. alpha: The SUPG stabilization parameter. beta: The PSPG stabilization parameter.

Returns:

A tuple containing the SUPG and PSPG stabilization constants.

set_density(rho)[source]

Set the density for the Navier-Stokes problem.

Parameters:

rho: The density value.

set_dynamic_viscosity(mu)[source]

Set the dynamic viscosity for the Navier-Stokes problem.

Parameters:

mu: The dynamic viscosity value.

set_initial_guess(initial_guess_u=None, initial_guess_p=None)[source]

Set the initial guess for the steady Navier-Stokes problem.

Parameters:

initial_guess_u: A user-defined initial guess for the velocity field. If None, a zero initial guess is used. initial_guess_p: A user-defined initial guess for the pressure field. If None, a zero initial guess is used.

Returns:

None

set_weak_form(stab=False)[source]

Set the weak form for the steady Navier-Stokes problem.

Parameters:

stab: A boolean indicating whether to include stabilization terms in the weak form.

This class solves the steady Navier Stokes problem. In this case, the solver uses the Cauchy stress formulation of the problem

Strong formulation

Define the Cauchy stress for incompressible flow as

\[\boldsymbol{\sigma} := -p\textbf{I} + 2\mu(\nabla \textbf{u} + \nabla \textbf{u}^T)\]

Momentum equation

\[\rho \textbf{u} \cdot \nabla \textbf{u} = \nabla \cdot \boldsymbol{\sigma} + \textbf{b}\]

Continuity

\[\nabla \cdot \textbf{u} = 0\]

where \(\textbf{u}\) and p are the velocity and pressure field respectively with the constants \(\rho\) and \(\mu\) are the fluid density and dynamic viscosity respectively.

Boundary conditions

Fixed value boundary condition

\[\textbf{u} = \textbf{u}_D \;\forall \textbf{x} \in \Gamma_D\]

Traction boundary condition

\[\boldsymbol{\sigma} \cdot \hat{\textbf{n}} = \textbf{t} \;\;\forall \textbf{x} \in \Gamma_N\]

Weak formulation

The weak formulation is stated as follows:

For the same test/trial function spaces as Stokes, the weak formulation for the Navier-Stokes problem is

\[0 = \left(\textbf{w}, \rho \textbf{u} \cdot \nabla \textbf{u} \right)_\Omega + \left(\nabla\textbf{w}, \boldsymbol{\sigma}\right)_\Omega - \left(q, \nabla \cdot \textbf{u}\right)_\Omega + (\textbf{w}, \textbf{t})_{\Gamma_N} - (\textbf{w}, \textbf{b}_\Omega) + S_{SUPG} + S_{PSPG}\]

Where the stabilization terms are defined as

\[S_{SUPG} = \sum_{\Omega_e} \int_{\Omega_e} \tau \textbf{u} \cdot \nabla \textbf{w} \cdot \textbf{R} d\Omega\]
\[S_{PSPG} = \sum_{\Omega_e} \int_{\Omega_e} \frac{1}{\rho} \tau \nabla q \cdot \textbf{R} d\Omega\]

where \(\textbf{R}\) is the residue of the strong form

Stabilization parameters

For linear element, the stabilization is defined as

\[\begin{split}\tau = \left( \left(\frac{2|\textbf{u}|}{h}\right)^2 + 9\left(\frac{4\nu}{h^2}\right)^2 \right)^{-0.5} \\\end{split}\]

In this case, we use the same stabilization parameter for both SUPG and PSPG

Transient Navier-Stokes

class flatiron_tk.physics.transient_navier_stokes.TransientNavierStokes(mesh, dt=0.01, theta=0.5, *args, **kwargs)[source]

Bases: SteadyNavierStokes

Transient scalar transport problem. Supers SteadyNavierStokes.

Parameters:
  • mesh (flatiron_tk.mesh) – The mesh on which to solve the problem.

  • dt (float) – The time step size.

  • theta (float, optional) – The theta parameter for the implicit-explicit scheme. Default is 0.5.

add_stab()[source]

Add stabilization terms to the weak form for the steady Navier-Stokes problem. This method computes the SUPG and PSPG stabilization terms and adds them to the weak form.

build_function_space()[source]

Build the function space for the transient Navier-Stokes problem.

get_residual()[source]

Compute the residual for the transient Navier-Stokes problem.

Returns:

The residual expression for the transient Navier-Stokes equations.

set_initial_conditions(u_init, p_init)[source]

Set the initial conditions for the transient Navier-Stokes problem.

Parameters:

u_init: dolfinx.fem.Function or dolfinx.fem.Expression

Initial velocity field

p_init: dolfinx.fem.Function or dolfinx.fem.Expression

Initial pressure field

set_midpoint_theta(theta)[source]

Set the theta parameter for the implicit-explicit scheme.

Parameters:

theta: The theta parameter.

set_time_step_size(dt)[source]

Set the time step size for the transient Navier-Stokes problem.

Parameters:

dt: The time step size.

set_weak_form(stab=False)[source]

Set the weak form for the transient Navier-Stokes problem.

Parameters:

stab: A boolean indicating whether to include stabilization terms in the weak form.

update_previous_solution()[source]

Update the previous solution with the current solution. This method copies the current solution to the previous solution for the next time step.

This class solves the transient Navier Stokes problem.

Strong formulation

Momentum equation

\[\rho \frac{\partial \textbf{u}}{\partial t} + \rho \textbf{u} \cdot \nabla \textbf{u} = \nabla \cdot \boldsymbol{\sigma} + \textbf{b}\]

Continuity

\[\nabla \cdot \textbf{u} = 0\]

where \(\textbf{u}\) and p are the velocity and pressure field respectively with the constants \(\rho\) and \(\mu\) are the fluid density and dynamic viscosity respectively.

Boundary conditions

Fixed value boundary condition

\[\textbf{u} = \textbf{u}_D \;\forall \textbf{x} \in \Gamma_D\]

Traction boundary condition

\[\boldsymbol{\sigma} \cdot \hat{\textbf{n}} = \textbf{t} \;\;\forall \textbf{x} \in \Gamma_N\]

Weak formulation

In this implementation, we the mid-point method for time integration. Let \(\mathcal{L}(u, p)\) be the weak formulation obtained in the above steady forumation, the weak formulation for the transient problem is

\[0 = \left( \textbf{w}, \frac{\textbf{u}^n - \textbf{u}^{n-1}}{\Delta t} \right) + \theta\mathcal{L}(\textbf{u}^n, p^n) + (1-\theta)\mathcal{L}(\textbf{u}^0, p^n)\]

Stabilization parameters

Stabilization parameter now has time dependence and is defined as

\[\begin{split}\tau = \left( \left( \frac{1}{\Delta t} \right)^2 + \left(\frac{2|\textbf{u}|}{h}\right)^2 + 9\left(\frac{4\nu}{h^2}\right)^2 \right)^{-0.5} \\\end{split}\]

In this case, we use the same stabilization parameter for both SUPG and PSPG