You are on page 1of 29

# Immersed boundary method in

OpenFOAM
ˇ
´ Hrvoje Jasak
Zeljko
Tukovic,
Zeljko.Tukovic@fsb.hr

Faculty of Mechanical Engineering and Naval Architecture
University of Zagreb, Croatia

Immersed boundary method in OpenFOAM – p. 1

Outline
Objective
• Show current state of Immersed Boundary Method
implementation in OpenFOAM-1.6-ext
• Demonstrate application of the immersed boundary method with few tutorial cases
Topics
• Immersed Boundary Method (IBM) in general
• Selected IBM approach
• Imposition of Dirichlet and Neumann boundary conditions
• Treatment of pressure equation
• Implementation details
• Tutorial cases

Immersed boundary method in OpenFOAM – p. 2

3 .Immersed Boundary Methods (IBM) • Simulation of the flow around immersed boundary is carried out on a grid (usually Cartesian) which does not conform to the boundary shape • Immersed boundary (IB) is represented by surface grid • Imposition of boundary conditions at IB requires modification of governing equations Fluid IB Solid Immersed boundary method in OpenFOAM – p.

4 . nondeforming grid Disadvantages: • Imposition of boundary conditions at IB is not straightforward • Problem with grid resolution control in boundary layer • Limited to low and moderate Reynolds number flows Immersed boundary method in OpenFOAM – p.IBM: pros and cons Advantages: • Substantially simplified grid generation for complex geometry • Including of body motion is relatively simple due to the use of stationary.

◦ Independent of the spatial discretisation procedure ◦ Accuracy and stability problems. ∗ Sharpness of IB is preserved ∗ Best accuracy and highest Reynolds number flows Immersed boundary method in OpenFOAM – p. ◦ Requires solution of governing equations inside IB • Discrete forcing approach ◦ Indirect BC imposition ∗ Forcing term is introduced into discretised equation ∗ Forcing function still spread over the band of cells ◦ Direct BC imposition ∗ Modification of discretised equations near the IB to directly impose BC on IB. 5 .IBM: Different approaches for BC imposition The procedure for imposition of boundary conditions at the IB is what distinguishes one IB method from another: • Continuous forcing approach ◦ Effect of IB is imposed by the source (force) terms in governing equations. ◦ Continuous forcing function is spread over the band of cells near IB.

OpenFOAM IBM: selected approach • Discrete forcing approach with direct imposition of boundary conditions • Basic principle: Value of dependent variable in the IB cell centres is calculated by interpolation using neighbouring cells values and boundary condition at the corresponding IB point Fluid cells Solid cells IB cells n IB points Immersed boundary method in OpenFOAM – p. 6 .

11 00 00011 111 0011 00 000 111 00 11 00 11 00011 111 0011 00 00 11 000 111 00 11 000 111 111 000 00 11 000 111 00 11 Fluid cells Solid cells IB cells IB points ib P Extended stencil Immersed boundary method in OpenFOAM – p.BC imposition using quadratic interpolation Dirichlet IB condition φP = φib + C0 (xP − xib ) + C1 (yP − yib ) + C2 (xP − xib )(yP − yib ) + C3 (xP − xib )2 + C4 (yP − yib )2 (1) Unknown coefficients of quadratic polynomial determined using weighted least square method on extended stencil. 7 .

BC imposition using quadratic interpolation Neumann IB condition Interpolation is performed in local coordinate system x′ y ′ where x′ -axis coincides with the normal to the immersed boundary at the point ib: ′ ′ ′ 2 φP = C0 + [nib •(∇φ)ib ] x′P + C1 yP + C2 x′P yP + C3 (x′P )2 + C4 (yP ) x′ y′ nib (2) Fluid cells Solid cells IB cells IB points ib P Immersed boundary method in OpenFOAM – p. 8 .

9 .Least squares weighting factors Two options are considered: • inverse quadratic distance weight function wi = 1 ri2 (3) • cosine weight function    ri 1 1 + cos π wi = 2 Srmax (4) Fluid cells Solid cells i ri rmax IB cells IB points ib P 111 000 000 111 Extended stencil Immersed boundary method in OpenFOAM – p.

10 . for a fluid cell P next to IB cells   X X X 1  HP nf •(∇p)f Sf = nf • Sf + nfib •vfib Sfib a a P f P f f f f (5) ib Fluid cells P fib f N IB cells Nib IB faces vfib = 21 (vP + vNib ) Immersed boundary method in OpenFOAM – p.Pressure equation and its BC at IB Pressure Eq.

