xref: /libCEED/examples/fluids/README.md (revision b8962995f2086e83ec045f19f82798eb8f9e9baf)
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* - `-dm_plex_box_faces`
84  - Number of faces in each linear direction
85  - `3,3,3`
86
87* - `-snes_view`
88  - View PETSc `SNES` nonlinear solver configuration
89  -
90
91* - `-log_view`
92  - View PETSc performance log
93  -
94
95* - `-help`
96  - View comprehensive information about run-time options
97  -
98:::
99
100For the 2D advection problem, the following additional command-line options are available:
101
102:::{list-table} Advection2D Runtime Options
103:header-rows: 1
104
105* - Option
106  - Description
107  - Default value
108  - Unit
109
110* - `-lx`
111  - Length scale in x direction
112  - `8000`
113  - `m`
114
115* - `-ly`
116  - Length scale in y direction
117  - `8000`
118  - `m`
119
120* - `-rc`
121  - Characteristic radius of thermal bubble
122  - `1000`
123  - `m`
124
125* - `-units_meter`
126  - 1 meter in scaled length units
127  - `1E-2`
128  -
129
130* - `-units_second`
131  - 1 second in scaled time units
132  - `1E-2`
133  -
134
135* - `-units_kilogram`
136  - 1 kilogram in scaled mass units
137  - `1E-6`
138  -
139
140* - `-strong_form`
141  - Strong (1) or weak/integrated by parts (0) residual
142  - `0`
143  -
144
145* - `-stab`
146  - Stabilization method (`none`, `su`, or `supg`)
147  - `none`
148  -
149
150* - `-CtauS`
151  - Scale coefficient for stabilization tau (nondimensional)
152  - `0`
153  -
154
155* - `-wind_type`
156  - Wind type in Advection (`rotation` or `translation`)
157  - `rotation`
158  -
159
160* - `-wind_translation`
161  - Constant wind vector when `-wind_type translation`
162  - `1,0,0`
163  -
164
165* - `-E_wind`
166  - Total energy of inflow wind when `-wind_type translation`
167  - `1E6`
168  - `J`
169:::
170
171An example of the `rotation` mode can be run with:
172
173```
174./navierstokes -problem advection2d -wind_type rotation -implicit -stab supg
175```
176
177and the `translation` mode with:
178
179```
180./navierstokes -problem advection2d -wind_type translation -wind_translation 1,-.5
181```
182
183For the 3D advection problem, the following additional command-line options are available:
184
185:::{list-table} Advection3D Runtime Options
186:header-rows: 1
187
188* - Option
189  - Description
190  - Default value
191  - Unit
192
193* - `-lx`
194  - Length scale in x direction
195  - `8000`
196  - `m`
197
198* - `-ly`
199  - Length scale in y direction
200  - `8000`
201  - `m`
202
203* - `-lz`
204  - Length scale in z direction
205  - `4000`
206  - `m`
207
208* - `-rc`
209  - Characteristic radius of thermal bubble
210  - `1000`
211  - `m`
212
213* - `-units_meter`
214  - 1 meter in scaled length units
215  - `1E-2`
216  -
217
218* - `-units_second`
219  - 1 second in scaled time units
220  - `1E-2`
221  -
222
223* - `-units_kilogram`
224  - 1 kilogram in scaled mass units
225  - `1E-6`
226  -
227
228* - `-strong_form`
229  - Strong (1) or weak/integrated by parts (0) residual
230  - `0`
231  -
232
233* - `-stab`
234  - Stabilization method (`none`, `su`, or `supg`)
235  - `none`
236  -
237
238* - `-CtauS`
239  - Scale coefficient for stabilization tau (nondimensional)
240  - `0`
241  -
242
243* - `-wind_type`
244  - Wind type in Advection (`rotation` or `translation`)
245  - `rotation`
246  -
247
248* - `-wind_translation`
249  - Constant wind vector when `-wind_type translation`
250  - `1,0,0`
251  -
252
253* - `-E_wind`
254  - Total energy of inflow wind when `-wind_type translation`
255  - `1E6`
256  - `J`
257
258* - `-bubble_type`
259  - `sphere` (3D) or `cylinder` (2D)
260  - `shpere`
261  -
262
263* - `-bubble_continuity`
264  - `smooth`, `back_sharp`, or `thick`
265  - `smooth`
266  -
267:::
268
269An example of the `rotation` mode can be run with:
270
271```
272./navierstokes -problem advection -wind_type rotation -implicit -stab supg
273```
274
275and the `translation` mode with:
276
277```
278./navierstokes -problem advection -wind_type translation -wind_translation .5,-1,0
279```
280
281For the Isentropic Vortex problem, the following additional command-line options are available:
282
283:::{list-table} Isentropic Vortex Runtime Options
284:header-rows: 1
285
286* - Option
287  - Description
288  - Default value
289  - Unit
290
291* - `-lx`
292  - Length scale in x direction
293  - `1000`
294  - `m`
295
296* - `-ly`
297  - Length scale in y direction
298  - `1000`
299  - `m`
300
301* - `-lz`
302  - Length scale in z direction
303  - `1`
304  - `m`
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 -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* - `-lx`
354  - Length scale in x direction
355  - `8000`
356  - `m`
357
358* - `-ly`
359  - Length scale in y direction
360  - `8000`
361  - `m`
362
363* - `-lz`
364  - Length scale in z direction
365  - `4000`
366  - `m`
367
368* - `-center`
369  - Location of bubble center
370  - `(lx,ly,lz)/2`
371  - `(m,m,m)`
372
373* - `-dc_axis`
374  - Axis of density current cylindrical anomaly, or `(0,0,0)` for spherically symmetric
375  - `(0,0,0)`
376  -
377
378* - `-rc`
379  - Characteristic radius of thermal bubble
380  - `1000`
381  - `m`
382
383* - `-bc_wall`
384  - Use wall boundary conditions on this list of faces
385  - `-`
386  -
387
388* - `-bc_slip_x`
389  - Use slip boundary conditions, for the x component, on this list of faces
390  - `5,6`
391  -
392
393* - `-bc_slip_y`
394  - Use slip boundary conditions, for the y component, on this list of faces
395  - `3,4`
396  -
397
398* - `-bc_slip_z`
399  - Use slip boundary conditions, for the z component, on this list of faces
400  - `1,2`
401  -
402
403* - `-units_meter`
404  - 1 meter in scaled length units
405  - `1E-2`
406  -
407
408* - `-units_second`
409  - 1 second in scaled time units
410  - `1E-2`
411  -
412
413* - `-units_kilogram`
414  - 1 kilogram in scaled mass units
415  - `1E-6`
416  -
417
418* - `-units_Kelvin`
419  - 1 Kelvin in scaled temperature units
420  - `1`
421  -
422
423* - `-stab`
424  - Stabilization method (`none`, `su`, or `supg`)
425  - `none`
426  -
427
428* - `-c_tau`
429  - Stabilization constant
430  - `0.5`
431  -
432
433* - `-theta0`
434  - Reference potential temperature
435  - `300`
436  - `K`
437
438* - `-thetaC`
439  - Perturbation of potential temperature
440  - `-15`
441  - `K`
442
443* - `-P0`
444  - Atmospheric pressure
445  - `1E5`
446  - `Pa`
447
448* - `-N`
449  - Brunt-Vaisala frequency
450  - `0.01`
451  - `1/s`
452
453* - `-cv`
454  - Heat capacity at constant volume
455  - `717`
456  - `J/(kg K)`
457
458* - `-cp`
459  - Heat capacity at constant pressure
460  - `1004`
461  - `J/(kg K)`
462
463* - `-g`
464  - Gravitational acceleration
465  - `9.81`
466  - `m/s^2`
467
468* - `-lambda`
469  - Stokes hypothesis second viscosity coefficient
470  - `-2/3`
471  -
472
473* - `-mu`
474  - Shear dynamic viscosity coefficient
475  - `75`
476  -  `Pa s`
477
478* - `-k`
479  - Thermal conductivity
480  - `0.02638`
481  - `W/(m K)`
482:::
483
484For the case of a square/cubic mesh, the list of face indices to be used with `-bc_wall` and/or `-bc_slip_x`, `-bc_slip_y`, and `-bc_slip_z` are:
485
486* 2D:
487  - faceMarkerBottom = 1
488  - faceMarkerRight  = 2
489  - faceMarkerTop    = 3
490  - faceMarkerLeft   = 4
491* 3D:
492  - faceMarkerBottom = 1
493  - faceMarkerTop    = 2
494  - faceMarkerFront  = 3
495  - faceMarkerBack   = 4
496  - faceMarkerRight  = 5
497  - faceMarkerLeft   = 6
498
499This problem can be run with:
500
501```
502./navierstokes -problem density_current -dm_plex_box_faces 16,1,8 -degree 1 -lx 2000 -ly 125 -lz 1000 -rc 400. -bc_wall 1,2,5,6 -bc_slip_y 3,4 -viz_refine 2
503```
504