xref: /libCEED/examples/fluids/README.md (revision f190906abec33cf8d9eb9776bd62dd828c8ae3fd)
1## libCEED: Navier-Stokes Example
2
3This page provides a description of the Navier-Stokes example for the libCEED library, based on PETSc.
4PETSc v3.17 or a development version of PETSc at commit 0e95d842 or later is required.
5
6The Navier-Stokes problem solves the compressible Navier-Stokes equations in three dimensions using an explicit time integration.
7The state variables are mass density, momentum density, and energy density.
8
9The main Navier-Stokes solver for libCEED is defined in [`navierstokes.c`](navierstokes.c) with different problem definitions according to the application of interest.
10
11Build by using:
12
13`make`
14
15and run with:
16
17```
18./navierstokes -ceed [ceed] -problem [problem type] -degree [degree]
19```
20
21## Runtime options
22
23% inclusion-fluids-marker
24
25The Navier-Stokes mini-app is controlled via command-line options.
26The following options are common among all problem types:
27
28:::{list-table} Common Runtime Options
29:header-rows: 1
30
31* - Option
32  - Description
33  - Default value
34
35* - `-ceed`
36  - CEED resource specifier
37  - `/cpu/self/opt/blocked`
38
39* - `-test`
40  - Run in test mode
41  - `false`
42
43* - `-compare_final_state_atol`
44  - Test absolute tolerance
45  - `1E-11`
46
47* - `-compare_final_state_filename`
48  - Test filename
49  -
50
51* - `-problem`
52  - Problem to solve (`advection`, `advection2d`, `density_current`, or `euler_vortex`)
53  - `density_current`
54
55* - `-implicit`
56  - Use implicit time integartor formulation
57  -
58
59* - `-degree`
60  - Polynomial degree of tensor product basis (must be >= 1)
61  - `1`
62
63* - `-qextra`
64  - Number of extra quadrature points
65  - `2`
66
67* - `-viz_refine`
68  - Use regular refinement for visualization
69  - `0`
70
71* - `-output_freq`
72  - Frequency of output, in number of steps
73  - `10`
74
75* - `-continue`
76  - Continue from previous solution
77  - `0`
78
79* - `-output_dir`
80  - Output directory
81  - `.`
82
83* - `-bc_wall`
84  - Use wall boundary conditions on this list of faces
85  -
86
87* - `-wall_comps`
88  - An array of constrained component numbers for wall BCs
89  -
90
91* - `-bc_slip_x`
92  - Use slip boundary conditions, for the x component, on this list of faces
93  -
94
95* - `-bc_slip_y`
96  - Use slip boundary conditions, for the y component, on this list of faces
97  -
98
99* - `-bc_slip_z`
100  - Use slip boundary conditions, for the z component, on this list of faces
101  -
102
103* - `-bc_inflow`
104  - Use inflow boundary conditions on this list of faces
105  -
106
107* - `-bc_outflow`
108  - Use outflow boundary conditions on this list of faces
109  -
110
111* - `-snes_view`
112  - View PETSc `SNES` nonlinear solver configuration
113  -
114
115* - `-log_view`
116  - View PETSc performance log
117  -
118
119* - `-help`
120  - View comprehensive information about run-time options
121  -
122:::
123
124For the case of a square/cubic mesh, the list of face indices to be used with `-bc_wall`, `bc_inflow`, `bc_outflow` and/or `-bc_slip_x`, `-bc_slip_y`, and `-bc_slip_z` are:
125
126* 2D:
127  - faceMarkerBottom = 1
128  - faceMarkerRight  = 2
129  - faceMarkerTop    = 3
130  - faceMarkerLeft   = 4
131* 3D:
132  - faceMarkerBottom = 1
133  - faceMarkerTop    = 2
134  - faceMarkerFront  = 3
135  - faceMarkerBack   = 4
136  - faceMarkerRight  = 5
137  - faceMarkerLeft   = 6
138
139For the 2D advection problem, the following additional command-line options are available:
140
141:::{list-table} Advection2D Runtime Options
142:header-rows: 1
143
144* - Option
145  - Description
146  - Default value
147  - Unit
148
149* - `-rc`
150  - Characteristic radius of thermal bubble
151  - `1000`
152  - `m`
153
154* - `-units_meter`
155  - 1 meter in scaled length units
156  - `1E-2`
157  -
158
159* - `-units_second`
160  - 1 second in scaled time units
161  - `1E-2`
162  -
163
164* - `-units_kilogram`
165  - 1 kilogram in scaled mass units
166  - `1E-6`
167  -
168
169* - `-strong_form`
170  - Strong (1) or weak/integrated by parts (0) residual
171  - `0`
172  -
173
174* - `-stab`
175  - Stabilization method (`none`, `su`, or `supg`)
176  - `none`
177  -
178
179* - `-CtauS`
180  - Scale coefficient for stabilization tau (nondimensional)
181  - `0`
182  -
183
184* - `-wind_type`
185  - Wind type in Advection (`rotation` or `translation`)
186  - `rotation`
187  -
188
189* - `-wind_translation`
190  - Constant wind vector when `-wind_type translation`
191  - `1,0,0`
192  -
193
194* - `-E_wind`
195  - Total energy of inflow wind when `-wind_type translation`
196  - `1E6`
197  - `J`
198:::
199
200An example of the `rotation` mode can be run with:
201
202```
203./navierstokes -problem advection2d -dm_plex_box_faces 20,20 -dm_plex_box_lower 0,0 -dm_plex_box_upper 1000,1000 -bc_wall 1,2,3,4 -wall_comps 4 -wind_type rotation -implicit -stab supg
204```
205
206and the `translation` mode with:
207
208```
209./navierstokes -problem advection2d -dm_plex_box_faces 20,20 -dm_plex_box_lower 0,0 -dm_plex_box_upper 1000,1000 -units_meter 1e-4 -wind_type translation -wind_translation 1,-.5 -bc_inflow 1,2,3,4
210```
211Note the lengths in `-dm_plex_box_upper` are given in meters, and will be nondimensionalized according to `-units_meter`.
212
213For the 3D advection problem, the following additional command-line options are available:
214
215:::{list-table} Advection3D Runtime Options
216:header-rows: 1
217
218* - Option
219  - Description
220  - Default value
221  - Unit
222
223* - `-rc`
224  - Characteristic radius of thermal bubble
225  - `1000`
226  - `m`
227
228* - `-units_meter`
229  - 1 meter in scaled length units
230  - `1E-2`
231  -
232
233* - `-units_second`
234  - 1 second in scaled time units
235  - `1E-2`
236  -
237
238* - `-units_kilogram`
239  - 1 kilogram in scaled mass units
240  - `1E-6`
241  -
242
243* - `-strong_form`
244  - Strong (1) or weak/integrated by parts (0) residual
245  - `0`
246  -
247
248* - `-stab`
249  - Stabilization method (`none`, `su`, or `supg`)
250  - `none`
251  -
252
253* - `-CtauS`
254  - Scale coefficient for stabilization tau (nondimensional)
255  - `0`
256  -
257
258* - `-wind_type`
259  - Wind type in Advection (`rotation` or `translation`)
260  - `rotation`
261  -
262
263* - `-wind_translation`
264  - Constant wind vector when `-wind_type translation`
265  - `1,0,0`
266  -
267
268* - `-E_wind`
269  - Total energy of inflow wind when `-wind_type translation`
270  - `1E6`
271  - `J`
272
273* - `-bubble_type`
274  - `sphere` (3D) or `cylinder` (2D)
275  - `shpere`
276  -
277
278* - `-bubble_continuity`
279  - `smooth`, `back_sharp`, or `thick`
280  - `smooth`
281  -
282:::
283
284An example of the `rotation` mode can be run with:
285
286```
287./navierstokes -problem advection -dm_plex_box_faces 10,10,10 -dm_plex_dim 3 -dm_plex_box_lower 0,0,0 -dm_plex_box_upper 8000,8000,8000 -bc_wall 1,2,3,4,5,6 -wall_comps 4 -wind_type rotation -implicit -stab su
288```
289
290and the `translation` mode with:
291
292```
293./navierstokes -problem advection -dm_plex_box_faces 10,10,10 -dm_plex_dim 3 -dm_plex_box_lower 0,0,0 -dm_plex_box_upper 8000,8000,8000 -wind_type translation -wind_translation .5,-1,0 -bc_inflow 1,2,3,4,5,6
294```
295
296For the Isentropic Vortex problem, the following additional command-line options are available:
297
298:::{list-table} Isentropic Vortex Runtime Options
299:header-rows: 1
300
301* - Option
302  - Description
303  - Default value
304  - Unit
305
306* - `-center`
307  - Location of vortex center
308  - `(lx,ly,lz)/2`
309  - `(m,m,m)`
310
311* - `-units_meter`
312  - 1 meter in scaled length units
313  - `1E-2`
314  -
315
316* - `-units_second`
317  - 1 second in scaled time units
318  - `1E-2`
319  -
320
321* - `-mean_velocity`
322  - Background velocity vector
323  - `(1,1,0)`
324  -
325
326* - `-vortex_strength`
327  - Strength of vortex < 10
328  - `5`
329  -
330
331* - `-c_tau`
332  - Stabilization constant
333  - `0.5`
334  -
335:::
336
337This problem can be run with:
338
339```
340./navierstokes -problem euler_vortex -dm_plex_box_faces 20,20,1 -dm_plex_box_lower 0,0,0 -dm_plex_box_upper 1000,1000,50 -dm_plex_dim 3 -bc_inflow 4,6 -bc_outflow 3,5 -bc_slip_z 1,2 -mean_velocity .5,-.8,0.
341```
342
343For the Density Current problem, the following additional command-line options are available:
344
345:::{list-table} Euler Vortex Runtime Options
346:header-rows: 1
347
348* - Option
349  - Description
350  - Default value
351  - Unit
352
353* - `-center`
354  - Location of bubble center
355  - `(lx,ly,lz)/2`
356  - `(m,m,m)`
357
358* - `-dc_axis`
359  - Axis of density current cylindrical anomaly, or `(0,0,0)` for spherically symmetric
360  - `(0,0,0)`
361  -
362
363* - `-rc`
364  - Characteristic radius of thermal bubble
365  - `1000`
366  - `m`
367
368* - `-units_meter`
369  - 1 meter in scaled length units
370  - `1E-2`
371  -
372
373* - `-units_second`
374  - 1 second in scaled time units
375  - `1E-2`
376  -
377
378* - `-units_kilogram`
379  - 1 kilogram in scaled mass units
380  - `1E-6`
381  -
382
383* - `-units_Kelvin`
384  - 1 Kelvin in scaled temperature units
385  - `1`
386  -
387
388* - `-stab`
389  - Stabilization method (`none`, `su`, or `supg`)
390  - `none`
391  -
392
393* - `-c_tau`
394  - Stabilization constant
395  - `0.5`
396  -
397
398* - `-theta0`
399  - Reference potential temperature
400  - `300`
401  - `K`
402
403* - `-thetaC`
404  - Perturbation of potential temperature
405  - `-15`
406  - `K`
407
408* - `-P0`
409  - Atmospheric pressure
410  - `1E5`
411  - `Pa`
412
413* - `-N`
414  - Brunt-Vaisala frequency
415  - `0.01`
416  - `1/s`
417
418* - `-cv`
419  - Heat capacity at constant volume
420  - `717`
421  - `J/(kg K)`
422
423* - `-cp`
424  - Heat capacity at constant pressure
425  - `1004`
426  - `J/(kg K)`
427
428* - `-g`
429  - Gravitational acceleration
430  - `9.81`
431  - `m/s^2`
432
433* - `-lambda`
434  - Stokes hypothesis second viscosity coefficient
435  - `-2/3`
436  -
437
438* - `-mu`
439  - Shear dynamic viscosity coefficient
440  - `75`
441  -  `Pa s`
442
443* - `-k`
444  - Thermal conductivity
445  - `0.02638`
446  - `W/(m K)`
447:::
448
449This problem can be run with:
450
451```
452./navierstokes -problem density_current -dm_plex_box_faces 16,1,8 -degree 1 -dm_plex_box_lower 0,0,0 -dm_plex_box_upper 2000,125,1000 -dm_plex_dim 3 -rc 400. -bc_wall 1,2,5,6 -wall_comps 1,2,3 -bc_slip_y 3,4 -viz_refine 2
453```
454