Customiza*on	
  of	
  LES	
  turbulence	
  	
  model	
  
in	
  OpenFOAM	
yotakagi77	
  
Open	
  CAE	
  Local	
  User	
  Groups	
  in	
  Japan	
  
@Kansai	
  
June	
  13,	
  2015,	
  Osaka	
  University
Agenda	
•  Basic	
  informa*on	
  on	
  turbulence	
  model	
  
•  Tensor	
  mathema*cs	
  
•  Exercise	
  1:	
  Compiling	
  and	
  execu*on	
  of	
  WALE	
  
model	
  
•  Exercise	
  2:	
  Implementa*on	
  of	
  coherent	
  
structure	
  Smagorisky	
  model	
  
•  Addi*onal	
  works	
  
Basic	
  informa*on	
  on	
  turbulence	
  model	
  
Turbulent	
  flow	
  simula*on	
DNS	
 LES	
 RANS	
Modeling	
 No	
 Subgrid	
  scale	
 Reynolds	
  average	
Accuracy	
 ◎	
 ○	
 △	
Cost	
 ×	
 ○	
 ◎	
Vortex	
  (eddy)	
  field	
 Reynolds	
  average	
 4
Turbulent	
  flow	
  simula*on	
DNS	
 LES	
 RANS	
Modeling	
 No	
 Subgrid	
  scale	
 Reynolds	
  average	
Accuracy	
 ◎	
 ○	
 △	
Cost	
 ×	
 ○	
 ◎	
DNS	
  grid,	
  u	
 Reynolds	
  average	
 5
Turbulent	
  flow	
  simula*on	
DNS	
 LES	
 RANS	
Modeling	
 No	
 Subgrid	
  scale	
 Reynolds	
  average	
Accuracy	
 ◎	
 ○	
 △	
Cost	
 ×	
 ○	
 ◎	
LES	
  grid,	
  u	
  =	
  u	
  –	
  u’	
 Reynolds	
  average	
 6
Turbulent	
  flow	
  simula*on	
DNS	
 LES	
 RANS	
Modeling	
 No	
 Subgrid	
  scale	
 Reynolds	
  average	
Accuracy	
 ◎	
 ○	
 △	
Cost	
 ×	
 ○	
 ◎	
Filtering	
  approach	
 Reynolds	
  average	
 7
Detached-­‐eddy	
  simula*on	
  (DES)	
•  P.	
  R.	
  Spalart	
  (1997):	
  
–  We	
  name	
  the	
  new	
  approach	
  “Detached-­‐Eddy	
  
Simula8on”	
  (DES)	
  to	
  emphasize	
  its	
  dis8nct	
  treatments	
  of	
  
a?ached	
  and	
  separated	
  regions.	
Super-­‐Region	
 Region	
Euler	
  (ER)	
RANS	
  (RR)	
 Viscous	
  (VR)	
Outer	
  (OR)	
LES	
  (LR)	
 Viscous	
  (VR)	
Focus	
  (FR)	
Departure	
  (DR)	
8	
Spalart	
  (2001)
Detached-­‐eddy	
  simula*on	
  (DES)	
•  P.	
  R.	
  Spalart	
  (1997):	
  
–  We	
  name	
  the	
  new	
  approach	
  “Detached-­‐Eddy	
  
Simula8on”	
  (DES)	
  to	
  emphasize	
  its	
  dis8nct	
  treatments	
  of	
  
a?ached	
  and	
  separated	
  regions.	
Super-­‐Region	
 Region	
Euler	
  (ER)	
RANS	
  (RR)	
 Viscous	
  (VR)	
Outer	
  (OR)	
LES	
  (LR)	
 Viscous	
  (VR)	
Focus	
  (FR)	
Departure	
  (DR)	
Spalart	
  (2001)	
9
Coupling	
  with	
  momentum	
  equa*on	
  
through	
  viscosity	
•  RANS	
  
	
  
•  LES	
∂U
∂t
+ ∇⋅ UU( )− ∇⋅ ν+ νt( ) ∇U + (∇U)T
( )( )= ∇p
∂U
∂t
+ ∇⋅ UU( )− ∇⋅ ν+ νSGS( ) ∇U + (∇U)T
( )( )= ∇p
Turbulent viscosity	
Sub-grid scale viscosity	
Only	
  change	
  viscosity!	
10
Significant	
  problem:	
  	
  
difference	
  of	
  filtering	
  (average)	
  approaches	
LES	
  Filtering	
 Reynolds	
  average	
Spa*al	
 Temporal	
Inconsistency	
  at	
  the	
  interface	
  between	
  LES	
  and	
  RANS	
  regions	
11
Standard	
  SGS	
  model	
  in	
  OpenFOAM	
Library	
  name	
 Note	
Smagorinksy	
 Smagorinsky	
  model	
Smagorinksy2	
 Smagorinsky	
  model	
  with	
  3-­‐D	
  filter	
homogeneousDynSmagor
insky	
Homogeneous	
  dynamic	
  Smagorinsky	
  model	
dynLagragian	
 Lagrangian	
  two	
  equa*on	
  eddy-­‐viscosity	
  model	
scaleSimilarity	
 Scale	
  similarity	
  model	
mixedSmagorinsky	
 Mixed	
  Smagorinsky	
  /	
  scale	
  similarity	
  model	
homogeneousDynOneEqE
ddy	
One	
  Equa*on	
  Eddy	
  Viscosity	
  Model	
  for	
  incompressible	
  
flows	
laminar	
 Simply	
  returns	
  laminar	
  proper*es	
kOmegaSSTSAS	
 k-­‐ω	
  SST	
  scale	
  adap*ve	
  simula*on	
  (SAS)	
  model
Standard	
  SGS	
  model	
  in	
  OpenFOAM	
Library	
  name	
 Note	
oneEqEddy	
 k-­‐equa*on	
  eddy-­‐viscosity	
  model	
dynOneEqEddy	
 Dynamic	
  k-­‐equa*on	
  eddy-­‐viscosity	
  model	
spectEddyVisc	
 Spectral	
  eddy	
  viscosity	
  model	
LRDDiffStress	
 LRR	
  differen*al	
  stress	
  model	
DeardorffDiffStress	
 Deardorff	
  differen*al	
  stress	
  model	
SpalartAllmaras	
 Spalart-­‐Allmaras	
  model	
SpalartAllmarasDDES	
 Spalart-­‐Allmaras	
  delayed	
  detached	
  eddy	
  simula*on	
  
(DDES)	
  model	
SpalartAllmarasIDDES	
 Spalart-­‐Allmaras	
  improved	
  DDES	
  (IDDES)	
  model	
vanDriestDelta	
   Simple	
  cube-­‐root	
  of	
  cell	
  volume	
  delta	
  used	
  in	
  
incompressible	
  LES	
  models
Tensor	
  mathema*cs
Tensor	
•  Rank	
  0:	
  ‘scalar’,	
  e.g.	
  volume	
  V,	
  pressure	
  p.	
  
•  Rank	
  1:	
  ‘vector’,	
  e.g.	
  velocity	
  vector	
  u,	
  surface	
  
vector	
  S.	
  Descrip*on:	
  a	
  =	
  ai	
  =	
  (a1,	
  a2,	
  a3).	
  
•  Rank	
  2:	
  ‘tensor’,	
  e.g.	
  strain	
  rate	
  tensor	
  Sij,	
  
rota*on	
  tensor	
  Ωij.	
  	
  
	
  	
  	
  	
  Descrip*on:	
  
	
  	
  
	
