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