26
OpenFOAM q Open source CFD toolbox, which supplies preconfigured solvers, utilities and libraries. q Flexible set of efficient C++ modules---object-oriented. q Use Finite-Volume Method (FVM) to solve systems of PDEs ascribed on any 3D unstructured mesh of polyhedral cells. q Good parallelization. Overview of OpenFOAM structures q Resourceful community (CFD forum, http://www.cfd-online.com/Forums/openfoam/ ) contribution (user-defined libraries). q interFoam, which is a solver for 2 incompressible fluids with interface tracking, is used in the present study. Tutorials: http://cfd.direct/openfoam/user-guide/dambreak/

OpenFOAM€¦ · OpenFOAM q Open source CFD toolbox, which supplies preconfigured solvers, utilitiesand libraries. q Flexible set of efficient C++ modules---object-oriented

Embed Size (px)

Citation preview

Page 1: OpenFOAM€¦ · OpenFOAM q Open source CFD toolbox, which supplies preconfigured solvers, utilitiesand libraries. q Flexible set of efficient C++ modules---object-oriented

OpenFOAMq OpensourceCFDtoolbox,which

suppliespreconfiguredsolvers,utilities andlibraries.

q FlexiblesetofefficientC++modules---object-oriented.

q UseFinite-VolumeMethod(FVM)tosolvesystemsofPDEsascribedonany3Dunstructured meshofpolyhedralcells.

q Goodparallelization. Overview of OpenFOAM structures

q Resourcefulcommunity (CFDforum,http://www.cfd-online.com/Forums/openfoam/)contribution(user-definedlibraries).

q interFoam,whichisasolverfor2incompressiblefluidswithinterfacetracking,isusedinthepresentstudy.Tutorials:http://cfd.direct/openfoam/user-guide/dambreak/

Page 2: OpenFOAM€¦ · OpenFOAM q Open source CFD toolbox, which supplies preconfigured solvers, utilitiesand libraries. q Flexible set of efficient C++ modules---object-oriented

0whereboundaryconditions aredefinedforalpha.water,B,k,nuSgs,p_rgh,U

constant

system

Meshbuilding -- blockMeshDict

Turbulence closure– turbulenceProperties,LESProperties

Computational timecontrol-- controlDict

Numerical schemes -- fvSchemes

Numerical solvers-- fvSolution

Initialcondition -- setFieldslDict

Domaindecomposition -- decomposeParDict

Page 3: OpenFOAM€¦ · OpenFOAM q Open source CFD toolbox, which supplies preconfigured solvers, utilitiesand libraries. q Flexible set of efficient C++ modules---object-oriented

Buildthedomainandsetthegrids

Choosetheturbulence closure

Setthe initial condition

Settheboundarycondition

Choosethenumericalschemes

Choosethenumericalsolvers

Setthetimecontrol

Decompose thedomain

Runthecase

Page 4: OpenFOAM€¦ · OpenFOAM q Open source CFD toolbox, which supplies preconfigured solvers, utilitiesand libraries. q Flexible set of efficient C++ modules---object-oriented

Buildthedomainandsetthegrids

Choosetheturbulence closure

Setthe initial condition

Settheboundarycondition

Choosethenumericalschemes

Choosethenumericalsolvers

Setthetimecontrol

Decompose thedomain

Runthecase

Page 5: OpenFOAM€¦ · OpenFOAM q Open source CFD toolbox, which supplies preconfigured solvers, utilitiesand libraries. q Flexible set of efficient C++ modules---object-oriented

x

y

z

0 (00-0.3)

1 (18.200.064)

2 (18.200.3)

Howtochooseanappropriatedomainheight?- Bigenoughtomakesurethebreakingwavewillnottouchthetopboundary;- Nottobig,tosavecomputationalcost.

3 (000.3)

4 (00.6 -0.3)

5 (18.2 0.60.064)

6 (18.20.60.3)

7 (00.60.3)

Howtochooseanappropriatedomainwidth?- Bigenoughtocoverseverallargesteddiesintheexperiment;- Nottobig,tosavecomputationalcost.

Inthiscase,thedomainlengthissettobesmallerthanthatintheexperiment[Ting2006,2008]butlongenoughtocovertheinitialshorelineandswashzone

DomainLayout

Page 6: OpenFOAM€¦ · OpenFOAM q Open source CFD toolbox, which supplies preconfigured solvers, utilitiesand libraries. q Flexible set of efficient C++ modules---object-oriented

Nz=80.Howtodeterminethenumberofgridsintheverticaldirection?-- Determined bythenumberofgridsneededtosolvethewave.

E.g.,inthiscase,H0=0.22m.Using30gridstosolvethewave∆z =7.5mmattheleftboundaryNz =Domainheight/∆z =80

z

Nx=2427.Howtodeterminethenumberofgridsinthestreamwise direction?--Makesuretheratioof∆𝑥/∆𝑧 isnottoobig(<5).

E.g.,inthiscase,Dzmax=7.5mmattheleftboundary;Dzmin=3mmattherightboundary.Tomake∆𝑥/∆𝑧 <5,chooseDxmax=11.5mm(∆𝑥/∆𝑧=3.8)attheleftboundaryandDxmin=4.6mm (∆𝑥/∆𝑧 =1.5)attherightboundary.∆𝑥 isshrinkingfromthelefttotheright.(Sois∆𝑧 )

Buildthegrids

Ny=80.Howtodeterminethenumberofgridsinthespanwisedirection?Makesuretheratiosof∆𝑦/∆𝑧 and∆𝑥/∆𝑦 arenottoobig.E.g.,inthiscase,∆y =7.5mm

x

Page 7: OpenFOAM€¦ · OpenFOAM q Open source CFD toolbox, which supplies preconfigured solvers, utilitiesand libraries. q Flexible set of efficient C++ modules---object-oriented

Buildthedomainandsetthegrids

Choosetheturbulence closure

Setthe initial condition

Settheboundarycondition

Choosethenumericalschemes

Choosethenumericalsolvers

Setthetimecontrol

Decompose thedomain

Runthecase

Page 8: OpenFOAM€¦ · OpenFOAM q Open source CFD toolbox, which supplies preconfigured solvers, utilitiesand libraries. q Flexible set of efficient C++ modules---object-oriented

Choose theturbulenceclosure

Large-eddysimulation inthissimulation

DynamicSmagorinsky closure isused,andanimprovedversionofdynamicSmagorinsky closuredeveloped byAlbertoPassalacqua isadopted.

HowtoinstalltheimproveddynamicSmagorinsky closureinOpenFOAM?1. Downloadthesourcecodeusinggit:

git clonegit://github.com/AlbertoPa/dynamicSmagorinsky.git2.Enterthedirectorywherethesourcecodehasbeenextracted,andcompileitbytyping:

wmake libso3.AddthefollowinglinetothecontrolDict ofyourcase:libs("libOpenFOAM.so""libdynamicSmagorinskyModel.so");4.SpecifyLESModel dynamicSmagorinsky;deltacubeRootVol;inLESModel.5.Addthesubdictionary

dynamicSmagorinskyCoeffs{filtersimple;ce 1.048;}

toLESModels.

Filter isdefinedas Δ = Vcell3

https://github.com/AlbertoPa/dynamicSmagorinsky

Page 9: OpenFOAM€¦ · OpenFOAM q Open source CFD toolbox, which supplies preconfigured solvers, utilitiesand libraries. q Flexible set of efficient C++ modules---object-oriented

Buildthedomainandsetthegrids

Choosetheturbulence closure

Setthe initial condition

Settheboundarycondition

Choosethenumericalschemes

Choosethenumericalsolvers

Setthetimecontrol

Decompose thedomain

Runthecase

Page 10: OpenFOAM€¦ · OpenFOAM q Open source CFD toolbox, which supplies preconfigured solvers, utilitiesand libraries. q Flexible set of efficient C++ modules---object-oriented

Settheinitial condition

(00-0.3)

(00.6-0.3)

(000) (00.60)

(150.60)(1500)

Offshore

Onshore

Page 11: OpenFOAM€¦ · OpenFOAM q Open source CFD toolbox, which supplies preconfigured solvers, utilitiesand libraries. q Flexible set of efficient C++ modules---object-oriented

Buildthedomainandsetthegrids

Choosetheturbulence closure

Setthe initial condition

Settheboundarycondition

Choosethenumericalschemes

Choosethenumericalsolvers

Setthetimecontrol

Decompose thedomain

Runthecase

Page 12: OpenFOAM€¦ · OpenFOAM q Open source CFD toolbox, which supplies preconfigured solvers, utilitiesand libraries. q Flexible set of efficient C++ modules---object-oriented

Definetheboundaries

(Wall function isused)

Sends inthetargetsolitarywavethroughgroovyBC

WhatisgroovyBC?-- Alibrarythatcanbeusedtogeneratearbitraryboundaryconditions basedonexpressions. Itisincluded intheswak4Foamlibrarypackage.

Link:https://openfoamwiki.net/index.php/Contrib/swak4Foam

Page 13: OpenFOAM€¦ · OpenFOAM q Open source CFD toolbox, which supplies preconfigured solvers, utilitiesand libraries. q Flexible set of efficient C++ modules---object-oriented

InstallgroovyBC

1.Downloadswak4Foamlibrarypackagefrom

svn checkoutsvn://svn.code.sf.net/p/openfoam-extend/svn/trunk/Breeder_2.0/libraries/swak4Foam/ swak4Foam_2.x

2.Inthedirectoryofthesources,type

wmake all

Page 14: OpenFOAM€¦ · OpenFOAM q Open source CFD toolbox, which supplies preconfigured solvers, utilitiesand libraries. q Flexible set of efficient C++ modules---object-oriented

UsegroovyBC tosendinsolitarywave

ExpressionofthetheoreticalsurfaceelevationinLeeetal.[1982]

ExpressionofthetheoreticalvelocityinLeeetal.[1982]

α1 =

1, z ≤ Hcosh2 atp −ct + xs( )( )

0, z > Hcosh2 atp −ct + xs( )( )

#

$

%%

&

%%

c = gh 1+H h( )h = 0.3m H = 0.22m fs = 2.644 g = 0,0,−9.81( ) xs = hfsH h

atp = 0.75Hh3

u =

ghHcosh2 atp −ct + xs( )"# $%h

1− 0.25Hcosh2 atp −ct + xs( )"# $%h

"

#&&

$

%'', z ≤ H

cosh2 atp −ct + xs( )( )

0, z > Hcosh2 atp −ct + xs( )( )

)

*

++

,

++

w =

− ghzh

1− 0.5Hdexcosh2 atp −ct + xs( )"# $%h

"

#&&

$

%'', z ≤ H

cosh2 atp −ct + xs( )( )

0, z > Hcosh2 atp −ct + xs( )( )

)