T = Tij =
T11 T12 T13
T21 T22 T23
T31 T32 T33
!
"
#
#
#
$
%
&
&
&
Symmetric/an*symmetric	
  tensor	
  	
•  Velocity	
  gradient	
  tensor	
  is	
  decomposed	
  into	
  
strain	
  rate	
  tensor	
  (symmetric)	
  and	
  vor*city	
  
tensor	
  (an*symmetric,	
  skew).	
  	
  
•  In	
  turbulence	
  modeling,	
  Sij	
  and	
  Ωij	
  are	
  usually	
  
used.	
Dij =
∂ui
∂xj
, Sij =
1
2
∂ui
∂xj
+
∂uj
∂xi
"
#
$$
%
&
'', Ωij =
1
2
∂ui
∂xj
−
∂uj
∂xi
"
#
$$
%
&
''
Dij = Sij +Ωij
Opera*ons	
  exclusive	
  to	
  tensors	
  of	
  rank	
  2	
T =
1
2
(T+ TT
)+
1
2
(T− TT
) = symmT+skewT,
trT = T11 +T22 +T33,
diagT = (T11,T22,T33),
T = T−
1
3
(trT)I+
1
3
(trT)I = devT+ hydT,
detT =
T11 T12 T13
T21 T22 T23
T31 T32 T33
OpenFOAM	
  tensor	
  classes	
Opera2on	
 Mathema2cal	
 Class	
Addi*on	
 a	
  +	
  b	
 a	
  +	
  b	
Subtrac*on	
 a	
  –	
  b	
 a	
  –	
  b	
Scalar	
  mul*plica*on	
 sa	
 s	
  *	
  a	
Scalar	
  division	
 a	
  /	
  s	
 a	
  /	
  s	
Outer	
  product	
 a	
  b	
 a	
  *	
  b	
Inner	
  product	
 a	
  ·∙	
  b	
 a	
  &	
  b	
Double	
  inner	
  product	
 a	
  :	
  b	
 a	
  &&	
  b	
Cross	
  product	
 a	
  ×	
  b	
 a	
  ^	
  b	
Square	
 a2	
 sqr(a)	
Magnitude	
  squared	
 |a|2	
 magSqr(a)	
Magnitude	
 |a|	
 mag(a)	
Power	
 an	
 pow(a,	
  n)
OpenFOAM	
  tensor	
  classes	
Opera2on	
 Mathema2cal	
 Class	
Transpose	
 TT	
 T.T()	
Diagonal	
 diag	
  T	
 diag(T)	
Trace	
 tr	
  T	
 tr(T)	
Deviatoric	
  component	
 dev	
  T	
 dev(T)	
Symmetric	
  component	
 symm	
  T	
 symm(T)	
Skew-­‐symmetric	
  
component	
skew	
  T	
 skew(T)	
Determinant	
 det	
  T	
 det(T)	
Cofactors	
 cof	
  T	
 cof(T)	
Inverse	
 inv	
  T	
 inv(T)
Exercise	
  1:	
  Compiling	
  and	
  execu*on	
  of	
  
WALE	
  model	
  
Governing	
  equa*on	
  for	
  incompressible	
  LES	
•  Filtered	
  con*nuity	
  and	
  Navier-­‐Stokes	
  equa*ons	
  
	
  	
  	
  	
  	
  	
  where	
∂ui
∂xi
= 0,
∂ui
∂t
+uj
∂ui
∂xj
= −
1
ρ
∂p
∂xi
+
∂
∂xi
(−τij + 2νSij )
τij = uiuj −uiuj
SGS	
  eddy	
  viscosity	
  model	
•  Decomposi*on	
  of	
  kine*c	
  energy	
  	
  
•  Conserva*on	
  of	
  GS	
  energy	
  kGS	
  
•  Conserva*on	
  of	
  SGS	
  energy	
  kSGS	
  
