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