Basilisk CFD
Adaptive Cartesian mesh PDE framework
Loading...
Searching...
No Matches
entrainment.h
Go to the documentation of this file.
1/** @file entrainment.h
2 */
3/**
4# Diapycnal "entrainment" and "detrainment"
5
6This implements the entrainment/detrainment between isopycnal layers
7briefly described in [Hurlburt & Hogan, 2000](#hurlburt2000), section
82, equations 1), 2) and 3).
9
10`omr` is the average entrainment velocity between layers
11(\f$\tilde{\omega}_k\f$ in H&H, 2000) and `Cm` is the coefficient of
12additional interfacial friction associated with entrainment (\f$C_M\f$ in
13H&H, 2000). They are parameters provided by the user. */
14
15extern double omr, Cm;
16
17/**
18The maximum and minimum layer thicknesses (\f$h_k^+\f$ and \f$h_k^-\f$
19respectively in H&H, 2000) are provided by the user and used to define
20the weighing factors appearing in the definition of the "diapycnal
21mixing velocities" \f$\omega_k^+\f$ and \f$\omega_k^-\f$ in H&H, 2000. */
22
23extern double * hmin, * hmax;
24#define wmin(h,hmin) (h >= hmin ? 0. : sq((hmin - h)/hmin))
25#define wmax(h,hmax) (h <= hmax ? 0. : sq((h - hmax)/hmax))
26
27/**
28These come from the [multilayer solver](hydro.h). */
29
30extern double dt, dry;
31
32/** @brief Event: viscous_term (i++) */
34{
35
36 /**
37 If the average entrainment velocity is negative or null, we do
38 nothing. */
39
40 if (omr <= 0.)
41 return 0;
42
43 /**
44 We compute the volumed-averaged entrainment/detrainment for each
45 layer (bottom layer excepted). */
46
47 double oma[nl], wa[nl];
48 for (int l = 0; l < nl; l++)
49 oma[l] = 0., wa[l] = 0.;
51 double o = 0., w = 0.;
52 if (_layer > 0)
53 foreach(reduction(+:o) reduction(+:w)) {
54 double om = omr*(wmin((h[]), hmin[_layer]) - wmax((h[]), hmax[_layer]));
55 if (h[] + dt*om > dry && h[0,0,-1] - dt*om > dry)
56 o += dv()*om, w += dv();
57 }
58 oma[_layer] = o, wa[_layer] = w;
59 }
60
61 /**
62 The local entrainment/detrainment is then applied as the sum of a
63 global contribution and a local contribution which depends on the
64 local thickness. */
65
66 for (int _i = 0; _i < _N; _i++) /* foreach */ {
67 double hn[nl];
68 coord un[nl];
70 hn[point.l] = h[];
71 for (int _d = 0; _d < dimension; _d++)
72 un[point.l].x = h[]*u.x[];
73 }
74 for (int l = nl - 1; l >= 1; l--) {
75 double om = omr*(wmin((h[0,0,l]), hmin[l]) - wmax((h[0,0,l]), hmax[l]));
76 if (h[0,0,l] + dt*om > dry && h[0,0,l-1] - dt*om > dry) {
77 om -= oma[l]/wa[l];
78 hn[l] += dt*om;
79 hn[l - 1] -= dt*om;
80
81 /**
82 These are the entrainment and detrainment terms for the
83 velocity components in eqs. 1) and 2) of H&H, 2000. */
84
85 int lum = om >= 0 ? l - 1 : l;
86 for (int _d = 0; _d < dimension; _d++) {
87 double flux = dt*om*(u.x[0,0,lum]*(1. + Cm) - Cm*u.x[0,0,l]);
88 un[l].x += flux;
89 un[l - 1].x -= flux;
90 }
91 }
92 }
93
94 /**
95 We then update `h` and `u`. */
96
98 h[] = hn[point.l];
99 for (int _d = 0; _d < dimension; _d++)
100 u.x[] = h[] > dry ? un[point.l].x/h[] : 0.;
101 }
102 }
103}
104
105/**
106## References
107
108~~~bib
109@article{hurlburt2000,
110 title={Impact of 1/8 to 1/64 resolution on {G}ulf {S}tream model--data
111 comparisons in basin-scale subtropical {A}tlantic {O}cean models},
112 author={Hurlburt, Harley E and Hogan, Patrick J},
113 journal={Dynamics of Atmospheres and Oceans},
114 volume={32},
115 number={3-4},
116 pages={283--329},
117 year={2000},
118 publisher={Elsevier},
119 DOI={10.1016/S0377-0265(00)00050-6},
120 PDF={https://apps.dtic.mil/sti/tr/pdf/ADA531039.pdf}
121}
122~~~
123*/
#define u
Definition advection.h:30
vector un[]
Definition atmosphere.h:5
scalar hn[]
Definition atmosphere.h:6
scalar h[]
Definition atmosphere.h:6
#define dimension
Definition bitree.h:3
define l
int x
Definition common.h:76
#define dv()
Definition common.h:92
vector w[]
Point point
Definition conserving.h:86
coord o
Definition curvature.h:672
double Cm
Definition entrainment.h:15
double dt
These come from the multilayer solver.
double omr
double * hmax
Definition entrainment.h:23
#define wmax(h, hmax)
Definition entrainment.h:25
double * hmin
The maximum and minimum layer thicknesses ( and respectively in H&H, 2000) are provided by the user...
double dry
Definition entrainment.h:30
#define wmin(h, hmin)
Definition entrainment.h:24
void event_viscous_term(void)
Event: viscous_term (i++)
Definition entrainment.h:33
int nl
Definition layers.h:9
which uses a global _layer index *int _layer
Definition layers.h:15
#define foreach_layer()
def _i
Definition stencils.h:405
Definition common.h:78
scalar x
Definition common.h:47
scalar flux[]
Definition vof.h:166