CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   cellZone not taking all the cells inside (https://www.cfd-online.com/Forums/openfoam-solving/213745-cellzone-not-taking-all-cells-inside.html)

rahulksoni January 7, 2019 13:27

cellZone not taking all the cells inside
 
2 Attachment(s)
My case details can be found at https://www.cfd-online.com/Forums/op...tml#post720660

i am using OpenFOAM-3.0.x. My case is very similar to the propeller tutorial of pimpleDyMFoam except for one change that is the different design of propeller. Obviously, the dimensions of innerCylinderSmall and other cylinders were updated according to the new design/dimension of the propeller. Moreover, it is a fluid-filled closed chamber now without any inlet and outlet.

The Courant number issue was resolved as per discussions stated in https://www.cfd-online.com/Forums/op...tml#post720660

The simulation runs seamlessly after changes. Thereafter I wanted to define the whole simulation zone as a porous zone called porosity1. Therefore, following part was added to the file createInletOutletSets.topoSetDict

Code:

    // Load initial cellSet
    {
        name    porosity1;
        type    cellSet;
        action  new;
        source  boxToCell;
        sourceInfo
        {
            box (-0.1 0.0 -0.1) (0.1 0.18 0.1);
        }
    }

    // Setting cellZone
    {
        name    porosity1;
        type    cellZoneSet;
        action  new;
        source  setToCellZone;
        sourceInfo
        {
                set porosity1;
        }
    }

The total number of cells in the system as stated by checkMesh is 577544. Part of checkMesh result is shown below:
Code:

Mesh stats
    points:          719644
    faces:            1873121
    internal faces:  1704405
    cells:            577544
    faces per cell:  6.19438
    boundary patches: 8
    point zones:      0
    face zones:      1
    cell zones:      1

Here, I also want to show the output of topoSet command which clearly tells that all 577544 cells get included in the cellZone 'porosity':
Code:

/*---------------------------------------------------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  3.0.x                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
Build  : 3.0.x-ac3f6c67e02f
Exec  : topoSet -dict system/createInletOutletSets.topoSetDict
Date  : Jan 02 2019
Time  : 18:25:33
Host  : "MSLab02"
PID    : 15445
Case  : /media/mslab02/Elements/CFD/StirredMill/OpenFOAM/V11_V10_originalStirredMillRPM1000/V11_V10_originalStirredMillRPM1000
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Allowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create polyMesh for time = 0

Reading topoSetDict

Time = 0
    mesh not changed.
Created faceSet boundaryFaces
    Applying source patchToFace
    Adding all faces of patch outerCylinder ...
    Found matching patch outerCylinder with 4036 faces.
    faceSet boundaryFaces now size 4036
Created faceSet outletFaces
    Applying source faceToFace
    Adding all faces from faceSet boundaryFaces ...
    faceSet outletFaces now size 4036
Created faceSet inletFaces
    Applying source faceToFace
    Adding all faces from faceSet boundaryFaces ...
    faceSet inletFaces now size 4036
Read set faceSet outletFaces with size 4036
    Applying source normalToFace
    normalToFace : Normalized vector to (0 -1 0)
    Adding faces according to normal being aligned with (0 -1 0) (to within 0.3) ...
    faceSet outletFaces now size 1440
Read set faceSet inletFaces with size 4036
    Applying source normalToFace
    normalToFace : Normalized vector to (0 1 0)
    Adding faces according to normal being aligned with (0 1 0) (to within 0.3) ...
    faceSet inletFaces now size 0
Created cellSet porosity1
    Applying source boxToCell
    Adding cells with center within boxes 1((-0.1 0 -0.1) (0.1 0.18 0.1))
    cellSet porosity1 now size 577544
Created cellZoneSet porosity1
    Applying source setToCellZone
    Adding all cells from cellSet porosity1 ...
    cellZoneSet porosity1 now size 577544


End

In the end, I run the solver pimpleDyMFoam. Let's see the initial output in the log.pimpleDyMFoam (which gets repeated throughout the simulation):
Code:

/*---------------------------------------------------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  3.0.x                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
Build  : 3.0.x-ac3f6c67e02f
Exec  : pimpleDyMFoam -parallel
Date  : Jan 02 2019
Time  : 18:30:05
Host  : "MSLab02"
PID    : 16340
Case  : /media/mslab02/Elements/CFD/StirredMill/OpenFOAM/V11_V10_originalStirredMillRPM1000/V11_V10_originalStirredMillRPM1000
nProcs : 4
Slaves :
3
(
"MSLab02.16341"
"MSLab02.16342"
"MSLab02.16343"
)

Pstream initialized with:
    floatTransfer      : 0
    nProcsSimpleSum    : 0
    commsType          : nonBlocking
    polling iterations : 0
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Allowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0

Selecting dynamicFvMesh solidBodyMotionFvMesh
Selecting solid-body motion function rotatingMotion
Applying solid body motion to cellZone innerCylinderSmall

PIMPLE: no residual control data found. Calculations will employ 2 corrector loops

Reading field p

Reading field U

Reading/calculating face flux field phi

AMI: Creating addressing and weights between 31980 source faces and 31980 target faces
AMI: Patch source sum(weights) min/max/average = 0.864049, 1.06838, 0.950135
AMI: Patch target sum(weights) min/max/average = 0.777792, 1.00559, 0.942769
Selecting incompressible transport model Newtonian
Selecting turbulence model type RAS
Selecting RAS turbulence model kEpsilon
kEpsilonCoeffs
{
    Cmu            0.09;
    C1              1.44;
    C2              1.92;
    C3              -0.33;
    sigmak          1;
    sigmaEps        1.3;
}

Reading/calculating face velocity Uf

No MRF models present

Creating finite volume options from "constant/fvOptions"

Selecting finite volume options model type explicitPorositySource
    Source: porosity1
    - selecting cells using cellZone porosity1
    - selected 89136 cell(s) with volume 0.00272961

Porosity region porosity1:
    selecting model: DarcyForchheimer
    creating porous zone: porosity1
Courant Number mean: 0 max: 0

Starting time loop

Reading surface description:
    zNormal
    isoQ
    propeller

forces forces:
    Not including porosity effects

Courant Number mean: 0 max: 0
deltaT = 1.19904e-05
Time = 1.19904e-05

solidBodyMotionFunctions::rotatingMotion::transformation(): Time = 1.19904e-05 transformation: ((0 0 0) (1 (0 0.000629496 0)))
AMI: Creating addressing and weights between 31980 source faces and 31980 target faces
AMI: Patch source sum(weights) min/max/average = 0.890328, 1.11472, 0.980946
AMI: Patch target sum(weights) min/max/average = 0.813328, 1.06253, 0.973343
PIMPLE: iteration 1
- selecting cells using cellZone porosity1
- selected 89136 cell(s) with volume 0.00272961
- selecting cells using cellZone porosity1
- selected 89136 cell(s) with volume 0.00272961

smoothSolver:  Solving for Ux, Initial residual = 1, Final residual = 0.00347262, No Iterations 1
smoothSolver:  Solving for Uy, Initial residual = 1, Final residual = 0.00361454, No Iterations 1
smoothSolver:  Solving for Uz, Initial residual = 1, Final residual = 0.00357922, No Iterations 1
- selecting cells using cellZone porosity1
- selected 89136 cell(s) with volume 0.00272961
GAMG:  Solving for p, Initial residual = 1, Final residual = 0.00518406, No Iterations 5
time step continuity errors : sum local = 8.59148e-07, global = -1.54541e-10, cumulative = -1.54541e-10
- selecting cells using cellZone porosity1
- selected 89136 cell(s) with volume 0.00272961
PIMPLE: iteration 2
- selecting cells using cellZone porosity1
- selected 89136 cell(s) with volume 0.00272961
- selecting cells using cellZone porosity1
- selected 89136 cell(s) with volume 0.00272961
smoothSolver:  Solving for Ux, Initial residual = 0.030644, Final residual = 6.75332e-07, No Iterations 2
smoothSolver:  Solving for Uy, Initial residual = 0.0254633, Final residual = 5.55156e-07, No Iterations 2
smoothSolver:  Solving for Uz, Initial residual = 0.030196, Final residual = 7.25131e-07, No Iterations 2
- selecting cells using cellZone porosity1
- selected 89136 cell(s) with volume 0.00272961
GAMG:  Solving for p, Initial residual = 0.171561, Final residual = 1.61213e-06, No Iterations 50
time step continuity errors : sum local = 5.96149e-10, global = -4.95493e-11, cumulative = -2.0409e-10
- selecting cells using cellZone porosity1
- selected 89136 cell(s) with volume 0.00272961
smoothSolver:  Solving for epsilon, Initial residual = 0.00240751, Final residual = 4.53715e-08, No Iterations 2
smoothSolver:  Solving for k, Initial residual = 1, Final residual = 6.08364e-07, No Iterations 3
ExecutionTime = 21.82 s  ClockTime = 28 s

forces forces output:
    sum of forces:
        pressure : (0.32169 -0.0611844 -0.31682)
        viscous  : (6.64668e-06 -2.1396e-07 -6.79721e-07)
        porous  : (0 0 0)
    sum of moments:
        pressure : (-0.556742 -0.54134 -0.344258)
        viscous  : (-1.27764e-05 -6.49338e-05 -8.20582e-06)
        porous  : (0 0 0)

Courant Number mean: 0.0219529 max: 0.173894
deltaT = 1.43712e-05
Time = 2.63616e-05

We can see only 89136 cells out of total 577544 cells get selected for cellZone porosity1. Can anyone explain why it is happening?

I tried to visualize these cellZones and found that in otal two cellZones get created 'porosity1' and 'innerCylinderSmall'. Total 577544 cells gets divided in these two cellZones. 89136 cells in 'porosity1' and rest in 'innerCylinderSmall'. The same is evident in constant/polyMesh/cellZones file.

I have made the visual comparison of complete mesh and the two cellZones as in the attached image.
I also know that the defined porosity conditions are working fine but only for the outer region. I have attached the simulation snapshot at the end of 1 second of two simulations, one with defined porosity (left) and another without porosity (right). One can see that the simulation without porosity (right) has continuous velocity field throughout the region. However, one with porosity (left) has discretely reduced velocity particulary in the discussed outer porous region.

Everything is good to go except one that why porosity1 region even after being defined for the whole region is leaving the cells contained in innerCylinderSmall region/cellZone.

Someone please explain.

Any help is greatly appreciable.

wyldckat January 20, 2019 15:49

Quick answer: A "zone" (pointZone, faceZone or cellZone) cannot hold the same ID as another zone. So the problem is that at first you say "I wanted everything to have porosity" and later on "but I want this region of the mesh to be in another cellZone for rotation"... and the result "everything that rotates is no longer in the porosity zone".

If you want all of the mesh to have a fixed porosity, OpenFOAM does allow that without the need to define a new zone... and I can't remember if 3.0.x allows using a cellSet...

OK, before I forget: a "set" (pointSet, faceSet or cellSet) can hold the same ID as another set of the same type.

If you had provided the "fvOptions" file, it would be easier for be to point out where you can change it... now I have to look for a tutorial with it... here we go: https://github.com/OpenFOAM/OpenFOAM...tant/fvOptions

This:
Code:

        selectionMode  cellZone;
        cellZone porosity;

can be something like this:
Code:

        selectionMode  cellSet;
        cellSet porosity;

or this:
Code:

        selectionMode  all;
if my memory doesn't fail me. If in doubt: https://openfoamwiki.net/index.php/O...de/Use_bananas

rahulksoni January 21, 2019 05:39

Thanks a lot for the informative response and clarification. My toposet file and fvOptions file contents are below for your reference:

topoSetDict
Code:

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

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

actions
(
    {
        name    boundaryFaces;
        type    faceSet;
        action  new;
        source  patchToFace;
        sourceInfo
        {
            name outerCylinder;
        }
    }

    {
        name    outletFaces;
        type    faceSet;
        action  new;
        source  faceToFace;
        sourceInfo
        {
            set boundaryFaces;
        }
    }

    {
        name    inletFaces;
        type    faceSet;
        action  new;
        source  faceToFace;
        sourceInfo
        {
            set boundaryFaces;
        }
    }

    {
        name    outletFaces;
        type    faceSet;
        action  subset;
        source  normalToFace;
        sourceInfo
        {
            normal  (0 -1 0);  // Vector
            cos    0.3;        // Tolerance (max cos of angle)
        }
    }

    {
        name    inletFaces;
        type    faceSet;
        action  subset;
        source  normalToFace;
        sourceInfo
        {
            normal  (0 1 0);    // Vector
            cos    0.3;        // Tolerance (max cos of angle)
        }
    }

    // Load initial cellSet
    {
        name    porosity1;
        type    cellSet;
        action  new;
        source  boxToCell;
        sourceInfo
        {
            box (-0.1 0.0 -0.1) (0.1 0.18 0.1);
        }
    }

    // Setting cellZone
    {
        name    porosity1;
        type    cellZoneSet;
        action  new;
        source  setToCellZone;
        sourceInfo
        {
                set porosity1;
        }
    }
);


//

fvOptions
Code:

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

porosity1
{
    type            explicitPorositySource;
    active          yes;

    explicitPorositySourceCoeffs
    {
        selectionMode  cellZone;
        cellZone        porosity1;

        type            DarcyForchheimer;

        DarcyForchheimerCoeffs
        {
            d  (4.4e6 4.4e6 4.4e6);
            f  (1020 1020 1020);

            coordinateSystem
            {
                type    cartesian;
                origin  (0 0 0);
                coordinateRotation
                {
                    type    axesRotation;
                    e1      (1 0 0);  //x-axis
                    e2      (0 0 1);  //z-axis
                    //e3 is orthogonal to e1 and e2 and gets created automatically
                }
            }
        }
    }
}


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


Actually, I am playing with the simulation settings. In my final settings I shall need to setup more than one porous zones for assigning different porosity values. That is why I chose to have region definintion based cellZone settings.

Please guide me how can achieve that and what changes do I require to do so.

Thanks a lot in advance.

wyldckat January 22, 2019 19:44

Quick answer: I haven't tested to confirm it, but I believe that if you change this in "fvOptions":
Code:

        selectionMode  cellZone;
        cellZone        porosity1;

to this:
Code:

        selectionMode  cellSet;
        cellSet        porosity1;

it should work, given that you have a cellSet of the same name in "topoSetDict".

But be careful, because this will allow you to have overlapping porosity regions, because you can have multiple cellSets with common cell IDs.

rahulksoni January 24, 2019 05:42

FOAM FATAL ERROR: [1] selection mode is cellSet
 
Thanks for the info

I made changes according to your suggestion as below:

topoSetDict
Code:

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

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

actions
(
    {
        name    boundaryFaces;
        type    faceSet;
        action  new;
        source  patchToFace;
        sourceInfo
        {
            name outerCylinder;
        }
    }

    {
        name    outletFaces;
        type    faceSet;
        action  new;
        source  faceToFace;
        sourceInfo
        {
            set boundaryFaces;
        }
    }

    {
        name    inletFaces;
        type    faceSet;
        action  new;
        source  faceToFace;
        sourceInfo
        {
            set boundaryFaces;
        }
    }

    {
        name    outletFaces;
        type    faceSet;
        action  subset;
        source  normalToFace;
        sourceInfo
        {
            normal  (0 -1 0);  // Vector
            cos    0.3;        // Tolerance (max cos of angle)
        }
    }

    {
        name    inletFaces;
        type    faceSet;
        action  subset;
        source  normalToFace;
        sourceInfo
        {
            normal  (0 1 0);    // Vector
            cos    0.3;        // Tolerance (max cos of angle)
        }
    }

    // Load initial cellSet
    {
        name    porosity1;
        type    cellSet;
        action  new;
        //source  boxToCell;
        source  cylinderToCell;
        sourceInfo
        {
            //box (-0.1 0.0 -0.1) (0.1 0.18 0.1);
            p1 (0 0 0);  // start point on cylinder axis//
            p2 (0 0.18 0);  // end point on cylinder axis//
            radius 0.1;     
        }

    }

    // Setting cellZone
    /*{
        name    porosity1;
        type    cellZoneSet;
        action  new;
        source  setToCellZone;
        sourceInfo
        {
                set porosity1;
        }
    }*/
);


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

