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 180For the 2D advection problem, the following additional command-line options are available: 181 182:::{list-table} Advection2D Runtime Options 183:header-rows: 1 184 185* - Option 186 - Description 187 - Default value 188 - Unit 189 190* - `-rc` 191 - Characteristic radius of thermal bubble 192 - `1000` 193 - `m` 194 195* - `-units_meter` 196 - 1 meter in scaled length units 197 - `1E-2` 198 - 199 200* - `-units_second` 201 - 1 second in scaled time units 202 - `1E-2` 203 - 204 205* - `-units_kilogram` 206 - 1 kilogram in scaled mass units 207 - `1E-6` 208 - 209 210* - `-strong_form` 211 - Strong (1) or weak/integrated by parts (0) residual 212 - `0` 213 - 214 215* - `-stab` 216 - Stabilization method (`none`, `su`, or `supg`) 217 - `none` 218 - 219 220* - `-CtauS` 221 - Scale coefficient for stabilization tau (nondimensional) 222 - `0` 223 - 224 225* - `-wind_type` 226 - Wind type in Advection (`rotation` or `translation`) 227 - `rotation` 228 - 229 230* - `-wind_translation` 231 - Constant wind vector when `-wind_type translation` 232 - `1,0,0` 233 - 234 235* - `-E_wind` 236 - Total energy of inflow wind when `-wind_type translation` 237 - `1E6` 238 - `J` 239::: 240 241An example of the `rotation` mode can be run with: 242 243``` 244./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 245``` 246 247and the `translation` mode 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 -units_meter 1e-4 -wind_type translation -wind_translation 1,-.5 -bc_inflow 1,2,3,4 251``` 252Note the lengths in `-dm_plex_box_upper` are given in meters, and will be nondimensionalized according to `-units_meter`. 253 254For the 3D advection problem, the following additional command-line options are available: 255 256:::{list-table} Advection3D Runtime Options 257:header-rows: 1 258 259* - Option 260 - Description 261 - Default value 262 - Unit 263 264* - `-rc` 265 - Characteristic radius of thermal bubble 266 - `1000` 267 - `m` 268 269* - `-units_meter` 270 - 1 meter in scaled length units 271 - `1E-2` 272 - 273 274* - `-units_second` 275 - 1 second in scaled time units 276 - `1E-2` 277 - 278 279* - `-units_kilogram` 280 - 1 kilogram in scaled mass units 281 - `1E-6` 282 - 283 284* - `-strong_form` 285 - Strong (1) or weak/integrated by parts (0) residual 286 - `0` 287 - 288 289* - `-stab` 290 - Stabilization method (`none`, `su`, or `supg`) 291 - `none` 292 - 293 294* - `-CtauS` 295 - Scale coefficient for stabilization tau (nondimensional) 296 - `0` 297 - 298 299* - `-wind_type` 300 - Wind type in Advection (`rotation` or `translation`) 301 - `rotation` 302 - 303 304* - `-wind_translation` 305 - Constant wind vector when `-wind_type translation` 306 - `1,0,0` 307 - 308 309* - `-E_wind` 310 - Total energy of inflow wind when `-wind_type translation` 311 - `1E6` 312 - `J` 313 314* - `-bubble_type` 315 - `sphere` (3D) or `cylinder` (2D) 316 - `shpere` 317 - 318 319* - `-bubble_continuity` 320 - `smooth`, `back_sharp`, or `thick` 321 - `smooth` 322 - 323::: 324 325An example of the `rotation` mode can be run with: 326 327``` 328./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 329``` 330 331and the `translation` mode with: 332 333``` 334./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 335``` 336 337For the Isentropic Vortex problem, the following additional command-line options are available: 338 339:::{list-table} Isentropic Vortex Runtime Options 340:header-rows: 1 341 342* - Option 343 - Description 344 - Default value 345 - Unit 346 347* - `-center` 348 - Location of vortex center 349 - `(lx,ly,lz)/2` 350 - `(m,m,m)` 351 352* - `-units_meter` 353 - 1 meter in scaled length units 354 - `1E-2` 355 - 356 357* - `-units_second` 358 - 1 second in scaled time units 359 - `1E-2` 360 - 361 362* - `-mean_velocity` 363 - Background velocity vector 364 - `(1,1,0)` 365 - 366 367* - `-vortex_strength` 368 - Strength of vortex < 10 369 - `5` 370 - 371 372* - `-c_tau` 373 - Stabilization constant 374 - `0.5` 375 - 376::: 377 378This problem can be run with: 379 380``` 381./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. 382``` 383 384For the Density Current, Channel, and Blasius problems, the following common command-line options are available: 385 386:::{list-table} Newtonian Ideal Gas problems Runtime Options 387:header-rows: 1 388 389* - Option 390 - Description 391 - Default value 392 - Unit 393 394* - `-units_meter` 395 - 1 meter in scaled length units 396 - `1` 397 - 398 399* - `-units_second` 400 - 1 second in scaled time units 401 - `1` 402 - 403 404* - `-units_kilogram` 405 - 1 kilogram in scaled mass units 406 - `1` 407 - 408 409* - `-units_Kelvin` 410 - 1 Kelvin in scaled temperature units 411 - `1` 412 - 413 414* - `-stab` 415 - Stabilization method (`none`, `su`, or `supg`) 416 - `none` 417 - 418 419* - `-c_tau` 420 - Stabilization constant, $c_\tau$ 421 - `0.5` 422 - 423 424* - `-Ctau_t` 425 - Stabilization time constant, $C_t$ 426 - `1.0` 427 - 428 429* - `-Ctau_v` 430 - Stabilization viscous constant, $C_v$ 431 - `36.0` 432 - 433 434* - `-Ctau_C` 435 - Stabilization continuity constant, $C_c$ 436 - `1.0` 437 - 438 439* - `-Ctau_M` 440 - Stabilization momentum constant, $C_m$ 441 - `1.0` 442 - 443 444* - `-Ctau_E` 445 - Stabilization energy constant, $C_E$ 446 - `1.0` 447 - 448 449* - `-cv` 450 - Heat capacity at constant volume 451 - `717` 452 - `J/(kg K)` 453 454* - `-cp` 455 - Heat capacity at constant pressure 456 - `1004` 457 - `J/(kg K)` 458 459* - `-g` 460 - Gravitational acceleration 461 - `9.81` 462 - `m/s^2` 463 464* - `-lambda` 465 - Stokes hypothesis second viscosity coefficient 466 - `-2/3` 467 - 468 469* - `-mu` 470 - Shear dynamic viscosity coefficient 471 - `75` 472 - `Pa s` 473 474* - `-k` 475 - Thermal conductivity 476 - `0.02638` 477 - `W/(m K)` 478::: 479 480The Density Current problem the following command-line options are available in 481addition to the Newtonian Ideal Gas options: 482 483:::{list-table} Density Current Runtime Options 484:header-rows: 1 485 486* - Option 487 - Description 488 - Default value 489 - Unit 490 491* - `-center` 492 - Location of bubble center 493 - `(lx,ly,lz)/2` 494 - `(m,m,m)` 495 496* - `-dc_axis` 497 - Axis of density current cylindrical anomaly, or `(0,0,0)` for spherically symmetric 498 - `(0,0,0)` 499 - 500 501* - `-rc` 502 - Characteristic radius of thermal bubble 503 - `1000` 504 - `m` 505 506* - `-theta0` 507 - Reference potential temperature 508 - `300` 509 - `K` 510 511* - `-thetaC` 512 - Perturbation of potential temperature 513 - `-15` 514 - `K` 515 516* - `-P0` 517 - Atmospheric pressure 518 - `1E5` 519 - `Pa` 520 521* - `-N` 522 - Brunt-Vaisala frequency 523 - `0.01` 524 - `1/s` 525::: 526 527This problem can be run with: 528 529``` 530./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 531``` 532 533The Channel problem the following command-line options are available in 534addition to the Newtonian Ideal Gas options: 535 536:::{list-table} Channel Runtime Options 537:header-rows: 1 538 539* - Option 540 - Description 541 - Default value 542 - Unit 543 544* - `-umax` 545 - Maximum/centerline velocity of the flow 546 - `10` 547 - `m/s` 548 549* - `-theta0` 550 - Reference potential temperature 551 - `300` 552 - `K` 553 554* - `-P0` 555 - Atmospheric pressure 556 - `1E5` 557 - `Pa` 558::: 559 560This problem can be run with the `channel.yaml` file via: 561 562``` 563./navierstokes -options_file channel.yaml 564``` 565```{literalinclude} ../../../../../examples/fluids/channel.yaml 566:language: yaml 567``` 568 569The Blasius problem the following command-line options are available in 570addition to the Newtonian Ideal Gas options: 571 572:::{list-table} Blasius Runtime Options 573:header-rows: 1 574 575* - Option 576 - Description 577 - Default value 578 - Unit 579 580* - `-Uinf` 581 - Freestream velocity 582 - `40` 583 - `m/s` 584 585* - `-delta0` 586 - Boundary layer height at the inflow 587 - `4.2e-4` 588 - `m` 589 590* - `-theta0` 591 - Reference potential temperature 592 - `288` 593 - `K` 594 595* - `-P0` 596 - Atmospheric pressure 597 - `1.01E5` 598 - `Pa` 599 600* - `-refine_height` 601 - Height at which `-Ndelta` number of elements should refined into 602 - `5.9E-4` 603 - `m` 604 605* - `-Ndelta` 606 - Number of elements to keep below `-refine_height` 607 - `45` 608 - 609 610* - `-growth` 611 - Growth rate of the elements in the refinement region 612 - `1.08` 613 - 614 615* - `-top_angle` 616 - Downward angle of the top face of the domain. This face serves as an outlet. 617 - `5` 618 - `degrees` 619::: 620 621This problem can be run with the `blasius.yaml` file via: 622 623``` 624./navierstokes -options_file blasius.yaml 625``` 626 627```{literalinclude} ../../../../../examples/fluids/blasius.yaml 628:language: yaml 629``` 630