CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   [TUTORIAL] Implementing porous zones to PisoFOAM (https://www.cfd-online.com/Forums/openfoam-programming-development/141181-tutorial-implementing-porous-zones-pisofoam.html)

ssss September 1, 2014 13:04

[TUTORIAL] Implementing porous zones to PisoFOAM
 
  1. Run the following to make a copy of the original pisoFoam
Code:

cp -r $WM_PROJECT_DIR/applications/solvers/incompressible/pisoFoam/ $WM_PROJECT_USER_DIR/applications/solvers/my_pisoFoamPOROUS
  • Change names
Code:

cd $WM_PROJECT_USER_DIR/applications/solvers/my_pisoFoamPOROUS
Code:

mv pisoFoam.C my_pisoFoamPOROUS.C
  • Change link options so that we can compile
Change Make/files to

Code:

my_pisoFoamPOROUS.C

EXE = $(FOAM_USER_APPBIN)/my_pisoFoamPOROUS

First line says which is the main file for the compilation, second line tells the compiler where to save the new solver and the new of the new solver (the name you will use to call the new solver)

Change Make/options to:

Code:

EXE_INC = \
    -I$(LIB_SRC)/turbulenceModels/incompressible/turbulenceModel \
    -I$(LIB_SRC)/transportModels \
    -I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \
    -I$(LIB_SRC)/finiteVolume/lnInclude \
    -I$(LIB_SRC)/meshTools/lnInclude


EXE_LIBS = \
    -lincompressibleTurbulenceModel \
    -lincompressibleRASModels \
    -lincompressibleLESModels \
    -lincompressibleTransportModels \
    -lfiniteVolume \
    -lmeshTools

The \ tells the compiler there is a new line, and we added meshTools library in order to access the mesh object during runTime
  • Remove old compiled files
Code:

rm -rf Make/linux* pisoFoam.dep
  • Create new file createPorousZones.H
Code:

touch createPorousZones.H
This will create the file. Then add to it the following


Code:

    porousZones pZones(mesh); //creates the object porousZones from the mesh object
    Switch pressureImplicitPorosity(false);// Sets the pressure solver as explicit

  • Open my_pisoFoamPOROUS.C and add this before the main function
Code:

...
#include "porousZones.H" // object porousZone
int main(){
...
}

This is needed to have the porousZones constructor

  • Add the following after the main function
Code:

int main(){

    #include "CourantNo.H"
    #include "createPorousZones.H"
   
    // PISO LOOP
    ....

}

This will create the object porousZones as stated before
  • Inside the PISO corrector add the following
Code:

//PISO corrector

{
            fvVectorMatrix UEqn
            (
                fvm::ddt(U)
              + fvm::div(phi, U)
              + turbulence->divDevReff(U)
            );
          pZones.addResistance(UEqn);
          ...

}

  • Compile the solver
Code:

wmake
  • The solver is completed now you need to put inside your constant/ folder a file with name porousZones where you will write your porous properties. You can get one from
    Code:

    $WM_PROJECT_DIR/tutorials/incompressible/porousSimpleFoam/angledDuctExplicit/constant/
  • To set a porous zone inside your mesh
Run
Code:

topoSet
with your topoSetDict, example setting a box:


Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  2.1.0                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    object      topoSetDict;
}

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

actions
(
    {
        name    porosity;
        type    cellSet;
        action  new;
        source  boxToCell;
        sourceInfo
        {
          box (10 0 0) (35 2 0.5); //box (minVertex) (maxVertex)
        }
    }

After that run
Code:

setsToZones
because we have selected only Cells, but the solver needs zones.

At last call
Code:

my_pisoFoamPOROUS
inside your case folder, and it should hopefully run with porous zones.

Hope you found it helpful.

Tempest October 30, 2016 21:58

I get the error "fatal error: porousZones.H: No such file or directory
compilation terminated".

What can be the possible reasons?>

wouter November 2, 2016 17:16

Hello
To make this work you either need to have the same version as OF that is used by ssss or get the right name of the include file for porousSimpleFoam.
#include "IOporosityModelList.H" in stead of
#include "porousZones.H"

This change also needs to be made in the code exchange porousZones by IOporosityModelList.

( I tried this with OF-dev and I had to change the tutorial also quite a lot because there are links to files that I could not copy)

Hope this helps
Wouter

Tempest November 2, 2016 21:00

Yeah I figured that out.

To add porous zones in any solver:

1. Create createPorousZones.H file.

Add

IOporosityModelList pZones(mesh); //creates the object porousZones from the mesh object

Switch pressureImplicitPorosity(false);// Sets the pressure solver as explicit

2. Add #include "IOporosityModelList.H" in header of .C
#include "createPorousZones.H" in main prog.

3. Add pZones.addResistance(UEqn); after the governing equations.

Peace!

Tempest November 25, 2016 21:44

Quote:

Originally Posted by wouter (Post 623876)
Hello
To make this work you either need to have the same version as OF that is used by ssss or get the right name of the include file for porousSimpleFoam.
#include "IOporosityModelList.H" in stead of
#include "porousZones.H"

This change also needs to be made in the code exchange porousZones by IOporosityModelList.

( I tried this with OF-dev and I had to change the tutorial also quite a lot because there are links to files that I could not copy)

Hope this helps
Wouter

Is it necessary to multiply porosity explicitly in the Ueqn as given in various articles on porous media or OF takes care of it when you define darcyForchheimer type fvOptions?

ashishmagar600 September 26, 2017 12:55

Hello everyone.

Is there a similar method for including cellzones inside a solver, maybe icofoam or simplefoam??

mnaufalazwar July 31, 2018 14:23

what is the different if i want to implement porous zones to icoFoam? thanks


All times are GMT -4. The time now is 09:43.