xref: /libCEED/examples/fluids/README.md (revision 72d852595123308417bcd99e2ca111c71d29cbff)
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
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
539
540#### Density current
541
542The Density Current problem the following command-line options are available in addition to the Newtonian Ideal Gas options:
543
544:::{list-table} Density Current Runtime Options
545:header-rows: 1
546
547* - Option
548  - Description
549  - Default value
550  - Unit
551
552* - `-center`
553  - Location of bubble center
554  - `(lx,ly,lz)/2`
555  - `(m,m,m)`
556
557* - `-dc_axis`
558  - Axis of density current cylindrical anomaly, or `(0,0,0)` for spherically symmetric
559  - `(0,0,0)`
560  -
561
562* - `-rc`
563  - Characteristic radius of thermal bubble
564  - `1000`
565  - `m`
566
567* - `-theta0`
568  - Reference potential temperature
569  - `300`
570  - `K`
571
572* - `-thetaC`
573  - Perturbation of potential temperature
574  - `-15`
575  - `K`
576
577* - `-P0`
578  - Atmospheric pressure
579  - `1E5`
580  - `Pa`
581
582* - `-N`
583  - Brunt-Vaisala frequency
584  - `0.01`
585  - `1/s`
586:::
587
588This problem can be run with:
589
590```
591./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
592```
593
594#### Channel flow
595
596The Channel problem the following command-line options are available in addition to the Newtonian Ideal Gas options:
597
598:::{list-table} Channel Runtime Options
599:header-rows: 1
600
601* - Option
602  - Description
603  - Default value
604  - Unit
605
606* - `-umax`
607  - Maximum/centerline velocity of the flow
608  - `10`
609  - `m/s`
610
611* - `-theta0`
612  - Reference potential temperature
613  - `300`
614  - `K`
615
616* - `-P0`
617  - Atmospheric pressure
618  - `1E5`
619  - `Pa`
620
621* - `-body_force_scale`
622  - Multiplier for body force (`-1` for flow reversal)
623  - 1
624  -
625:::
626
627This problem can be run with the `channel.yaml` file via:
628
629```
630./navierstokes -options_file channel.yaml
631```
632```{literalinclude} ../../../../../examples/fluids/channel.yaml
633:language: yaml
634```
635
636#### Blasius boundary layer
637
638The Blasius problem the following command-line options are available in addition to the Newtonian Ideal Gas options:
639
640:::{list-table} Blasius Runtime Options
641:header-rows: 1
642
643* - Option
644  - Description
645  - Default value
646  - Unit
647
648* - `-Uinf`
649  - Freestream velocity
650  - `40`
651  - `m/s`
652
653* - `-delta0`
654  - Boundary layer height at the inflow
655  - `4.2e-4`
656  - `m`
657
658* - `-theta0`
659  - Reference potential temperature
660  - `288`
661  - `K`
662
663* - `-P0`
664  - Atmospheric pressure
665  - `1.01E5`
666  - `Pa`
667
668* - `-platemesh_refine_height`
669  - Height at which `-platemesh_Ndelta` number of elements should refined into
670  - `5.9E-4`
671  - `m`
672
673* - `-platemesh_Ndelta`
674  - Number of elements to keep below `-platemesh_refine_height`
675  - `45`
676  -
677
678* - `-platemesh_growth`
679  - Growth rate of the elements in the refinement region
680  - `1.08`
681  -
682
683* - `-platemesh_top_angle`
684  - Downward angle of the top face of the domain. This face serves as an outlet.
685  - `5`
686  - `degrees`
687
688* - `-stg_use`
689  - Whether to use stg for the inflow conditions
690  - `false`
691  -
692
693* - `-platemesh_y_node_locs_path`
694  - Path to file with y node locations. If empty, will use mesh warping instead.
695  - `""`
696  -
697:::
698
699This problem can be run with the `blasius.yaml` file via:
700
701```
702./navierstokes -options_file blasius.yaml
703```
704
705```{literalinclude} ../../../../../examples/fluids/blasius.yaml
706:language: yaml
707```
708
709#### STG Inflow for Flat Plate
710
711Using the STG Inflow for the blasius problem adds the following command-line options:
712
713:::{list-table} Blasius Runtime Options
714:header-rows: 1
715
716* - Option
717  - Description
718  - Default value
719  - Unit
720
721* - `-stg_inflow_path`
722  - Path to the STGInflow file
723  - `./STGInflow.dat`
724  -
725
726* - `-stg_rand_path`
727  - Path to the STGRand file
728  - `./STGRand.dat`
729  -
730
731* - `-stg_alpha`
732  - Growth rate of the wavemodes
733  - `1.01`
734  -
735
736* - `-stg_u0`
737  - Convective velocity, $U_0$
738  - `0.0`
739  - `m/s`
740
741* - `-stg_mean_only`
742  - Only impose the mean velocity (no fluctutations)
743  - `false`
744  -
745
746* - `-stg_strong`
747  - Strongly enforce the STG inflow boundary condition
748  - `false`
749  -
750
751:::
752
753This problem can be run with the `blasius.yaml` file via:
754
755```
756./navierstokes -options_file blasius.yaml -stg_use true
757```
758
759Note the added `-stg_use true` flag
760This overrides the `stg: use: false` setting in the `blasius.yaml` file, enabling the use of the STG inflow.
761