xref: /libCEED/examples/fluids/README.md (revision 2b89d87e089857a3cae26709579e6a27709cba4a)
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* - `-q_extra`
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. `0` has no output, `-1` outputs final state only
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:::{list-table} 2D Face ID Labels
127:header-rows: 1
128* - PETSc Face Name
129  - Cartesian direction
130  - Face ID
131
132* - faceMarkerBottom
133  - -z
134  - 1
135
136* - faceMarkerRight
137  - +x
138  - 2
139
140* - faceMarkerTop
141  - +z
142  - 3
143
144* - faceMarkerLeft
145  - -x
146  - 4
147:::
148
149:::{list-table} 2D Face ID Labels
150:header-rows: 1
151* - PETSc Face Name
152  - Cartesian direction
153  - Face ID
154
155* - faceMarkerBottom
156  - -z
157  - 1
158
159* - faceMarkerTop
160  - +z
161  - 2
162
163* - faceMarkerFront
164  - -y
165  - 3
166
167* - faceMarkerBack
168  - +y
169  - 4
170
171* - faceMarkerRight
172  - +x
173  - 5
174
175* - faceMarkerLeft
176  - -x
177  - 6
178:::
179
180### Advection
181
182For testing purposes, there is a reduced mode for pure advection, which holds density $\rho$ and momentum density $\rho \bm u$ constant while advecting "total energy density" $E$.
183These are available in 2D and 3D.
184
185#### 2D advection
186
187For the 2D advection problem, the following additional command-line options are available:
188
189:::{list-table} Advection2D Runtime Options
190:header-rows: 1
191
192* - Option
193  - Description
194  - Default value
195  - Unit
196
197* - `-rc`
198  - Characteristic radius of thermal bubble
199  - `1000`
200  - `m`
201
202* - `-units_meter`
203  - 1 meter in scaled length units
204  - `1E-2`
205  -
206
207* - `-units_second`
208  - 1 second in scaled time units
209  - `1E-2`
210  -
211
212* - `-units_kilogram`
213  - 1 kilogram in scaled mass units
214  - `1E-6`
215  -
216
217* - `-strong_form`
218  - Strong (1) or weak/integrated by parts (0) residual
219  - `0`
220  -
221
222* - `-stab`
223  - Stabilization method (`none`, `su`, or `supg`)
224  - `none`
225  -
226
227* - `-CtauS`
228  - Scale coefficient for stabilization tau (nondimensional)
229  - `0`
230  -
231
232* - `-wind_type`
233  - Wind type in Advection (`rotation` or `translation`)
234  - `rotation`
235  -
236
237* - `-wind_translation`
238  - Constant wind vector when `-wind_type translation`
239  - `1,0,0`
240  -
241
242* - `-E_wind`
243  - Total energy of inflow wind when `-wind_type translation`
244  - `1E6`
245  - `J`
246:::
247
248An example of the `rotation` mode can be run with:
249
250```
251./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
252```
253
254and the `translation` mode with:
255
256```
257./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
258```
259Note the lengths in `-dm_plex_box_upper` are given in meters, and will be nondimensionalized according to `-units_meter`.
260
261#### 3D advection
262
263For the 3D advection problem, the following additional command-line options are available:
264
265:::{list-table} Advection3D Runtime Options
266:header-rows: 1
267
268* - Option
269  - Description
270  - Default value
271  - Unit
272
273* - `-rc`
274  - Characteristic radius of thermal bubble
275  - `1000`
276  - `m`
277
278* - `-units_meter`
279  - 1 meter in scaled length units
280  - `1E-2`
281  -
282
283* - `-units_second`
284  - 1 second in scaled time units
285  - `1E-2`
286  -
287
288* - `-units_kilogram`
289  - 1 kilogram in scaled mass units
290  - `1E-6`
291  -
292
293* - `-strong_form`
294  - Strong (1) or weak/integrated by parts (0) residual
295  - `0`
296  -
297
298* - `-stab`
299  - Stabilization method (`none`, `su`, or `supg`)
300  - `none`
301  -
302
303* - `-CtauS`
304  - Scale coefficient for stabilization tau (nondimensional)
305  - `0`
306  -
307
308* - `-wind_type`
309  - Wind type in Advection (`rotation` or `translation`)
310  - `rotation`
311  -
312
313* - `-wind_translation`
314  - Constant wind vector when `-wind_type translation`
315  - `1,0,0`
316  -
317
318* - `-E_wind`
319  - Total energy of inflow wind when `-wind_type translation`
320  - `1E6`
321  - `J`
322
323* - `-bubble_type`
324  - `sphere` (3D) or `cylinder` (2D)
325  - `shpere`
326  -
327
328* - `-bubble_continuity`
329  - `smooth`, `back_sharp`, or `thick`
330  - `smooth`
331  -
332:::
333
334An example of the `rotation` mode can be run with:
335
336```
337./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
338```
339
340and the `translation` mode with:
341
342```
343./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
344```
345
346### Inviscid Ideal Gas
347
348#### Isentropic Euler vortex
349
350For the Isentropic Vortex problem, the following additional command-line options are available:
351
352:::{list-table} Isentropic Vortex Runtime Options
353:header-rows: 1
354
355* - Option
356  - Description
357  - Default value
358  - Unit
359
360* - `-center`
361  - Location of vortex center
362  - `(lx,ly,lz)/2`
363  - `(m,m,m)`
364
365* - `-units_meter`
366  - 1 meter in scaled length units
367  - `1E-2`
368  -
369
370* - `-units_second`
371  - 1 second in scaled time units
372  - `1E-2`
373  -
374
375* - `-mean_velocity`
376  - Background velocity vector
377  - `(1,1,0)`
378  -
379
380* - `-vortex_strength`
381  - Strength of vortex < 10
382  - `5`
383  -
384
385* - `-c_tau`
386  - Stabilization constant
387  - `0.5`
388  -
389:::
390
391This problem can be run with:
392
393```
394./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.
395```
396
397#### Sod shock tube
398
399For the Shock Tube problem, the following additional command-line options are available:
400
401:::{list-table} Shock Tube Runtime Options
402:header-rows: 1
403
404* - Option
405  - Description
406  - Default value
407  - Unit
408
409* - `-units_meter`
410  - 1 meter in scaled length units
411  - `1E-2`
412  -
413
414* - `-units_second`
415  - 1 second in scaled time units
416  - `1E-2`
417  -
418
419* - `-yzb`
420  - Use YZB discontinuity capturing
421  - `none`
422  -
423
424* - `-stab`
425  - Stabilization method (`none`, `su`, or `supg`)
426  - `none`
427  -
428:::
429
430This problem can be run with:
431
432```
433./navierstokes -problem shocktube -yzb -stab su -bc_slip_z 3,4 -bc_slip_y 1,2 -bc_wall 5,6 -dm_plex_dim 3 -dm_plex_box_lower 0,0,0 -dm_plex_box_upper 1000,100,100 -dm_plex_box_faces 200,1,1 -units_second 0.1
434```
435
436### Newtonian viscosity, Ideal Gas
437
438For the Density Current, Channel, and Blasius problems, the following common command-line options are available:
439
440:::{list-table} Newtonian Ideal Gas problems Runtime Options
441:header-rows: 1
442
443* - Option
444  - Description
445  - Default value
446  - Unit
447
448* - `-units_meter`
449  - 1 meter in scaled length units
450  - `1`
451  -
452
453* - `-units_second`
454  - 1 second in scaled time units
455  - `1`
456  -
457
458* - `-units_kilogram`
459  - 1 kilogram in scaled mass units
460  - `1`
461  -
462
463* - `-units_Kelvin`
464  - 1 Kelvin in scaled temperature units
465  - `1`
466  -
467
468* - `-stab`
469  - Stabilization method (`none`, `su`, or `supg`)
470  - `none`
471  -
472
473* - `-c_tau`
474  - Stabilization constant, $c_\tau$
475  - `0.5`
476  -
477
478* - `-Ctau_t`
479  - Stabilization time constant, $C_t$
480  - `1.0`
481  -
482
483* - `-Ctau_v`
484  - Stabilization viscous constant, $C_v$
485  - `36.0`
486  -
487
488* - `-Ctau_C`
489  - Stabilization continuity constant, $C_c$
490  - `1.0`
491  -
492
493* - `-Ctau_M`
494  - Stabilization momentum constant, $C_m$
495  - `1.0`
496  -
497
498* - `-Ctau_E`
499  - Stabilization energy constant, $C_E$
500  - `1.0`
501  -
502
503* - `-cv`
504  - Heat capacity at constant volume
505  - `717`
506  - `J/(kg K)`
507
508* - `-cp`
509  - Heat capacity at constant pressure
510  - `1004`
511  - `J/(kg K)`
512
513* - `-g`
514  - Gravitational acceleration
515  - `9.81`
516  - `m/s^2`
517
518* - `-lambda`
519  - Stokes hypothesis second viscosity coefficient
520  - `-2/3`
521  -
522
523* - `-mu`
524  - Shear dynamic viscosity coefficient
525  - `75`
526  -  `Pa s`
527
528* - `-k`
529  - Thermal conductivity
530  - `0.02638`
531  - `W/(m K)`
532
533* - `-newtonian_unit_tests`
534  - Developer option to test properties
535  - `false`
536  - boolean
537
538* - `-primitive`
539  - Use primitive variables (pressure, velocity, temperature) instead of conservative variables (density, momentum, total energy)
540  - `false`
541  - boolean
542:::
543
544
545#### Density current
546
547The Density Current problem the following command-line options are available in addition to the Newtonian Ideal Gas options:
548
549:::{list-table} Density Current Runtime Options
550:header-rows: 1
551
552* - Option
553  - Description
554  - Default value
555  - Unit
556
557* - `-center`
558  - Location of bubble center
559  - `(lx,ly,lz)/2`
560  - `(m,m,m)`
561
562* - `-dc_axis`
563  - Axis of density current cylindrical anomaly, or `(0,0,0)` for spherically symmetric
564  - `(0,0,0)`
565  -
566
567* - `-rc`
568  - Characteristic radius of thermal bubble
569  - `1000`
570  - `m`
571
572* - `-theta0`
573  - Reference potential temperature
574  - `300`
575  - `K`
576
577* - `-thetaC`
578  - Perturbation of potential temperature
579  - `-15`
580  - `K`
581
582* - `-P0`
583  - Atmospheric pressure
584  - `1E5`
585  - `Pa`
586
587* - `-N`
588  - Brunt-Vaisala frequency
589  - `0.01`
590  - `1/s`
591:::
592
593This problem can be run with:
594
595```
596./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 -mu 75
597```
598
599#### Channel flow
600
601The Channel problem the following command-line options are available in addition to the Newtonian Ideal Gas options:
602
603:::{list-table} Channel Runtime Options
604:header-rows: 1
605
606* - Option
607  - Description
608  - Default value
609  - Unit
610
611* - `-umax`
612  - Maximum/centerline velocity of the flow
613  - `10`
614  - `m/s`
615
616* - `-theta0`
617  - Reference potential temperature
618  - `300`
619  - `K`
620
621* - `-P0`
622  - Atmospheric pressure
623  - `1E5`
624  - `Pa`
625
626* - `-body_force_scale`
627  - Multiplier for body force (`-1` for flow reversal)
628  - 1
629  -
630:::
631
632This problem can be run with the `channel.yaml` file via:
633
634```
635./navierstokes -options_file channel.yaml
636```
637```{literalinclude} ../../../../../examples/fluids/channel.yaml
638:language: yaml
639```
640
641#### Blasius boundary layer
642
643The Blasius problem the following command-line options are available in addition to the Newtonian Ideal Gas options:
644
645:::{list-table} Blasius Runtime Options
646:header-rows: 1
647
648* - Option
649  - Description
650  - Default value
651  - Unit
652
653* - `-Uinf`
654  - Freestream velocity
655  - `40`
656  - `m/s`
657
658* - `-delta0`
659  - Boundary layer height at the inflow
660  - `4.2e-4`
661  - `m`
662
663* - `-theta0`
664  - Reference potential temperature
665  - `288`
666  - `K`
667
668* - `-P0`
669  - Atmospheric pressure
670  - `1.01E5`
671  - `Pa`
672
673* - `-platemesh_refine_height`
674  - Height at which `-platemesh_Ndelta` number of elements should refined into
675  - `5.9E-4`
676  - `m`
677
678* - `-platemesh_Ndelta`
679  - Number of elements to keep below `-platemesh_refine_height`
680  - `45`
681  -
682
683* - `-platemesh_growth`
684  - Growth rate of the elements in the refinement region
685  - `1.08`
686  -
687
688* - `-platemesh_top_angle`
689  - Downward angle of the top face of the domain. This face serves as an outlet.
690  - `5`
691  - `degrees`
692
693* - `-stg_use`
694  - Whether to use stg for the inflow conditions
695  - `false`
696  -
697
698* - `-platemesh_y_node_locs_path`
699  - Path to file with y node locations. If empty, will use mesh warping instead.
700  - `""`
701  -
702:::
703
704This problem can be run with the `blasius.yaml` file via:
705
706```
707./navierstokes -options_file blasius.yaml
708```
709
710```{literalinclude} ../../../../../examples/fluids/blasius.yaml
711:language: yaml
712```
713
714#### STG Inflow for Flat Plate
715
716Using the STG Inflow for the blasius problem adds the following command-line options:
717
718:::{list-table} Blasius Runtime Options
719:header-rows: 1
720
721* - Option
722  - Description
723  - Default value
724  - Unit
725
726* - `-stg_inflow_path`
727  - Path to the STGInflow file
728  - `./STGInflow.dat`
729  -
730
731* - `-stg_rand_path`
732  - Path to the STGRand file
733  - `./STGRand.dat`
734  -
735
736* - `-stg_alpha`
737  - Growth rate of the wavemodes
738  - `1.01`
739  -
740
741* - `-stg_u0`
742  - Convective velocity, $U_0$
743  - `0.0`
744  - `m/s`
745
746* - `-stg_mean_only`
747  - Only impose the mean velocity (no fluctutations)
748  - `false`
749  -
750
751* - `-stg_strong`
752  - Strongly enforce the STG inflow boundary condition
753  - `false`
754  -
755
756:::
757
758This problem can be run with the `blasius.yaml` file via:
759
760```
761./navierstokes -options_file blasius.yaml -stg_use true
762```
763
764Note the added `-stg_use true` flag
765This overrides the `stg: use: false` setting in the `blasius.yaml` file, enabling the use of the STG inflow.
766