Skip to content

Commit 5fd7389

Browse files
committed
Add documentation
1 parent 9f772a7 commit 5fd7389

File tree

3 files changed

+156
-18
lines changed

3 files changed

+156
-18
lines changed

doc/sphinx/source/references.bib

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ @book{hughes2012finite
6464
publisher={Courier Corporation}
6565
}
6666

67+
@article{rancic,
68+
author = {Rančić, M. and Purser, R. J. and Mesinger, F.},
69+
title = {A global shallow-water model using an expanded spherical cube: Gnomonic versus conformal coordinates},
70+
journal = {Quarterly Journal of the Royal Meteorological Society},
71+
volume = {122},
72+
pages = {959-982},
73+
doi = {10.1002/qj.49712253209},
74+
year = {1996}
75+
}
76+
6777
@article{straka1993numerical,
6878
title={Numerical solutions of a non-linear density current: A benchmark solution and comparisons},
6979
author={Straka, Jerry M and Wilhelmson, Robert B and Wicker, Louis J and Anderson, John R and Droegemeier, Kelvin K},
@@ -76,6 +86,25 @@ @article{straka1993numerical
7686
doi={10.1002/fld.1650170103}
7787
}
7888

89+
@article{taylor2010ACA,
90+
title={A compatible and conservative spectral element method on unstructured grids},
91+
author={Mark A. Taylor and Aim{\'e} Fournier},
92+
journal={J. Comput. Phys.},
93+
year={2010},
94+
volume={229},
95+
pages={5879-5895}
96+
}
97+
98+
@Article{ullrich,
99+
author = {Ullrich, P. A.},
100+
title = {A global finite-element shallow-water model supporting continuous and discontinuous elements},
101+
journal = {Geoscientific Model Development},
102+
volume = {7},
103+
year = {2014},
104+
pages = {3017--3035},
105+
doi = {10.5194/gmd-7-3017-2014}
106+
}
107+
79108
@article{williams2009roofline,
80109
title={Roofline: an insightful visual performance model for multicore architectures},
81110
author={Williams, Samuel and Waterman, Andrew and Patterson, David},

examples/fluids/index.rst

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,3 +307,103 @@ and non-penetration boundary conditions for :math:`\bm{u}`, and no-flux
307307
for mass and energy densities. This problem can be run with::
308308

309309
./navierstokes -problem density_current
310+
311+
312+
.. _example-petsc-shallow-water:
313+
314+
Shallow-water Equations mini-app
315+
========================================
316+
317+
This example is located in the subdirectory :file:`examples/fluids/shallow-water`. It solves
318+
the time-dependent shallow-water equations on a cubed-sphere. The geometry of the cubed-sphere and the relative coordinate transformations are explained in the section :ref:`example-petsc-area-sphere`. The discretization of most of the spatial differential terms needed in the shallow-water equations is already described in the section :ref:`example-petsc-bps-sphere`.
319+
320+
The mathematical formulation (from :cite:`taylor2010ACA`) is given in what
321+
follows
322+
323+
.. math::
324+
:label: eq-swe
325+
326+
\begin{aligned}
327+
\frac{\partial \bm u}{\partial t} &= - (\omega + f) \bm{\hat k} \times \bm u - \nabla \left( \frac{|\bm u|^2}{2} + g (h + h_s) \right) \\
328+
\frac{\partial h}{\partial t} &= - \nabla \cdot (H_0 + h) \bm u \, , \\
329+
\end{aligned}
330+
331+
where quantities are expressed in spherical coordinates :math:`r^1 = \lambda` for longitude, :math:`r^2 = \theta` for latitude and :math:`r^3 = r` for the radius, with associated unit vectors :math:`\bm{ \hat \lambda}`, :math:`\bm {\hat \theta}`, and :math:`\bm{\hat k}`, respectively. We consider a unit sphere, hence, :math:`r = 1` and :math:`\partial / \partial r = 0`. In equations :math:numref:`eq-swe`, :math:`\bm u` represents velocity field with longitudinal and latitudinal components :math:`\bm u = (u_{\lambda}, u_{\theta}) \equiv (u_1, u_2)`, and :math:`h` represents the height function of the fluid thickness; moreover, :math:`\omega = \nabla \times \bm u` is the vorticity, :math:`f` the Coriolis parameter such that :math:`f = 2 \bm{\Omega} \sin(\theta)` with :math:`\bm{\Omega}` Earth's rotation, :math:`g` represents the gravitational acceleration, :math:`h_s` the bottom surface (terrain) elevation, and :math:`H_0` the constant mean depth, such that the total fluid surface height is given by :math:`h_s + H_0 + h`. On the two-dimensional Riemannian manifold describing the sphere, we can use the coordinate indices :math:`x^s = {\alpha, \beta}`, so that we can express :math:`\bm u = u^{\alpha} \bm g_{\alpha} + u^{\beta} \bm g_{\beta}`, where :math:`\bm g_{\alpha} = \partial / \partial \alpha` and :math:`\bm g_{\beta} = \partial / \partial \beta` are the natural basis vectors on the manifold :cite:`ullrich,rancic`.
332+
333+
We solve equations :math:numref:`eq-swe` for the state variable :math:`\bm q = (q_1, q_2, q_3) = (\bm u, h) = (u_{\lambda}, u_{\theta}, h) \equiv (u_1, u_2, h)` with a semi-implicit time integration, for which
334+
335+
.. math::
336+
:label: eq-swe-semi-implicit
337+
338+
\bm F(t, \bm q, \bm {\dot q}) = G(t, \bm q) \, ,
339+
340+
where the time derivative :math:`\bm{\dot q}` is defined by
341+
342+
.. math::
343+
\bm{\dot q}(\bm q) = \sigma \bm q + \bm z
344+
345+
in terms of :math:`\bm z` from prior state and :math:`\sigma > 0`,
346+
both of which depend on the specific time integration scheme. We split the implicit and explicit terms as follows:
347+
348+
.. math::
349+
:label: eq-swe-implicit-part
350+
351+
\bm F(t, \bm q, \bm {\dot q}) :=
352+
\left\{
353+
\begin{array}{l}
354+
F_1 (u_{\lambda}, u_{\theta}, h) = \frac{\partial u_{\lambda}}{\partial t} + g \frac{\partial }{\partial \alpha} \left( h + h_s \right)\\
355+
F_2 (u_{\lambda}, u_{\theta}, h) = \frac{\partial u_{\theta}}{\partial t} + g \frac{\partial }{\partial \beta} \left( h + h_s \right)\\
356+
F_3 (u_{\lambda}, u_{\theta}, h) = \frac{\partial h}{\partial t} + \frac{\partial }{\partial \alpha} \left( (H_0 + h) u_{\lambda} \right) + \frac{\partial }{\partial \beta} \left( (H_0 + h) u_{\theta} \right) .
357+
\end{array}
358+
\right.
359+
360+
While for the explicit part we specify
361+
362+
.. math::
363+
:label: eq-swe-explicit-part
364+
365+
\bm G(t, \bm q) :=
366+
\left\{
367+
\begin{array}{l}
368+
G_1 (u_{\lambda}, u_{\theta}, h) = - u_{\lambda} \frac{\partial u_{\lambda}}{\partial \alpha} - u_{\theta} \frac{\partial u_{\lambda}}{\partial \beta} - f u_{\theta}\\
369+
G_2 (u_{\lambda}, u_{\theta}, h) = - u_{\lambda} \frac{\partial u_{\theta}}{\partial \alpha} - u_{\theta} \frac{\partial u_{\theta}}{\partial \beta} + f u_{\lambda}\\
370+
G_3 (u_{\lambda}, u_{\theta}, h) = 0 .
371+
\end{array}
372+
\right.
373+
374+
The differentiation of the implicit part :math:numref:`eq-swe-implicit-part` with respect to the increment :math:`\delta \bm q = (\delta \bm u, \delta h)` gives the strong form of the incremental Jacobian :math:`\partial F_i / \partial \delta q_j`, with :math:`i,j = 1,2,3`
375+
376+
.. math::
377+
:label: eq-strong-swe-Jacobian
378+
379+
\frac{\partial \bm F}{\partial \delta \bm q} :=
380+
\left(
381+
\begin{array}{ccc}
382+
\frac{\partial F_1}{\partial \delta u_{\lambda}} & \frac{\partial F_1}{\partial \delta u_{\theta}} & \frac{\partial F_1}{\partial \delta h}\\
383+
\frac{\partial F_2}{\partial \delta u_{\lambda}} & \frac{\partial F_2}{\partial \delta u_{\theta}} & \frac{\partial F_2}{\partial \delta h}\\
384+
\frac{\partial F_3}{\partial \delta u_{\lambda}} & \frac{\partial F_3}{\partial \delta u_{\theta}} & \frac{\partial F_3}{\partial \delta h}
385+
\end{array}
386+
\right)
387+
=
388+
\left(
389+
\begin{array}{ccc}
390+
0 & 0 & g \partial (\delta h) / \partial \alpha \\
391+
0 & 0 & g \partial (\delta h) / \partial \beta \\
392+
\frac{\partial ((H_0 + h) \delta u_{\lambda})}{\partial \alpha} & \frac{\partial ((H_0 + h) \delta u_{\theta})}{\partial \beta} & \frac{\partial (\delta h u_{\lambda})}{\partial \alpha} + \frac{\partial (\delta h u_{\theta})}{\partial \beta} ,
393+
\end{array}
394+
\right)
395+
396+
whose integrands of the weak form are found by multiplying each entry of :math:`\partial F_i / \partial \delta q_j` by a test function :math:`\phi \in H^1(\Omega)`
397+
and integrating by parts
398+
399+
.. math::
400+
:label: eq-weak-swe-Jacobian
401+
402+
\left(
403+
\begin{array}{ccc}
404+
0 & 0 & - g \delta h \partial \phi / \partial \alpha \\
405+
0 & 0 & - g \delta h \partial \phi / \partial \beta \\
406+
- \frac{\partial \phi}{\partial \alpha} ((H_0 + h) \delta u_{\lambda}) & - \frac{\partial \phi}{\partial \beta} ((H_0 + h) \delta u_{\theta}) & - \frac{\partial \phi}{\partial \alpha} (\delta h u_{\lambda}) - \frac{\partial \phi}{\partial \beta} (\delta h u_{\theta})
407+
\end{array}
408+
\right) .
409+

examples/fluids/shallow-water/qfunctions/shallowwater.h

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,16 @@ CEED_QFUNCTION(ICsSW)(void *ctx, CeedInt Q,
104104
// equations
105105
//
106106
// The equations represent 2D shallow-water flow on a spherical surface, where
107-
// the state variables, u_lambda, u_theta, represent the longitudinal and latitudinal components
108-
// of the velocity field, and h, represents the height function.
107+
// the state variables, u_lambda, u_theta (or u_1, u_2) represent the
108+
// longitudinal and latitudinal components of the velocity field, and h,
109+
// represents the height function.
109110
//
110-
// State variable vector: q = (u_lambda,u_theta,h)
111+
// State variable vector: q = (u_lambda, u_theta, h)
111112
//
112-
// Shallow-water Equations spatial terms of explicit function G(t,q) = (G_1(t,q), G_2(t,q)):
113-
// G_1(t,q) = - (omega + f) * khat curl u - grad(|u|^2/2)
114-
// G_2(t,q) = 0
113+
// Shallow-water Equations spatial terms of explicit function
114+
// G(t,q) = (G_1(t,q), G_2(t,q)):
115+
// G_1(t,q) = - (omega + f) * khat curl u - grad(|u|^2/2)
116+
// G_2(t,q) = 0
115117
// *****************************************************************************
116118
CEED_QFUNCTION(SWExplicit)(void *ctx, CeedInt Q, const CeedScalar *const *in,
117119
CeedScalar *const *out) {
@@ -145,10 +147,10 @@ CEED_QFUNCTION(SWExplicit)(void *ctx, CeedInt Q, const CeedScalar *const *in,
145147
q[1][i]
146148
};
147149
// *INDENT-OFF*
148-
const CeedScalar du[2][2] = {{dq[0][0][i], // du/dx
149-
dq[1][0][i]}, // du/dy
150-
{dq[0][1][i], // dv/dx
151-
dq[1][1][i]} // dv/dy
150+
const CeedScalar du[2][2] = {{dq[0][0][i], // du_1/dx
151+
dq[1][0][i]}, // du_1/dy
152+
{dq[0][1][i], // du_2/dx
153+
dq[1][1][i]} // du_2/dy
152154
};
153155
// *INDENT-ON*
154156
// Interp-to-Interp qdata
@@ -189,14 +191,18 @@ CEED_QFUNCTION(SWExplicit)(void *ctx, CeedInt Q, const CeedScalar *const *in,
189191
// equations
190192
//
191193
// The equations represent 2D shallow-water flow on a spherical surface, where
192-
// the state variables, u_lambda, u_theta, represent the longitudinal and latitudinal components
193-
// of the velocity field, and h, represents the height function.
194+
// the state variables, u_lambda, u_theta (or u_1, u_2) represent the
195+
// longitudinal and latitudinal components of the velocity field, and h,
196+
// represents the height function.
194197
//
195198
// State variable vector: q = (u_lambda, u_theta, h)
196199
//
197-
// Shallow-water Equations spatial terms of implicit function: F(t,q) = (F_1(t,q), F_2(t,q)):
198-
// F_1(t,q) = g(grad(h + h_s))
199-
// F_2(t,q) = div((h + H_0) u)
200+
// Shallow-water Equations spatial terms of implicit function:
201+
// F(t,q) = (F_1(t,q), F_2(t,q)):
202+
// F_1(t,q) = g(grad(h + h_s))
203+
// F_2(t,q) = div((h + H_0) u)
204+
//
205+
// To the spatial term F(t,q) one needs to add qdot (time derivative) on the LHS
200206
// *****************************************************************************
201207
CEED_QFUNCTION(SWImplicit)(void *ctx, CeedInt Q, const CeedScalar *const *in,
202208
CeedScalar *const *out) {
@@ -280,10 +286,13 @@ CEED_QFUNCTION(SWImplicit)(void *ctx, CeedInt Q, const CeedScalar *const *in,
280286
// equations
281287
//
282288
// The equations represent 2D shallow-water flow on a spherical surface, where
283-
// the state variables, u_lambda, u_theta, represent the longitudinal and latitudinal components
284-
// of the velocity field, and h, represents the height function.
289+
// the state variables, u_lambda, u_theta (or u_1, u_2) represent the
290+
// longitudinal and latitudinal components of the velocity field, and h,
291+
// represents the height function.
285292
//
286-
// Discrete Jacobian: dF/dq^n = sigma * dF/dqdot|q^n + dF/dq|q^n ("sigma * dF/dqdot|q^n" will be added later)
293+
// Discrete Jacobian:
294+
// dF/dq^n = sigma * dF/dqdot|q^n + dF/dq|q^n
295+
// ("sigma * dF/dqdot|q^n" will be added later)
287296
// *****************************************************************************
288297
CEED_QFUNCTION(SWJacobian)(void *ctx, CeedInt Q, const CeedScalar *const *in,
289298
CeedScalar *const *out) {

0 commit comments

Comments
 (0)