Introduction about How to Use OpanFOAM Oliver December 8, 2012

Why OpenFOAM
Using OpenFOAM
Simulation Cases
Introduction about How to Use OpanFOAM
Oliver
Center for Scientific Computing
December 8, 2012
Oliver
Open∇FOAM
Why OpenFOAM
Using OpenFOAM
Simulation Cases
Why OpenFOAM
Using OpenFOAM
Mesh Generating
blockMesh
snappyHexMesh
Boundary and Solvers
Simulation Cases
Supersonic Flow over a Forward-facing Step
Simple Pipeline Flow
Make Your Own Solver
Oliver
Open∇FOAM
Why OpenFOAM
Using OpenFOAM
Simulation Cases
1. OpenFOAM is an open source CFD software, which means you
can make any modification, as long as you understant the code
well.
2. Many researchers are doing their work based on OpenFOAM,
and impliment many new methods into OpenFOAM based C++
code.
Oliver
Open∇FOAM
Why OpenFOAM
Using OpenFOAM
Simulation Cases
Mesh Generating
Boundary and Solvers
Figure : Three popular commercial CFD software (from left to right:
FLUENT, CFX, StarCCM+)
Any CFD software must depends these 3 steps to solve a spcific
flow problem:
Pre-processing (mesh generating) −→ Set boundary condition,
choose solver and run simulation (Solve PED) −→ Post-processing
(flow field visulization)
Oliver
Open∇FOAM
Why OpenFOAM
Using OpenFOAM
Simulation Cases
Mesh Generating
Boundary and Solvers
HOWEVER, the interface can be quite different. In OpenFOAM
you can only see some folders structured like this:
Figure : Folder structure in OpenFOAM (here Folder straight pipe is
where we put simulation case file)
Oliver
Open∇FOAM
Why OpenFOAM
Using OpenFOAM
Simulation Cases
Mesh Generating
Boundary and Solvers
blockMesh
./case/constant/polyMesh/blockMeshDict
Vertices : (give pisition for each point)
0→1→2→3→0→4→5→6→7→4
(0, 0, 0)(1, 0, 0)(1, 1, 0)(0, 1, 0)
(0, 0, 0.1)(1, 0, 0.1)(1, 1, 0.1)(0, 1, 0.1)
Faces :(define the face plane)
{0 3 2 1} {4 5 6 7} {0 3 7 4} {2 3 7 6} {1 2 6 5} {0 1 5 4}
Oliver
Open∇FOAM
Why OpenFOAM
Using OpenFOAM
Simulation Cases
Mesh Generating
Boundary and Solvers
blockMesh
blocks
(
hex (0 1 2 3 4 5 6 7 ) (100 100 1 ) simpleGrading (2 0.5 1 )
)
Figure : Different simpleGrading value (left (1 1 1 ); right (3 3 1 ))
Oliver
Open∇FOAM
Why OpenFOAM
Using OpenFOAM
Simulation Cases
Mesh Generating
Boundary and Solvers
blockMesh
Oliver
Open∇FOAM
Why OpenFOAM
Using OpenFOAM
Simulation Cases
Mesh Generating
Boundary and Solvers
snappyHexMesh
./case/system/snapplyHexMeshDict
The main problem is to generate .STL data file for each face. One
possible way is to use StarCCM by exporting every splitted face.
Oliver
Open∇FOAM
Why OpenFOAM
Using OpenFOAM
Simulation Cases
Mesh Generating
Boundary and Solvers
snappyHexMesh
a
b
c
Figure : snappyHexMesh meshing process (a: generating background
mesh; b: cell splitting and cell removal; c: surface snapping)
Oliver
Open∇FOAM
Why OpenFOAM
Using OpenFOAM
Simulation Cases
Mesh Generating
Boundary and Solvers
./case/constant/polyMesh/boundary
./case/0/p ...
Figure : boundary type
Oliver
Open∇FOAM
Why OpenFOAM
Using OpenFOAM
Simulation Cases
Mesh Generating
Boundary and Solvers
Many Solvers can be chose according to your flow problem. The
following two files can help choose the approperate numerical
scheme.
./case/system/fvSolution
./case/system/fvScheme
Table : Typical Solvers
icoFoam
pisoFoam
sonicFoam
dnsFoam
...
Transient solver for incompressible, laminar flow of Newton
Transient solver for incompressible flow
Transient solver for trans-sonic/supersonic, laminar or turbu
Direct numerical simulation solver for boxes of isotropic tur
...
Oliver
Open∇FOAM
Why OpenFOAM
Using OpenFOAM
Simulation Cases
Supersonic Flow over a Forward-facing Step
Simple Pipeline Flow
Make Your Own Solver
Figure : Geometry condition
Mesh generating: blockMesh Boundary:
inlet: fixedValue for U, p and T; outlet: zeroGradient; wall:
non-slip (U fixedValue (0 0 0 ) )
Solver: sonicFoam
Oliver
Open∇FOAM
Why OpenFOAM
Using OpenFOAM
Simulation Cases
Supersonic Flow over a Forward-facing Step
Simple Pipeline Flow
Make Your Own Solver
Figure : contour distribution (top: pressure; leftbottom: velocity;
rightbottom: tempreture)
Oliver
Open∇FOAM
Why OpenFOAM
Using OpenFOAM
Simulation Cases
Supersonic Flow over a Forward-facing Step
Simple Pipeline Flow
Make Your Own Solver
Mesh generating: snappyHexMesh Boundary:
inlet: fixedValue for U=0.04, zeroGradient for p; outlet:
zeroGradient for U and p; wall: non-slip
Solver: icoFoam
Figure : contour distribution (left: pressure; right: velocity)
Oliver
Open∇FOAM
Why OpenFOAM
Using OpenFOAM
Simulation Cases
Supersonic Flow over a Forward-facing Step
Simple Pipeline Flow
Make Your Own Solver
fluentToFoam
Oliver
Open∇FOAM
Why OpenFOAM
Using OpenFOAM
Simulation Cases
Supersonic Flow over a Forward-facing Step
Simple Pipeline Flow
Make Your Own Solver
Figure : Single bifurcation
Oliver
Open∇FOAM
Why OpenFOAM
Using OpenFOAM
Simulation Cases
Supersonic Flow over a Forward-facing Step
Simple Pipeline Flow
Make Your Own Solver
Figure : Double bifurcation
Oliver
Open∇FOAM
Why OpenFOAM
Using OpenFOAM
Simulation Cases
Supersonic Flow over a Forward-facing Step
Simple Pipeline Flow
Make Your Own Solver
Figure : Mesh for lungA017
Oliver
Open∇FOAM
Why OpenFOAM
Using OpenFOAM
Simulation Cases
Supersonic Flow over a Forward-facing Step
Simple Pipeline Flow
Make Your Own Solver
Figure : Pressure and Velocity distribution for lungA017 at t=3.6
Oliver
Open∇FOAM
Why OpenFOAM
Using OpenFOAM
Simulation Cases
Supersonic Flow over a Forward-facing Step
Simple Pipeline Flow
Make Your Own Solver
∂ρU
∂t
+ ∇ · φU − ∇ · µ∇U = −∇p
solve
(
fvm::ddt(rho,U)+fvm::div(phi,U)-fvm::laplacian(mu,U)==fvc::grad(p)
)
wmake → newApp
Oliver
Open∇FOAM
Why OpenFOAM
Using OpenFOAM
Simulation Cases
Supersonic Flow over a Forward-facing Step
Simple Pipeline Flow
Make Your Own Solver
passiveScalarFoam based on icoFoam Governing equation for a
passive scaler s:
∂s
∂t + ∇ · (sU) = 0
1. Creat scaler s in creatField.H;
volScalarField s
(
IOobject
(
”s”,
runTime.timeName(),
mesh,
IOobject::MUST READ,
IOobject::AUTO WRITE
),
mesh
);
Oliver
Open∇FOAM
Why OpenFOAM
Using OpenFOAM
Simulation Cases
Supersonic Flow over a Forward-facing Step
Simple Pipeline Flow
Make Your Own Solver
2. Establish transport equation for s in passiveScalarFoam.C;
solve(fvm::ddt(s)+fvm::div(phi,s));
3. wmake passiveScalarFoam
4. creat s in 0 folder
5. define solution for s in system/fvSolution
s
{
solver PBiCG;
preconditioner DILU;
tolerance 1e-06
relTol 0;
}
6. define scheme for s in system/fvScheme
div(phi,s) Gauss linearUpwind Gauss;
Oliver
Open∇FOAM
Why OpenFOAM
Using OpenFOAM
Simulation Cases
Supersonic Flow over a Forward-facing Step
Simple Pipeline Flow
Make Your Own Solver
run passiveScalarFoam
Figure : Evolution of passive scalar s in rotate flow field
Oliver
Open∇FOAM
Why OpenFOAM
Using OpenFOAM
Simulation Cases
Supersonic Flow over a Forward-facing Step
Simple Pipeline Flow
Make Your Own Solver
End
Thank You
Oliver
Open∇FOAM