Lecture 2: Fundamentals 2/3: Navier-Stokes Equation Basics of Discretization V.Vuorinen Aalto University School of Engineering CFD Course, Spring 2018 January 15th 2018, Otaniemi ville.vuorinen@aalto.fi
Overview First glimpse to OpenFOAM Navier-Stokes equation Finite difference discretization of NS-eqn About homework 1
Part 1: First Glimpse to OpenFOAM: No More Engineers Who Just Click Buttons
OpenFOAM (Open Source Field Operation and Manipulation) is a free software for CFD simulations with popularity comparable to the commercial code Ansys Fluent
CFD: From Geometry Model to Post-Processing 3) Flow model (governing eqs) - Navier-Stokes? - inflow/outflow/wall boundary conditions - initial conditions 2) 3d volume mesh - fill the space with small volume elements 1) Surface model CAD software Example: The MotorBike tutorial from the OpenFOAM code showing usage of SnappyHexMesh cell-splitting utility 4) CFD simulation - turbulence approach (RANS/LES/DNS) - numerical methods (linear solvers, discretization, timestep etc) - the flow model influences the above 5) Post-processing - visualization (e.g. velocity vectors) - numeric quantities (e.g. Cd) - time-averaged quantities and time series - statistical analysis
Overview of OpenFOAM CFD Code Structure (Source: OpenFOAM User's Manual)
Overview of OpenFOAM CFD Code Structure (Source: OpenFOAM User's Manual) lity: i t u ple m a y Ex t i c ti vor and m m o the c rsion e v own r u o n g. y w. e O s : ple ent m d a u x t E ms a o F ico lvers o s ible e s h s t e pr m ple: m o m c a a n o i x h F E Mes : the pimple k e l c p o bl Exam oam or F ico nd a m com
Simulation Input: Rough Overview of OpenFOAM Lid Driven Cavity Case Folder Structure Give velocity and /0/ U p controldict /cavity/ /system/ fvschemes fvsolution blockmeshdict /constant/ /polymesh/ pressure BC's and IC's here Give simulation duration, timestep, print-out interval etc here Give time/space discretization and interpolation schemes Give e.g. linear solver settings here Simple block-structured meshes can be generated in text file format Created mesh storage transportproperties Viscosity...
Info<< "\nstarting time loop\n" << endl; while (runtime.loop()) { Info<< "Time = "<<runtime.timename()<< nl <<endl; Example: Top-level OpenFOAM icofoam incompressible solver code syntax taken from file icofoam.c #include "CourantNo.H" // Momentum predictor fvvectormatrix UEqn ( fvm::ddt(u) fvm::div(phi, U) -fvm::laplacian(nu,u) );... if (piso.momentumpredictor()) { solve(ueqn == -fvc::grad(p));} // --- PISO loop while (piso.correct()) { volscalarfield rau(1.0/ueqn.a()); volvectorfield HbyA("HbyA", U); HbyA = rau*ueqn.h(); surfacescalarfield phihbya ( "phihbya", (fvc::interpolate(hbya) & mesh.sf()) No fvc::interpolate(rau)*fvc::ddtcorr(u, phi) more engineers who just click buttons you can read the code ); lines above and relate them to CFD theory tell how simulation methods affect simulation quality Discuss in the class room what the bold faced lines could mean. Which lines can you understand, which not?
Part 2: Navier-Stokes Equation
Incompressible fluid flows can be described by NavierStokes equation Note: Typically incompressible refers to liquid or low speed gas (Mach number < 0.3) ϕ1 ( u ϕ1)= (ν 1 ϕ1 ) ϕ2 ( u ϕ2)= ( ν2 ϕ2) Navier-Stokes equation u uu=- p ν Δ u Continuity equation u=0 ρ=constant
Navier-Stokes Equation (Conservation of Momentum) Pressure gradient: ensures mass conservation u uu=- p ν Δ u Velocity vector changes in time in a given position Velocity changes in space because of molecular diffusivity 2nd derivatives Velocity changes in space because of velocity field itself 1st derivatives ν=kinematic viscosity, [ν]=m2/s u=fluid velocity
Recap of Notation and Opening Up the Differential Operators The gradient is a vector operator: = i j k x y z Used short-hand notation for multiplying vectors uu If we define u as 3 by 1 vector then how can we multiply two vectors? The used short-hand can be understood as matrix product u u=u ut In the present notation uu defines a 3 by 3 matrix, also called, tensor u u=[u i u j ] 3 3 Row index Column index
Recap of Notation Divergence of a vector is a scalar: u1 u2 u3 u= x y z Divergence of a tensor is a vector: uu=c Thus: we can think that taking divergence reduces the dimensionality of the object.
Index Notation and Einstein Summation Convention Einstein summation convention: if index appears twice, sum over the index Divergence of vector: u= ui 3 ui =Σ i=1 xi xi Divergence of tensor: ui u j ui u j uu= =u j u xj xj i xj uj ui =u u i xj ui uj =0 xj (incompressibility) Divergence of gradient of vector is a vector (why?): (ν u)=ν u=ν Δ u ν u=δ u=ν 2 ui x 2 ν 2 ui y 2 ν 2 ui z 2
Navier-Stokes in Index Notation Note that component i of velocity is the transported quantity 2 ui ui u j ui p =ν 2 xj xi xj Note that the j velocities convect the i velocity component i i Note: NS is essentially the CD equation form ϕ ϕ u j 2 ϕ =ν 2 x j xj
The Navier-Stokes Equation ϕ ( u ϕ)= ( ν ϕ) u uu=- pν Δ u u=0 NS-eqs vector form ρ=constant NS-eqs all terms opened u u u uv uw p 2 u 2 u 2 u =ν 2 ν 2 ν 2 x y z x x y z Note: we embed density into pressure because it is assumed to be a constant v v u vv vw p 2 v 2 v 2 v =ν 2 ν 2 ν 2 x y z y x y z 2 2 2 w w u wv ww p w w w =ν 2 ν ν 2 2 x y z z x y z Note: because the flow is divergence-free (incompressible) u uu=- p ν Δ u equivalence u u u=- p ν Δ u
Part 3: Lid Driven Cavity Note: Related to Homework 1
Example: the Lid driven cavity benchmark case At the moving lid the flow velocity matches the lid velocity u=( U, 0) At static walls we use the no-slip boundary condition Reynolds number Ud Re= ν u uu=- pν Δ u u=0 At static walls we use the zero-gradient boundary condition for pressure p n=0 u=( 0,0) But how do we get velocity and pressure?!
The grid and the simple grid generation of this structured grid Snapshot from the OpenFOAM mesh generation dictionary cavity/system/blockmeshdict converttometers 0.1; vertices ( (0 0 0) (1 0 0) (1 1 0) (0 1 0) (0 0 0.1) (1 0 0.1) (1 1 0.1) (0 1 0.1) ); blocks ( hex (0 1 2 3 4 5 6 7) (20 20 1) simplegrading (1 1 1) );...
Comparison of lid-driven cavity simulation with literature data Simulation by V. Vuorinen using OpenFOAM
Part 4: The very 1st basic idea of numerical solution of NS-equation Note: This is a brief first look and we will go more into detail later on.
Basic idea of numerical solution of NS-eqs The projection method (Hirsch Ch. 12) Step 1: find velocity increment in each grid point Step 2: find new velocity which must be divergence free i, j u n1 * Δ un=δ u n P u uu=- pν Δ u u =PD C Cell (i,j) Δu =P n D n C n Δt Δ u=δ t (D n C n P n ) u n1=un Δ un i, j un
Comments: - convection and diffusion terms can be easily calculated with carefully chosen finite difference methods on each timestep - pressure correction method is needed in order to find pressure - in incompressible flows pressure can not be expressed with a simple equation of state but finding pressure requires solution of linear system of Eqs - you will use pressure correction method called PISO (Pressure Implicit Splitting of Operators) which is the standard approach in OpenFOAM - the pressure correction approach we teach in the lectures is called projection method which is most typically used in modern LES/DNS simulations - Projection method is simple to learn and PISO essentially does the same job: pressure is needed to keep velocity field divergence free (incompressible)
Thank you for your attention!