11 .Pressure equation and its BC at IB • Boundary condition for pressure is not needed for solution of pressure equation since velocity at “IB faces” is treated as specified. • Interpolated velocity at IB faces (vfib ) must be scaled in such a way to impose zero net mass flux through the closed cage of IB faces around immersed boundary. Fluid cells P f fib N IB cells Nib IB faces vfib = 1 (vP 2 + vNib ) Immersed boundary method in OpenFOAM – p. • Pressure for IB faces and IB cells is calculated after solution of pressure equation by applying procedure for Neumann boundary condition imposition using quadratic interpolation. • Pressure at IB faces (pfib ) is needed for solution of momentum equation for fluid cells next to IB cells.

Implementation details Immersed boundary implementation is based on three classes: • class immersedBoundaryPolyPatch • class immersedBoundaryFvPatch • class immersedBoundaryFvPatchField Immersed boundary method in OpenFOAM – p. 12 .

} //.Implementation details class immersedBoundaryPolyPatch : public polyPatch { . }. Immersed boundary method in OpenFOAM – p. // Member Functions // Access //. } //. 13 ...Return true if solving for flow inside the IB bool internalFlow() const { return internalFlow_.Return triSurface search object const triSurfaceSearch& triSurfSearch() const.Return immersed boundary surface mesh const triSurfaceMesh& ibMesh() const { return ibMesh_.

3650. 14 . type nFaces startFace patch. nFaces 0.. 25. internalFlow no. ) Immersed boundary method in OpenFOAM – p.. } in { } .Implementation details Including immersedBoundaryPolyPatch into boundary mesh of a polyMesh by modifying constant/polyMesh/boundary dictionary 6 ( ibCylinder // constant/triSurface/ibCylinder.ftr { type immersedBoundary. startFace 3650.

Return list of fluid cells next to immersed boundary (IB cel const labelList& ibCells() const. Immersed boundary method in OpenFOAM – p.Implementation details class immersedBoundaryFvPatch : public fvPatch { // Private data //. 15 . marking only live fluid cells const volScalarField& gamma() const.Reference to processor patch const immersedBoundaryPolyPatch& ibPolyPatch_. // Member Functions // Immersed boundary data access //. //. //.Get fluid cells indicator. //.Return list of faces for which one neighbour is an IB cell // and another neighbour is a live fluid cell (IB faces) const labelList& ibFaces() const.Finite volume mesh reference const fvMesh& mesh_. }.

//.Get inverse Dirichlet interpolation matrix const PtrList<scalarRectangularMatrix>& invDirichletMatrices() const.Return live cells const labelList& liveCells() const.Return IB points const vectorField& ibPoints() const.Return dead cells const labelList& deadCells() const.Implementation details class immersedBoundaryFvPatch : public fvPatch { . //.Get inverse Neumann interpolation matrix const PtrList<scalarRectangularMatrix>& invNeumannMatrices() const. //. //. //. 16 ... }.Return IB cell extended stencil const labelListList& ibCellCells() const. //. Immersed boundary method in OpenFOAM – p.

Defining value field Field<Type> refValue_.Implementation details template<class Type> class immersedBoundaryFvPatchField : public fvPatchField<Type> { // Private data //. //. 17 .Does the boundary condition fix the value Switch fixesValue_..Defining normal gradient field Field<Type> refGrad_.. //.Local reference to fvMesh const fvMesh& mesh_.Local reference cast into the processor patch const immersedBoundaryFvPatch& ibPatch_. . Immersed boundary method in OpenFOAM – p. //. //. }.

. // Private Member Functions //. }. 18 . Immersed boundary method in OpenFOAM – p.Impose Neumann BC at IB cells and return corrected cells values // Calculate value and gradient on IB intersection points tmp<Field<Type> > imposeNeumannCondition() const.Implementation details template<class Type> class immersedBoundaryFvPatchField : public fvPatchField<Type> { ..Impose Dirichlet BC at IB cells and return corrected cells value // Calculate value and gradient on IB intersection points tmp<Field<Type> > imposeDirichletCondition() const... //. .

// Evaluation functions //. //.. Immersed boundary method in OpenFOAM – p.Evaluate the patch field virtual void evaluate ( const Pstream::commsTypes commsType = Pstream::blocking ). }.. 19 . //.Update the coefficients associated with the patch field void updateCoeffs()..Manipulate matrix virtual void manipulateMatrix(fvMatrix<Type>& matrix)..Implementation details template<class Type> class immersedBoundaryFvPatchField : public fvPatchField<Type> { . .

refGradient uniform (0 0 0). y (1 0 0). n (1 0 0). (0 0 0).375. refValue uniform (0 0 0). maxValue 0. } movingWall { type parabolicVelocity. value uniform (0.Implementation details Including immersedBoundaryFvPatchField into boundary of a volVectorField boundaryField { ibCylinder { type immersedBoundary. setDeadCellValue deadCellValue yes.375 0 0). } Immersed boundary method in OpenFOAM – p. } . fixesValue yes... value uniform (0 0 0). 20 .

solve(UEqn == -cellIbMask*fvc::grad(p)).boundaryManipulate(U..icoIbFoam while (runTime. do { fvVectorMatrix UEqn ( fvm::ddt(U) + fvm::div(phi. 21 .timeName() << nl << endl.loop()) { Info<< "Time = " << runTime. .. } .. } Immersed boundary method in OpenFOAM – p.Implementation details Example of solver source code . ..boundaryField()). UEqn..fvm::laplacian(nu.. // Pressure-velocity corrector int oCorr = 0. U) . U) ).

22 .5 m • Reynolds number: 37.375 m/s • Cylinder diameter: 0.Tutorial: Flow around cylinder in cavity Tutorial case: cavity Laminar flow around cylinder driven by motion of cavity top wall Case setup data: • Cavity dimension: 1 × 1 m • Moving wall velocity: 0.5 Immersed boundary method in OpenFOAM – p.

stl}) into constat/triSurface folder • Include immersedBoundaryPolyPatch into polyMesh boundary • Include immersedBoundaryFvPatchField into boundary field of pressure and velocity fields • Set discretization schemes in .Tutorial: Flow around cylinder in cavity Basic case setup steps: • Define volume mesh in constant/polyMesh/blockMeshDict dictionary • Create polyMesh using blockMesh • Copy immersed boundary mesh (ibCylinder.{ftr. 23 ./system/faSolution dictionary • Set time step size ./system/controlDict • Run the case using icoIbFoam • Postprocess the case using paraFoam Immersed boundary method in OpenFOAM – p./system/faSchemes dictionary • Set solution controls in .

24 .Tutorial: Flow around cylinder in open space Tutorial case: flowOverCylinder Laminar flow around circular cylinder in open space Case setup data: • Open space dimensions: 90 × 90 m • Inlet velocity: 1 m/s • Cylinder diameter: 1 m • Reynolds number: 100 Immersed boundary method in OpenFOAM – p.

Tutorial: Flow around cylinder in open space Basic case setup steps: • Define volume mesh in constant/polyMesh/blockMeshDict dictionary • Create polyMesh using blockMesh • Copy immersed boundary mesh (ibCylinder.stl}) into constat/triSurface folder • Include immersedBoundaryPolyPatch into polyMesh boundary • Include immersedBoundaryFvPatchField into boundary field for pressure and velocity fields • Refine volume mesh using refineCylinderMesh application which must be compiled before • Refine volume mesh using refineImmersedBoundaryMesh application • Set discretization schemes in . 25 ./system/controlDict • Run the case using icoIbFoam • Post-process the case using paraFoam Immersed boundary method in OpenFOAM – p./system/faSolution dictionary • Set time step size .{ftr./system/faSchemes dictionary • Set solution controls in .

26 .Tutorial: Backward-facing step by Pitz and Daily Tutorial case: pitzDailyLaminar Laminar flow over a backward-facing step by Pitz and Daily Case setup data: • Inlet velocity: 1 m/s • Reynolds number: 2500 Immersed boundary method in OpenFOAM – p.

27 .Tutorial: Backward-facing step by Pitz and Daily Basic case setup steps: • Define volume mesh in constant/polyMesh/blockMeshDict dictionary • Create polyMesh using blockMesh • Copy immersed boundary mesh (pitzDailyIB./system/controlDict • Run the case using icoIbFoam • Post-process the case using paraFoam Immersed boundary method in OpenFOAM – p.stl}) into constat/triSurface folder • Include immersedBoundaryPolyPatch into polyMesh boundary • Include immersedBoundaryFvPatchField into boundary field of pressure and velocity fields • Set discretization schemes in .{ftr./system/faSolution dictionary • Set time step size ./system/faSchemes dictionary • Set solution controls in .

5 m • Water-air multi-phase system Immersed boundary method in OpenFOAM – p. 28 .Tutorial: Dam break over bump Tutorial case: damBreakWithCylinder Dam break VOF interface capturing simulation with circular bump at the bottom boundary Case setup data: • Domain dimension: 2 × 2 m • Bump diameter: 0.

/system/controlDict • Run the case using interIbFoam • Post-process the case using paraFoam Immersed boundary method in OpenFOAM – p.{ftr./system/faSolution dictionary • Set time step size .Tutorial: Dam break over bump Basic case setup steps: • Define volume mesh in constant/polyMesh/blockMeshDict dictionary • Create polyMesh using blockMesh • Copy immersed boundary mesh (ibCylinder. 29 ./system/faSchemes dictionary • Set solution controls in .stl}) into constat/triSurface folder • Include immersedBoundaryPolyPatch into polyMesh boundary • Include immersedBoundaryFvPatchField into boundary field of pressure and velocity fields • Set discretization schemes in .