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