Basilisk CFD
Adaptive Cartesian mesh PDE framework
Loading...
Searching...
No Matches
coriolis.h
Go to the documentation of this file.
1/** @file coriolis.h
2 */
3/**
4# Coriolis/friction terms for the multilayer solver
5
6This approximates
7\f[
8\partial_t\mathbf{u} = \mathbf{B}\mathbf{u} + \mathbf{a}
9\f]
10with
11\f[
12 \mathbf{B} = \left( \begin{array}{cc}
13 - K_0 & F_0\\
14 - F_0 & - K_0
15 \end{array} \right),
16\f]
17and \f$K_0\f$ and \f$F_0\f$ the linear friction and Coriolis parameters
18respectively. The time-implicit discretisation of these terms can be
19written
20\f[
21 \frac{\mathbf{u}^{n + 1} -\mathbf{u}^n}{\Delta t} = \mathbf{B} [(1
22 - \alpha_H) \mathbf{u}^n + \alpha_H \mathbf{u}^{n + 1}] + \mathbf{a}^n
23\f]
24This then gives
25\f[
26 \mathbf{u}^{n + 1} (\mathbf{I}- \alpha_H \Delta t\mathbf{B}) =
27 \mathbf{u}^n + (1 - \alpha_H) \Delta t\mathbf{B}\mathbf{u}^n + \Delta
28 t\mathbf{a}^n
29\f]
30The local \f$2 \times 2\f$ linear system is easily inverted analytically. The
31final value is obtained by substracting the acceleration i.e.
32\f[
33 \mathbf{u}^{\star} = \mathbf{u}^{n + 1} - \Delta t\mathbf{a}^n
34\f]
35
36The `K0()` and/or `F0()` macros should be defined before including the
37file. */
38
39#ifndef K0
40# define K0() 0.
41#endif
42#ifndef F0
43# define F0() 0.
44#endif
45#ifndef alpha_H
46# define alpha_H 1.
47#endif
48
49/** @brief Event: acceleration (i++) */
51{
52 for (int _i = 0; _i < _N; _i++) /* foreach */
54 if (h[] > dry) {
55 coord b0 = { - K0(), - K0() }, b1 = { F0(), -F0() };
56 coord m0 = { 1. - alpha_H*dt*b0.x, 1. - alpha_H*dt*b0.y };
57 coord m1 = { - alpha_H*dt*b1.x, - alpha_H*dt*b1.y };
58 double det = m0.x*m0.y - m1.x*m1.y;
59 coord r, a;
60 for (int _d = 0; _d < dimension; _d++) {
61 a.x = dt*(ha.x[] + ha.x[1])/(hf.x[] + hf.x[1] + dry);
62 r.x = u.x[] + (1. - alpha_H)*dt*(b0.x*u.x[] + b1.x*u.y[]) + a.x;
63 }
64 for (int _d = 0; _d < dimension; _d++)
65 u.x[] = (m0.y*r.x - m1.x*r.y)/det - a.x;
66 }
67}
68
69#undef alpha_H
70
71/**
72## Geostrophic velocity */
73
75{
76 coord ug;
77 static const coord a = {-1.[0], 1.[0]};
78 for (int _d = 0; _d < dimension; _d++) {
79 double hl = h[] > dry && h[-1] > dry, hr = h[] > dry && h[1] > dry;
80 ug.y = a.y*G*(hl*gmetric(0)*(eta[] - eta[-1]) +
81 hr*gmetric(1)*(eta[1] - eta[]))
82 /(Delta*F0()*(hl + hr + 1e-12));
83 }
84 return ug;
85}
double b1
Definition NASG.h:19
#define u
Definition advection.h:30
const vector a
Definition all-mach.h:59
double G
Definition atmosphere.h:12
scalar h[]
Definition atmosphere.h:6
#define dimension
Definition bitree.h:3
int x
Definition common.h:76
Point point
Definition conserving.h:86
double dt
double dry
Definition entrainment.h:30
scalar eta
Definition hydro.h:50
vector hf
Definition hydro.h:209
#define gmetric(i)
The macro below can be overloaded to define the barotropic acceleration.
Definition hydro.h:195
vector ha
Definition hydro.h:209
void event_acceleration(void)
Event: acceleration (i++)
Definition coriolis.h:50
#define K0()
Definition coriolis.h:40
coord geostrophic_velocity(Point point)
Definition coriolis.h:74
#define alpha_H
Definition coriolis.h:46
#define F0()
Definition coriolis.h:43
#define foreach_layer()
def _i
Definition stencils.h:405
Definition linear.h:21
Definition common.h:78
double x
Definition common.h:79
double y
Definition common.h:79
scalar x
Definition common.h:47
scalar y
Definition common.h:49