*

++

,

++

v = 0

Page 15: OpenFOAM€¦ · OpenFOAM q Open source CFD toolbox, which supplies preconfigured solvers, utilitiesand libraries. q Flexible set of efficient C++ modules---object-oriented

Specifytheboundary conditions

p_rgh:dynamicpressure

U:velocity

alpha.water: (percentageofwaterineachcell) intheVOFequationα1

B:subgrid-scale tensor inLES.istheunittensor; isthedeviatoric partofthesubgrid-scale tensorandisparameterizedbysubgrid closure

B = 2 3kI +Beff I

k:subgrid-scale kineticenergyinLES.,,istherateofstrain

k = cIΔ2 D 2 cI ≈ 0.2 D

nuSgs:,sub-gridscale viscosity inLESν sgs

Page 16: OpenFOAM€¦ · OpenFOAM q Open source CFD toolbox, which supplies preconfigured solvers, utilitiesand libraries. q Flexible set of efficient C++ modules---object-oriented

Specifytheboundary conditions

zeroGradient:normalgradientiszero

cyclic:periodic boundarycondition

inletOutlet:≈ zeroGradient.ButswitchtofixedValue (using“inletValue”) ifthevelocityjustoutside theboundaryisflowingintothedomain

pressureInletOutletVelocity: =pressureInletVelocity +inletOutpressureInletVelocity: When𝑝 isknownattheinlet,𝑈 isevaluatedfromthefluxnormaltothepath.

