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