Lecture 5: Finite Volume Methods from OpenFOAM Viewpoint: Part 1
V.Vuorinen Aalto University School of Engineering CFD Course, prin! "#1$
January 30th 2017, Otaniemi
[email protected]
Lecture 5: Finite Volume Methods from OpenFOAM Viewpoint 1%"
V.Vuorinen Aalto University School of Engineering CFD Course, prin! "#1$
January 30th 2017, Otaniemi
[email protected]
Objective to provide overview of: & Kinetic energy and dissipation – periodic flow as an example & “FOAM” – Field Operation A nd Manipulation & Line by line look into an explicit OpenFOAM code
What happens to the kinetic energy of the flow if you stop stirring/pouring milk? tot
dEkin =−χ tot < 0 d t E kin=∫V tot
1 2
u
2
dV
χ tot =∫V ν | ∇ u |2 dV
Note: equation is derived by u⋅ NS and volume integrating because
What happens to the kinetic energy of the flow if you stop stirring/pouring milk? tot
dEkin =−χ tot < 0 d t E kin=∫V tot
1 2
u
2
dV
χ tot =∫V ν | ∇ u |2 dV
/* Code snapshot from the utility kinE calculating total kinetic energy */ scalar meshVol = gSum( mesh.V() ); scalar kinE = 0.5*(fvc::domainIntegrate(magSqr(U)).value())/meshVol;
Kinetic energy dissipates into heat as seen in this 2d uasi!turbulent case "periodic boundary conditions# t =10s
t =90s
t =30s
Kinetic energy dissipates into heat as seen in this 2d uasi!turbulent case "periodic boundary conditions# t =10s
t =90s
t =30s
2nd order FVM
Spectral method
$W2: %ou monitored/controlled the kinetic energy decay by numerics "numerical diffusion due to diffusive numerical scheme#
Numerics: tot
dEkin tot =−χ tot visc −χnum d t Note: the equation is derived by: u⋅( NS +ϵ ) + volume num integrating
ϵ num=ϵ dispersive +ϵ diffusive
Overview of Open&O'( )&* )ode +tructure "+ource: Open&O'( ,ser-s (anual#
Overview of Open&O'( )&* )ode +tructure "+ource: Open&O'( ,ser-s (anual#
a n d m m e c o h t : i li t y t u p l e y ” m a x E i t t i c r o “ v
r s i o n e v o ! n ” r u o g y t s O w n e : p l e t u d e n m a x S E o a m F o “ i c
n d a m m ” m a o o c F c o t h e i : “ e l r p ” l v e o s e E x a m i n e M e s h : t h e l f p e “ r E x a m
.ssentials of Open&O'( top!level solver rk4projectionFoam Vuorinen et al "omputers # Fluids $2%&'( Vuorinen et al )dvances in *ngineering Sot!are $2%&,(
.ssentials of Open&O'( top!level solver rk4projectionFoam Vuorinen et al "omputers # Fluids $2%&'( Vuorinen et al )dvances in *ngineering Sot!are $2%&,(
●
●
●
'th order e-plicit .unge/0utta time integration 2nd order e-plicit inite volumes space 1roection method $3irsch( or pressure correction
.ssentials of Open&O'( top!level solver rk4projectionFoam Vuorinen et al "omputers # Fluids $2%&'( Vuorinen et al )dvances in *ngineering Sot!are $2%&,(
.ssentials of Open&O'( top!level solver rk4projectionFoam File name:rk4projectionFoam.C
Vuorinen et al "omputers # Fluids $2%&'( Vuorinen et al )dvances in *ngineering Sot!are $2%&,( ●
●
*g pimpleFoam or icoFoam are “top/level” solvers ) top/level solver $eg rk4projectionFoam( !ould
mean: storing rk4projectionFoam.C +
some other iles in older /rk4projectionFoam/
and compiling the solver into e-ecutable !ith wmake ●
●
1art o top/level solver code can be appended to header iles $3 e-tension( 4mportant: conigure the /Make/ older accordingly
.ssentials of Open&O'( top!level solver rk4projectionFoam Vuorinen et al "omputers # Fluids $2%&'( Vuorinen et al )dvances in *ngineering Sot!are $2%&,(
phi = fvc::interpolate(U) & mesh.Sf(); dU = dt*(fvc::laplacian(nu, U) – fvc::div(phi,U)); phi = fvc::interpolate(U) & mesh.Sf(); dU = dt*(fvc::laplacian(nu, U) – fvc::div(phi,U));
Vuorinen et al "omputers # Fluids $2%&'(
FOAM – OpenFOAM provides extremely handy data types for storing data
Vuorinen et al "omputers # Fluids $2%&'(
FOAM – OpenFOAM provides extremely handy data types for storing data – Snapshots from CreateFields.H showing how fields p/U can e created
volScalarField p ( IOobject ( "p", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ), p );
volVectorField U ( IOobject ( "U", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh );
Vuorinen et al "omputers # Fluids $2%&'(
FOAM – Some possile examples of field operation and manipulation !field algera" P = rho*R*T; // ideal gas law at cell centers P = correctBoundaryConditions(); U = U + dU; // only update cell centers U.correctBoundaryConditions(); // read BC from /0/U U == U + dU; // also correct BC's P.boundaryField() = rho.boundaryField()*R.boundaryField()*T.boundaryField(); T = fvc::grad(U); // create a volTensorField
5he synta- above !or6s directly in parallel 7 the strength o FOAM
Vuorinen et al "omputers # Fluids $2%&'(
#et us interpret the following lines from math viewpoint 8 control volume centroid 8 control volume ace center
dU is a volVectorField – “vol” because it is deined at cell volume centers similar to U dU = dt*(fvc::laplacian(nu, U) – fvc::div(phi,U));
phi is a surfaceScalarField - “surface” because it
is deined at cell suraces phi = fvc::interpolate(U) & mesh.Sf();
Aout interpolation and flux limiting
5his interpolation can be carried out in various !ays:
5his interpolation is very commonly carried out by:
linear GammaV limitedLinearV vanLeer
linear
f B f C f A
f C
F9; 94M45*.S
F#$% #&M&'&N( is useul interpolation technique close to high oscillating parts: ho! !ould you numerically compute lu-
Vuorinen et al "omputers # Fluids $2%&'(
#et us interpret the following lines from math viewpoint 8 control volume centroid 8 control volume ace center
dU is a volVectorField – “vol” because it is deined at cell volume centers similar to U dU = dt*(fvc::laplacian(nu, U) – fvc::div(phi,U));
phi is a surfaceScalarField - “surface” because it
is deined at cell suraces phi = fvc::interpolate(U) & mesh.Sf(); dot product
@uter normal vectors multiplied by surace area o ace in the mesh
(otivation for $W : &luid solid interfaces "boundary layers# are crucial in heat transfer0 flow friction0 turbulence production etc C f =
Bynamic viscosity
μ=ρν
τs
Friction coeicient $local(
2
ρ U ∞ / 2
τ s =μ
( ) ∂u ∂ y
Surace shear stress
y =0
' '
q s = h (T s −T ∞ ) ' '
q s =−k T k T
ρ c p
( )
=ν T
∂ T ∂ y
y =0
Ne!tonAs cooling la! FourierAs la!
Fluid thermal conductivity
Source for pictures from instructor resources: 4ncroperaC de DittC 3eat and Mass 5ranser
Examples on #ES*+NS simulations of flows with oundary layers
BNS o turbulent pipe lo! at riction .eynolds number E%
https: