xref: /libCEED/examples/fluids/README.md (revision 81f92cf0318b9f3402d1efd37c448462967c3131)
1ccaff030SJeremy L Thompson## libCEED: Navier-Stokes Example
2ccaff030SJeremy L Thompson
3ccaff030SJeremy L ThompsonThis page provides a description of the Navier-Stokes example for the libCEED library, based on PETSc.
4ccaff030SJeremy L Thompson
5ccaff030SJeremy L ThompsonThe Navier-Stokes problem solves the compressible Navier-Stokes equations in three dimensions using an
6ccaff030SJeremy L Thompsonexplicit time integration. The state variables are mass density, momentum density, and energy density.
7ccaff030SJeremy L Thompson
8ccaff030SJeremy L ThompsonThe main Navier-Stokes solver for libCEED is defined in [`navierstokes.c`](navierstokes.c)
9ccaff030SJeremy L Thompsonwith different problem definitions according to the application of interest.
10ccaff030SJeremy L Thompson
11ccaff030SJeremy L ThompsonBuild by using
12ccaff030SJeremy L Thompson
13ccaff030SJeremy L Thompson`make`
14ccaff030SJeremy L Thompson
15ccaff030SJeremy L Thompsonand run with
16ccaff030SJeremy L Thompson
17ff6701fcSJed Brown`./navierstokes`
18ccaff030SJeremy L Thompson
19ccaff030SJeremy L ThompsonAvailable runtime options are:
20ccaff030SJeremy L Thompson
21ccaff030SJeremy L Thompson|  Option                               | Meaning                                                                                         |
22*81f92cf0SLeila Ghaffari| :-------------------------------------| :-----------------------------------------------------------------------------------------------|
23ccaff030SJeremy L Thompson| `-ceed`                               | CEED resource specifier                                                                         |
24ccaff030SJeremy L Thompson| `-test`                               | Run in test mode                                                                                |
25ccaff030SJeremy L Thompson| `-problem`                            | Problem to solve (`advection`, `advection2d`, or `density_current`)                             |
26*81f92cf0SLeila Ghaffari| `-problem_advection_wind`             | Wind type in Advection (`rotation` or `translation`)                                            |
27*81f92cf0SLeila Ghaffari| `-problem_advection_wind_translation` | Constant wind vector when `-problem_advection_wind translation`                                 |
28ccaff030SJeremy L Thompson| `-stab`                               | Stabilization method                                                                            |
29ccaff030SJeremy L Thompson| `-implicit`                           | Use implicit time integartor formulation                                                        |
30ccaff030SJeremy L Thompson| `-bc_wall`                            | Use wall boundary conditions on this list of faces                                              |
31ccaff030SJeremy L Thompson| `-bc_slip_x`                          | Use slip boundary conditions, for the x component, on this list of faces                        |
32ccaff030SJeremy L Thompson| `-bc_slip_y`                          | Use slip boundary conditions, for the y component, on this list of faces                        |
33ccaff030SJeremy L Thompson| `-bc_slip_z`                          | Use slip boundary conditions, for the z component, on this list of faces                        |
34ccaff030SJeremy L Thompson| `-viz_refine`                         | Use regular refinement for visualization                                                        |
35ff6701fcSJed Brown| `-degree`                             | Polynomial degree of tensor product basis (must be >= 1)                                        |
36ccaff030SJeremy L Thompson| `-units_meter`                        | 1 meter in scaled length units                                                                  |
37ccaff030SJeremy L Thompson| `-units_second`                       | 1 second in scaled time units                                                                   |
38ccaff030SJeremy L Thompson| `-units_kilogram`                     | 1 kilogram in scaled mass units                                                                 |
39ccaff030SJeremy L Thompson| `-units_Kelvin`                       | 1 Kelvin in scaled temperature units                                                            |
40ccaff030SJeremy L Thompson| `-theta0`                             | Reference potential temperature                                                                 |
41ccaff030SJeremy L Thompson| `-thetaC`                             | Perturbation of potential temperature                                                           |
42ccaff030SJeremy L Thompson| `-P0`                                 | Atmospheric pressure                                                                            |
43*81f92cf0SLeila Ghaffari| `-P_wind`                             | Inflow wind pressure                                                                            |
44*81f92cf0SLeila Ghaffari| `-rho_wind`                           | Inflow wind density                                                                            |
45ccaff030SJeremy L Thompson| `-N`                                  | Brunt-Vaisala frequency                                                                         |
46ccaff030SJeremy L Thompson| `-cv`                                 | Heat capacity at constant volume                                                                |
47ccaff030SJeremy L Thompson| `-cp`                                 | Heat capacity at constant pressure                                                              |
48ccaff030SJeremy L Thompson| `-g`                                  | Gravitational acceleration                                                                      |
49ccaff030SJeremy L Thompson| `-lambda`                             | Stokes hypothesis second viscosity coefficient                                                  |
50ccaff030SJeremy L Thompson| `-mu`                                 | Shear dynamic viscosity coefficient                                                             |
51ccaff030SJeremy L Thompson| `-k`                                  | Thermal conductivity                                                                            |
52ccaff030SJeremy L Thompson| `-CtauS`                              | Scale coefficient for stabilization tau (nondimensional)                                        |
53ccaff030SJeremy L Thompson| `-strong_form`                        | Strong (1) or weak/integrated by parts (0) advection residual                                   |
54ccaff030SJeremy L Thompson| `-lx`                                 | Length scale in x direction                                                                     |
55ccaff030SJeremy L Thompson| `-ly`                                 | Length scale in y direction                                                                     |
56ccaff030SJeremy L Thompson| `-lz`                                 | Length scale in z direction                                                                     |
57ccaff030SJeremy L Thompson| `-rc`                                 | Characteristic radius of thermal bubble                                                         |
58ccaff030SJeremy L Thompson| `-resx`                               | Resolution in x                                                                                 |
59ccaff030SJeremy L Thompson| `-resy`                               | Resolution in y                                                                                 |
60ccaff030SJeremy L Thompson| `-resz`                               | Resolution in z                                                                                 |
61ccaff030SJeremy L Thompson| `-center`                             | Location of bubble center                                                                       |
62ccaff030SJeremy L Thompson| `-dc_axis`                            | Axis of density current cylindrical anomaly, or {0,0,0} for spherically symmetric               |
63ccaff030SJeremy L Thompson| `-output_freq`                        | Frequency of output, in number of steps                                                         |
64ccaff030SJeremy L Thompson| `-continue`                           | Continue from previous solution                                                                 |
65ccaff030SJeremy L Thompson| `-degree`                             | Polynomial degree of tensor product basis                                                       |
66ccaff030SJeremy L Thompson| `-qextra`                             | Number of extra quadrature points                                                               |
67*81f92cf0SLeila Ghaffari| `-qextra_boundary`                    | Number of extra quadrature points on in/outflow faces                                           |
68ccaff030SJeremy L Thompson| `-of`                                 | Output folder                                                                                   |
69ccaff030SJeremy L Thompson
70c063f476SvaleriabarraFor the case of a square/cubic mesh, the list of face indices to be used with `-bc_wall` and/or `-bc_slip_x`,
71ed1c75c9SLeila Ghaffari`-bc_slip_y`, and `-bc_slip_z` are:
72c063f476Svaleriabarra
73c063f476Svaleriabarra* 2D:
74c063f476Svaleriabarra  - faceMarkerBottom = 1;
75c063f476Svaleriabarra  - faceMarkerRight  = 2;
76c063f476Svaleriabarra  - faceMarkerTop    = 3;
77c063f476Svaleriabarra  - faceMarkerLeft   = 4;
78c063f476Svaleriabarra* 3D:
79c063f476Svaleriabarra  - faceMarkerBottom = 1;
80c063f476Svaleriabarra  - faceMarkerTop    = 2;
81c063f476Svaleriabarra  - faceMarkerFront  = 3;
82c063f476Svaleriabarra  - faceMarkerBack   = 4;
83c063f476Svaleriabarra  - faceMarkerRight  = 5;
84c063f476Svaleriabarra  - faceMarkerLeft   = 6;
85ccaff030SJeremy L Thompson
86ccaff030SJeremy L Thompson### Advection
87ccaff030SJeremy L Thompson
88ccaff030SJeremy L ThompsonThis problem solves the convection (advection) equation for the total (scalar) energy density,
89ccaff030SJeremy L Thompsontransported by the (vector) velocity field.
90ccaff030SJeremy L Thompson
91ccaff030SJeremy L ThompsonThis is 3D advection given in two formulations based upon the weak form.
92ccaff030SJeremy L Thompson
93ccaff030SJeremy L ThompsonState Variables:
94ccaff030SJeremy L Thompson
95ccaff030SJeremy L Thompson   *q = ( rho, U<sub>1</sub>, U<sub>2</sub>, U<sub>3</sub>, E )*
96ccaff030SJeremy L Thompson
97ccaff030SJeremy L Thompson   *rho* - Mass Density
98ccaff030SJeremy L Thompson
99ccaff030SJeremy L Thompson   *U<sub>i</sub>*  - Momentum Density    ,   *U<sub>i</sub> = rho ui*
100ccaff030SJeremy L Thompson
101ccaff030SJeremy L Thompson   *E*   - Total Energy Density,   *E  = rho Cv T + rho (u u) / 2 + rho g z*
102ccaff030SJeremy L Thompson
103ccaff030SJeremy L ThompsonAdvection Equation:
104ccaff030SJeremy L Thompson
105ccaff030SJeremy L Thompson   *dE/dt + div( E _u_ ) = 0*
106ccaff030SJeremy L Thompson
107ccaff030SJeremy L Thompson#### Initial Conditions
108ccaff030SJeremy L Thompson
109ccaff030SJeremy L ThompsonMass Density:
110ccaff030SJeremy L Thompson    Constant mass density of 1.0
111ccaff030SJeremy L Thompson
112ccaff030SJeremy L ThompsonMomentum Density:
113ccaff030SJeremy L Thompson    Rotational field in x,y with no momentum in z
114ccaff030SJeremy L Thompson
115ccaff030SJeremy L ThompsonEnergy Density:
116ccaff030SJeremy L Thompson    Maximum of 1. x0 decreasing linearly to 0. as radial distance increases
117ccaff030SJeremy L Thompson    to 1/8, then 0. everywhere else
118ccaff030SJeremy L Thompson
119ccaff030SJeremy L Thompson#### Boundary Conditions
120ccaff030SJeremy L Thompson
121ccaff030SJeremy L ThompsonMass Density:
122ccaff030SJeremy L Thompson    0.0 flux
123ccaff030SJeremy L Thompson
124ccaff030SJeremy L ThompsonMomentum Density:
125ccaff030SJeremy L Thompson    0.0
126ccaff030SJeremy L Thompson
127ccaff030SJeremy L ThompsonEnergy Density:
128ccaff030SJeremy L Thompson    0.0 flux
129ccaff030SJeremy L Thompson
130ccaff030SJeremy L Thompson### Density Current
131ccaff030SJeremy L Thompson
132ccaff030SJeremy L ThompsonThis problem solves the full compressible Navier-Stokes equations, using
133ccaff030SJeremy L Thompsonoperator composition and design of coupled solvers in the context of atmospheric
134ccaff030SJeremy L Thompsonmodeling. This problem uses the formulation given in Semi-Implicit Formulations
135ccaff030SJeremy L Thompsonof the Navier-Stokes Equations: Application to Nonhydrostatic Atmospheric Modeling,
136ccaff030SJeremy L ThompsonGiraldo, Restelli, and Lauter (2010).
137ccaff030SJeremy L Thompson
138ccaff030SJeremy L ThompsonThe 3D compressible Navier-Stokes equations are formulated in conservation form with state
139ccaff030SJeremy L Thompsonvariables of density, momentum density, and total energy density.
140ccaff030SJeremy L Thompson
141ccaff030SJeremy L ThompsonState Variables:
142ccaff030SJeremy L Thompson
143ccaff030SJeremy L Thompson   *q = ( rho, U<sub>1</sub>, U<sub>2</sub>, U<sub>3</sub>, E )*
144ccaff030SJeremy L Thompson
145ccaff030SJeremy L Thompson   *rho* - Mass Density
146ccaff030SJeremy L Thompson
147ccaff030SJeremy L Thompson   *U<sub>i</sub>*  - Momentum Density   ,  *U<sub>i</sub> = rho u<sub>i</sub>*
148ccaff030SJeremy L Thompson
149ccaff030SJeremy L Thompson   *E*   - Total Energy Density,  *E  = rho c<sub>v</sub> T + rho (u u) / 2 + rho g z*
150ccaff030SJeremy L Thompson
151ccaff030SJeremy L ThompsonNavier-Stokes Equations:
152ccaff030SJeremy L Thompson
153ccaff030SJeremy L Thompson   *drho/dt + div( U )                               = 0*
154ccaff030SJeremy L Thompson
155ccaff030SJeremy L Thompson   *dU/dt   + div( rho (u x u) + P I<sub>3</sub> ) + rho g khat = div( F<sub>u</sub> )*
156ccaff030SJeremy L Thompson
157ccaff030SJeremy L Thompson   *dE/dt   + div( (E + P) u )                       = div( F<sub>e</sub> )*
158ccaff030SJeremy L Thompson
159ccaff030SJeremy L ThompsonViscous Stress:
160ccaff030SJeremy L Thompson
161ccaff030SJeremy L Thompson   *F<sub>u</sub> = mu (grad( u ) + grad( u )^T + lambda div ( u ) I<sub>3</sub>)*
162ccaff030SJeremy L Thompson
163ccaff030SJeremy L ThompsonThermal Stress:
164ccaff030SJeremy L Thompson
165ccaff030SJeremy L Thompson   *F<sub>e</sub> = u F<sub>u</sub> + k grad( T )*
166ccaff030SJeremy L Thompson
167ccaff030SJeremy L ThompsonEquation of State:
168ccaff030SJeremy L Thompson
169ccaff030SJeremy L Thompson   *P = (gamma - 1) (E - rho (u u) / 2 - rho g z)*
170ccaff030SJeremy L Thompson
171ccaff030SJeremy L ThompsonTemperature:
172ccaff030SJeremy L Thompson
173ccaff030SJeremy L Thompson   *T = (E / rho - (u u) / 2 - g z) / c<sub>v</sub>*
174ccaff030SJeremy L Thompson
175ccaff030SJeremy L ThompsonConstants:
176ccaff030SJeremy L Thompson
177ccaff030SJeremy L Thompson   *lambda = - 2 / 3*,  From Stokes hypothesis
178ccaff030SJeremy L Thompson
179ccaff030SJeremy L Thompson   *mu*              ,  Dynamic viscosity
180ccaff030SJeremy L Thompson
181ccaff030SJeremy L Thompson   *k*               ,  Thermal conductivity
182ccaff030SJeremy L Thompson
183ccaff030SJeremy L Thompson   *c<sub>v</sub>*              ,  Specific heat, constant volume
184ccaff030SJeremy L Thompson
185ccaff030SJeremy L Thompson   *c<sub>p</sub>*              ,  Specific heat, constant pressure
186ccaff030SJeremy L Thompson
187ccaff030SJeremy L Thompson   *g*               ,  Gravity
188ccaff030SJeremy L Thompson
189ccaff030SJeremy L Thompson   *gamma  = c<sub>p</sub> / c<sub>v</sub>*,  Specific heat ratio
190ccaff030SJeremy L Thompson
191ccaff030SJeremy L Thompson#### Initial Conditions
192ccaff030SJeremy L Thompson
193ccaff030SJeremy L ThompsonPotential Temperature:
194ccaff030SJeremy L Thompson
195ccaff030SJeremy L Thompson   *theta = thetabar + deltatheta*
196ccaff030SJeremy L Thompson
197ccaff030SJeremy L Thompson   *thetabar   = theta0 exp( N * * 2 z / g )*
198ccaff030SJeremy L Thompson
199ccaff030SJeremy L Thompson   *deltatheta =
200ccaff030SJeremy L Thompson        r <= rc : theta0(1 + cos(pi r)) / 2
201ccaff030SJeremy L Thompson        r > rc : 0*
202ccaff030SJeremy L Thompson
203ccaff030SJeremy L Thompson   *r        = sqrt( (x - xc) * * 2 + (y - yc) * * 2 + (z - zc) * * 2 )*
204ccaff030SJeremy L Thompson    with *(xc,yc,zc)* center of domain
205ccaff030SJeremy L Thompson
206ccaff030SJeremy L ThompsonExner Pressure:
207ccaff030SJeremy L Thompson
208ccaff030SJeremy L Thompson   *Pi = Pibar + deltaPi*
209ccaff030SJeremy L Thompson
210ccaff030SJeremy L Thompson   *Pibar      = g * * 2 (exp( - N * * 2 z / g ) - 1) / (cp theta0 N * * 2)*
211ccaff030SJeremy L Thompson
212ccaff030SJeremy L Thompson   *deltaPi    = 0* (hydrostatic balance)
213ccaff030SJeremy L Thompson
214ccaff030SJeremy L ThompsonVelocity/Momentum Density:
215ccaff030SJeremy L Thompson
216ccaff030SJeremy L Thompson   *U<sub>i</sub> = u<sub>i</sub> = 0*
217ccaff030SJeremy L Thompson
218ccaff030SJeremy L ThompsonConversion to Conserved Variables:
219ccaff030SJeremy L Thompson
220ccaff030SJeremy L Thompson   *rho = P0 Pi**(c<sub>v</sub>/R<sub>d</sub>) / (R<sub>d</sub> theta)*
221ccaff030SJeremy L Thompson
222ccaff030SJeremy L Thompson   *E   = rho (c<sub>v</sub> theta Pi + (u u)/2 + g z)*
223ccaff030SJeremy L Thompson
224ccaff030SJeremy L ThompsonConstants:
225ccaff030SJeremy L Thompson
226ccaff030SJeremy L Thompson   *theta0*          ,  Potential temperature constant
227ccaff030SJeremy L Thompson
228ccaff030SJeremy L Thompson   *thetaC*          ,  Potential temperature perturbation
229ccaff030SJeremy L Thompson
230ccaff030SJeremy L Thompson   *P0*              ,  Pressure at the surface
231ccaff030SJeremy L Thompson
232ccaff030SJeremy L Thompson   *N*               ,  Brunt-Vaisala frequency
233ccaff030SJeremy L Thompson
234ccaff030SJeremy L Thompson   *c<sub>v</sub>*              ,  Specific heat, constant volume
235ccaff030SJeremy L Thompson
236ccaff030SJeremy L Thompson   *c<sub>p</sub>*              ,  Specific heat, constant pressure
237ccaff030SJeremy L Thompson
238ccaff030SJeremy L Thompson   *R<sub>d</sub>*     = c<sub>p</sub> - c<sub>v</sub>,  Specific heat difference
239ccaff030SJeremy L Thompson
240ccaff030SJeremy L Thompson   *g*               ,  Gravity
241ccaff030SJeremy L Thompson
242ccaff030SJeremy L Thompson   *r<sub>c</sub>*              ,  Characteristic radius of thermal bubble
243ccaff030SJeremy L Thompson
244ccaff030SJeremy L Thompson   *l<sub>x</sub>*              ,  Characteristic length scale of domain in x
245ccaff030SJeremy L Thompson
246ccaff030SJeremy L Thompson   *l<sub>y</sub>*              ,  Characteristic length scale of domain in y
247ccaff030SJeremy L Thompson
248ccaff030SJeremy L Thompson   *l<sub>z</sub>*              ,  Characteristic length scale of domain in z
249ccaff030SJeremy L Thompson
250ccaff030SJeremy L Thompson
251ccaff030SJeremy L Thompson#### Boundary Conditions
252ccaff030SJeremy L Thompson
253ccaff030SJeremy L ThompsonMass Density:
254ccaff030SJeremy L Thompson    0.0 flux
255ccaff030SJeremy L Thompson
256ccaff030SJeremy L ThompsonMomentum Density:
257ccaff030SJeremy L Thompson    0.0
258ccaff030SJeremy L Thompson
259ccaff030SJeremy L ThompsonEnergy Density:
260ccaff030SJeremy L Thompson    0.0 flux
261ccaff030SJeremy L Thompson
262ccaff030SJeremy L Thompson### Time Discretization
263ccaff030SJeremy L Thompson
264c063f476SvaleriabarraFor all different problems, the time integration is performed with an explicit
265c063f476Svaleriabarraor implicit formulation.
266ccaff030SJeremy L Thompson
267ccaff030SJeremy L Thompson### Space Discretization
268ccaff030SJeremy L Thompson
269ccaff030SJeremy L ThompsonThe geometric factors and coordinate transformations required for the integration of the weak form
270ccaff030SJeremy L Thompsonare described in the file [`common.h`](common.h)
271