Skip to content

Commit dfc1060

Browse files
authored
Merge pull request #57 from FourierFlows/TwoModes
Two modes
2 parents b70e1ee + 8b2b6c1 commit dfc1060

21 files changed

+2232
-147
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@
55
**/*.mp4
66
**/*.DS_Store
77

8+
**/.nfs*
9+
810
docs/build/
911
docs/site/

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,27 @@ Here's an overview of the code structure:
4444
- Forward Euler
4545
- 3rd-order Adams-Bashforth (AB3)
4646
- 4th-order Runge-Kutta (RK4)
47-
- 4th-order Runge-Kutta Exponential Time Differencing
47+
- 4th-order Runge-Kutta Exponential Time Differencing (ETDRK4)
48+
- 4th-order Dual Runge-Kutta (DualRK4)
49+
- 4th-order Dual Runge-Kutta Exponential Time Differencing (DualETDRK4)
4850

4951
For each time-stepper exists also a "filtered" version that filters
50-
out high-wavenumber spectral components of the solution.
52+
out high-wavenumber spectral components of the solution. The `Dual`
53+
time-steppers evolve a state variable that comprises both of real valued
54+
and complex valued fields.
55+
5156
- `physics/`
52-
- `kuramotosivashinsky.jl`: Defines a `KuramotoSivashinsky` module that
53-
provides the one-dimensional Kuramoto-Sivashinsky equation.
5457
- `twodturb.jl`: Defines a `TwoDTurb` module that provides a
5558
solver for the two-dimensional vorticity equation.
5659
- `barotropicqg.jl`: Defines a `BarotropicQG` module that provides
5760
several solvers for the barotropic QG model that permit beta,
5861
topography, beta + topography, and forcing.
62+
- `kuramotosivashinsky.jl`: Defines a `KuramotoSivashinsky` module that
63+
solves the Kuramoto-Sivashinsky.
64+
- `verticallyfourierboussinesq.jl`: Defines a `VerticallyFourierBoussinesq` module that
65+
solves the two-mode truncation of the Fourier series thin-layer approximation to the hydrostatic Boussinesq equations.
66+
- `verticallycosinerboussinesq.jl`: Defines a `VerticallyCosineBoussinesq` module that
67+
solves the two-mode truncation of the Sin/Cos series thin-layer approximation to the hydrostatic Boussinesq equations.
5968
- `traceradvdiff.jl`: Defines a `TracerAdvDiff` module that
6069
provides a solver for a two-dimensional and periodic tracer
6170
field in a given 2D flow (u, w), which can be an arbitrary

docs/make.jl

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
using Documenter, FourierFlows
22

