1ea10196cSJeremy L Thompson## libCEED: Navier-Stokes Example 2ea10196cSJeremy L Thompson 3ea10196cSJeremy L ThompsonThis page provides a description of the Navier-Stokes example for the libCEED library, based on PETSc. 4ea10196cSJeremy L Thompson 5ea10196cSJeremy L ThompsonThe Navier-Stokes problem solves the compressible Navier-Stokes equations in three dimensions using an 6ea10196cSJeremy L Thompsonexplicit time integration. The state variables are mass density, momentum density, and energy density. 7ea10196cSJeremy L Thompson 8ea10196cSJeremy L ThompsonThe main Navier-Stokes solver for libCEED is defined in [`navierstokes.c`](navierstokes.c) 9ea10196cSJeremy L Thompsonwith different problem definitions according to the application of interest. 10ea10196cSJeremy L Thompson 11ea10196cSJeremy L ThompsonBuild by using 12ea10196cSJeremy L Thompson 13ea10196cSJeremy L Thompson`make` 14ea10196cSJeremy L Thompson 15ea10196cSJeremy L Thompsonand run with 16ea10196cSJeremy L Thompson 1740f3b208SJed Brown`./navierstokes` 18ea10196cSJeremy L Thompson 19ea10196cSJeremy L ThompsonAvailable runtime options are: 20ea10196cSJeremy L Thompson 21ea10196cSJeremy L Thompson| Option | Meaning | 22925b3829SLeila Ghaffari| :-------------------------------------| :-----------------------------------------------------------------------------------------------| 23ea10196cSJeremy L Thompson| `-ceed` | CEED resource specifier | 24ea10196cSJeremy L Thompson| `-test` | Run in test mode | 25*268c6924SLeila Ghaffari| `-problem` | Problem to solve (`advection`, `advection2d`, `density_current`, or `euler_vortex`) | 26925b3829SLeila Ghaffari| `-problem_advection_wind` | Wind type in Advection (`rotation` or `translation`) | 27925b3829SLeila Ghaffari| `-problem_advection_wind_translation` | Constant wind vector when `-problem_advection_wind translation` | 28*268c6924SLeila Ghaffari| `-problem_euler_mean_velocity` | Constant mean velocity vector in `euler_vortex` | 29*268c6924SLeila Ghaffari| `-vortex_strength` | Strength of vortex in `euler_vortex` | 30ea10196cSJeremy L Thompson| `-stab` | Stabilization method | 31ea10196cSJeremy L Thompson| `-implicit` | Use implicit time integartor formulation | 32ea10196cSJeremy L Thompson| `-bc_wall` | Use wall boundary conditions on this list of faces | 33ea10196cSJeremy L Thompson| `-bc_slip_x` | Use slip boundary conditions, for the x component, on this list of faces | 34ea10196cSJeremy L Thompson| `-bc_slip_y` | Use slip boundary conditions, for the y component, on this list of faces | 35ea10196cSJeremy L Thompson| `-bc_slip_z` | Use slip boundary conditions, for the z component, on this list of faces | 36ea10196cSJeremy L Thompson| `-viz_refine` | Use regular refinement for visualization | 3740f3b208SJed Brown| `-degree` | Polynomial degree of tensor product basis (must be >= 1) | 38ea10196cSJeremy L Thompson| `-units_meter` | 1 meter in scaled length units | 39ea10196cSJeremy L Thompson| `-units_second` | 1 second in scaled time units | 40ea10196cSJeremy L Thompson| `-units_kilogram` | 1 kilogram in scaled mass units | 41ea10196cSJeremy L Thompson| `-units_Kelvin` | 1 Kelvin in scaled temperature units | 42ea10196cSJeremy L Thompson| `-theta0` | Reference potential temperature | 43ea10196cSJeremy L Thompson| `-thetaC` | Perturbation of potential temperature | 44ea10196cSJeremy L Thompson| `-P0` | Atmospheric pressure | 452aaf65e8SLeila Ghaffari| `-E_wind` | Total energy of inflow wind | 46ea10196cSJeremy L Thompson| `-N` | Brunt-Vaisala frequency | 47ea10196cSJeremy L Thompson| `-cv` | Heat capacity at constant volume | 48ea10196cSJeremy L Thompson| `-cp` | Heat capacity at constant pressure | 49ea10196cSJeremy L Thompson| `-g` | Gravitational acceleration | 50ea10196cSJeremy L Thompson| `-lambda` | Stokes hypothesis second viscosity coefficient | 51ea10196cSJeremy L Thompson| `-mu` | Shear dynamic viscosity coefficient | 52ea10196cSJeremy L Thompson| `-k` | Thermal conductivity | 53ea10196cSJeremy L Thompson| `-CtauS` | Scale coefficient for stabilization tau (nondimensional) | 54ea10196cSJeremy L Thompson| `-strong_form` | Strong (1) or weak/integrated by parts (0) advection residual | 55ea10196cSJeremy L Thompson| `-lx` | Length scale in x direction | 56ea10196cSJeremy L Thompson| `-ly` | Length scale in y direction | 57ea10196cSJeremy L Thompson| `-lz` | Length scale in z direction | 58ea10196cSJeremy L Thompson| `-rc` | Characteristic radius of thermal bubble | 59ea10196cSJeremy L Thompson| `-resx` | Resolution in x | 60ea10196cSJeremy L Thompson| `-resy` | Resolution in y | 61ea10196cSJeremy L Thompson| `-resz` | Resolution in z | 62ea10196cSJeremy L Thompson| `-center` | Location of bubble center | 63ea10196cSJeremy L Thompson| `-dc_axis` | Axis of density current cylindrical anomaly, or {0,0,0} for spherically symmetric | 64ea10196cSJeremy L Thompson| `-output_freq` | Frequency of output, in number of steps | 65ea10196cSJeremy L Thompson| `-continue` | Continue from previous solution | 66ea10196cSJeremy L Thompson| `-degree` | Polynomial degree of tensor product basis | 67ea10196cSJeremy L Thompson| `-qextra` | Number of extra quadrature points | 68925b3829SLeila Ghaffari| `-qextra_boundary` | Number of extra quadrature points on in/outflow faces | 692dcc5c0fSLeila Ghaffari| `-output_dir` | Output directory | 70ea10196cSJeremy L Thompson 71682b106eSvaleriabarraFor the case of a square/cubic mesh, the list of face indices to be used with `-bc_wall` and/or `-bc_slip_x`, 72a240d89fSLeila Ghaffari`-bc_slip_y`, and `-bc_slip_z` are: 73682b106eSvaleriabarra 74682b106eSvaleriabarra* 2D: 75682b106eSvaleriabarra - faceMarkerBottom = 1; 76682b106eSvaleriabarra - faceMarkerRight = 2; 77682b106eSvaleriabarra - faceMarkerTop = 3; 78682b106eSvaleriabarra - faceMarkerLeft = 4; 79682b106eSvaleriabarra* 3D: 80682b106eSvaleriabarra - faceMarkerBottom = 1; 81682b106eSvaleriabarra - faceMarkerTop = 2; 82682b106eSvaleriabarra - faceMarkerFront = 3; 83682b106eSvaleriabarra - faceMarkerBack = 4; 84682b106eSvaleriabarra - faceMarkerRight = 5; 85682b106eSvaleriabarra - faceMarkerLeft = 6; 86ea10196cSJeremy L Thompson 87ea10196cSJeremy L Thompson### Advection 88ea10196cSJeremy L Thompson 89ea10196cSJeremy L ThompsonThis problem solves the convection (advection) equation for the total (scalar) energy density, 90ea10196cSJeremy L Thompsontransported by the (vector) velocity field. 91ea10196cSJeremy L Thompson 92ea10196cSJeremy L ThompsonThis is 3D advection given in two formulations based upon the weak form. 93ea10196cSJeremy L Thompson 94ea10196cSJeremy L ThompsonState Variables: 95ea10196cSJeremy L Thompson 96ea10196cSJeremy L Thompson *q = ( rho, U<sub>1</sub>, U<sub>2</sub>, U<sub>3</sub>, E )* 97ea10196cSJeremy L Thompson 98ea10196cSJeremy L Thompson *rho* - Mass Density 99ea10196cSJeremy L Thompson 100ea10196cSJeremy L Thompson *U<sub>i</sub>* - Momentum Density , *U<sub>i</sub> = rho ui* 101ea10196cSJeremy L Thompson 102ea10196cSJeremy L Thompson *E* - Total Energy Density, *E = rho Cv T + rho (u u) / 2 + rho g z* 103ea10196cSJeremy L Thompson 104ea10196cSJeremy L ThompsonAdvection Equation: 105ea10196cSJeremy L Thompson 106ea10196cSJeremy L Thompson *dE/dt + div( E _u_ ) = 0* 107ea10196cSJeremy L Thompson 108ea10196cSJeremy L Thompson#### Initial Conditions 109ea10196cSJeremy L Thompson 110ea10196cSJeremy L ThompsonMass Density: 111ea10196cSJeremy L Thompson Constant mass density of 1.0 112ea10196cSJeremy L Thompson 113ea10196cSJeremy L ThompsonMomentum Density: 114ea10196cSJeremy L Thompson Rotational field in x,y with no momentum in z 115ea10196cSJeremy L Thompson 116ea10196cSJeremy L ThompsonEnergy Density: 117ea10196cSJeremy L Thompson Maximum of 1. x0 decreasing linearly to 0. as radial distance increases 118ea10196cSJeremy L Thompson to 1/8, then 0. everywhere else 119ea10196cSJeremy L Thompson 120ea10196cSJeremy L Thompson#### Boundary Conditions 121ea10196cSJeremy L Thompson 122ea10196cSJeremy L ThompsonMass Density: 123ea10196cSJeremy L Thompson 0.0 flux 124ea10196cSJeremy L Thompson 125ea10196cSJeremy L ThompsonMomentum Density: 126ea10196cSJeremy L Thompson 0.0 127ea10196cSJeremy L Thompson 128ea10196cSJeremy L ThompsonEnergy Density: 129ea10196cSJeremy L Thompson 0.0 flux 130ea10196cSJeremy L Thompson 131*268c6924SLeila Ghaffari### Euler Traveling Vortex 132*268c6924SLeila Ghaffari 133*268c6924SLeila GhaffariThis problem solves the 3D Euler equations for vortex evolution provided 134*268c6924SLeila Ghaffariin On the Order of Accuracy and Numerical Performance of Two Classes of 135*268c6924SLeila GhaffariFinite Volume WENO Schemes, Zhang, Zhang, and Shu (2011). 136*268c6924SLeila Ghaffari 137*268c6924SLeila GhaffariState Variables: 138*268c6924SLeila Ghaffari 139*268c6924SLeila Ghaffari *q = ( rho, U<sub>1</sub>, U<sub>2</sub>, U<sub>3</sub>, E )* 140*268c6924SLeila Ghaffari 141*268c6924SLeila Ghaffari *rho* - Mass Density 142*268c6924SLeila Ghaffari 143*268c6924SLeila Ghaffari *U<sub>i</sub>* - Momentum Density , *U<sub>i</sub> = rho u<sub>i</sub>* 144*268c6924SLeila Ghaffari 145*268c6924SLeila Ghaffari *E* - Total Energy Density, *E = P / (gamma - 1) + rho (u u) / 2* 146*268c6924SLeila Ghaffari 147*268c6924SLeila GhaffariEuler Equations: 148*268c6924SLeila Ghaffari 149*268c6924SLeila Ghaffari *drho/dt + div( U ) = 0* 150*268c6924SLeila Ghaffari 151*268c6924SLeila Ghaffari *dU/dt + div( rho (u x u) + P I<sub>3</sub> ) = 0* 152*268c6924SLeila Ghaffari 153*268c6924SLeila Ghaffari *dE/dt + div( (E + P) u ) = 0* 154*268c6924SLeila Ghaffari 155*268c6924SLeila GhaffariConstants: 156*268c6924SLeila Ghaffari 157*268c6924SLeila Ghaffari *c<sub>v</sub>* , Specific heat, constant volume 158*268c6924SLeila Ghaffari 159*268c6924SLeila Ghaffari *c<sub>p</sub>* , Specific heat, constant pressure 160*268c6924SLeila Ghaffari 161*268c6924SLeila Ghaffari *gamma = c<sub>p</sub> / c<sub>v</sub>*, Specific heat ratio 162*268c6924SLeila Ghaffari 163*268c6924SLeila Ghaffari *epsilon* , Vortex Strength 164*268c6924SLeila Ghaffari 165*268c6924SLeila Ghaffari#### Initial Conditions 166*268c6924SLeila Ghaffari 167*268c6924SLeila GhaffariTemperature: 168*268c6924SLeila Ghaffari 169*268c6924SLeila Ghaffari *T = 1 - (gamma - 1) epsilon^2 exp(1 - r^2) / (8 gamma pi^2)* 170*268c6924SLeila Ghaffari 171*268c6924SLeila GhaffariEntropy: 172*268c6924SLeila Ghaffari 173*268c6924SLeila Ghaffari *S = 1* , Constant entropy 174*268c6924SLeila Ghaffari 175*268c6924SLeila GhaffariDensity: 176*268c6924SLeila Ghaffari 177*268c6924SLeila Ghaffari *rho = (T/S)^(1 / (gamma - 1))* 178*268c6924SLeila Ghaffari 179*268c6924SLeila GhaffariPressure: 180*268c6924SLeila Ghaffari 181*268c6924SLeila Ghaffari *P = rho T* 182*268c6924SLeila Ghaffari 183*268c6924SLeila GhaffariVelocity: 184*268c6924SLeila Ghaffari 185*268c6924SLeila Ghaffari *u<sub>i</sub> = 1 + epsilon exp((1 - r^2)/2) [yc - y, x - xc, 0] / (2 pi)* 186*268c6924SLeila Ghaffari 187*268c6924SLeila Ghaffari *r = sqrt( (x - xc)^2 + (y - yc)^2 )* 188*268c6924SLeila Ghaffari with *(xc,yc)* center of the xy-plane in the domain 189*268c6924SLeila Ghaffari 190*268c6924SLeila Ghaffari#### Boundary Conditions 191*268c6924SLeila Ghaffari 192*268c6924SLeila GhaffariFor this problem, in/outflow BCs are implemented where the validity of the weak 193*268c6924SLeila Ghaffariform of the governing equations is extended to the outflow. 194*268c6924SLeila GhaffariFor the inflow fluxes, prescribed T_inlet and P_inlet are converted to 195*268c6924SLeila Ghaffariconservative variables and applied weakly. 196*268c6924SLeila Ghaffari 197ea10196cSJeremy L Thompson### Density Current 198ea10196cSJeremy L Thompson 199ea10196cSJeremy L ThompsonThis problem solves the full compressible Navier-Stokes equations, using 200ea10196cSJeremy L Thompsonoperator composition and design of coupled solvers in the context of atmospheric 201ea10196cSJeremy L Thompsonmodeling. This problem uses the formulation given in Semi-Implicit Formulations 202ea10196cSJeremy L Thompsonof the Navier-Stokes Equations: Application to Nonhydrostatic Atmospheric Modeling, 203ea10196cSJeremy L ThompsonGiraldo, Restelli, and Lauter (2010). 204ea10196cSJeremy L Thompson 205ea10196cSJeremy L ThompsonThe 3D compressible Navier-Stokes equations are formulated in conservation form with state 206ea10196cSJeremy L Thompsonvariables of density, momentum density, and total energy density. 207ea10196cSJeremy L Thompson 208ea10196cSJeremy L ThompsonState Variables: 209ea10196cSJeremy L Thompson 210ea10196cSJeremy L Thompson *q = ( rho, U<sub>1</sub>, U<sub>2</sub>, U<sub>3</sub>, E )* 211ea10196cSJeremy L Thompson 212ea10196cSJeremy L Thompson *rho* - Mass Density 213ea10196cSJeremy L Thompson 214ea10196cSJeremy L Thompson *U<sub>i</sub>* - Momentum Density , *U<sub>i</sub> = rho u<sub>i</sub>* 215ea10196cSJeremy L Thompson 216ea10196cSJeremy L Thompson *E* - Total Energy Density, *E = rho c<sub>v</sub> T + rho (u u) / 2 + rho g z* 217ea10196cSJeremy L Thompson 218ea10196cSJeremy L ThompsonNavier-Stokes Equations: 219ea10196cSJeremy L Thompson 220ea10196cSJeremy L Thompson *drho/dt + div( U ) = 0* 221ea10196cSJeremy L Thompson 222ea10196cSJeremy L Thompson *dU/dt + div( rho (u x u) + P I<sub>3</sub> ) + rho g khat = div( F<sub>u</sub> )* 223ea10196cSJeremy L Thompson 224ea10196cSJeremy L Thompson *dE/dt + div( (E + P) u ) = div( F<sub>e</sub> )* 225ea10196cSJeremy L Thompson 226ea10196cSJeremy L ThompsonViscous Stress: 227ea10196cSJeremy L Thompson 228ea10196cSJeremy L Thompson *F<sub>u</sub> = mu (grad( u ) + grad( u )^T + lambda div ( u ) I<sub>3</sub>)* 229ea10196cSJeremy L Thompson 230ea10196cSJeremy L ThompsonThermal Stress: 231ea10196cSJeremy L Thompson 232ea10196cSJeremy L Thompson *F<sub>e</sub> = u F<sub>u</sub> + k grad( T )* 233ea10196cSJeremy L Thompson 234ea10196cSJeremy L ThompsonEquation of State: 235ea10196cSJeremy L Thompson 236ea10196cSJeremy L Thompson *P = (gamma - 1) (E - rho (u u) / 2 - rho g z)* 237ea10196cSJeremy L Thompson 238ea10196cSJeremy L ThompsonTemperature: 239ea10196cSJeremy L Thompson 240ea10196cSJeremy L Thompson *T = (E / rho - (u u) / 2 - g z) / c<sub>v</sub>* 241ea10196cSJeremy L Thompson 242ea10196cSJeremy L ThompsonConstants: 243ea10196cSJeremy L Thompson 244ea10196cSJeremy L Thompson *lambda = - 2 / 3*, From Stokes hypothesis 245ea10196cSJeremy L Thompson 246ea10196cSJeremy L Thompson *mu* , Dynamic viscosity 247ea10196cSJeremy L Thompson 248ea10196cSJeremy L Thompson *k* , Thermal conductivity 249ea10196cSJeremy L Thompson 250ea10196cSJeremy L Thompson *c<sub>v</sub>* , Specific heat, constant volume 251ea10196cSJeremy L Thompson 252ea10196cSJeremy L Thompson *c<sub>p</sub>* , Specific heat, constant pressure 253ea10196cSJeremy L Thompson 254ea10196cSJeremy L Thompson *g* , Gravity 255ea10196cSJeremy L Thompson 256ea10196cSJeremy L Thompson *gamma = c<sub>p</sub> / c<sub>v</sub>*, Specific heat ratio 257ea10196cSJeremy L Thompson 258ea10196cSJeremy L Thompson#### Initial Conditions 259ea10196cSJeremy L Thompson 260ea10196cSJeremy L ThompsonPotential Temperature: 261ea10196cSJeremy L Thompson 262ea10196cSJeremy L Thompson *theta = thetabar + deltatheta* 263ea10196cSJeremy L Thompson 264ea10196cSJeremy L Thompson *thetabar = theta0 exp( N * * 2 z / g )* 265ea10196cSJeremy L Thompson 266ea10196cSJeremy L Thompson *deltatheta = 267ea10196cSJeremy L Thompson r <= rc : theta0(1 + cos(pi r)) / 2 268ea10196cSJeremy L Thompson r > rc : 0* 269ea10196cSJeremy L Thompson 270ea10196cSJeremy L Thompson *r = sqrt( (x - xc) * * 2 + (y - yc) * * 2 + (z - zc) * * 2 )* 271ea10196cSJeremy L Thompson with *(xc,yc,zc)* center of domain 272ea10196cSJeremy L Thompson 273ea10196cSJeremy L ThompsonExner Pressure: 274ea10196cSJeremy L Thompson 275ea10196cSJeremy L Thompson *Pi = Pibar + deltaPi* 276ea10196cSJeremy L Thompson 277ea10196cSJeremy L Thompson *Pibar = g * * 2 (exp( - N * * 2 z / g ) - 1) / (cp theta0 N * * 2)* 278ea10196cSJeremy L Thompson 279ea10196cSJeremy L Thompson *deltaPi = 0* (hydrostatic balance) 280ea10196cSJeremy L Thompson 281ea10196cSJeremy L ThompsonVelocity/Momentum Density: 282ea10196cSJeremy L Thompson 283ea10196cSJeremy L Thompson *U<sub>i</sub> = u<sub>i</sub> = 0* 284ea10196cSJeremy L Thompson 285ea10196cSJeremy L ThompsonConversion to Conserved Variables: 286ea10196cSJeremy L Thompson 287ea10196cSJeremy L Thompson *rho = P0 Pi**(c<sub>v</sub>/R<sub>d</sub>) / (R<sub>d</sub> theta)* 288ea10196cSJeremy L Thompson 289ea10196cSJeremy L Thompson *E = rho (c<sub>v</sub> theta Pi + (u u)/2 + g z)* 290ea10196cSJeremy L Thompson 291ea10196cSJeremy L ThompsonConstants: 292ea10196cSJeremy L Thompson 293ea10196cSJeremy L Thompson *theta0* , Potential temperature constant 294ea10196cSJeremy L Thompson 295ea10196cSJeremy L Thompson *thetaC* , Potential temperature perturbation 296ea10196cSJeremy L Thompson 297ea10196cSJeremy L Thompson *P0* , Pressure at the surface 298ea10196cSJeremy L Thompson 299ea10196cSJeremy L Thompson *N* , Brunt-Vaisala frequency 300ea10196cSJeremy L Thompson 301ea10196cSJeremy L Thompson *c<sub>v</sub>* , Specific heat, constant volume 302ea10196cSJeremy L Thompson 303ea10196cSJeremy L Thompson *c<sub>p</sub>* , Specific heat, constant pressure 304ea10196cSJeremy L Thompson 305ea10196cSJeremy L Thompson *R<sub>d</sub>* = c<sub>p</sub> - c<sub>v</sub>, Specific heat difference 306ea10196cSJeremy L Thompson 307ea10196cSJeremy L Thompson *g* , Gravity 308ea10196cSJeremy L Thompson 309ea10196cSJeremy L Thompson *r<sub>c</sub>* , Characteristic radius of thermal bubble 310ea10196cSJeremy L Thompson 311ea10196cSJeremy L Thompson *l<sub>x</sub>* , Characteristic length scale of domain in x 312ea10196cSJeremy L Thompson 313ea10196cSJeremy L Thompson *l<sub>y</sub>* , Characteristic length scale of domain in y 314ea10196cSJeremy L Thompson 315ea10196cSJeremy L Thompson *l<sub>z</sub>* , Characteristic length scale of domain in z 316ea10196cSJeremy L Thompson 317ea10196cSJeremy L Thompson 318ea10196cSJeremy L Thompson#### Boundary Conditions 319ea10196cSJeremy L Thompson 320ea10196cSJeremy L ThompsonMass Density: 321ea10196cSJeremy L Thompson 0.0 flux 322ea10196cSJeremy L Thompson 323ea10196cSJeremy L ThompsonMomentum Density: 324ea10196cSJeremy L Thompson 0.0 325ea10196cSJeremy L Thompson 326ea10196cSJeremy L ThompsonEnergy Density: 327ea10196cSJeremy L Thompson 0.0 flux 328ea10196cSJeremy L Thompson 329ea10196cSJeremy L Thompson### Time Discretization 330ea10196cSJeremy L Thompson 331682b106eSvaleriabarraFor all different problems, the time integration is performed with an explicit 332682b106eSvaleriabarraor implicit formulation. 333ea10196cSJeremy L Thompson 334ea10196cSJeremy L Thompson### Space Discretization 335ea10196cSJeremy L Thompson 336ea10196cSJeremy L ThompsonThe geometric factors and coordinate transformations required for the integration of the weak form 337ea10196cSJeremy L Thompsonare described in the file [`common.h`](common.h) 338