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 | 22*925b3829SLeila Ghaffari| :-------------------------------------| :-----------------------------------------------------------------------------------------------| 23ea10196cSJeremy L Thompson| `-ceed` | CEED resource specifier | 24ea10196cSJeremy L Thompson| `-test` | Run in test mode | 25ea10196cSJeremy L Thompson| `-problem` | Problem to solve (`advection`, `advection2d`, or `density_current`) | 26*925b3829SLeila Ghaffari| `-problem_advection_wind` | Wind type in Advection (`rotation` or `translation`) | 27*925b3829SLeila Ghaffari| `-problem_advection_wind_translation` | Constant wind vector when `-problem_advection_wind translation` | 28ea10196cSJeremy L Thompson| `-stab` | Stabilization method | 29ea10196cSJeremy L Thompson| `-implicit` | Use implicit time integartor formulation | 30ea10196cSJeremy L Thompson| `-bc_wall` | Use wall boundary conditions on this list of faces | 31ea10196cSJeremy L Thompson| `-bc_slip_x` | Use slip boundary conditions, for the x component, on this list of faces | 32ea10196cSJeremy L Thompson| `-bc_slip_y` | Use slip boundary conditions, for the y component, on this list of faces | 33ea10196cSJeremy L Thompson| `-bc_slip_z` | Use slip boundary conditions, for the z component, on this list of faces | 34ea10196cSJeremy L Thompson| `-viz_refine` | Use regular refinement for visualization | 3540f3b208SJed Brown| `-degree` | Polynomial degree of tensor product basis (must be >= 1) | 36ea10196cSJeremy L Thompson| `-units_meter` | 1 meter in scaled length units | 37ea10196cSJeremy L Thompson| `-units_second` | 1 second in scaled time units | 38ea10196cSJeremy L Thompson| `-units_kilogram` | 1 kilogram in scaled mass units | 39ea10196cSJeremy L Thompson| `-units_Kelvin` | 1 Kelvin in scaled temperature units | 40ea10196cSJeremy L Thompson| `-theta0` | Reference potential temperature | 41ea10196cSJeremy L Thompson| `-thetaC` | Perturbation of potential temperature | 42ea10196cSJeremy L Thompson| `-P0` | Atmospheric pressure | 43*925b3829SLeila Ghaffari| `-P_wind` | Inflow wind pressure | 44*925b3829SLeila Ghaffari| `-rho_wind` | Inflow wind density | 45ea10196cSJeremy L Thompson| `-N` | Brunt-Vaisala frequency | 46ea10196cSJeremy L Thompson| `-cv` | Heat capacity at constant volume | 47ea10196cSJeremy L Thompson| `-cp` | Heat capacity at constant pressure | 48ea10196cSJeremy L Thompson| `-g` | Gravitational acceleration | 49ea10196cSJeremy L Thompson| `-lambda` | Stokes hypothesis second viscosity coefficient | 50ea10196cSJeremy L Thompson| `-mu` | Shear dynamic viscosity coefficient | 51ea10196cSJeremy L Thompson| `-k` | Thermal conductivity | 52ea10196cSJeremy L Thompson| `-CtauS` | Scale coefficient for stabilization tau (nondimensional) | 53ea10196cSJeremy L Thompson| `-strong_form` | Strong (1) or weak/integrated by parts (0) advection residual | 54ea10196cSJeremy L Thompson| `-lx` | Length scale in x direction | 55ea10196cSJeremy L Thompson| `-ly` | Length scale in y direction | 56ea10196cSJeremy L Thompson| `-lz` | Length scale in z direction | 57ea10196cSJeremy L Thompson| `-rc` | Characteristic radius of thermal bubble | 58ea10196cSJeremy L Thompson| `-resx` | Resolution in x | 59ea10196cSJeremy L Thompson| `-resy` | Resolution in y | 60ea10196cSJeremy L Thompson| `-resz` | Resolution in z | 61ea10196cSJeremy L Thompson| `-center` | Location of bubble center | 62ea10196cSJeremy L Thompson| `-dc_axis` | Axis of density current cylindrical anomaly, or {0,0,0} for spherically symmetric | 63ea10196cSJeremy L Thompson| `-output_freq` | Frequency of output, in number of steps | 64ea10196cSJeremy L Thompson| `-continue` | Continue from previous solution | 65ea10196cSJeremy L Thompson| `-degree` | Polynomial degree of tensor product basis | 66ea10196cSJeremy L Thompson| `-qextra` | Number of extra quadrature points | 67*925b3829SLeila Ghaffari| `-qextra_boundary` | Number of extra quadrature points on in/outflow faces | 68ea10196cSJeremy L Thompson| `-of` | Output folder | 69ea10196cSJeremy L Thompson 70682b106eSvaleriabarraFor the case of a square/cubic mesh, the list of face indices to be used with `-bc_wall` and/or `-bc_slip_x`, 71a240d89fSLeila Ghaffari`-bc_slip_y`, and `-bc_slip_z` are: 72682b106eSvaleriabarra 73682b106eSvaleriabarra* 2D: 74682b106eSvaleriabarra - faceMarkerBottom = 1; 75682b106eSvaleriabarra - faceMarkerRight = 2; 76682b106eSvaleriabarra - faceMarkerTop = 3; 77682b106eSvaleriabarra - faceMarkerLeft = 4; 78682b106eSvaleriabarra* 3D: 79682b106eSvaleriabarra - faceMarkerBottom = 1; 80682b106eSvaleriabarra - faceMarkerTop = 2; 81682b106eSvaleriabarra - faceMarkerFront = 3; 82682b106eSvaleriabarra - faceMarkerBack = 4; 83682b106eSvaleriabarra - faceMarkerRight = 5; 84682b106eSvaleriabarra - faceMarkerLeft = 6; 85ea10196cSJeremy L Thompson 86ea10196cSJeremy L Thompson### Advection 87ea10196cSJeremy L Thompson 88ea10196cSJeremy L ThompsonThis problem solves the convection (advection) equation for the total (scalar) energy density, 89ea10196cSJeremy L Thompsontransported by the (vector) velocity field. 90ea10196cSJeremy L Thompson 91ea10196cSJeremy L ThompsonThis is 3D advection given in two formulations based upon the weak form. 92ea10196cSJeremy L Thompson 93ea10196cSJeremy L ThompsonState Variables: 94ea10196cSJeremy L Thompson 95ea10196cSJeremy L Thompson *q = ( rho, U<sub>1</sub>, U<sub>2</sub>, U<sub>3</sub>, E )* 96ea10196cSJeremy L Thompson 97ea10196cSJeremy L Thompson *rho* - Mass Density 98ea10196cSJeremy L Thompson 99ea10196cSJeremy L Thompson *U<sub>i</sub>* - Momentum Density , *U<sub>i</sub> = rho ui* 100ea10196cSJeremy L Thompson 101ea10196cSJeremy L Thompson *E* - Total Energy Density, *E = rho Cv T + rho (u u) / 2 + rho g z* 102ea10196cSJeremy L Thompson 103ea10196cSJeremy L ThompsonAdvection Equation: 104ea10196cSJeremy L Thompson 105ea10196cSJeremy L Thompson *dE/dt + div( E _u_ ) = 0* 106ea10196cSJeremy L Thompson 107ea10196cSJeremy L Thompson#### Initial Conditions 108ea10196cSJeremy L Thompson 109ea10196cSJeremy L ThompsonMass Density: 110ea10196cSJeremy L Thompson Constant mass density of 1.0 111ea10196cSJeremy L Thompson 112ea10196cSJeremy L ThompsonMomentum Density: 113ea10196cSJeremy L Thompson Rotational field in x,y with no momentum in z 114ea10196cSJeremy L Thompson 115ea10196cSJeremy L ThompsonEnergy Density: 116ea10196cSJeremy L Thompson Maximum of 1. x0 decreasing linearly to 0. as radial distance increases 117ea10196cSJeremy L Thompson to 1/8, then 0. everywhere else 118ea10196cSJeremy L Thompson 119ea10196cSJeremy L Thompson#### Boundary Conditions 120ea10196cSJeremy L Thompson 121ea10196cSJeremy L ThompsonMass Density: 122ea10196cSJeremy L Thompson 0.0 flux 123ea10196cSJeremy L Thompson 124ea10196cSJeremy L ThompsonMomentum Density: 125ea10196cSJeremy L Thompson 0.0 126ea10196cSJeremy L Thompson 127ea10196cSJeremy L ThompsonEnergy Density: 128ea10196cSJeremy L Thompson 0.0 flux 129ea10196cSJeremy L Thompson 130ea10196cSJeremy L Thompson### Density Current 131ea10196cSJeremy L Thompson 132ea10196cSJeremy L ThompsonThis problem solves the full compressible Navier-Stokes equations, using 133ea10196cSJeremy L Thompsonoperator composition and design of coupled solvers in the context of atmospheric 134ea10196cSJeremy L Thompsonmodeling. This problem uses the formulation given in Semi-Implicit Formulations 135ea10196cSJeremy L Thompsonof the Navier-Stokes Equations: Application to Nonhydrostatic Atmospheric Modeling, 136ea10196cSJeremy L ThompsonGiraldo, Restelli, and Lauter (2010). 137ea10196cSJeremy L Thompson 138ea10196cSJeremy L ThompsonThe 3D compressible Navier-Stokes equations are formulated in conservation form with state 139ea10196cSJeremy L Thompsonvariables of density, momentum density, and total energy density. 140ea10196cSJeremy L Thompson 141ea10196cSJeremy L ThompsonState Variables: 142ea10196cSJeremy L Thompson 143ea10196cSJeremy L Thompson *q = ( rho, U<sub>1</sub>, U<sub>2</sub>, U<sub>3</sub>, E )* 144ea10196cSJeremy L Thompson 145ea10196cSJeremy L Thompson *rho* - Mass Density 146ea10196cSJeremy L Thompson 147ea10196cSJeremy L Thompson *U<sub>i</sub>* - Momentum Density , *U<sub>i</sub> = rho u<sub>i</sub>* 148ea10196cSJeremy L Thompson 149ea10196cSJeremy L Thompson *E* - Total Energy Density, *E = rho c<sub>v</sub> T + rho (u u) / 2 + rho g z* 150ea10196cSJeremy L Thompson 151ea10196cSJeremy L ThompsonNavier-Stokes Equations: 152ea10196cSJeremy L Thompson 153ea10196cSJeremy L Thompson *drho/dt + div( U ) = 0* 154ea10196cSJeremy L Thompson 155ea10196cSJeremy L Thompson *dU/dt + div( rho (u x u) + P I<sub>3</sub> ) + rho g khat = div( F<sub>u</sub> )* 156ea10196cSJeremy L Thompson 157ea10196cSJeremy L Thompson *dE/dt + div( (E + P) u ) = div( F<sub>e</sub> )* 158ea10196cSJeremy L Thompson 159ea10196cSJeremy L ThompsonViscous Stress: 160ea10196cSJeremy L Thompson 161ea10196cSJeremy L Thompson *F<sub>u</sub> = mu (grad( u ) + grad( u )^T + lambda div ( u ) I<sub>3</sub>)* 162ea10196cSJeremy L Thompson 163ea10196cSJeremy L ThompsonThermal Stress: 164ea10196cSJeremy L Thompson 165ea10196cSJeremy L Thompson *F<sub>e</sub> = u F<sub>u</sub> + k grad( T )* 166ea10196cSJeremy L Thompson 167ea10196cSJeremy L ThompsonEquation of State: 168ea10196cSJeremy L Thompson 169ea10196cSJeremy L Thompson *P = (gamma - 1) (E - rho (u u) / 2 - rho g z)* 170ea10196cSJeremy L Thompson 171ea10196cSJeremy L ThompsonTemperature: 172ea10196cSJeremy L Thompson 173ea10196cSJeremy L Thompson *T = (E / rho - (u u) / 2 - g z) / c<sub>v</sub>* 174ea10196cSJeremy L Thompson 175ea10196cSJeremy L ThompsonConstants: 176ea10196cSJeremy L Thompson 177ea10196cSJeremy L Thompson *lambda = - 2 / 3*, From Stokes hypothesis 178ea10196cSJeremy L Thompson 179ea10196cSJeremy L Thompson *mu* , Dynamic viscosity 180ea10196cSJeremy L Thompson 181ea10196cSJeremy L Thompson *k* , Thermal conductivity 182ea10196cSJeremy L Thompson 183ea10196cSJeremy L Thompson *c<sub>v</sub>* , Specific heat, constant volume 184ea10196cSJeremy L Thompson 185ea10196cSJeremy L Thompson *c<sub>p</sub>* , Specific heat, constant pressure 186ea10196cSJeremy L Thompson 187ea10196cSJeremy L Thompson *g* , Gravity 188ea10196cSJeremy L Thompson 189ea10196cSJeremy L Thompson *gamma = c<sub>p</sub> / c<sub>v</sub>*, Specific heat ratio 190ea10196cSJeremy L Thompson 191ea10196cSJeremy L Thompson#### Initial Conditions 192ea10196cSJeremy L Thompson 193ea10196cSJeremy L ThompsonPotential Temperature: 194ea10196cSJeremy L Thompson 195ea10196cSJeremy L Thompson *theta = thetabar + deltatheta* 196ea10196cSJeremy L Thompson 197ea10196cSJeremy L Thompson *thetabar = theta0 exp( N * * 2 z / g )* 198ea10196cSJeremy L Thompson 199ea10196cSJeremy L Thompson *deltatheta = 200ea10196cSJeremy L Thompson r <= rc : theta0(1 + cos(pi r)) / 2 201ea10196cSJeremy L Thompson r > rc : 0* 202ea10196cSJeremy L Thompson 203ea10196cSJeremy L Thompson *r = sqrt( (x - xc) * * 2 + (y - yc) * * 2 + (z - zc) * * 2 )* 204ea10196cSJeremy L Thompson with *(xc,yc,zc)* center of domain 205ea10196cSJeremy L Thompson 206ea10196cSJeremy L ThompsonExner Pressure: 207ea10196cSJeremy L Thompson 208ea10196cSJeremy L Thompson *Pi = Pibar + deltaPi* 209ea10196cSJeremy L Thompson 210ea10196cSJeremy L Thompson *Pibar = g * * 2 (exp( - N * * 2 z / g ) - 1) / (cp theta0 N * * 2)* 211ea10196cSJeremy L Thompson 212ea10196cSJeremy L Thompson *deltaPi = 0* (hydrostatic balance) 213ea10196cSJeremy L Thompson 214ea10196cSJeremy L ThompsonVelocity/Momentum Density: 215ea10196cSJeremy L Thompson 216ea10196cSJeremy L Thompson *U<sub>i</sub> = u<sub>i</sub> = 0* 217ea10196cSJeremy L Thompson 218ea10196cSJeremy L ThompsonConversion to Conserved Variables: 219ea10196cSJeremy L Thompson 220ea10196cSJeremy L Thompson *rho = P0 Pi**(c<sub>v</sub>/R<sub>d</sub>) / (R<sub>d</sub> theta)* 221ea10196cSJeremy L Thompson 222ea10196cSJeremy L Thompson *E = rho (c<sub>v</sub> theta Pi + (u u)/2 + g z)* 223ea10196cSJeremy L Thompson 224ea10196cSJeremy L ThompsonConstants: 225ea10196cSJeremy L Thompson 226ea10196cSJeremy L Thompson *theta0* , Potential temperature constant 227ea10196cSJeremy L Thompson 228ea10196cSJeremy L Thompson *thetaC* , Potential temperature perturbation 229ea10196cSJeremy L Thompson 230ea10196cSJeremy L Thompson *P0* , Pressure at the surface 231ea10196cSJeremy L Thompson 232ea10196cSJeremy L Thompson *N* , Brunt-Vaisala frequency 233ea10196cSJeremy L Thompson 234ea10196cSJeremy L Thompson *c<sub>v</sub>* , Specific heat, constant volume 235ea10196cSJeremy L Thompson 236ea10196cSJeremy L Thompson *c<sub>p</sub>* , Specific heat, constant pressure 237ea10196cSJeremy L Thompson 238ea10196cSJeremy L Thompson *R<sub>d</sub>* = c<sub>p</sub> - c<sub>v</sub>, Specific heat difference 239ea10196cSJeremy L Thompson 240ea10196cSJeremy L Thompson *g* , Gravity 241ea10196cSJeremy L Thompson 242ea10196cSJeremy L Thompson *r<sub>c</sub>* , Characteristic radius of thermal bubble 243ea10196cSJeremy L Thompson 244ea10196cSJeremy L Thompson *l<sub>x</sub>* , Characteristic length scale of domain in x 245ea10196cSJeremy L Thompson 246ea10196cSJeremy L Thompson *l<sub>y</sub>* , Characteristic length scale of domain in y 247ea10196cSJeremy L Thompson 248ea10196cSJeremy L Thompson *l<sub>z</sub>* , Characteristic length scale of domain in z 249ea10196cSJeremy L Thompson 250ea10196cSJeremy L Thompson 251ea10196cSJeremy L Thompson#### Boundary Conditions 252ea10196cSJeremy L Thompson 253ea10196cSJeremy L ThompsonMass Density: 254ea10196cSJeremy L Thompson 0.0 flux 255ea10196cSJeremy L Thompson 256ea10196cSJeremy L ThompsonMomentum Density: 257ea10196cSJeremy L Thompson 0.0 258ea10196cSJeremy L Thompson 259ea10196cSJeremy L ThompsonEnergy Density: 260ea10196cSJeremy L Thompson 0.0 flux 261ea10196cSJeremy L Thompson 262ea10196cSJeremy L Thompson### Time Discretization 263ea10196cSJeremy L Thompson 264682b106eSvaleriabarraFor all different problems, the time integration is performed with an explicit 265682b106eSvaleriabarraor implicit formulation. 266ea10196cSJeremy L Thompson 267ea10196cSJeremy L Thompson### Space Discretization 268ea10196cSJeremy L Thompson 269ea10196cSJeremy L ThompsonThe geometric factors and coordinate transformations required for the integration of the weak form 270ea10196cSJeremy L Thompsonare described in the file [`common.h`](common.h) 271