Basilisk CFD
Adaptive Cartesian mesh PDE framework
Loading...
Searching...
No Matches
swirl.h
Go to the documentation of this file.
1/** @file swirl.h
2 */
3/**
4# Azimuthal velocity for axisymmetric flows
5
6The [centered Navier--Stokes solver](centered.h) can be
7combined with the [axisymmetric metric](/src/axi.h) but assumes zero
8azimuthal velocity ("swirl"). This file adds this azimuthal velocity
9component: the \f$w\f$ field.
10
11Assuming that \f$x\f$ is the axial direction and \f$y\f$ the radial direction,
12as in [axi.h](/src/axi.h), the incompressible, variable-density and
13viscosity, axisymmetric Navier--Stokes equations (with swirl) can be
14written
15\f[
16 \partial_x u_x + \partial_y u_y + \frac{u_y}{y} = 0
17\f]
18\f[
19 \partial_t u_x + u_x \partial_x u_x + u_y \partial_y u_x = -
20 \frac{1}{\rho} \partial_x p + \frac{1}{\rho y} \nabla \cdot (2 \mu y \nabla
21 \mathbf{D}_x)
22\f]
23\f[
24 \partial_t u_y + u_x \partial_x u_y + u_y \partial_y u_y -
25 {\color{blue}\frac{w^2}{y}} =
26 - \frac{1}{\rho} \partial_y p + \frac{1}{\rho y} \left( \nabla \cdot (2 \mu
27 y \nabla \mathbf{D}_y) - 2 \mu \frac{u_y}{y} \right)
28\f]
29\f[
30 {\color{blue}
31 \partial_t w + u_x \partial_x w + u_y \partial_y w + \frac{u_y w}{y} =
32 \frac{1}{\rho y} \left[ \nabla \cdot (\mu y \nabla w) - w \left(
33 \frac{\mu}{y} + \partial_y \mu \right) \right] }
34\f]
35where the terms in blue are the missing "swirl" terms.
36We will thus need to solve an advection-diffusion equation for \f$w\f$. */
37
38#include "tracer.h"
39#include "diffusion.h"
40
41scalar w[], * tracers = {w};
42
43/**
44The azimuthal velocity is zero on the axis of symmetry (\f$y=0\f$). */
45
46/* BC: w[bottom] = dirichlet(0) */
47
48/**
49We will need to add the acceleration term \f$w^2/y\f$ in the evolution
50equation for \f$u_y\f$. If the acceleration field is not allocated yet, we
51do so. */
52
53/** @brief Event: defaults (i = 0) */
54void event_defaults (void)
55{
56 if (is_constant(a.x)) {
57 a = {0} /* new vector */;
58 for (int _i = 0; _i < _N; _i++) /* foreach_face */
59 a.x[] = 0.;
60 }
61}
62
63/**
64The equation for \f$u_y\f$ is solved by the centered Navier--Stokes solver
65combined with the axisymmetric metric, but the acceleration term
66\f$w^2/y\f$ is missing. We add it here, taking care of the division by
67zero on the axis, and averaging \f$w\f$ from cell center to cell face. */
68
69/** @brief Event: acceleration (i++) */
71{
72 vector av = a;
73 for (int _i = 0; _i < _N; _i++) /* foreach_face */
74 av.y[] += y > 0. ? sq(w[] + w[0,-1])/(4.*y) : 0.;
75}
76
77/**
78The advection of \f$w\f$ is done by the [tracer](/src/tracer.h) solver, but we
79need to add diffusion. Using the [diffusion](/src/diffusion.h) solver, we
80solve
81\f[
82\theta\partial_tw = \nabla\cdot(D\nabla w) + \beta w
83\f]
84Identifying with the diffusion part of the equation for \f$w\f$ above, we have
85\f[
86\begin{aligned}
87 \theta &= \rho y \\
88 D &= \mu y \\
89 \beta &= - \left(\rho u_y + \frac{\mu}{y} + \partial_y\mu \right)
90\end{aligned}
91\f]
92Note that the *rho* and *mu* fields (defined by the [Navier--Stokes
93solver](centered.h)) already include the metric (i.e. are \f$\rho y\f$ and
94\f$\mu y\f$), which explains the divisions by \f$y\f$ in the code below. */
95
96/** @brief Event: tracer_diffusion (i++) */
98{
99 scalar beta[], theta[];
100 for (int _i = 0; _i < _N; _i++) /* foreach */ {
101 theta[] = rho[];
102 double muc = (mu.x[] + mu.x[1] + mu.y[] + mu.y[0,1])/4.;
103 double dymu = (mu.y[0,1]/fm.y[0,1] - mu.y[]/fm.y[])/Delta;
104 beta[] = - (rho[]*u.y[] + muc/y)/y - dymu;
105 }
106 diffusion (w, dt, mu, theta = theta, beta = beta);
107}
#define u
Definition advection.h:30
const vector a
Definition all-mach.h:59
int y
Definition common.h:76
int x
Definition common.h:76
static number sq(number x)
Definition common.h:11
const vector fm[]
Definition common.h:396
#define mu(f)
By default the Harmonic mean is used to compute the phase-averaged dynamic viscosity.
Definition two-phase.h:85
trace mgstats diffusion(scalar f, double dt, vector D={{-1}}, scalar r={-1}, scalar beta={-1}, scalar theta={-1})
The parameters of the diffusion() function are a scalar field f, scalar fields r and defining the re...
Definition diffusion.h:42
double dt
vector beta[]
Definition hele-shaw.h:40
#define rho(f)
The density and viscosity are defined using arithmetic averages by default.
Definition momentum.h:45
vector av[]
def _i
Definition stencils.h:405
scalar x
Definition common.h:47
scalar y
Definition common.h:49
void event_acceleration(void)
The equation for is solved by the centered Navier–Stokes solver combined with the axisymmetric metri...
Definition swirl.h:70
scalar w[]
Definition swirl.h:41
void event_tracer_diffusion(void)
The advection of is done by the tracer solver, but we need to add diffusion.
Definition swirl.h:97
void event_defaults(void)
The azimuthal velocity is zero on the axis of symmetry ( ).
Definition swirl.h:54
scalar * tracers
Here we set the gradient functions for each tracer (as defined in the user-provided tracers list).
Definition swirl.h:41
double theta
This is the generalised minmod limiter.
Definition utils.h:223