N CaseMini PorousInter v11

14

Click here to load reader

description

porousFoam

Transcript of N CaseMini PorousInter v11

  • OpenFOAM R CaseporousInterFoam: dambreak

    Julien Reveillon

    April 29, 2014

    University of Rouen - CORIA

    [email protected]

    Linkedin

    Julien Reveillon OpenFOAM R CaseporousInterFoam: dambreak

    v 1.1 April 29, 2014

  • 1 Porosity model 2

    Foreword Please do not hesitate to email me any remark or mistake (certainly numerous) you may have about thisdocument. Any constructive suggestion is welcome.

    Note that in the following, OpenFOAM R is denoted OF . It is recommended to accomplish the damBreak tutorial before reading this text. Note that OF v.2.3.0 has been used in the following example. Users returns indicate that it runs also

    with OF 2.2.x if you adapt the coordinate system format in the porosity dictionary.

    1 Porosity model The objective of this practical case is to realize a two-phase flow simulation (with interface) in a geometrycontaining a porous zone.

    Our starting point is the Darcy law for creeping flows that expresses the pressure gradient p within theporous media as follow:

    p = kv (1)

    where (kg m1 s1) is the dynamic viscosity and k (m2) the permeability of the porous system. It canbe read as an order of magnitude of the pores surface. It varies significantly for different porous material,typically: 106 m2 < k < 1012 m2. If anisotropic porous media are considered, k has to be consideredas a matrix.

    The following Darcy-Forchheimer equation includes the Darcys law for porous media and adds a newterm that account for the viscous effects of the fluid:

    p =(k

    + | v |)v , (2)

    where is the non-Darcy coefficient.

    In the OF solver, the permeability due to the porous area is represented by an additional sink term in themomentum equation:

    v

    t= [usual N.S. terms] + S (3)

    with:S =

    (d+ f 12 | v |

    )v , (4)

    where the tensors d (m2) and f (m1) are the porosity parameters. In the case of a fully homogeneousporous medium, they can be represented by scalars d and f . In OF homogenous directions are generallyconsidered thanks to vectors d and f that are defined in a local set of coordinates. If an homogeneousporous media is considered, it is possible to link directly the Darcy-Forchheimer equation (Eq. 2) to thesolver parameters through:

    d = 1k

    and f = 2 . (5)

    In this test case, using the OF semantic, the following data have been prescribed:d d[0 -2 0 0 0 0 0] (5e7 5e7 5e7)f f[0 -1 0 0 0 0 0] (0 0 0)Note that negative Darcy/Forchheimer parameters are invalid but they can be used to specify a multiplier(of the max component). The orientation of the porous region is defined with the same notation as acoordinate system, but only a Cartesian coordinate system is valid.

    Julien Reveillon OpenFOAM R CaseporousInterFoam: dambreak

    v 1.1 April 29, 2014

  • 2 Configuration 3

    X

    Y

    Z

    porous zone

    0

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    12

    13

    14

    15

    0.4(0,0) 0.6 1.0

    1.0

    0.1

    Figure 1: Sketch of the porousInterFoam configuration.

    2 Configuration A simple dambreak configuration has been selected for this example. Therefore, the starting case will be thedamBreak tutorial that may be found in $FOAM_TUTORIALS/multiphase/interFoam/laminar/damBreak.First, note that both fvSchemes and fvSolution files remain untouched. The flow will be considered aslaminar. The objective is to be able to run a porousInterFoam case first before considering the completephysics of the flow.

    The geometry is shown in figure 1. Details are as follows: 2D (X Y ) plan configuration 1 1 m (OF : pseudo 3D with 0.1 m thickness along Z). atmosphere at the top left, bottom and right: non slip wall a porous zone is defined in the center of the domain [(0.4 0 0) - (0.6 1 0.1)]

    2.1 Mesh Copy and rename the damBreak tutorial as a new working directory: porousDamBreak.$> cp -r $FOAM_TUTORIALS/multiphase/interFoam/laminar/damBreak $FOAM_RUN/porousDamBreak

    $> cd $FOAM_RUN/porousDamBreak

    Edit the blockMeshDict file:$> gedit constant/polyMesh/blockMeshDict

    Define the geometry vertices as shown in figure 1. Define the various zones of interest in the mesh by naming the blocks. left and right are the areassurrounding the porous section that is named porosity. The porosity laws will be applied inside thiscellZone. It needs to be labeled so that the solver affect the porosity model on the dedicated area.

    Define, as usual (see the damBreak tutorial in the OF User Guide), the various patches, mostly walls andatmosphere.

    Julien Reveillon OpenFOAM R CaseporousInterFoam: dambreak

    v 1.1 April 29, 2014

  • 2.1 Mesh 4

    1 /* --------------------------------*- C++ -*----------------------------------*\2 | ========= | |3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |4 | \\ / O peration | Version: 2.3.0 |5 | \\ / A nd | Web: www.OpenFOAM.org |6 | \\/ M anipulation | |7 \*---------------------------------------------------------------------------*/8 FoamFile9 {

    10 version 2.0;11 format ascii;12 class dictionary;13 object blockMeshDict;14 }15 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //1617 convertToMeters 1;1819 vertices20 (21 // left region22 ( 0 0 0 ) // pt 023 ( 0 1 0 ) // pt 124 ( 0 0 0.1) // pt 225 ( 0 1 0.1) // pt 32627 // left ->porous begins28 ( 0.4 0 0 ) // pt 429 ( 0.4 1 0 ) // pt 530 ( 0.4 0 0.1) // pt 631 ( 0.4 1 0.1) // pt 73233 // porosity ends ->right34 ( 0.6 0 0 ) // pt 835 ( 0.6 1 0 ) // pt 936 ( 0.6 0 0.1 ) // pt 1037 ( 0.6 1 0.1 ) // pt 113839 // right40 ( 1 0 0 ) // pt 1241 ( 1 1 0 ) // pt 1342 ( 1 0 0.1 ) // pt 1443 ( 1 1 0.1 ) // pt 1544 );4546 blocks47 (48 // left block49 hex (0 4 5 1 2 6 7 3)50 left ( 40 100 1 ) simpleGrading (1 1 1)5152 // porosity block53 hex (4 8 9 5 6 10 11 7)54 porosity ( 20 100 1 ) simpleGrading (1 1 1)5556 // right block57 hex (8 12 13 9 10 14 15 11)58 right ( 40 100 1 ) simpleGrading (1 1 1)59 );6061 edges62 (63 );6465 patches66 (67 wall leftWall68 (69 (1 0 2 3)70 )

    Julien Reveillon OpenFOAM R CaseporousInterFoam: dambreak

    v 1.1 April 29, 2014

  • 2.2 Fluid properties 5

    7172 wall rightWall73 (74 (13 12 14 15)75 )7677 wall lowerWall78 (79 (2 0 4 6)80 (10 8 12 14)81 )8283 wall porosityWall84 (85 (6 4 8 10)86 (11 9 5 7)87 )8889 atmosphere atmosphere90 (91 (1 5 7 3)92 (9 13 15 11)93 )9495 empty frontAndBack96 (97 (0 4 5 1)98 (4 8 9 5)99 (8 12 13 9)

    100 (2 6 7 3)101 (6 10 11 7)102 (10 14 15 11)103 )104105 );106107108 mergePatchPairs109 (110 );111112 // ************************************************************************* //

    2.2 Fluid properties In this example, we keep the fluids (water and air) properties of the original damBreak tutorial (unchangedconstant/transportProperties file).

    The gravity acceleration remains the same along the Y direction (unchanged constant/g file). The flow is laminar (unchanged constant/turbulenceProperties file).

    2.3 Porosity properties To define the porosity properties, a dictionary needs to be defined in the constant directory. You cancopy the file structure from the following path: $FOAM_TUTORIALS/incompressible/porousSimpleFoamwhere several porous tutorials are proposed.$> gedit constant/porosityProperties

    Porosity zones with various properties can be prescribed. In our case, only one zone: porosity1 is defined.It is linked to the porosity cell zone, the name and geometry of which were defined in the blockMeshDict(section 2.1).

    Setup the various parameters - mostly the DarcyForchheimer coefficients d and f and the local coordinatesystem e1 and e2 that are local coordinate vectors that are used to specify porosity orientation , if any.

    Julien Reveillon OpenFOAM R CaseporousInterFoam: dambreak

    v 1.1 April 29, 2014

  • 2.4 Initial setup 6

    The orientation of the porous region is defined with the same notation as a coordinate system, but onlya Cartesian coordinate system is valid. You specify three components of d and f. The first component isin the direction of e1, the second in the direction of e2 and the third in the direction perpendicular to e1and e2. Note that for isotropic media, all three components of d and f should have the same value.

    1 /* --------------------------------*- C++ -*----------------------------------*\2 | ========= | |3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |4 | \\ / O peration | Version: 2.3.0 |5 | \\ / A nd | Web: www.OpenFOAM.org |6 | \\/ M anipulation | |7 \*---------------------------------------------------------------------------*/8 FoamFile9 {

    10 version 2.0;11 format ascii;12 class dictionary;13 location "constant";14 object porosityProperties;15 }16 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //1718 porosity119 {20 type DarcyForchheimer;21 active yes;22 cellZone porosity;2324 DarcyForchheimerCoeffs25 {26 mu mu;27 d d [0 -2 0 0 0 0 0] (7e7 7e7 5e8);28 f f [0 -1 0 0 0 0 0] (0 0 0);2930 coordinateSystem31 {32 type cartesian;33 origin (0 0 0);34 coordinateRotation35 {36 type axesRotation;37 e1 (1 0 0); // (0.70710678 0.70710678 0);38 e2 (0 1 0);39 }40 }41 }42 }

    2.4 Initial setup The reference liquid volume fraction alpha.water.org is first set to be 0 everywhere, see section 5.1.Then, it is copied into the initial volume fraction field alpha.water.$> cp 0/alpha.water.org 0/alpha.water

    The initial velocity field U is at rest (0 m/s everywhere). See section 5.2. The initial pressure p_rgh is constant and null (relative pressure) everywhere as well. See section 5.3. The file system/setFieldDict is edited to set up the profile of the initial liquid step in the left side ofthe domain as shown in figure 2. The setFields application is then executed.$> setFields

    1 /* --------------------------------*- C++ -*----------------------------------*\2 | ========= | |3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |4 | \\ / O peration | Version: 2.2.2 |

    Julien Reveillon OpenFOAM R CaseporousInterFoam: dambreak

    v 1.1 April 29, 2014

  • 3 Dictionary/Solver modification 7

    Figure 2: Initial setup of alpha.water

    5 | \\ / A nd | Web: www.OpenFOAM.org |6 | \\/ M anipulation | |7 \*---------------------------------------------------------------------------*/8 FoamFile9 {

    10 version 2.0;11 format ascii;12 class dictionary;13 location "system";14 object setFieldsDict;15 }16 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //1718 defaultFieldValues19 (20 volScalarFieldValue alpha.water 021 );2223 regions24 (25 boxToCell26 {27 box (0 0 -1) (0.4 0.8 1);28 fieldValues29 (30 volScalarFieldValue alpha.water 131 );32 }33 );343536 // ************************************************************************* //

    3 Dictionary/Solver modification Apparently there is some problem in the basic porosity dictionary. If not modified, when the solver porousInterFoam is executed, the following error appears (and similar

    Julien Reveillon OpenFOAM R CaseporousInterFoam: dambreak

    v 1.1 April 29, 2014

  • 3 Dictionary/Solver modification 8

    error exists with versions 2.2.2 and 2.2.1) :

    --> FOAM FATAL ERROR:

    request for volScalarField thermo:mu from objectRegistry region0 failedavailable objects of type volScalarField are

    13(alpha.water_0Kalpha.waterrhop_rghnughnu1prho_0nu2alpha.airmu)

    From function objectRegistry::lookupObject(const word&) constin file /home/opencfd/OpenFOAM/OpenFOAM-2.3.0/src/OpenFOAM/lnInclude/......objectRegistryTemplates.C at line 198.

    FOAM aborting

    #0 Foam::error::printStack(Foam::Ostream&) in "/opt/openfoam230/platforms/......linuxGccDPOpt/lib/libOpenFOAM.so"#1 Foam::error::abort() in "/opt/openfoam230/platforms/linuxGccDPOpt/lib/libOpenFOAM.so"#2 Foam::GeometricField const& Foam::.......objectRegistry::lookupObject(Foam::word const&) const in ......"/opt/openfoam230/platforms/linuxGccDPOpt/lib/libinterfaceProperties.so"#3 Foam::porosityModels::DarcyForchheimer::correct(Foam::fvMatrix......&) ......const in "/opt/openfoam230/platforms/linuxGccDPOpt/lib/libfiniteVolume.so"#4 Foam::porosityModel::addResistance(Foam::fvMatrix&) ......const in "/opt/openfoam230/platforms/linuxGccDPOpt/lib/libfiniteVolume.so"#5 Foam::porosityModelList::addResistance(Foam::fvMatrix&) ......const in "/opt/openfoam230/platforms/linuxGccDPOpt/lib/libfiniteVolume.so"#6in "/opt/openfoam230/platforms/linuxGccDPOpt/bin/porousInterFoam"#7 __libc_start_main in "/lib/i386-linux-gnu/libc.so.6"#8

    Solution 1: dictionary modification. Apparently, the variable thermo:mu is used where it should be only mu.Add the line mu mu; in the DarcyForchheimer porosity dictionary defined in the constant/porosityPropertiesfile. By doing so the muName keyword should be set to mu instead of thermo:mu in the solver.

    24 DarcyForchheimerCoeffs25 {

    Julien Reveillon OpenFOAM R CaseporousInterFoam: dambreak

    v 1.1 April 29, 2014

  • 3 Dictionary/Solver modification 9

    26 mu mu;27 d d [0 -2 0 0 0 0 0] (7e7 7e7 5e8);28 f f [0 -1 0 0 0 0 0] (0 0 0);

    Solution 2: Library and solver compilation. Another solution is to correct the thermo:mu variable directlyinto the solver and to compile it again. Note that solution 1 is far more simpler. The following procedureis useless if there is no other change in the code. The line to modify is located in the libfiniteVolumelibrary and more precisely in the DarcyForchheimer.C file. Therefore, we need to correct the library andto compile it before recompiling the solver.

    1/ Creation of your personal source paths. Place yourself just above your run directory.

    $> cd $FOAM_RUN/.. Create a code directory that will contains you modified OF parts.

    $> mkdir code Copy the libfiniteVolume library sources,

    $> cp -r $FOAM_SRC/finiteVolume code/ and copy the interFoam family solvers sources (including porousInterFoam),

    $> cp -r $FOAM_APP/solvers/multiphase/interFoam code/2/ Correction of the library source. Edit the DarcyForchheimer.C file.

    $> gedit code/finiteVolume/cfdTools/general/porosityModel/DarcyForchheimer.CThe original file reads:

    57 rhoName_(coeffs_.lookupOrDefault ("rho", "rho")),58 muName_(coeffs_.lookupOrDefault ("mu", "thermo:mu")),59 nuName_(coeffs_.lookupOrDefault ("nu", "nu"))

    Correct it into:57 rhoName_(coeffs_.lookupOrDefault ("rho", "rho")),58 muName_(coeffs_.lookupOrDefault ("mu", "mu")),59 nuName_(coeffs_.lookupOrDefault ("nu", "nu"))

    3/ Compilations We need to redirect the compilation destination into the user library path. Edit the Make/files

    $> gedit code/finiteVolume/Make/files and modify the last line (two modifications) into420 LIB = $(FOAM_USER_LIBBIN )/ libmyFiniteVolume

    The new library will have a new name libmyFiniteVolume and will be locatedinto the $FOAM_USER_LIBBIN path.

    Compile the library$> cd code/finiteVolume$> wclean$> wmake libsoAt this stage the new library libmyFiniteVolume is present in the $FOAM_USER_LIBBIN path.

    The porousInterFoam solver needs to be compiled with the new library. It will be renamedmyPorousInterFoam to avoid confusion with the original solver. The whole interFoam sourcetree is needed for the compilation.

    Rename the source file. It does not need to be modified.$> cd $FOAM_RUN/../code/interFoam$> mv porousInterFoam/porousInterFoam.C porousInterFoam/myPorousInterFoam.C

    We need to redirect the compilation. Edit the porousInterFoam/Make/files (three modifica-tions).$> gedit porousInterFoam/Make/files

    1 myPorousInterFoam.C23 EXE = $(FOAM_USER_APPBIN )/ myPorousInterFoam

    Julien Reveillon OpenFOAM R CaseporousInterFoam: dambreak

    v 1.1 April 29, 2014

  • 4 Computation 10

    The newly compiled library libmyFiniteVolume must be used (two modifications: add line 14and modify line 22).$> gedit porousInterFoam/Make/options

    13 EXE_LIBS = \14 -L$(FOAM_USER_LIBBIN) \15 -ltwoPhaseMixture \16 -linterfaceProperties \17 -ltwoPhaseProperties \18 -lincompressibleTransportModels \19 -lincompressibleTurbulenceModel \20 -lincompressibleRASModels \21 -lincompressibleLESModels \22 -lmyFiniteVolume \23 -lmeshTools \24 -lfvOptions \25 -lsampling

    Clean and compile.$> wclean porousInterFoam$> wmake porousInterFoam

    The newly compiled solver myPorousInterFoam is now present in the $FOAM_USER_APPBIN di-rectory.

    4 Computation Go back to your case directory$> cd $FOAM_RUN/porousDamBreak

    Edit the controlDict at your convenience Execute the solver$> porousInterFoam(or my myPorousInterFoam if you used your own compiled version, solution 2).

    An example of the results may be seen in figure 3.

    5 Appendix: initial fields5.1 0/alpha.water.org

    1 /* --------------------------------*- C++ -*----------------------------------*\2 | ========= | |3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |4 | \\ / O peration | Version: 2.3.0 |5 | \\ / A nd | Web: www.OpenFOAM.org |6 | \\/ M anipulation | |7 \*---------------------------------------------------------------------------*/8 FoamFile9 {

    10 version 2.0;11 format ascii;12 class volScalarField;13 object alpha.water;14 }15 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //1617 dimensions [0 0 0 0 0 0 0];1819 internalField uniform 0;2021 boundaryField

    Julien Reveillon OpenFOAM R CaseporousInterFoam: dambreak

    v 1.1 April 29, 2014

  • 5.1 0/alpha.water.org 11

    Figure 3: Time evolution of alpha.water. See www.youtube.com/user/cfdandco

    Julien Reveillon OpenFOAM R CaseporousInterFoam: dambreak

    v 1.1 April 29, 2014

  • 5.2 0/U 12

    22 {23 leftWall24 {25 type zeroGradient;26 }27 rightWall28 {29 type zeroGradient;30 }31 lowerWall32 {33 type zeroGradient;34 }35 porosityWall36 {37 type zeroGradient;38 }39 atmosphere40 {41 type inletOutlet;42 inletValue uniform 0;43 value uniform 0;44 }45 frontAndBack46 {47 type empty;48 }49 }505152 // ************************************************************************* //

    5.2 0/U

    1 /* --------------------------------*- C++ -*----------------------------------*\2 | ========= | |3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |4 | \\ / O peration | Version: 2.2.2 |5 | \\ / A nd | Web: www.OpenFOAM.org |6 | \\/ M anipulation | |7 \*---------------------------------------------------------------------------*/8 FoamFile9 {

    10 version 2.0;11 format ascii;12 class volVectorField;13 location "0";14 object U;15 }16 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //1718 dimensions [0 1 -1 0 0 0 0];1920 internalField uniform (0 0 0);2122 boundaryField23 {24 leftWall25 {26 type fixedValue;27 value uniform (0 0 0);28 }29 rightWall30 {31 type fixedValue;32 value uniform (0 0 0);33 }34 lowerWall35 {36 type fixedValue;

    Julien Reveillon OpenFOAM R CaseporousInterFoam: dambreak

    v 1.1 April 29, 2014

  • 5.3 0/p_rgh 13

    37 value uniform (0 0 0);38 }39 atmosphere40 {41 type pressureInletOutletVelocity;42 value uniform (0 0 0);43 }44 porosityWall45 {46 type slip;47 value uniform (0 0 0);48 }49 frontAndBack50 {51 type empty;52 }53 }545556 // ************************************************************************* //

    5.3 0/p_rgh

    1 /* --------------------------------*- C++ -*----------------------------------*\2 | ========= | |3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |4 | \\ / O peration | Version: 2.2.2 |5 | \\ / A nd | Web: www.OpenFOAM.org |6 | \\/ M anipulation | |7 \*---------------------------------------------------------------------------*/8 FoamFile9 {

    10 version 2.0;11 format ascii;12 class volScalarField;13 object p_rgh;14 }15 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //1617 dimensions [1 -1 -2 0 0 0 0];1819 internalField uniform 0;2021 boundaryField22 {23 leftWall24 {25 type fixedFluxPressure;26 value uniform 0;27 }2829 rightWall30 {31 type fixedFluxPressure;32 value uniform 0;33 }3435 lowerWall36 {37 type fixedFluxPressure;38 value uniform 0;39 }4041 atmosphere42 {43 type totalPressure;44 p0 uniform 0;45 U U;46 phi phi;47 rho rho;

    Julien Reveillon OpenFOAM R CaseporousInterFoam: dambreak

    v 1.1 April 29, 2014

  • 5.3 0/p_rgh 14

    48 psi none;49 gamma 1;50 value uniform 0;51 }52 porosityWall53 {54 type fixedFluxPressure;55 value uniform 0;56 }57 frontAndBack58 {59 type empty;60 }61 }6263 // ************************************************************************* //

    Julien Reveillon OpenFOAM R CaseporousInterFoam: dambreak

    v 1.1 April 29, 2014

    Porosity modelConfigurationMeshFluid propertiesPorosity propertiesInitial setup

    Dictionary/Solver modificationComputationAppendix: initial fields0/alpha.water.org0/U0/p_rgh