totalPressure: Totalpressure is fixed;whenchanges,pwillbeadjustedaccordingly

p0 = p+1 2ρ U2

U

Page 17: OpenFOAM€¦ · OpenFOAM q Open source CFD toolbox, which supplies preconfigured solvers, utilitiesand libraries. q Flexible set of efficient C++ modules---object-oriented

Buildthedomainandsetthegrids

Choosetheturbulence closure

Setthe initial condition

Settheboundarycondition

Choosethenumericalschemes

Choosethenumericalsolvers

Setthetimecontrol

Decompose thedomain

Runthecase

Page 18: OpenFOAM€¦ · OpenFOAM q Open source CFD toolbox, which supplies preconfigured solvers, utilitiesand libraries. q Flexible set of efficient C++ modules---object-oriented

Numerical schemes

ddtSchemes: firsttime derivative 𝜕/𝜕𝑡 .“CrankNicholson 1”isthepure2nd-orderCrank-Nicolson scheme

gradSchemes: Gradient𝛻.“Gausslinear”meansGauss’theoremisusedwhentransformingintegralovervolumeintointegraloversurface;“linear”meanscentraldifferencescheme (CDS)

divSchemes: Divergent𝛻 ..“GausslimitedLinearV 1”and“GaussvanLeer”arebothTVDschemeswithdifferentlimiters. “Gauss interfaceCompression” isusedfortheinterfacecompression term