fvOptions
Code:

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

porosity1
{
    type            explicitPorositySource;
    active          yes;

    explicitPorositySourceCoeffs
    {
        //selectionMode  cellZone;
        //cellZone        porosity1;
        selectionMode  cellSet;
        cellSet        porosity1;


        type            DarcyForchheimer;

        DarcyForchheimerCoeffs
        {
            d  (4.4e6 4.4e6 4.4e6);
            f  (1020 1020 1020);

            coordinateSystem
            {
                type    cartesian;
                origin  (0 0 0);
                coordinateRotation
                {
                    type    axesRotation;
                    e1      (1 0 0);  //x-axis
                    e2      (0 0 1);  //z-axis
                    //e3 is orthogonal to e1 and e2 and gets created automatically
                }
            }
        }
    }
}


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

When I run the simulation I get the following error for pimpleDyMFoam solver(OpenFOAM-3.0.x)
Code:

Selecting finite volume options model type explicitPorositySource
    Source: porosity1
    - selecting cells using cellSet porosity1
    - selected 577544 cell(s) with volume 0.00551937
[3]
[3]
[3] --> FOAM FATAL ERROR:
[3] The porosity region must be specified as a cellZone.  Current selection mode is cellSet
[3]
[3]    From function void Foam::fv::explicitPorositySource::initialise()
[3]    in file sources/derived/explicitPorositySource/explicitPorositySource.C at line 66.

