Energy conserving schemes in OpenFOAM
Davide Modesti Matteo Bernardini Sergio Pirozzoli
Dipartimento di Ingegneria Meccanica ed AerospazialeUniversita’ di Roma ”La Sapienza”
HPC methods for Engineering - Milan, ItalyJune 17-19,2015
contact: [email protected]
Index
1 Introduction2 Numerical solvers3 Conservation principles4 Is OpenFOAM energy conserving?5 Energy-Conserving Schemes6 Implementation into OpenFOAM:rhoEnergyFoam7 Decaying homogeneous isotropic turbulence8 Taylor-Green flow9 Taylor-Green flow: Kinetic energy spectra10 Circular Cylinder at low Reynolds number11 Compressible channel flow: DNS12 Computational Efficiency13 Scalability14 Conclusions15 Tutorial:Time reversibility on unstructured meshes16 Tutorial:Time reversibility, extremely coarse mesh
Introduction
Objectives
I Give the idea of ”discrete energy consistency”I Capability of different schemes/solver to satisfy the kinetic
energy conservation property of Navier-Stokes equationsI Comparative study: OpenFOAM vs. other CFD solversI Test Cases:
1. Decaying isotropic turbulence2. Taylor-Green flow3. Laminar circular cylinder4. DNS of supersonic channel flows
Numerical solvers
OpenFOAM
I Open Source(GPL)I Unstructured,
Finite Volume(FV)I dnsFoam,
incompressible DNSPISO algorithm
I rhoCentralFoam,compressible,Kurganov andTadmor (TVD).
Numerical solvers
OpenFOAM
I Open Source(GPL)I Unstructured,
Finite Volume(FV)I dnsFoam,
incompressible DNSPISO algorithm
I rhoCentralFoam,compressible,Kurganov andTadmor (TVD).
Commercial Solver
I ProprietaryI Unstructured(FV)I Upwinding, TVD
Numerical solvers
OpenFOAM
I Open Source(GPL)I Unstructured,
Finite Volume(FV)I dnsFoam,
incompressible DNSPISO algorithm
I rhoCentralFoam,compressible,Kurganov andTadmor (TVD).
Commercial Solver
I ProprietaryI Unstructured(FV)I Upwinding, TVD
Finite Differencesin-house solver
I Compressibleenergy-conserving
I 3D, CartesianI Arbitrary order of
accuracy
Conservation principles
Kinetic energy
Conservation principles
Kinetic Energy
It is important to satisfy the conservation of the kinetic energy in theinviscid and incompressible limit, in an unbounded domain
Conservation principles
Kinetic Energy
It is important to satisfy the conservation of the kinetic energy in theinviscid and incompressible limit, in an unbounded domain
Discrete energy conservation:
the nonlinear terms in the Navier-Stokes equations:I do not contribute to the net variation of kinetic energyI do not dissipate or inject spurious energy
Is OpenFOAM energy conserving?cfd-online Forum
I May 27, 2011 longamon asked:”Hey Foamers...........has anyone used kinetic energyconservative schemes in OF?”
Low-dissipative schemes
I Vuorinen, V., et al. ”A low-dissipative, scale-selectivediscretization scheme for the Navier-Stokes equations.”Computers & Fluids 70 (2012): 195-205.
I Vuorinen, V., et al. ”On the implementation oflow-dissipative Runge-Kutta projection methods for timedependent flows using OpenFOAM.” Computers & Fluids 93(2014): 153-163.
Energy-Conserving SchemesNumerical Flux:
∂(ρ uϕ)∂x = 1
h
(f̂j+1/2 − f̂j−1/2
), f̂j+1/2 = 1
2 (ρj uj ϕj + ρj+1 uj+1 ϕj+1)
Energy-Conserving SchemesNumerical Flux:
∂(ρ uϕ)∂x = 1
h
(f̂j+1/2 − f̂j−1/2
), f̂j+1/2 = 1
2 (ρj uj ϕj + ρj+1 uj+1 ϕj+1)
A conservative and energy-consistent scheme has been proposed byDucros et al. (2000) and generalized by Pirozzoli (2010):
FD : f̂j+1/2 = 18 (ρj + ρj+1) (ϕj + ϕj+1) (uj + uj+1)
j j + 1
j + 1/2
Implementation into OpenFOAM:rhoEnergyFoam
Space discretization
Energy consistent numerical fluxes implementedin the OpenFOAM library:
I stability without numerical dissipation
Time integration
Explicit fourth-order Runge-Kutta time integration:I low-storage implementation, suitable for LES and DNS.
Implementation into OpenFOAM:rhoEnergyFoam
rhoEnergyFoam:
I compressible unsteady solver (subsonic and supersonic shock-freeflows)
I exact kinetic energy conservation in the inviscid andincompressible limit
I 2nd order accurate in space, 4th order in timeI Integration with the OpenFOAM thermodynamic and
turbulence librariesI Suitable for DNS and LES of compressible flows.
Decaying homogeneous isotropic turbulence
Test case proposed by Honein and Moin (2004)
E(k) = A
(k
k0
)4e−2 (k/k0)2
Viscous
Reλ ≈ 100 Mt0 = urms〈a〉
= 0.2
Inviscid
Decaying homogeneous isotropic turbulence
Mesh 323 t/τ = 5
1e-07
1e-06
1e-05
0.0001
0.001
1 10 100k
E(k)
1e-07
1e-06
1e-05
0.0001
0.001
1 10 100k
E(k)
FDFD
Viscous
1 10 100k
E(k)
1 10 100k
E(k)
FDk2FDk2
Inviscid
Decaying homogeneous isotropic turbulence
Mesh 323 t/τ = 5
1e-07
1e-06
1e-05
0.0001
0.001
1 10 100k
E(k)
1e-07
1e-06
1e-05
0.0001
0.001
1 10 100k
E(k)
FDrEFoam
FDrEFoam
Viscous
1 10 100k
E(k)
1 10 100k
E(k)
FDrEFoam
k2
FDrEFoam
k2
Inviscid
Decaying homogeneous isotropic turbulence
Mesh 323 t/τ = 5
1e-07
1e-06
1e-05
0.0001
0.001
1 10 100k
E(k)
1e-07
1e-06
1e-05
0.0001
0.001
1 10 100k
E(k)
FDrEFoam
dnsFoam
FDrEFoam
dnsFoam
Viscous
1 10 100k
E(k)
1 10 100k
E(k)
FDrEFoam
dnsFoamk2
FDrEFoam
dnsFoamk2
Inviscid
Decaying homogeneous isotropic turbulence
Mesh 323 t/τ = 5
1e-07
1e-06
1e-05
0.0001
0.001
1 10 100k
E(k)
1e-07
1e-06
1e-05
0.0001
0.001
1 10 100k
E(k)
FDrEFoam
dnsFoamCommercial
FDrEFoam
dnsFoamCommercial
Viscous
1 10 100k
E(k)
1 10 100k
E(k)
FDrEFoam
dnsFoamCommercial
k2
FDrEFoam
dnsFoamCommercial
k2
Inviscid
Decaying homogeneous isotropic turbulence
Mesh 643 t/τ = 5
1e-07
1e-06
1e-05
0.0001
0.001
1 10 100k
E(k)
1e-07
1e-06
1e-05
0.0001
0.001
1 10 100k
E(k)
FDrEFoam
dnsFoamCommercial
FDrEFoam
dnsFoamCommercial
Viscous
1 10 100k
E(k)
1 10 100k
E(k)
FDrEFoam
dnsFoamCommercial
k2
FDrEFoam
dnsFoamCommercial
k2
Inviscid
Decaying homogeneous isotropic turbulenceMesh 323
00.10.20.30.40.50.60.70.80.9
11.1
0 5 10 15 20 25 30 35 40
KTKT 0
t/τ
FDrhoEnergyFoam
dnsFoamCommercial
Inviscid
Taylor-Green flow
Test case proposed by Duponcheel et al. (2008)
Initial Conditions
u = u0 sin (k0 x) cos (k0 y) cos (k0 z)v = −u0 cos (k0 x) sin (k0 y) cos (k0 z)w = 0
Time reversibility
Euler equations are time reversible,that is:u(t, x)⇒ −u(−t, x)
Taylor-Green flow
0
1
2
3
4
5
6
7
0 2 4 6 8 10 12 14 16t
ωmax/ωmax0
0
1
2
3
4
5
6
7
0 2 4 6 8 10 12 14 16t
ωmax/ωmax0
FDFD
Taylor-Green flow
0
1
2
3
4
5
6
7
0 2 4 6 8 10 12 14 16t
ωmax/ωmax0
0
1
2
3
4
5
6
7
0 2 4 6 8 10 12 14 16t
ωmax/ωmax0
FDrhoEnergyFoam
FDrhoEnergyFoam
Taylor-Green flow
0
1
2
3
4
5
6
7
0 2 4 6 8 10 12 14 16t
ωmax/ωmax0
0
1
2
3
4
5
6
7
0 2 4 6 8 10 12 14 16t
ωmax/ωmax0
FDrhoEnergyFoam
dnsFoam
FDrhoEnergyFoam
dnsFoam
Taylor-Green flow
0
1
2
3
4
5
6
7
0 2 4 6 8 10 12 14 16t
ωmax/ωmax0
0
1
2
3
4
5
6
7
0 2 4 6 8 10 12 14 16t
ωmax/ωmax0
FDrhoEnergyFoam
dnsFoamrhoCentralFoam
FDrhoEnergyFoam
dnsFoamrhoCentralFoam
Taylor-Green flow
0
1
2
3
4
5
6
7
0 2 4 6 8 10 12 14 16t
ωmax/ωmax0
0
1
2
3
4
5
6
7
0 2 4 6 8 10 12 14 16t
ωmax/ωmax0
FDrhoEnergyFoam
dnsFoamrhoCentralFoam
Commercial
FDrhoEnergyFoam
dnsFoamrhoCentralFoam
Commercial
Taylor-Green flow
dnsFoam rhoEnergyFoam
Taylor-Green flow: Kinetic energy spectra
1e-14
1e-12
1e-10
1e-08
1e-06
0.0001
0.01
1 10k
E(k) k−2
1e-14
1e-12
1e-10
1e-08
1e-06
0.0001
0.01
1 10k
E(k) k−2
t = 0t = 16t = 0t = 16
Circular Cylinder at low Reynolds number
Regimes
Williamson (1996)I Re < 49 stationary laminarI 49 < Re < 190 laminar,
vortex sheddingI 190 < Re < 260 transitional
wake
Re=40, Mesh=64x64
l/d CD
rhoEnergyFoam 2.40 1.54icoFOAM 2.36 1.53rhoCentralFoam 1.19 1.90Commercial 1.58 1.63Taira et al. (2007) 2.30 1.56Linnick et al. (2005) 2.28 1.54Coutanceau et al. (1977)* 2.13 1.59
Circular Cylinder at low Reynolds number
rhoEnergyFoam
Vorticity
Re=200, Mesh=128x128
CD CL
rhoEnergyFoam 1.33± 0.050 ±0.66icoFoam 1.33± 0.045 ±0.69Commercial 1.26±? ±0.57rhoCentralFoam 1.30±? ±0.40Taira et al. 1.35± 0.044 ±0.69Linnick et al.* 1.34± 0.044 ±0.69
Compressible channel flow: DNSrhoEnergyFoam
Streamwise velocity in the YZ plane
Computational set-up
I Parameters:Reτ (= uτh/ν) = 220,Mb(= ub/aw) = 1.5
I Forcing: momentum andtotal energy equation, tomaintain constant massflow rate.
I Box dimensions:Lx × Ly × Lz =4πh× 2h× 4/3πh
I Mesh resolution: ∆x+ ≈10, ∆y+ < 4, ∆z+ ≈ 5About 9 milions cells
Compressible channel flow: DNSMean velocity
0
5
10
15
20
25
0.1 1 10 100
u+
y+
0
5
10
15
20
25
0.1 1 10 100
u+
y+
FDrhoEnergyFoam
FDrhoEnergyFoam
Compressible channel flow: DNSStreamwise velocity fluctuations
0
1
2
3
4
5
6
7
8
9
10
0 50 100 150 200 250
ρ/ρ
wu
′ 2+
y+
0
1
2
3
4
5
6
7
8
9
10
0 50 100 150 200 250
ρ/ρ
wu
′ 2+
y+
FDrhoEnergyFoam
FDrhoEnergyFoam
Compressible channel flow: DNSWall-normal velocity fluctuations
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0 50 100 150 200 250
ρ/ρ
wv
′ 2+
y+
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0 50 100 150 200 250
ρ/ρ
wv
′ 2+
y+
FDrhoEnergyFoam
FDrhoEnergyFoam
Compressible channel flow: DNSSpanwise velocity fluctuations
0
0.2
0.4
0.6
0.8
1
1.2
0 50 100 150 200 250
ρ/ρ
ww
′ 2+
y+
0
0.2
0.4
0.6
0.8
1
1.2
0 50 100 150 200 250
ρ/ρ
ww
′ 2+
y+
FDrhoEnergyFoam
FDrhoEnergyFoam
Compressible channel flow: DNSReynolds stress
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0 50 100 150 200 250
ρ/ρ
wu′ v′+
y+
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0 50 100 150 200 250
ρ/ρ
wu′ v′+
y+
FDrhoEnergyFoam
FDrhoEnergyFoam
Computational Efficiency
rhoCentralFoam gives the same results as the in-house(FD) solver.
Computational Efficiency
rhoCentralFoam gives the same results as the in-house(FD) solver.
⇓
What about the computational efficiency ?
Computational Efficiency
rhoCentralFoam gives the same results as the in-house(FD) solver.
⇓
What about the computational efficiency ?
Computational times
FD rhoEnergyFoam rhoCentralFoam dnsFoam Commercial1.0 5.9 5.9 5.1 20
Scalability
Linear Scalability
I FD: up to 64K CPUs and moreI standard OpenFOAM solvers: up to 1K CPUs.
Bottlenecks: I/O and linear solversI rhoEnergyFoam: ?
Conclusions
Discrete kinetic energy conservation guarantees:I stability without addition of artificial dissipationI a greater fidelity to the physicsI OpenFOAM/Commercial are not energy-conservingI OpenFOAM can be modified, the proposed scheme is easy to be
implemented in an existing solver
Future work
I Provide rhoEnergyFoam with shock-capturing capabilitiesI Scalability analysis of rhoEnergyFoamI RANS and LES simulations of complex geometries
Tutorial:Time reversibility on unstructured meshes
X
Y
0 1 2 3 4 5 60
1
2
3
4
5
6
XY Plane
0.5
1
1.5
2
2.5
3
0 2 4 6 8 10 12 14 16t∗
ωmax/ωmax0
0.5
1
1.5
2
2.5
3
0 2 4 6 8 10 12 14 16t
ωmax/ωmax0
rhoEnergyFoamrhoEnergyFoam
Tutorial:Time reversibility on unstructured meshes
Initial Time
X
Y
0 1 2 3 4 5 60
1
2
3
4
5
6
Ux: 0.1 0.06 0.02 0.02 0.06 0.1
Reversal Time
X
Y
0 1 2 3 4 5 60
1
2
3
4
5
6
Ux: 0.1 0.06 0.02 0.02 0.06 0.1
Final Time
X
Y
0 1 2 3 4 5 60
1
2
3
4
5
6
Ux: 0.1 0.04 0.02 0.08
Tutorial:Time reversibility, extremely coarse mesh
rhoEnergyFoam
I Time reversibility and energy consistency do no depend onthe mesh resolution !!!
I Let us consider a coarse mesh, 83.I Kinetic energy conservation is guaranteed ⇒ Time reversibility
Tutorial:Time reversibility, extremely coarse mesh
Tutorial:Time reversibility, extremely coarse mesh