interpolationSchemes: numericalscheme fortheevaluation offacevaluesfromthecellcentervalues

snGradSchemes: component ofgradientnormaltoacell face

fluxRequired: fieldswhichrequirethegeneration ofaflux

laplacianSchemes: Laplacian .“Gauss linearcorrected”isCDSwithsomecorrectionterms

∇2

Page 19: OpenFOAM€¦ · OpenFOAM q Open source CFD toolbox, which supplies preconfigured solvers, utilitiesand libraries. q Flexible set of efficient C++ modules---object-oriented

Buildthedomainandsetthegrids

Choosetheturbulence closure

Setthe initial condition

Settheboundarycondition

Choosethenumericalschemes

Choosethenumericalsolvers

Setthetimecontrol

Decompose thedomain

Runthecase

Page 20: OpenFOAM€¦ · OpenFOAM q Open source CFD toolbox, which supplies preconfigured solvers, utilitiesand libraries. q Flexible set of efficient C++ modules---object-oriented

Numerical solvers

SolvesthePressurePoissonEquation

Setthesolversforp_rgh andU

PIMPLE=SIMPLE+PISO

Page 21: OpenFOAM€¦ · OpenFOAM q Open source CFD toolbox, which supplies preconfigured solvers, utilitiesand libraries. q Flexible set of efficient C++ modules---object-oriented

Buildthedomainandsetthegrids

Choosetheturbulence closure

Setthe initial condition

Settheboundarycondition

Choosethenumericalschemes

Choosethenumericalsolvers

Setthetimecontrol

Decompose thedomain

Runthecase

Page 22: OpenFOAM€¦ · OpenFOAM q Open source CFD toolbox, which supplies preconfigured solvers, utilitiesand libraries. q Flexible set of efficient C++ modules---object-oriented

Setthetimecontrol

startFrom

stopAt

deltaT

writeControl

adjustTimeStep

maxCo

maxAlphaCo

maxDeltaT

Page 23: OpenFOAM€¦ · OpenFOAM q Open source CFD toolbox, which supplies preconfigured solvers, utilitiesand libraries. q Flexible set of efficient C++ modules---object-oriented

Buildthedomainandsetthegrids

Choosetheturbulence closure

Setthe initial condition

Settheboundarycondition

Choosethenumericalschemes

Choosethenumericalsolvers

Setthetimecontrol

Decompose thedomain

Runthecase

Page 24: OpenFOAM€¦ · OpenFOAM q Open source CFD toolbox, which supplies preconfigured solvers, utilitiesand libraries. q Flexible set of efficient C++ modules---object-oriented

Decompose thedomain

“decomposeParDict”

simpleCoeffs{n(412);…

}

numberOfSubdomains 8;

x

y

z

TypedecomposePar

Page 25: OpenFOAM€¦ · OpenFOAM q Open source CFD toolbox, which supplies preconfigured solvers, utilitiesand libraries. q Flexible set of efficient C++ modules---object-oriented

Buildthedomainandsetthegrids

Choosetheturbulence closure

Setthe initial condition

Settheboundarycondition

Choosethenumericalschemes

Choosethenumericalsolvers

Setthetimecontrol

Decompose thedomain

Runthecase

Page 26: OpenFOAM€¦ · OpenFOAM q Open source CFD toolbox, which supplies preconfigured solvers, utilitiesand libraries. q Flexible set of efficient C++ modules---object-oriented

Runthecase

TypeinterFoam