I also ran the same case with OpenFOAM-5.x (as said that OpenFOAM-3.0.x does not allow...). However, slightly different result was obtained:
Code:

Selecting finite volume options model type explicitPorositySource
    Source: porosity1
    - selecting cells using cellSet porosity1
    - selected 577544 cell(s) with volume 0.00551937
[1]
[1]
[1] --> FOAM FATAL ERROR:
[1] selection mode is cellSet
[1]
[1]    From function Foam::fv::explicitPorositySource::explicitPorositySource(const Foam::word&, const Foam::word&, const Foam::dictionary&, const Foam::fvMesh&)
[1]    in file sources/derived/explicitPorositySource/explicitPorositySource.C at line 66.

If I change the selectionMode to all in fvOptions then error is
Code:

[0] --> FOAM FATAL ERROR:
[0] selection mode is all



Any hint on what I am missing.

Thanks in advance

wyldckat January 24, 2019 20:18

Quick answer: Nooooooooooooooo..... :(
Sorry, I completely forgot that porous regions require that a cellZone is used...

The quickest solution then is to add as many porous regions as needed... for example, use something like this:
Code:

porosity1
{
    type            explicitPorositySource;
    active          yes;

    explicitPorositySourceCoeffs
    {
        selectionMode  cellZone;
        cellZone        porosity1;
 
        type            DarcyForchheimer;

        DarcyForchheimerCoeffs
        {
            d  (4.4e6 4.4e6 4.4e6);
            f  (1020 1020 1020);

            coordinateSystem
            {
                type    cartesian;
                origin  (0 0 0);
                coordinateRotation
                {
                    type    axesRotation;
                    e1      (1 0 0);  //x-axis
                    e2      (0 0 1);  //z-axis
                    //e3 is orthogonal to e1 and e2 and gets created automatically
                }
            }
        }
    }
}

porousRotor
{
  $porosity1;

  explicitPorositySourceCoeffs
  {
        selectionMode  cellZone;
        cellZone        rotorZone;
  }
}

"$porosity1;" indicates that it will include all of the definitions done in the "porosity1" block. Then the next lines will override only the new definitions for this new block "porousRotor". The name "rotorZone" is just an example for the cellZone that is defined for the part of the mesh that was created by snappyHexMesh, if I remember your posts correctly.

rahulksoni January 25, 2019 00:11

I can do like that 'defining as many as porous zones as needed' but whether the earlier discussed problem i.e. 'the part of the porous zone which also falls in the dynamic/AMI/rotary region can be assigned only to one cellZone and that is the rotary one' will be solved by this.

I did what you said and part of output is pasted below which says that no cell selected for rotorZone
Code:

- selecting cells using cellZone porosity1
- selected 89136 cell(s) with volume 0.00272961
- selecting cells using cellZone rotorZone
- selected 0 cell(s) with volume 0



All times are GMT -4. The time now is 13:50.