∂kGS
∂t
+uj
∂kGS
∂xj
= τijSij −εGS +
∂
∂xi
−uiτij −
puj
ρ
+ν
∂kGS
∂xj
#
$
%%
&
'
((
k =
1
2
ukuk =
1
2
ukuk +
1
2
(ukuk −ukuk )
kGS
kSGS
∂kSGS
∂t
+uj
∂kSGS
∂xj
= −τijSij −εSGS +
∂
∂xi
uiτij −
1
2
(uiuiuj +uj uiui )−
puj − puj
ρ
+ν
∂kSGS
∂xj
#
$
%
%
&
'
(
(
Smagorinsky	
  model	
•  Local	
  equilibrium	
  between	
  SGS	
  produc*on	
  
rate	
  and	
  SGS	
  energy	
  dissipa*on:	
  
•  Eddy	
  viscosity	
  approxima*on:	
  
•  Aper	
  dimensional	
  analysis	
  and	
  scaling,	
  
εSGS ≡ν
∂ui
∂xj
∂ui
∂uj
−ν
∂ui
∂xj
∂ui
∂xj
$
%
&&
'
(
)) = −τijSij
τij
a
= −2vSGS Sij
νSGS = (CS Δ)2
| S |, | S |= 2SijSij , CS : Smagorinsky	
  constant
WALE	
  model	
•  Traceless	
  symmetric	
  part	
  of	
  the	
  square	
  of	
  the	
  
velocity	
  gradient	
  tensor:	
  
•  Eddy	
  viscosity	
  of	
  WALE	
  model:	
  
Sij
d
=
1
2
(Dij
2
+ Dji
2
)−
1
3
δijDkk
2
= SikSkj +ΩikΩkj −
1
3
δij SmnSmn −ΩmnΩmn
#$ %&
Sij
d
Sij
d
=
1
6
(S2
S2
+Ω2
Ω2
)+
2
3
S2
Ω2
+ 2IVSΩ,
S2
= SijSij, Ω2
= ΩijΩij, IVSΩ = SikSkjΩjlΩli
νSGS = (CwΔ)2
(Sij
d
Sij
d
)3/ 2
(SijSij )5/ 2
+ (Sij
d
Sij
d
)5/ 4
(Nicoud	
  and	
  Ducros,	
  1999)
Model	
  parameters	
  of	
  WALE	
  model	
Field	
  a	
 Field	
  b	
 Field	
  c	
 Field	
  d	
 Field	
  e	
 Field	
  f	
Cw
2/Cs
2	
 10.81	
 10.52	
 10.84	
 10.55	
 10.70	
 11.27	
If CS = 0.18, 0.55 ≤ CW ≤ 0.6.
If CS = 0.1, 0.32 ≤ CW ≤ 0.34.
Model	
  parameter	
  Cw	
  is	
  dependent	
  on	
  Smagorinsky	
  
constant	
  CS.	
(Nicoud	
  and	
  Ducros,	
  1999)
Source	
  code	
  of	
  WALE	
  model	
•  V&V	
  working	
  group,	
  Open	
  CAE	
  Society	
  of	
  Japan	
  
	
  	
  	
  	
  	
  hsps://github.com/opencae/VandV/tree/master/
OpenFOAM/2.2.x/src/libraries/incompressibleWALE	
  
	
  
•  OpenFOAM-­‐dev	
  
	
  	
  	
  	
  	
  hsps://github.com/OpenFOAM/OpenFOAM-­‐dev/tree/
master/src/TurbulenceModels/turbulenceModels/LES/WALE	
  
	
  
Download	
  and	
  compile	
$  mkdir	
  –p	
  $FOAM_RUN	
  
$  cd	
  
$  git	
  clone	
  https://github.com/opencae/VandV	
  
$  cd	
  VandV/OpenFOAM/OpenFOAM-­‐BenchmarkTest/
channelReTau110	
  
$  cp	
  –r	
  src	
  $FOAM_RUN/..	
  
$  run	
  
$  cd	
  ../src/libraries/incompressibleWALE	
  
$  wmake	
  libso	
  
$  ls	
  $FOAM_USER_LIBBIN	
  
1.  Download	
  the	
  source	
  code	
  of	
  WALE	
  model	
  from	
  the	
  V&V	
  
repository,	
  and	
  compile	
  the	
  WALE	
  model	
  library.
Simula*on	
  of	
  channel	
  flow	
  	
$  run	
  
$  cp	
  –r	
  $FOAM_TUTORIALS/incompressible/pimpleFoam/
channel395/	
  ./ReTau395WALE	
  
$  cd	
  ReTau395WALE	
  
2.  The	
  standard	
  tutorial	
  case	
  of	
  channel	
  flow	
  at	
  Reτ	
  =	
  395:	
  	
  	
  
copy	
  the	
  tutorial	
  case	
  file	
  into	
  your	
  run	
  directory.	
3.  Edit	
  constant/LESProper*es	
  and	
  system/controlDict	
$  gedit	
  constant/LESProperties	
  
LESModel	
  	
  	
  	
  	
  	
  	
  	
  WALE;	
  
printCoeffs	
  	
  	
  	
  	
  on;	
  
delta	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  cubeRootVol;	
  
...
Simula*on	
  of	
  channel	
  flow	
  	
$  gedit	
  system/controlDict	
...	
  
libs 	
  ("libincompressibleWALE.so");	
  	
This	
  line	
  is	
  necessary	
  to	
  call	
  the	
  new	
  WALE	
  library	
  in	
  solver.	
$  ./Allrun	
  
4.  Aper	
  checking	
  other	
  numerical	
  condi*ons	
  and	
  parameter,	
  
run	
  the	
  solver.	
5.  If	
  the	
  solver	
  calcula*on	
  is	
  normally	
  finished,	
  you	
  check	
  the	
  
logs	
  and	
  visualize	
  the	
  flow	
  field	
  with	
  ParaView,	
  and	
  plot	
  the	
  
fields	
  profile	
  generated	
  by	
  postChannel.
Simula*on	
  of	
  channel	
  flow	
  at	
  Reτ	
  =	
  110	
$  run	
  
$  cp	
  –r	
  ~/VandV/OpenFOAM/OpenFOAM-­‐BenchmarkTest/
channelReTau110/template	
  $FOAM_RUN/ReTau110WALE	
  
$  cd	
  ReTau110WALE	
  
$  gedit	
  caseSettings	
  
6.  If	
  you	
  use	
  the	
  test	
  case	
  of	
  channel	
  flow	
  supplied	
  in	
  the	
  V&V	
  
repository,	
  copy	
  the	
  template	
  case	
  and	
  edit	
  the	
  seung.	
controlDict	
  
{	
  
	
  	
  deltaT	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  0.002;	
  
	
  	
  endTime	
  	
  	
  	
  	
  	
  	
  	
  	
  0.022;	
  
	
  	
  libs	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "libincompressibleWALE.so";	
  
}	
  
Simula*on	
  of	
  channel	
  flow	
  at	
  Reτ	
  =	
  110	
turbulenceProperties	
  
{	
  
	
  	
  simulationType	
  LESModel;	
  
}	
  
	
  
LESProperties	
  
{	
  
	
  	
  LESModel	
  WALE;	
  
	
  	
  delta	
  cubeRootVol;	
  
}	
  
The	
  original	
  caseSeungs	
  is	
  for	
  DNS	
  simula*on	
  on	
  large	
  parallel	
  
machine.	
  You	
  had	
  beser	
  to	
  change	
  other	
  parameters	
  in	
  
blockMeshDict	
  and	
  decomposeParDict.
Simula*on	
  of	
  channel	
  flow	
  at	
  Reτ	
  =	
  110	
  	
$  ./Allrun	
  
7.  Aper	
  checking	
  other	
  numerical	
  condi*ons	
  and	
  parameter,	
  
run	
  the	
  solver.	
8.  If	
  the	
  solver	
  calcula*on	
  is	
  normally	
  finished,	
  you	
  check	
  the	
  
logs	
  and	
  visualize	
  the	
  flow	
  field	
  with	
  ParaView.	
  If	
  the	
  
integra*on	
  *me	
  is	
  not	
  sufficient	
  for	
  the	
  flow	
  field	
  to	
  become	
  
fully	
  developed	
  state,	
  run	
  longer	
  simula*ons.
Exercise	
  2:	
  Implementa*on	
  of	
  coherent	
  
structure	
  Smagorisky	
  model
Original	
  source	
  codes	
  for	
  SGS	
  model	
$  src	
  
$  cd	
  turbulenceModels/incompressible/LES/	
  
$  ls	
  
1.  Check	
  the	
  original	
  source	
  code	
  for	
  SGS	
  model.	
2.  Glance	
  the	
  codes	
  of	
  Smagorinsky	
  model.	
  
$  gedit	
  Smagorinsky/Smagorinsky.*	
  
3.  In	
  this	
  exercise,	
  we	
  look	
  the	
  codes	
  of	
  dynamic	
  models.	
  
$  ls	
  *[Dd]yn*	
  
4.  Compare	
  the	
  structures	
  and	
  statements	
  of	
  the	
  related	
  codes	
  
(*.C	
  and	
  *.H).	
  
Private	
  member	
  func*ons:	
  
updateSubGridScaleFields	
  	
  	
void	
  Smagorinsky::updateSubGridScaleFields	
  
(const	
  volTensorField&	
  gradU)	
  
{	
  	
  	
  nuSgs_	
  =	
  ck_*delta()*sqrt(k(gradU));	
  
	
  	
  	
  	
  nuSgs_.correctBoundaryConditions(); 	
   	
  }	
  
void	
  dynLagrangian::updateSubGridScaleFields	
  
(const	
  tmp<volTensorField>&	
  gradU)	
  
{	
  	
  	
  nuSgs_	
  =	
  (flm_/fmm_)*sqr(delta())*mag(dev(symm(gradU)));	
  
	
  	
  	
  	
  nuSgs_.correctBoundaryConditions(); 	
   	
  }	
  
void	
  dynOneEqEddy::updateSubGridScaleFields	
  
(	
  	
  	
  const	
  volSymmTensorField&	
  D,	
  
	
  	
  	
  	
  const	
  volScalarField&	
  KK	
   	
  )	
  
{	
  	
  	
  nuSgs_	
  =	
  ck(D,	
  KK)*sqrt(k_)*delta();	
  
	
  	
  	
  	
  nuSgs_.correctBoundaryConditions(); 	
   	
  }	
  
In	
  Smagorinsky.C	
In	
  dynLagrangian.C	
In	
  dynOneEqEddy.C
Understanding	
  formula*on	
  with	
  codes	
•  What	
  calcula*on,	
  mathema*cal	
  opera*on,	
  and	
  variable	
  are	
  
necessary	
  for	
  coherent	
  structure	
  Smagosinsky	
  model	
  (CSM)?	
  
Compare	
  the	
  formula*on	
  of	
  models	
  with	
  the	
  related	
  source	
  
codes.	
  
•  In	
  CSM,	
  the	
  second	
  invariant	
  of	
  velocity	
  gradient	
  is	
  used:	
  
	
  	
  	
  	
  	
  where	
  
€
Q =
1
2
ΩijΩij − SijSij( )= −
1
2
∂uj
∂xi
∂ui
∂xj
Sij =
1
2
∂ui
∂xj
+
∂uj
∂xi
#
$
%%
&
'
((, Ωij =
1
2
∂ui
∂xj
−
∂uj
∂xi
#
$
%%
&
'
((
Coherent	
  structure	
  Smagorinsky	
  model	
  for	
  non-­‐
rota*ng	
  flow	
  (NRCSM)	
•  Smagorinsky	
  model	
  (SM)	
  based	
  on	
  an	
  eddy-­‐viscosity,	
  
•  The	
  model	
  parameter	
  C	
  is	
  determined	
  as	
  follows:	
  
	
  with	
  
	
  where	
  
	
  
	
  
	
  	
  	
  	
  	
  NRCSM	
  model	
  is	
  invalid	
  for	
  rota*ng	
  flow.	
  
	
  
€
C = C1 | FCS |3/ 2
€
C1 =
1
20
, FCS =
Q
E
€
τij
a
= −2CΔ2
| S | Sij
(τij
a
= −2νt Sij, νt = CΔ2
| S |)
E =
1
2
ΩijΩij + SijSij( )=
1
2
∂ui
∂xj
$
%
&&
'
(
))
2
Coherent	
  structure	
  Smagorinsky	
  model	
  (CSM)	
•  Smagorinsky	
  model	
  (SM)	
  based	
  on	
  an	
  eddy-­‐viscosity,	
  
•  The	
  model	
  parameter	
  C	
  is	
  determined	
  as	
  follows:	
  
	
  with	
  
	
  where	
  
	
  
	
  
	
  Improved	
  CSM	
  model	
  is	
  valid	
  for	
  rota*ng	
  flow.	
  
	
  
€
C = C2 | FCS |3/ 2
FΩ
€
C2 =
1
22
, FCS =
Q
E
, FΩ =1− FCS
€
τij
a
= −2CΔ2
| S | Sij
(τij
a
= −2νt Sij, νt = CΔ2
| S |)
E =
1
2
ΩijΩij + SijSij( )=
1
2
∂ui
∂xj
$
%
&&
'
(
))
2
Seung	
  for	
  making	
  new	
  library	
$  run	
  
$  cd	
  ../src/libraries	
  
$  cp	
  -­‐r	
  incompressibleWALE/WALE/	
  ./NRCSM	
  
$  cp	
  –r	
  incompressibleWALE/Make	
  ./NRCSM	
  
$  cd	
  NRCSM	
  
$  rename	
  WALE	
  NRCSM	
  *	
  
$  rm	
  –r	
  NRCSM.dep	
  
$  rm	
  –rf	
  Make/linux64Gcc47DPOpt	
  
$  gedit	
  Make/files	
  
1.  Copy	
  the	
  source	
  code	
  of	
  	
  WALE	
  model.	
  Compile	
  them.	
NRCSM.C	
  
LIB	
  =	
  $(FOAM_USER_LIBBIN)/libNRCSM	
  
$  sed	
  –i	
  ‘s/WALE/NRCSM/g’	
  NRCSM.C	
  	
  
$  sed	
  –i	
  ‘s/WALE/NRCSM/g’	
  NRCSM.H	
  
Seung	
  for	
  making	
  new	
  library	
$  wmake	
  libso	
  
$  ls	
  $FOAM_USER_LIBBIN	
  
If	
  you	
  find	
  the	
  renamed	
  and	
  recompiled	
  library	
  (libNRCSM.so),	
  
you	
  are	
  ready	
  to	
  make	
  a	
  new	
  library	
  for	
  the	
  NRCSM.	
  
	
  
2. You	
  can	
  easily	
  learn	
  the	
  codes	
  for	
  calcula*ng	
  the	
  Q	
  and	
  E	
  
terms	
  from	
  the	
  postProcessing	
  u*li*es.	
  
	
  
	
  
	
  
	
  
There	
  are	
  two	
  ways	
  of	
  calcula*ng	
  Q,	
  that	
  is,	
  with	
  velocity	
  
gradient	
  tensor	
  and	
  with	
  SS	
  and	
  ΩΩ terms.	
$  util	
  
$  cd	
  postProcessing/velocityField/Q	
  
$  gedit	
  Q.C	
  &	
  
Introducing	
  model	
  coefficient	
  C1	
$  run	
  
$  cd	
  ../src/libraries/NRCSM/	
  
$  gedit	
  NRCSM.C	
  NRCSM.H	
  
3.  Replace	
  all	
  ‘cw’	
  with	
  ‘c1’	
  (gedit	
  or	
  sed),	
  and	
  change	
  the	
  value	
  
to	
  0.05.	
  
	
  	
  	
  	
  c1_	
  
	
  	
  	
  	
  (	
  
	
  	
  	
  	
  	
  	
  	
  	
  dimensioned<scalar>::lookupOrAddToDict	
  
	
  	
  	
  	
  	
  	
  	
  	
  (	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "c1",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  coeffDict_,	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  0.05	
  
	
  	
  	
  	
  	
  	
  	
  	
  )	
  
	
  	
  	
  	
  )	
  
NRCSM.C	
  
$  wmake	
  libso	
  
Q	
  and	
  E	
  calcula*ons	
4.  In	
  NRCSM.C,	
  insert	
  the	
  calcula*on	
  of	
  Q	
  and	
  E.	
  Copy&Paste	
  
the	
  corresponding	
  sec*on	
  from	
  Q.C.	
  Save	
  and	
  Compile	
  them.	
  
volScalarField	
  Q	
  
(	
  
	
  0.5*(sqr(tr(gradU))	
  -­‐	
  tr(((gradU)&(gradU))))	
  
);	
  
volScalarField	
  E	
  
(	
  
	
  0.5*(gradU	
  &&	
  gradU)	
  
);	
  
NRCSM.C	
  
$  gedit	
  NRCSM.C	
  
$  wmake	
  libso	
  
FCS	
  and	
  C	
  calcula*ons	
5.  In	
  NRCSM.C,	
  insert	
  the	
  calcula*on	
  of	
  FCS	
  and	
  C	
  (coefficient	
  
of	
  eddy	
  viscosity	
  model).	
  Save	
  and	
  Compile	
  them.	
  
volScalarField	
  Fcs	
  
(	
  
	
  Q/
max(E,dimensionedScalar("SMALL",E.dimensions(),SMALL))	
  
);	
  
volScalarField	
  ccsm_	
  
(	
  
	
  	
  	
  c1_*pow(mag(Fcs),1.5)	
  
);	
  
NRCSM.C	
  
$  gedit	
  NRCSM.C	
  
$  wmake	
  libso	
  
νSGS	
  calcula*on	
6.  In	
  NRCSM.C,	
  modify	
  the	
  nuSGS_	
  calcula*on.	
  Look	
  the	
  other	
  
updateSubGridScaleFields	
  func*ons	
  in	
  the	
  dynamic	
  models.	
  
nuSgs_	
  =	
  ccsm_*sqr(delta())*mag(dev(symm(gradU)));	
  
NRCSM.C	
  
Save	
  and	
  compile	
  them.	
  
$  wmake	
  libso	
  
7.  Finally,	
  comment	
  out	
  or	
  delete	
  unnecessary	
  statements	
  (the	
  
calcula*ons	
  for	
  WALE	
  model).	
  Save	
  and	
  compile	
  them.	
  
$  wmake	
  libso	
  
$  gedit	
  NRCSM.C	
  
kSGS	
  calcula*on	
//-­‐	
  Return	
  SGS	
  kinetic	
  energy	
  
//	
  	
  calculated	
  from	
  the	
  given	
  velocity	
  gradient	
  
tmp<volScalarField>	
  k(const	
  tmp<volTensorField>&	
  gradU)	
  const	
  
{	
  
	
  return	
  (2.0*c1_/ce_)*sqr(delta())*magSqr(dev(symm(gradU)));	
  
}	
  
NRCSM.H	
  
8.  The	
  calcula*on	
  of	
  kSGS	
  is	
  invalid,	
  but	
  the	
  value	
  of	
  kSGS	
  is	
  not	
  
actually	
  used	
  in	
  LES	
  with	
  NRCSM	
  model.	
  If	
  you	
  requires	
  a	
  
proper	
  kSGS,	
  consult	
  the	
  paper	
  of	
  Kobayashi	
  (PoF,	
  2005).	
  
Valida*on	
  with	
  channel	
  flow	
$  run	
  
$  cp	
  –r	
  $FOAM_TUTORIALS/incompressible/pimpleFoam/
channel395/	
  ./ReTau395NRCSM	
  
$  cd	
  ReTau395NRCSM	
  
9.  The	
  standard	
  tutorial	
  case	
  of	
  channel	
  flow	
  at	
  Reτ	
  =	
  395:	
  	
  	
  
copy	
  the	
  tutorial	
  case	
  file	
  into	
  your	
  run	
  directory.	
10. Edit	
  constant/LESProper*es	
  and	
  system/controlDict	
$  gedit	
  constant/LESProperties	
  
LESModel	
  	
  	
  	
  	
  	
  	
  	
  NRCSM;	
  
printCoeffs	
  	
  	
  	
  	
  on;	
  
delta	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  cubeRootVol;	
  
...
Valida*on	
  with	
  channel	
  flow	
$  gedit	
  system/controlDict	
...	
  
libs 	
  ("libNRCSM.so");	
  	
This	
  line	
  is	
  necessary	
  to	
  call	
  the	
  new	
  NRCSM	
  library	
  in	
  solver.	
$  ./Allrun	
  
11. Aper	
  checking	
  other	
  numerical	
  condi*ons	
  and	
  parameter,	
  
run	
  the	
  solver.	
12. If	
  the	
  solver	
  calcula*on	
  is	
  normally	
  finished,	
  you	
  check	
  the	
  
logs	
  and	
  visualize	
  the	
  flow	
  field	
  with	
  ParaView,	
  and	
  plot	
  the	
  
fields	
  profile	
  generated	
  by	
  postChannel.
Addi*onal	
  works	
1.  Compile	
  and	
  test	
  the	
  WALE	
  model	
  supplied	
  from	
  
openfoam-­‐dev.	
  Prepare	
  a	
  Make	
  directory	
  by	
  
yourself.	
  
2.  Implementa*on	
  of	
  CSM	
  model.	
  Add	
  FΩ	
  term	
  and	
  C2	
  
coefficient.	
  
3.  Calcula*on	
  of	
  Q	
  and	
  E	
  terms	
  with	
  SS	
  and	
  ΩΩ	
  terms.	
  
Compare	
  the	
  results	
  with	
  the	
  solu*on	
  of	
  Exercise	
  2.	
  
4.  Valida*on	
  of	
  customized	
  model	
  with	
  other	
  flow	
  
fields	
  such	
  pipe,	
  backstep,	
  cylinder,	
  and	
  rota*ng	
  
flow.	
  
References	
•  OpenFOAM	
  User	
  Guide	
  
•  OpenFOAM	
  Programmer’s	
  Guide	
  
•  梶島,	
  乱流の数値シミュレーション 改訂版,	
  養賢堂	
  (2014).	
  
•  P.	
  R.	
  Spalart	
  et	
  al.,	
  “Comments	
  on	
  the	
  Feasibility	
  of	
  LES	
  for	
  
Wings,	
  and	
  on	
  a	
  Hybrid	
  RANS/LES	
  Approach”,	
  1st	
  ASOSR	
  
CONFERENCE	
  on	
  DNS/LES	
  (1997).	
  
•  P.	
  R.	
  Spalart,	
  “Young-­‐Person’s	
  Guide	
  to	
  Detached-­‐Eddy	
  
Simula*on	
  Grids”,	
  NASA	
  CR-­‐2001-­‐211032	
  (2001).	
  
•  F.	
  Nicoud	
  and	
  F.	
  Ducros,	
  “Subgrid-­‐scale	
  modelling	
  based	
  on	
  
the	
  square	
  of	
  velocity	
  gradient	
  tensor”,	
  Flow,	
  Turbulence	
  and	
  
Combus*on,	
  62,	
  pp.183-­‐200	
  (1999).	
  
References	
•  小林,	
  “乱流構造に基づくサブグリッドスケールモデルの開
発”,	
  ながれ,	
  29,	
  pp.157-­‐160	
  (2010).	
  
•  H.	
  Kobayashi,	
  “The	
  subgrid-­‐scale	
  models	
  based	
  on	
  coherent	
  
structures	
  for	
  rota*ng	
  homogeneous	
  turbulence	
  and	
  
turbulent	
  channel	
  flow”,	
  Phys.	
  Fluids,	
  17,	
  045104	
  (2005).	
  
•  H.	
  Kobayashi,	
  F.	
  Ham	
  and	
  X.	
  Wu,	
  “Applica*on	
  of	
  a	
  local	
  SGS	
  
model	
  based	
  on	
  coherent	
  structures	
  to	
  complex	
  geometries”,	
  
Int.	
  J.	
  Heat	
  Fluid	
  Flow,	
  29,	
  pp.640-­‐653	
  (2008).	
  

Customization of LES turbulence model in OpenFOAM

  • 1.
    Customiza*on  of  LES  turbulence    model   in  OpenFOAM yotakagi77   Open  CAE  Local  User  Groups  in  Japan   @Kansai   June  13,  2015,  Osaka  University
  • 2.
    Agenda •  Basic  informa*on  on  turbulence  model   •  Tensor  mathema*cs   •  Exercise  1:  Compiling  and  execu*on  of  WALE   model   •  Exercise  2:  Implementa*on  of  coherent   structure  Smagorisky  model   •  Addi*onal  works  
  • 3.
    Basic  informa*on  on  turbulence  model  
  • 4.
    Turbulent  flow  simula*on DNS LES RANS Modeling No Subgrid  scale Reynolds  average Accuracy ◎ ○ △ Cost × ○ ◎ Vortex  (eddy)  field Reynolds  average 4
  • 5.
    Turbulent  flow  simula*on DNS LES RANS Modeling No Subgrid  scale Reynolds  average Accuracy ◎ ○ △ Cost × ○ ◎ DNS  grid,  u Reynolds  average 5
  • 6.
    Turbulent  flow  simula*on DNS LES RANS Modeling No Subgrid  scale Reynolds  average Accuracy ◎ ○ △ Cost × ○ ◎ LES  grid,  u  =  u  –  u’ Reynolds  average 6
  • 7.
    Turbulent  flow  simula*on DNS LES RANS Modeling No Subgrid  scale Reynolds  average Accuracy ◎ ○ △ Cost × ○ ◎ Filtering  approach Reynolds  average 7
  • 8.
    Detached-­‐eddy  simula*on  (DES) • P.  R.  Spalart  (1997):   –  We  name  the  new  approach  “Detached-­‐Eddy   Simula8on”  (DES)  to  emphasize  its  dis8nct  treatments  of   a?ached  and  separated  regions. Super-­‐Region Region Euler  (ER) RANS  (RR) Viscous  (VR) Outer  (OR) LES  (LR) Viscous  (VR) Focus  (FR) Departure  (DR) 8 Spalart  (2001)
  • 9.
    Detached-­‐eddy  simula*on  (DES) • P.  R.  Spalart  (1997):   –  We  name  the  new  approach  “Detached-­‐Eddy   Simula8on”  (DES)  to  emphasize  its  dis8nct  treatments  of   a?ached  and  separated  regions. Super-­‐Region Region Euler  (ER) RANS  (RR) Viscous  (VR) Outer  (OR) LES  (LR) Viscous  (VR) Focus  (FR) Departure  (DR) Spalart  (2001) 9
  • 10.
    Coupling  with  momentum  equa*on   through  viscosity •  RANS     •  LES ∂U ∂t + ∇⋅ UU( )− ∇⋅ ν+ νt( ) ∇U + (∇U)T ( )( )= ∇p ∂U ∂t + ∇⋅ UU( )− ∇⋅ ν+ νSGS( ) ∇U + (∇U)T ( )( )= ∇p Turbulent viscosity Sub-grid scale viscosity Only  change  viscosity! 10
  • 11.
    Significant  problem:     difference  of  filtering  (average)  approaches LES  Filtering Reynolds  average Spa*al Temporal Inconsistency  at  the  interface  between  LES  and  RANS  regions 11
  • 12.
    Standard  SGS  model  in  OpenFOAM Library  name Note Smagorinksy Smagorinsky  model Smagorinksy2 Smagorinsky  model  with  3-­‐D  filter homogeneousDynSmagor insky Homogeneous  dynamic  Smagorinsky  model dynLagragian Lagrangian  two  equa*on  eddy-­‐viscosity  model scaleSimilarity Scale  similarity  model mixedSmagorinsky Mixed  Smagorinsky  /  scale  similarity  model homogeneousDynOneEqE ddy One  Equa*on  Eddy  Viscosity  Model  for  incompressible   flows laminar Simply  returns  laminar  proper*es kOmegaSSTSAS k-­‐ω  SST  scale  adap*ve  simula*on  (SAS)  model
  • 13.
    Standard  SGS  model  in  OpenFOAM Library  name Note oneEqEddy k-­‐equa*on  eddy-­‐viscosity  model dynOneEqEddy Dynamic  k-­‐equa*on  eddy-­‐viscosity  model spectEddyVisc Spectral  eddy  viscosity  model LRDDiffStress LRR  differen*al  stress  model DeardorffDiffStress Deardorff  differen*al  stress  model SpalartAllmaras Spalart-­‐Allmaras  model SpalartAllmarasDDES Spalart-­‐Allmaras  delayed  detached  eddy  simula*on   (DDES)  model SpalartAllmarasIDDES Spalart-­‐Allmaras  improved  DDES  (IDDES)  model vanDriestDelta   Simple  cube-­‐root  of  cell  volume  delta  used  in   incompressible  LES  models
  • 14.
  • 15.
    Tensor •  Rank  0:  ‘scalar’,  e.g.  volume  V,  pressure  p.   •  Rank  1:  ‘vector’,  e.g.  velocity  vector  u,  surface   vector  S.  Descrip*on:  a  =  ai  =  (a1,  a2,  a3).   •  Rank  2:  ‘tensor’,  e.g.  strain  rate  tensor  Sij,   rota*on  tensor  Ωij.            Descrip*on:       T = Tij = T11 T12 T13 T21 T22 T23 T31 T32 T33 ! " # # # $ % & & &
  • 16.
    Symmetric/an*symmetric  tensor   • Velocity  gradient  tensor  is  decomposed  into   strain  rate  tensor  (symmetric)  and  vor*city   tensor  (an*symmetric,  skew).     •  In  turbulence  modeling,  Sij  and  Ωij  are  usually   used. Dij = ∂ui ∂xj , Sij = 1 2 ∂ui ∂xj + ∂uj ∂xi " # $$ % & '', Ωij = 1 2 ∂ui ∂xj − ∂uj ∂xi " # $$ % & '' Dij = Sij +Ωij
  • 17.
    Opera*ons  exclusive  to  tensors  of  rank  2 T = 1 2 (T+ TT )+ 1 2 (T− TT ) = symmT+skewT, trT = T11 +T22 +T33, diagT = (T11,T22,T33), T = T− 1 3 (trT)I+ 1 3 (trT)I = devT+ hydT, detT = T11 T12 T13 T21 T22 T23 T31 T32 T33
  • 18.
    OpenFOAM  tensor  classes Opera2on Mathema2cal Class Addi*on a  +  b a  +  b Subtrac*on a  –  b a  –  b Scalar  mul*plica*on sa s  *  a Scalar  division a  /  s a  /  s Outer  product a  b a  *  b Inner  product a  ·∙  b a  &  b Double  inner  product a  :  b a  &&  b Cross  product a  ×  b a  ^  b Square a2 sqr(a) Magnitude  squared |a|2 magSqr(a) Magnitude |a| mag(a) Power an pow(a,  n)
  • 19.
    OpenFOAM  tensor  classes Opera2on Mathema2cal Class Transpose TT T.T() Diagonal diag  T diag(T) Trace tr  T tr(T) Deviatoric  component dev  T dev(T) Symmetric  component symm  T symm(T) Skew-­‐symmetric   component skew  T skew(T) Determinant det  T det(T) Cofactors cof  T cof(T) Inverse inv  T inv(T)
  • 20.
    Exercise  1:  Compiling  and  execu*on  of   WALE  model  
  • 21.
    Governing  equa*on  for  incompressible  LES •  Filtered  con*nuity  and  Navier-­‐Stokes  equa*ons              where ∂ui ∂xi = 0, ∂ui ∂t +uj ∂ui ∂xj = − 1 ρ ∂p ∂xi + ∂ ∂xi (−τij + 2νSij ) τij = uiuj −uiuj
  • 22.
    SGS  eddy  viscosity  model •  Decomposi*on  of  kine*c  energy     •  Conserva*on  of  GS  energy  kGS   •  Conserva*on  of  SGS  energy  kSGS   ∂kGS ∂t +uj ∂kGS ∂xj = τijSij −εGS + ∂ ∂xi −uiτij − puj ρ +ν ∂kGS ∂xj # $ %% & ' (( k = 1 2 ukuk = 1 2 ukuk + 1 2 (ukuk −ukuk ) kGS kSGS ∂kSGS ∂t +uj ∂kSGS ∂xj = −τijSij −εSGS + ∂ ∂xi uiτij − 1 2 (uiuiuj +uj uiui )− puj − puj ρ +ν ∂kSGS ∂xj # $ % % & ' ( (
  • 23.
    Smagorinsky  model •  Local  equilibrium  between  SGS  produc*on   rate  and  SGS  energy  dissipa*on:   •  Eddy  viscosity  approxima*on:   •  Aper  dimensional  analysis  and  scaling,   εSGS ≡ν ∂ui ∂xj ∂ui ∂uj −ν ∂ui ∂xj ∂ui ∂xj $ % && ' ( )) = −τijSij τij a = −2vSGS Sij νSGS = (CS Δ)2 | S |, | S |= 2SijSij , CS : Smagorinsky  constant
  • 24.
    WALE  model •  Traceless  symmetric  part  of  the  square  of  the   velocity  gradient  tensor:   •  Eddy  viscosity  of  WALE  model:   Sij d = 1 2 (Dij 2 + Dji 2 )− 1 3 δijDkk 2 = SikSkj +ΩikΩkj − 1 3 δij SmnSmn −ΩmnΩmn #$ %& Sij d Sij d = 1 6 (S2 S2 +Ω2 Ω2 )+ 2 3 S2 Ω2 + 2IVSΩ, S2 = SijSij, Ω2 = ΩijΩij, IVSΩ = SikSkjΩjlΩli νSGS = (CwΔ)2 (Sij d Sij d )3/ 2 (SijSij )5/ 2 + (Sij d Sij d )5/ 4 (Nicoud  and  Ducros,  1999)
  • 25.
    Model  parameters  of  WALE  model Field  a Field  b Field  c Field  d Field  e Field  f Cw 2/Cs 2 10.81 10.52 10.84 10.55 10.70 11.27 If CS = 0.18, 0.55 ≤ CW ≤ 0.6. If CS = 0.1, 0.32 ≤ CW ≤ 0.34. Model  parameter  Cw  is  dependent  on  Smagorinsky   constant  CS. (Nicoud  and  Ducros,  1999)
  • 26.
    Source  code  of  WALE  model •  V&V  working  group,  Open  CAE  Society  of  Japan            hsps://github.com/opencae/VandV/tree/master/ OpenFOAM/2.2.x/src/libraries/incompressibleWALE     •  OpenFOAM-­‐dev            hsps://github.com/OpenFOAM/OpenFOAM-­‐dev/tree/ master/src/TurbulenceModels/turbulenceModels/LES/WALE    
  • 27.
    Download  and  compile $ mkdir  –p  $FOAM_RUN   $  cd   $  git  clone  https://github.com/opencae/VandV   $  cd  VandV/OpenFOAM/OpenFOAM-­‐BenchmarkTest/ channelReTau110   $  cp  –r  src  $FOAM_RUN/..   $  run   $  cd  ../src/libraries/incompressibleWALE   $  wmake  libso   $  ls  $FOAM_USER_LIBBIN   1.  Download  the  source  code  of  WALE  model  from  the  V&V   repository,  and  compile  the  WALE  model  library.
  • 28.
    Simula*on  of  channel  flow   $  run   $  cp  –r  $FOAM_TUTORIALS/incompressible/pimpleFoam/ channel395/  ./ReTau395WALE   $  cd  ReTau395WALE   2.  The  standard  tutorial  case  of  channel  flow  at  Reτ  =  395:       copy  the  tutorial  case  file  into  your  run  directory. 3.  Edit  constant/LESProper*es  and  system/controlDict $  gedit  constant/LESProperties   LESModel                WALE;   printCoeffs          on;   delta                      cubeRootVol;   ...
  • 29.
    Simula*on  of  channel  flow   $  gedit  system/controlDict ...   libs  ("libincompressibleWALE.so");   This  line  is  necessary  to  call  the  new  WALE  library  in  solver. $  ./Allrun   4.  Aper  checking  other  numerical  condi*ons  and  parameter,   run  the  solver. 5.  If  the  solver  calcula*on  is  normally  finished,  you  check  the   logs  and  visualize  the  flow  field  with  ParaView,  and  plot  the   fields  profile  generated  by  postChannel.
  • 30.
    Simula*on  of  channel  flow  at  Reτ  =  110 $  run   $  cp  –r  ~/VandV/OpenFOAM/OpenFOAM-­‐BenchmarkTest/ channelReTau110/template  $FOAM_RUN/ReTau110WALE   $  cd  ReTau110WALE   $  gedit  caseSettings   6.  If  you  use  the  test  case  of  channel  flow  supplied  in  the  V&V   repository,  copy  the  template  case  and  edit  the  seung. controlDict   {      deltaT                    0.002;      endTime                  0.022;      libs                        "libincompressibleWALE.so";   }  
  • 31.
    Simula*on  of  channel  flow  at  Reτ  =  110 turbulenceProperties   {      simulationType  LESModel;   }     LESProperties   {      LESModel  WALE;      delta  cubeRootVol;   }   The  original  caseSeungs  is  for  DNS  simula*on  on  large  parallel   machine.  You  had  beser  to  change  other  parameters  in   blockMeshDict  and  decomposeParDict.
  • 32.
    Simula*on  of  channel  flow  at  Reτ  =  110   $  ./Allrun   7.  Aper  checking  other  numerical  condi*ons  and  parameter,   run  the  solver. 8.  If  the  solver  calcula*on  is  normally  finished,  you  check  the   logs  and  visualize  the  flow  field  with  ParaView.  If  the   integra*on  *me  is  not  sufficient  for  the  flow  field  to  become   fully  developed  state,  run  longer  simula*ons.
  • 33.
    Exercise  2:  Implementa*on  of  coherent   structure  Smagorisky  model
  • 34.
    Original  source  codes  for  SGS  model $  src   $  cd  turbulenceModels/incompressible/LES/   $  ls   1.  Check  the  original  source  code  for  SGS  model. 2.  Glance  the  codes  of  Smagorinsky  model.   $  gedit  Smagorinsky/Smagorinsky.*   3.  In  this  exercise,  we  look  the  codes  of  dynamic  models.   $  ls  *[Dd]yn*   4.  Compare  the  structures  and  statements  of  the  related  codes   (*.C  and  *.H).  
  • 35.
    Private  member  func*ons:   updateSubGridScaleFields     void  Smagorinsky::updateSubGridScaleFields   (const  volTensorField&  gradU)   {      nuSgs_  =  ck_*delta()*sqrt(k(gradU));          nuSgs_.correctBoundaryConditions();    }   void  dynLagrangian::updateSubGridScaleFields   (const  tmp<volTensorField>&  gradU)   {      nuSgs_  =  (flm_/fmm_)*sqr(delta())*mag(dev(symm(gradU)));          nuSgs_.correctBoundaryConditions();    }   void  dynOneEqEddy::updateSubGridScaleFields   (      const  volSymmTensorField&  D,          const  volScalarField&  KK    )   {      nuSgs_  =  ck(D,  KK)*sqrt(k_)*delta();          nuSgs_.correctBoundaryConditions();    }   In  Smagorinsky.C In  dynLagrangian.C In  dynOneEqEddy.C
  • 36.
    Understanding  formula*on  with  codes •  What  calcula*on,  mathema*cal  opera*on,  and  variable  are   necessary  for  coherent  structure  Smagosinsky  model  (CSM)?   Compare  the  formula*on  of  models  with  the  related  source   codes.   •  In  CSM,  the  second  invariant  of  velocity  gradient  is  used:            where   € Q = 1 2 ΩijΩij − SijSij( )= − 1 2 ∂uj ∂xi ∂ui ∂xj Sij = 1 2 ∂ui ∂xj + ∂uj ∂xi # $ %% & ' ((, Ωij = 1 2 ∂ui ∂xj − ∂uj ∂xi # $ %% & ' ((
  • 37.
    Coherent  structure  Smagorinsky  model  for  non-­‐ rota*ng  flow  (NRCSM) •  Smagorinsky  model  (SM)  based  on  an  eddy-­‐viscosity,   •  The  model  parameter  C  is  determined  as  follows:    with    where                NRCSM  model  is  invalid  for  rota*ng  flow.     € C = C1 | FCS |3/ 2 € C1 = 1 20 , FCS = Q E € τij a = −2CΔ2 | S | Sij (τij a = −2νt Sij, νt = CΔ2 | S |) E = 1 2 ΩijΩij + SijSij( )= 1 2 ∂ui ∂xj $ % && ' ( )) 2
  • 38.
    Coherent  structure  Smagorinsky  model  (CSM) •  Smagorinsky  model  (SM)  based  on  an  eddy-­‐viscosity,   •  The  model  parameter  C  is  determined  as  follows:    with    where        Improved  CSM  model  is  valid  for  rota*ng  flow.     € C = C2 | FCS |3/ 2 FΩ € C2 = 1 22 , FCS = Q E , FΩ =1− FCS € τij a = −2CΔ2 | S | Sij (τij a = −2νt Sij, νt = CΔ2 | S |) E = 1 2 ΩijΩij + SijSij( )= 1 2 ∂ui ∂xj $ % && ' ( )) 2
  • 39.
    Seung  for  making  new  library $  run   $  cd  ../src/libraries   $  cp  -­‐r  incompressibleWALE/WALE/  ./NRCSM   $  cp  –r  incompressibleWALE/Make  ./NRCSM   $  cd  NRCSM   $  rename  WALE  NRCSM  *   $  rm  –r  NRCSM.dep   $  rm  –rf  Make/linux64Gcc47DPOpt   $  gedit  Make/files   1.  Copy  the  source  code  of    WALE  model.  Compile  them. NRCSM.C   LIB  =  $(FOAM_USER_LIBBIN)/libNRCSM   $  sed  –i  ‘s/WALE/NRCSM/g’  NRCSM.C     $  sed  –i  ‘s/WALE/NRCSM/g’  NRCSM.H  
  • 40.
    Seung  for  making  new  library $  wmake  libso   $  ls  $FOAM_USER_LIBBIN   If  you  find  the  renamed  and  recompiled  library  (libNRCSM.so),   you  are  ready  to  make  a  new  library  for  the  NRCSM.     2. You  can  easily  learn  the  codes  for  calcula*ng  the  Q  and  E   terms  from  the  postProcessing  u*li*es.           There  are  two  ways  of  calcula*ng  Q,  that  is,  with  velocity   gradient  tensor  and  with  SS  and  ΩΩ terms. $  util   $  cd  postProcessing/velocityField/Q   $  gedit  Q.C  &  
  • 41.
    Introducing  model  coefficient  C1 $  run   $  cd  ../src/libraries/NRCSM/   $  gedit  NRCSM.C  NRCSM.H   3.  Replace  all  ‘cw’  with  ‘c1’  (gedit  or  sed),  and  change  the  value   to  0.05.          c1_          (                  dimensioned<scalar>::lookupOrAddToDict                  (                          "c1",                          coeffDict_,                          0.05                  )          )   NRCSM.C   $  wmake  libso  
  • 42.
    Q  and  E  calcula*ons 4.  In  NRCSM.C,  insert  the  calcula*on  of  Q  and  E.  Copy&Paste   the  corresponding  sec*on  from  Q.C.  Save  and  Compile  them.   volScalarField  Q   (    0.5*(sqr(tr(gradU))  -­‐  tr(((gradU)&(gradU))))   );   volScalarField  E   (    0.5*(gradU  &&  gradU)   );   NRCSM.C   $  gedit  NRCSM.C   $  wmake  libso  
  • 43.
    FCS  and  C  calcula*ons 5.  In  NRCSM.C,  insert  the  calcula*on  of  FCS  and  C  (coefficient   of  eddy  viscosity  model).  Save  and  Compile  them.   volScalarField  Fcs   (    Q/ max(E,dimensionedScalar("SMALL",E.dimensions(),SMALL))   );   volScalarField  ccsm_   (        c1_*pow(mag(Fcs),1.5)   );   NRCSM.C   $  gedit  NRCSM.C   $  wmake  libso  
  • 44.
    νSGS  calcula*on 6.  In  NRCSM.C,  modify  the  nuSGS_  calcula*on.  Look  the  other   updateSubGridScaleFields  func*ons  in  the  dynamic  models.   nuSgs_  =  ccsm_*sqr(delta())*mag(dev(symm(gradU)));   NRCSM.C   Save  and  compile  them.   $  wmake  libso   7.  Finally,  comment  out  or  delete  unnecessary  statements  (the   calcula*ons  for  WALE  model).  Save  and  compile  them.   $  wmake  libso   $  gedit  NRCSM.C  
  • 45.
    kSGS  calcula*on //-­‐  Return  SGS  kinetic  energy   //    calculated  from  the  given  velocity  gradient   tmp<volScalarField>  k(const  tmp<volTensorField>&  gradU)  const   {    return  (2.0*c1_/ce_)*sqr(delta())*magSqr(dev(symm(gradU)));   }   NRCSM.H   8.  The  calcula*on  of  kSGS  is  invalid,  but  the  value  of  kSGS  is  not   actually  used  in  LES  with  NRCSM  model.  If  you  requires  a   proper  kSGS,  consult  the  paper  of  Kobayashi  (PoF,  2005).  
  • 46.
    Valida*on  with  channel  flow $  run   $  cp  –r  $FOAM_TUTORIALS/incompressible/pimpleFoam/ channel395/  ./ReTau395NRCSM   $  cd  ReTau395NRCSM   9.  The  standard  tutorial  case  of  channel  flow  at  Reτ  =  395:       copy  the  tutorial  case  file  into  your  run  directory. 10. Edit  constant/LESProper*es  and  system/controlDict $  gedit  constant/LESProperties   LESModel                NRCSM;   printCoeffs          on;   delta                      cubeRootVol;   ...
  • 47.
    Valida*on  with  channel  flow $  gedit  system/controlDict ...   libs  ("libNRCSM.so");   This  line  is  necessary  to  call  the  new  NRCSM  library  in  solver. $  ./Allrun   11. Aper  checking  other  numerical  condi*ons  and  parameter,   run  the  solver. 12. If  the  solver  calcula*on  is  normally  finished,  you  check  the   logs  and  visualize  the  flow  field  with  ParaView,  and  plot  the   fields  profile  generated  by  postChannel.
  • 48.
    Addi*onal  works 1.  Compile  and  test  the  WALE  model  supplied  from   openfoam-­‐dev.  Prepare  a  Make  directory  by   yourself.   2.  Implementa*on  of  CSM  model.  Add  FΩ  term  and  C2   coefficient.   3.  Calcula*on  of  Q  and  E  terms  with  SS  and  ΩΩ  terms.   Compare  the  results  with  the  solu*on  of  Exercise  2.   4.  Valida*on  of  customized  model  with  other  flow   fields  such  pipe,  backstep,  cylinder,  and  rota*ng   flow.  
  • 49.
    References •  OpenFOAM  User  Guide   •  OpenFOAM  Programmer’s  Guide   •  梶島,  乱流の数値シミュレーション 改訂版,  養賢堂  (2014).   •  P.  R.  Spalart  et  al.,  “Comments  on  the  Feasibility  of  LES  for   Wings,  and  on  a  Hybrid  RANS/LES  Approach”,  1st  ASOSR   CONFERENCE  on  DNS/LES  (1997).   •  P.  R.  Spalart,  “Young-­‐Person’s  Guide  to  Detached-­‐Eddy   Simula*on  Grids”,  NASA  CR-­‐2001-­‐211032  (2001).   •  F.  Nicoud  and  F.  Ducros,  “Subgrid-­‐scale  modelling  based  on   the  square  of  velocity  gradient  tensor”,  Flow,  Turbulence  and   Combus*on,  62,  pp.183-­‐200  (1999).  
  • 50.
    References •  小林,  “乱流構造に基づくサブグリッドスケールモデルの開 発”,  ながれ,  29,  pp.157-­‐160  (2010).   •  H.  Kobayashi,  “The  subgrid-­‐scale  models  based  on  coherent   structures  for  rota*ng  homogeneous  turbulence  and   turbulent  channel  flow”,  Phys.  Fluids,  17,  045104  (2005).   •  H.  Kobayashi,  F.  Ham  and  X.  Wu,  “Applica*on  of  a  local  SGS   model  based  on  coherent  structures  to  complex  geometries”,   Int.  J.  Heat  Fluid  Flow,  29,  pp.640-­‐653  (2008).