CFD
with
OpenSource
so3ware
A
course
at
Chalmers
University
of
Technology
Taught
by
Hakan
Nilsson
Author:
Reza
Gooya
Project
work:
Porous
Media
Modeling
Developed
for
OpenFOAM-‐2.2.x
IntroducMon
fluid
movement
in
porous
material
Darcy's
law
Forchheimer
and
Brinkmann
IntroducMon
Direct
Modelling
of
Porous
Media
• Monte
Carlo
• Navier-‐Stokes
• Network
Base
• LaSce
Boltzmann
OF-‐porous
media-‐Tutorial
• Constant
•
porosityproperMes
•
polymesh/blockmesh
porosity1
{
Blocks
type DarcyForchheimer;
(
active yes;
hex (0 1 2 3 4 5 6 7) porosity (20 20 20)
cellZone porosity;
simpleGrading (1 1 1)
)
DarcyForchheimerCoeffs
{
boundaryCondition
d d [0 -2 0 0 0 0 0] (5e7 -1000 -1000);
(
f f [0 -1 0 0 0 0 0] (5e7 -1000 -1000);
wall porosityWall
coordinateSystem
faces
{
(…
e1 (1 1 0);
)
e2 (0 0 1);
}
}
}
OF-‐porous
media-‐Solver
• Incompressible/porousSimpleFoam
tmp<fvVectorMatrix>
UEqn
(
fvm::div(phi,
U)
+
turbulence-‐>divDevReff(U)
==
fvOpMons(U)
);
pZones.addResistance(UEqn());
OF-‐porous
media-‐Porous
model
• Darcy-‐Forchheimer
forAll(cells,
i)
{
const
label
cellI
=
cells[i];
const
tensor
Cd
=
mu[cellI]*D
+
(rho[cellI]*mag(U[cellI]))*F;
const
scalar
isoCd
=
tr(Cd);
dP=
(μ
*
D
*
v
+
0.5
*
ρ
*
F
*
v2)*L
term, S i , is composed of two parts, a viscous loss term and an inertial loss term
drop that is proportional to the velocity and velocity squared, respectively.
1
! "
OF-‐porous
media-‐Porous
model
S i = − µ Di j + ρ |ukk |Fi j ui
2
This equation is known as the Darcy-Forchheimer equation. In the case of si
porous media it becomes
PowerLaw:
1
! "
S i = − µ D + ρ |u j j | F ui
2
where
const
scalar
C0
D and Fi j are represented as the scalars D and F.
=
iCj 0_;
The Csource
const
scalar
1m1b2
term can
=
(C1_
also be modeled as a power law of the velocity magnitud
-‐
1.0)/2.0;
S i = −ρ C0 |ui |(C1 −1)/2
where C0 and C1 are user defined empirical coefficients.
forAll(cells,
i)
{
const
label
cellI
=
cells[i];
The Class
Udiag[cellI]
+=
The porous media source files in OpenFOAM-1.5 are located in the following
V[cellI]*rho[cellI]*C0*pow(magSqr(U[cellI]),
$FOAM_SRC/finiteVolume/cfdTools/general/porousMedia/
C1m1b2);
The porousMedia folder contains the following files:
}
• porousZones.H
• porousZones.C
ModificaMons
1-‐
removing
F
parameter
from
Darcy-‐Forchheimer
equaMon
forAll(cells,
i)
{
const
label
cellI
=
cells[i];
const
tensor
Cd
=
mu[cellI]*D;
const
scalar
isoCd
=
tr(Cd);
porosity
=
$(general)/porosityModel
$(porosity)/Brinkmann1/Brinkmann1.C
LIB
=
$(FOAM_USER_LIBBIN)/libmyfiniteVolume
ModificaMons
2-‐
Adding
source
term
of
brinkmann
equaMon
tmp<fvVectorMatrix>
UEqn
(
fvm::div(phi,
U)
-‐
fvm::laplacian(nu,
U)
+
turbulence-‐>divDevReff(U)
==
fvOpMons(U)
);
brinkmannFoam.C
EXE
=
$(FOAM_USER_APPBIN)/
brinkmannFoam
ModificaMons
Info<<
"Reading
transportProperMes\n"
<<
Adding
nu
to
endl;
createFields.H
IOdicMonary
transportProperMes
(
IOobject
(
"transportProperMes",
runTime.constant(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
);
dimensionedScalar
nu
(
transportProperMes.lookup("nu")
);
ModificaMons
Adding
nu
to
transportModel
Newtonian;
transportProperMes
nu
nu
[0
2
-‐1
0
0
0
0]
1e-‐06;
Adding
library
to
controlDict
libs
("libmyfiniteVolume.so");
ModificaMons
porosity1
Change
in
{
type
Brinkmann1;
porosityProperMes
acMve
yes;
cellZone
porosity;
Brinkmann1Coeffs
{
d
d
[0
-‐2
0
0
0
0
0]
(2678000000
-‐1966000000
-‐2841000000);
coordinateSystem
{
e1
(1
1
0);
e2
(0
0
1);
}
}
}
ImplementaMon
Foam
cp
–r
–parents
src/finiteVolume/cfdTools/general/porosityModel/DarcyForchheimer
$WM_PROJECT_USER_DIR
cd
$WM_PROJECT_USER_DIR/
src/finiteVolume/cfdTools/general/porosityModel/DarcyForchheimer
mv
DarcyForchheimer
Brinkmann1
cd
Brinkmann1
mv
DarcyForchheimer.C
Brinkmann1.C;
mv
DarcyForchheimer.H
Brinkmann1.H;
mv
DarcyForchheimerTemplates.C
Brinkmann1.C
Then
we
shoud
remove
menMoned
part
(related
to
F
value)
in
Brinkmann1Templates.C
And
we
should
modify
Make
files/opMons
in
finiteVolume
directory.
Make/files
to:
porosity
=
$(general)/porosityModel
$(porosity)/Brinkmann1/Brinkmann1.C
LIB
=
$(FOAM_USER_LIBBIN)/libmyfiniteVolume
And
Make/opMons:
EXE_INC
=
\
-‐I$(LIB_SRC)/triSurface/lnInclude
\
-‐I$(LIB_SRC)/meshTools/lnInclude
\
-‐I$(LIB_SRC)/finiteVolume/lnInclude
LIB_LIBS
=
\
-‐lOpenFOAM
\
-‐ltriSurface
\
-‐lmeshTools
wclean
wmake
libso
ImplementaMon
And
for
solver
part:
foam
cp
–r
–parents
applicaZons/solvers/incompressible/simpleFoam/porousSimpleFoam
$WM_PROJECT_USER_DIR
cd
$WM_PROJECT_USER_DIR/
applicaZons/solvers/incompressible/simpleFoam/porousSimpleFoam
mv
porousSimpleFoam
brinkmannFoam
cd
brinkmannFoam
mv
porousSimpleFoam.C
brinkmannFoam.C
Then
the
laplacian
part
should
be
added
to
UEqn.H
Modify
Make
directory
to:
brinkmannFoam.C
EXE
=
$(FOAM_USER_APPBIN)/brinkmannFoam
And
Make
opMon
file
should
be
like
this:
EXE_INC
=
\
-‐I..
\
-‐I$(LIB_SRC)/turbulenceModels
\
-‐I$(LIB_SRC)/turbulenceModels/incompressible/RAS/RASModel
\
-‐I$(LIB_SRC)/transportModels
\
-‐I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel
\
-‐I$(LIB_SRC)/finiteVolume/lnInclude
\
-‐I$(LIB_SRC)/meshTools/lnInclude
\
-‐I$(LIB_SRC)/fvOpZons/lnInclude
\
-‐I$(LIB_SRC)/sampling/lnInclude
….
ConZnue
next
Page
ImplementaMon
EXE_LIBS
=
\
-‐lincompressibleTurbulenceModel
\
-‐lincompressibleRASModels
\
-‐lincompressibleTransportModels
\
-‐lfiniteVolume
\
-‐lmeshTools
\
-‐lfvOpZons
\
-‐lsampling
wclean
wmake
And
for
runnig
the
case:
run
cp
–r
~/Downloads/Project.tgz
.
tar
xzf
Project.tgz
cp
-‐r
Project/case
.
cd
case
blockMesh
brinkmannFoam
Results
Results