3-
makedocs(modules=[FourierFlows],
4-
format = :html,
5-
sitename = "FourierFlows.jl",
6-
pages = Any[
7-
"Home" => "index.md",
8-
"Modules" => Any[
9-
"modules/twodturb.md",
10-
"modules/barotropicqg.md",
11-
"modules/kuramotosivashinsky.md",
12-
"modules/traceradvdiff.md"
3+
makedocs(
4+
modules = [FourierFlows],
5+
format = :html,
6+
sitename = "FourierFlows.jl",
7+
pages = Any[
8+
"Home" => "index.md",
9+
"Modules" => Any[
10+
"modules/twodturb.md",
11+
"modules/barotropicqg.md",
12+
"modules/boussinesq.md",
13+
"modules/kuramotosivashinsky.md",
14+
"modules/traceradvdiff.md"
1315
],
14-
"DocStrings" => Any[
15-
"man/docstrings.md"
16-
]
17-
])
16+
"DocStrings" => Any["man/docstrings.md"]
17+
]
18+
)
1819

1920
deploydocs(
20-
repo = "github.com/FourierFlows/FourierFlows.jl.git",
21+
repo = "github.com/FourierFlows/FourierFlows.jl.git",
2122
target = "build",
22-
julia = "0.6.2",
23+
julia = "0.6.2",
2324
osname = "linux",
24-
deps = nothing,
25-
make = nothing
25+
deps = nothing,
26+
make = nothing
2627
)

docs/src/index.md

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,18 @@ Here's an overview of the code structure:
5555
- Includes all sources files and physics files.
5656
- `timesteppers.jl`: defines modules and `stepforward!` routines for
5757
various time-steppers. Current implemented time-steppers are:
58-
- Forward Euler (+ Filtered Forward Euler)
58+
- Forward Euler
5959
- 3rd-order Adams-Bashforth (AB3)
60-
- 4th-order Runge-Kutta (RK4) (+ Filtered RK4)
60+
- 4th-order Runge-Kutta (RK4)
6161
- 4th-order Runge-Kutta Exponential Time Differencing (ETDRK4)
62-
(+ Filtered ETDRK4)
62+
- 4th-order Dual Runge-Kutta (DualRK4)
63+
- 4th-order Dual Runge-Kutta Exponential Time Differencing (DualETDRK4)
64+
65+
For each time-stepper exists also a "filtered" version that filters
66+
out high-wavenumber spectral components of the solution. The `Dual`
67+
time-steppers evolve a state variable that comprises both of real valued
68+
and complex valued fields.
69+
6370
- `physics/`
6471
- `twodturb.jl`: Defines a `TwoDTurb` module that provides a
6572
solver for the two-dimensional vorticity equation.
@@ -68,6 +75,10 @@ Here's an overview of the code structure:
6875
topography, beta + topography, and forcing.
6976
- `kuramotosivashinsky.jl`: Defines a `KuramotoSivashinsky` module that
7077
solves the Kuramoto-Sivashinsky.
78+
- `verticallyfourierboussinesq.jl`: Defines a `VerticallyFourierBoussinesq` module that
79+
solves the two-mode truncation of the Fourier series thin-layer approximation to the hydrostatic Boussinesq equations.
80+
- `verticallycosinerboussinesq.jl`: Defines a `VerticallyCosineBoussinesq` module that
81+
solves the two-mode truncation of the Sin/Cos series thin-layer approximation to the hydrostatic Boussinesq equations.
7182
- `traceradvdiff.jl`: Defines a `TracerAdvDiff` module that
7283
provides a solver for a two-dimensional and periodic tracer
7384
field in a given 2D flow (u, w), which can be an arbitrary
@@ -116,20 +127,25 @@ is to permit the use of shared memory parallelism in the compute-intensive
116127
routines (shared-memory parallelism provided already by FFTW/MKLFFT, but
117128
is not yet native to Julia for things like element-wise matrix multiplication,
118129
addition, and assignment). This feature may possibly be enabled by
119-
Intel Lab's
120-
[ParallelAccelerator](https://github.com/IntelLabs/ParallelAccelerator.jl)
130+
Intel Lab's [ParallelAccelerator](https://github.com/IntelLabs/ParallelAccelerator.jl)
121131
package.
122132

133+
123134
## Developers
124135

125-
FourierFlows is currently being developed by [Gregory L. Wagner](https://glwagner.github.io) and [Navid C. Constantinou](http://www.navidconstantinou.com).
136+
FourierFlows is currently being developed by [Gregory L. Wagner](https://glwagner.github.io) and
137+
[Navid C. Constantinou](http://www.navidconstantinou.com).
138+
126139

127140
## DocStrings
128141

129142
```@contents
130143
Pages = [
131144
"modules/twodturb.md",
132145
"modules/barotropicqg.md",
146+
"modules/boussinesq.md",
147+
"modules/kuramotosivashinsky.md",
148+
"modules/traceradvdiff.md",
133149
"man/docstrings.md",
134150
]
135151
Depth = 2
@@ -140,9 +156,10 @@ Depth = 2
140156
```@index
141157
Pages = [
142158
"modules/twodturb.md",
143-
"modules/barotropicqg.md"
144-
"modules/kuramotosivashinsky.md"
145-
"modules/traceradvdiff.md"
159+
"modules/barotropicqg.md",
160+
"modules/boussinesq.md",
161+
"modules/kuramotosivashinsky.md",
162+
"modules/traceradvdiff.md",
146163
"man/docstrings.md",
147164
]
148165
```

docs/src/modules/barotropicqg.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# BarotropicQG Module
22

3+
```math
4+
\newcommand{\J}{\mathsf{J}}
5+
```
6+
7+
### Basic Equations
8+
39
This module solves the quasi-geostrophic barotropic vorticity equation on a
410
beta-plane of variable fluid depth $H-h(x,y)$. The flow is obtained through a
511
streamfunction $\psi$ as $(u, \upsilon) = (-\partial_y\psi, \partial_x\psi)$. All flow
@@ -15,22 +21,23 @@ the plane of motion, $\zeta\equiv \partial_x \upsilon- \partial_y u = \nabla^2\p
1521
Also, we denote the topographic PV with $\eta\equiv f_0 h/H$. Thus, the
1622
equation solved by the module is:
1723

18-
$$\partial_t \zeta + J(\psi, \underbrace{\zeta + \eta}_{\equiv q}) +
24+
$$\partial_t \zeta + \J(\psi, \underbrace{\zeta + \eta}_{\equiv q}) +
1925
\beta\partial_x\psi = \underbrace{-\left[\mu + \nu(-1)^{n_\nu} \nabla^{2n_\nu}
2026
\right] \zeta }_{\textrm{dissipation}} + f\ .$$
2127

22-
where $J(f,g) = (\partial_xf)(\partial_y g)-(\partial_x g)(\partial_y f)$. On
28+
where $\J(a, b) = (\partial_x a)(\partial_y b)-(\partial_y a)(\partial_x b)$. On
2329
the right hand side, $f(x,y,t)$ is forcing, $\mu$ is linear drag, and $\nu$ is
2430
hyperviscosity. Plain old viscosity corresponds to $n_{\nu}=1$. The sum of
2531
relative vorticity and topographic PV is denoted with $q\equiv\zeta+\eta$.
2632

33+
### Implementation
2734

2835
The equation is time-stepped forward in Fourier space:
2936

30-
$$\partial_t \widehat{\zeta} = - \widehat{J(\psi, q)} +\beta\frac{\mathrm{i}k_x}{k^2}\widehat{\zeta} -\left(\mu
37+
$$\partial_t \widehat{\zeta} = - \widehat{\J(\psi, q)} +\beta\frac{\mathrm{i}k_x}{k^2}\widehat{\zeta} -\left(\mu
3138
+\nu k^{2n_\nu}\right) \widehat{\zeta} + \widehat{f}\ .$$
3239

33-
In doing so the Jacobian is computed in the conservative form: $J(f,g) =
40+
In doing so the Jacobian is computed in the conservative form: $\J(f,g) =
3441
\partial_y [ (\partial_x f) g] -\partial_x[ (\partial_y f) g]$.
3542

3643
Thus:

docs/src/modules/boussinesq.md

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
# Thin-layer Boussinesq modules
2+
3+
```math
4+
\newcommand{\bcdot}{\boldsymbol \cdot}
5+
\newcommand{\bnabla}{\boldsymbol \nabla}
6+
\newcommand{\pnabla}{\bnabla_{\! \perp}}
7+
8+
\newcommand{\com}{\, ,}
9+
\newcommand{\per}{\, .}
10+
11+
\newcommand{\bu}{\boldsymbol u}
12+
\newcommand{\bU}{\boldsymbol U}
13+
\newcommand{\buu}{{\boldsymbol{u}}}
14+
\newcommand{\bb}{{b}}
15+
\newcommand{\pp}{{p}}
16+
\newcommand{\ww}{{w}}
17+
\newcommand{\uu}{{u}}
18+
\newcommand{\v}{\upsilon}
19+
\newcommand{\vv}{{\upsilon}}
20+
\newcommand{\zzeta}{{\zeta}}
21+
\newcommand{\oomega}{{\omega}}
22+
\newcommand{\boomega}{\boldsymbol{\oomega}}
23+
24+
\newcommand{\bxh}{\widehat{\boldsymbol{x}}}
25+
\newcommand{\byh}{\widehat{\boldsymbol{y}}}
26+
\newcommand{\bzh}{\widehat{\boldsymbol{z}}}
27+
\newcommand{\ii}{\mathrm{i}}
28+
\newcommand{\ee}{\mathrm{e}}
29+
\newcommand{\cc}{\mathrm{c.c.}}
30+
\newcommand{\J}{\mathsf{J}}
31+
32+
\newcommand{\p}{\partial}
33+
```
34+
35+
These modules solve various thin-layer approximations to the hydrostatic Boussinesq
36+
equations. A thin-layer approximation is one that is appropriate for dynamics with
37+
small aspect ratios, or small vertical scales and large horizontal scales.
38+
Thin layer approximations include the shallow-water system, layered system, and
39+
spectral approximations that apply a Fourier or Sin/Cos eigenfunction expansion in the
40+
vertical coordinate to the Boussinesq equations, and truncate the expansion at just
41+
two or three modes. Approximations of this last flavor are described here.
42+
43+
The three-dimensional rotating, stratified, hydrostatic Boussinesq equations are
44+
45+
```math
46+
\p_t\buu + \left ( \buu \bcdot \bnabla \right ) \buu + f \bzh \times \buu + \bnabla \pp = D^{\buu} \com \\
47+
\p_z \pp = \bb \com \\
48+
\p_t\bb + \ww N^2 = D^\bb \com \\
49+
\bnabla \bcdot \buu = 0 \com
50+
```
51+
52+
where $\bu = (u, \v, w)$ is the three-dimensional velocity, $b$ is buoyancy, $p$ is pressure, $N^2$ is the
53+
buoyancy frequency (constant), and $f$ is the rotation or Coriolis frequency. The operators $D^{\buu}$ and $D^{\bb}$ are arbitrary dissipation that we define only after projecting onto vertical Fourier or Sin/Cos modes.
54+
Taking the curl of the horizontal momentum equation yields an evolution
55+
equation for vertical vorticity, $\zzeta = \p_x \vv - \p_y \uu$:
56+
57+
```math
58+
\p_t\zzeta + \buu \bcdot \bnabla \zzeta - \left (f \bzh + \boomega \right )
59+
\bcdot \bnabla \ww = D^{\zzeta} \per
60+
```
61+
62+
## Vertically Fourier Boussinesq
63+
64+
The vertically-Fourier Boussinesq module solves the Boussinesq system obtained by expanding the hydrostatic
65+
Boussinesq equations in a Fourier series. The horizontal velocity $\uu$, for example, is expanded with
66+
67+
```math
68+
\uu(x, y, z, t) \mapsto U(x, y, t) + \ee^{\ii m z} u(x, y, t) + \ee^{-\ii m z} u^*(x, y, t) \com
69+
```
70+
71+
The other variables $\vv$, $\bb$, $\pp$, $\zzeta$, and $\boomega$ are expanded identically. The barotropic
72+
horizontal velocity is $V$ and the barotropic vertical vorticity is $Z = \p_x V - \p_y U$. The barotropic
73+
vorticity obeys
74+
```math
75+
\p_t Z + \J \left ( \Psi, Z \right )
76+
+ \bnabla \bcdot \left ( \bu \zeta^* \right ) + \ii m \pnabla \bcdot \left ( \bu w^* \right ) + \cc
77+
= D_0 Z \com
78+
```
79+
80+
where $\cc$ denotes the complex conjugate and contraction with $\pnabla = -\p_y \bxh + \p_x \byh$
81+
gives the vertical component of the curl.
82+
83+
The baroclinic components obey
84+
85+
```math
86+
\p_t u - f \v + \p_x p = - \J \left ( \Psi, u \right ) - \bu \bcdot \bnabla U + D_1 u \com \\
87+
\p_t \v + f u + \p_y p = - \J \left ( \Psi, \v \right ) - \bu \bcdot \bnabla V + D_1 \v \com \\
88+
\p_t p - \tfrac{N^2}{m} w = - \J \left ( \Psi, p \right ) + D_1 p \per
89+
```
90+
91+
The dissipation operators are defined
92+
93+
```math
94+
D_0 = \nu_0 (-1)^{n_0} \nabla^{2n_0} + \mu_0 (-1)^{m_0} \nabla^{2m_0} \com \\
95+
D_1 = \nu_1 (-1)^{n_1} \nabla^{2n_1} + \mu_1 (-1)^{m_1} \nabla^{2m_1}
96+
```
97+
98+
where $U$ is the barotropic velocity and $u$ is the amplitude of the first baroclinic mode with periodic
99+
vertical structure $\mathrm{e}^{\mathrm{i} m z}$.
100+
101+
### Implementation
102+
103+
Coming soon.
104+
105+
106+
## Vertically Cosine Boussinesq
107+
108+
The vertically-Cosine Boussinesq module solves the Boussinesq system obtained by expanding the
109+
hydrostatic Boussinesq equations in a Sin/Cos series. The horizontal velocity, for example, becomes
110+
111+
```math
112+
\uu(x, y, z, t) \mapsto U(x, y, t) + \cos(mz) u(x, y, t) \per
113+
```
114+
115+
The horizontal velocity $\vv$, pressure $\pp$, and vertical vorticity $\zzeta$ are also expanded in $\cos(mz)$,
116+
where $Z = \p_x V - \p_y U$ denotes the barotropic component of the vertical vorticity. The vertical velocity $\ww$
117+
and buoyancy $\bb$ are expanded with $\sin(mz)$.
118+
119+
### Basic governing equations
120+
121+
Projecting the vertical vorticity equation onto Sin/Cos modes an equation for the evolution of $Z$,
122+
123+
```math
124+
\p_t Z + \J \left ( \Psi, Z \right )
125+
+ \tfrac{1}{2} \bnabla \bcdot \left ( \bu \zeta \right ) + \tfrac{m}{2} \pnabla \bcdot \left ( \bu w \right )
126+
= D_0 Z \com
127+
```
128+
129+
where $\J(a, b) = (\p_x a)(\p_y b) - (\p_y a)(\p_x b)$ is the Jacobian operator, contraction with $\pnabla = -\p_y \bxh + \p_x \byh$ gives the vertical component of the curl, and $\Psi$ is the barotropic streamfunction defined so that
130+
131+
```math
132+
\bU = -\p_y\Psi \bxh + \p_x\Psi \byh \qquad \text{and} \qquad Z = \nabla^2 \Psi \per
133+
```
134+
135+
The baroclinic components obey
136+
137+
```math
138+
\p_t u - f \v + \p_x p = - \J \left ( \Psi, u \right ) - \bu \bcdot \bnabla U + D_1u \com \\
139+
\p_t \v + f u + \p_y p = - \J \left ( \Psi, \v \right ) - \bu \bcdot \bnabla V + D_1\v \com \\
140+
\p_t p - \tfrac{N^2}{m} w = - \J \left ( \Psi, p \right ) + D_1p \per
141+
```
142+
143+
The dissipation operators are defined
144+
145+
```math
146+
D_0 = \nu_0 (-1)^{n_0} \nabla^{2n_0} + \mu_0 (-1)^{m_0} \nabla^{2m_0} \com \\
147+
D_1 = \nu_1 (-1)^{n_1} \nabla^{2n_1} + \mu_1 (-1)^{m_1} \nabla^{2m_1} \com
148+
```
149+
150+
where $2n_0$ and $2m_0$ are the hyperviscous orders of the arbitrary barotropic dissipation operators
151+
with coefficients $\nu_0$ and $\mu_0$, while $2n_1$ and $2m_1$ are the orders of the baroclinic
152+
dissipation operators.
153+
154+
A passive tracer in the Vertically Cosine Boussinesq system is assumed to satisfy a no-flux condition
155+
at the upper and lower boundaries, and thus expanded in cosine modes so that
156+
157+
```math
158+
c(x, y, z, t) = C(x, y, t) + \cos(mz) c(x, y, t) \per
159+
```
160+
161+
The barotropic and baroclinic passive tracer components then obey
162+
163+
```math
164+
\p_t C + \J(\Psi, C) + \tfrac{1}{2} \bnabla \bcdot \left ( \bu c \right ) =
165+
\kappa (-1)^{n_{\kappa}} \nabla^{2{n_{\kappa}}} C \com \\
166+
\p_t c + \J(\Psi, c) + \bu \bcdot \bnabla C = \kappa (-1)^{n_{\kappa}} \nabla^{2{n_{\kappa}}} c \com
167+
```
168+
169+
where $\kappa$ and $n_{\kappa}$ are the tracer hyperdiffusivity and order of the hyperdiffusivity, respectively.
170+
The choice $n_{\kappa} = 1$ corresponds to ordinary Fickian diffusivity.
171+
172+
### Implementation
173+
174+
Coming soon.

docs/src/modules/kuramotosivashinsky.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
# Kuramoto-Sivashinsky Module
22

3+
### Basic Equations
4+
35
This module solves the Kuramoto-Sivashinsky equation for $u(x,t)$:
46

57
$$\partial_t u + \partial_x^4 u + \partial_x^2 u + u\partial_x u = 0\ .$$
68

9+
### Implementation
10+
711
The equation is time-stepped forward in Fourier space:
812

913
$$\partial_t \widehat{u} + k_x^4 \widehat{u} - k_x^2 \widehat{u} + \widehat{ u\partial_x u } = 0\ .$$

0 commit comments

Comments
 (0)