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