CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Local porosity (http://www.cfd-online.com/Forums/openfoam-programming-development/72118-local-porosity.html)

Se9a January 26, 2010 04:09

Local porosity
 
Hello.
Please, give me hints about how to calculate a local porosity with OpenFOAM? I.e. I have a file with coordinates and radii of spherers and I want to map the spheres to a mesh, then calculate volume of spheres for each mesh cell and divide the cell volume by the volume of spheres in a given cell.
Thanks.

r08n March 22, 2010 07:31

I have a similar question - how to assign porosity values for each cell of the mesh individually and be able to modify it during the runtime. It seems that currently the porosity can be assigned to each porous zone, and each zone contains a number of cells.
It would be nice to (re)use the functionality provided by the porousZone class, but to be
able to create and destroy the porous zones at runtime, and to add and remove the cells
from the appropriate porous zones as needed. Is this approach reasonable? Or can somebody propose a better way?

From the existing solvers in OF 1.6, are rhoPorousSimpleFoam and porousExplicitSourceReactingParcelFoam the only ones dealing with porosity? It seems
that only the latter is able to treat the porosity, as defined by Se9a (volume ratio), because rhoPorousSimpleFoam is steady state and does not contain the terms with the
temporal derivatives.

olesen March 23, 2010 11:24

Quote:

Originally Posted by r08n (Post 251106)
I have a similar question - how to assign porosity values for each cell of the mesh individually and be able to modify it during the runtime. It seems that currently the porosity can be assigned to each porous zone, and each zone contains a number of cells.
It would be nice to (re)use the functionality provided by the porousZone class, but to be
able to create and destroy the porous zones at runtime, and to add and remove the cells
from the appropriate porous zones as needed. Is this approach reasonable? Or can somebody propose a better way?

While it would understandable be nice to reuse the existing porosity treatment, it sounds like what you need is much, much more general -- a field of porosity coefficients covering the entire calculation domain.

r08n June 28, 2010 12:05

Looking at the implementation of Foam::porousZone::modifyDdt, it seems that this function simply multiplies the matrix resulting from discretisation of the temporal derivative by the porosity. I wonder, is it reasonable (correct) to use a simple mimesis and rewrite the momentum equation like this, to include the cell-dependent porosity (using porousExplicitSourceReactingParcelFoam, 'UEqn.H', as the basis):

Code:

fvVectorMatrix UEqn
 (
    fvm::div(phi, U)
    + turbulence->divDevRhoReff(U)
    ==
    rho.dimensionedInternalField()*g
    //+ parcels.SU()
);

tmp<fvVectorMatrix> tmp_ddt = fvm::ddt (rho, U);

forAll (mesh.cells(), i)
{
    tmp_ddt().diag ()[i] *= gamma [i];
    tmp_ddt().source ()[i] *= gamma [i];
}

UEqn += tmp_ddt;

Here, 'gamma' is a scalar field of porosity (0 <= gamma <= 1.0). Can it be implemented
in such a simple way, or did I overlook something? I haven't tested this yet, but at least this block compiles and doesn't crash when running.

olesen June 29, 2010 02:53

Quote:

Originally Posted by r08n (Post 264844)
Looking at the implementation of Foam::porousZone::modifyDdt, it seems that this function simply multiplies the matrix resulting from discretisation of the temporal derivative by the porosity. I wonder, is it reasonable (correct) to use a simple mimesis and rewrite the momentum equation like this, to include the cell-dependent porosity (using porousExplicitSourceReactingParcelFoam, 'UEqn.H', as the basis):

Code:

fvVectorMatrix UEqn
 (
    fvm::div(phi, U)
    + turbulence->divDevRhoReff(U)
    ==
    rho.dimensionedInternalField()*g
    //+ parcels.SU()
);

tmp<fvVectorMatrix> tmp_ddt = fvm::ddt (rho, U);

forAll (mesh.cells(), i)
{
    tmp_ddt().diag ()[i] *= gamma [i];
    tmp_ddt().source ()[i] *= gamma [i];
}

UEqn += tmp_ddt;

Here, 'gamma' is a scalar field of porosity (0 <= gamma <= 1.0). Can it be implemented
in such a simple way, or did I overlook something? I haven't tested this yet, but at least this block compiles and doesn't crash when running.

If you are only taking care of the temporal terms, this should work fine, but of course doesn't handle any of the porous resistances at all.

Honey April 15, 2012 16:26

Quote:

Originally Posted by r08n (Post 264844)
Looking at the implementation of Foam::porousZone::modifyDdt, it seems that this function simply multiplies the matrix resulting from discretisation of the temporal derivative by the porosity. I wonder, is it reasonable (correct) to use a simple mimesis and rewrite the momentum equation like this, to include the cell-dependent porosity (using porousExplicitSourceReactingParcelFoam, 'UEqn.H', as the basis):

Code:

fvVectorMatrix UEqn
 (
    fvm::div(phi, U)
    + turbulence->divDevRhoReff(U)
    ==
    rho.dimensionedInternalField()*g
    //+ parcels.SU()
);

tmp<fvVectorMatrix> tmp_ddt = fvm::ddt (rho, U);

forAll (mesh.cells(), i)
{
    tmp_ddt().diag ()[i] *= gamma [i];
    tmp_ddt().source ()[i] *= gamma [i];
}

UEqn += tmp_ddt;

Here, 'gamma' is a scalar field of porosity (0 <= gamma <= 1.0). Can it be implemented
in such a simple way, or did I overlook something? I haven't tested this yet, but at least this block compiles and doesn't crash when running.


The porosity values for my problem is as a function of x, y, & z. So, I am willing to give porosity at every cells separately.

You have posted the code to do so but unfortunately I have understood 50% of it since I have just started to learn OF. However, here comes my questions:
1) where you able to run your code and assign different porosity at every cell?

2)How to give porosities at each individual cell as an input file for OF?

3) If I understood it correctly, OF calculates the centered value at every cell. Now, if we can introduce the porosity at each individual cell to the OF, shall it be centered value or can even be nodal values?

I look forward for some help,

Thank you very much & with best regards.

Hisham April 15, 2012 17:22

Hi

Quote:

Originally Posted by Honey (Post 354779)
2)How to give porosities at each individual cell as an input file for OF?

If the porosity is defined as a volScalarField, it is easy to use the funkySetFiellds utility to set initial values of porosity according to a given expression.
I do not know whether it is possible to do that with the codeStream feature. It would be great if anyone would elaborate on that!
Quote:

Originally Posted by Honey (Post 354779)
3) If I understood it correctly, OF calculates the centered value at every cell. Now, if we can introduce the porosity at each individual cell to the OF, shall it be centered value or can even be nodal values?

Again if the porosity is declared as a volScalarField, the values will be at cell centers (where integration occurs) and there will be other scalar fields that store values for faces of patches (useful if you need the variable in the BC calculations!)

Regards
Hisham

r08n April 18, 2012 08:51

On a related note: why is porous media defined as porousZone, not as a scalar field?
Introducing a field (rather than a zone) would be more flexible, allow for runtime modifications
(moving porous zones, coupling with discrete phase, etc.) and definitions using standard field
manipulation utilities. But, probably, there are reasons for the current implementation. I ask this because I used the sources with some modifications in the porosity treatment and I want
to know that mistakes can be made in doing so.

Hisham April 18, 2012 10:43

Hi r08n,

As Olesen mentioned, if you have no need to update resistance according to change in porosity, then your approach is fine.

The current implementation allows for introducing several porous media models to the same simulation.

To allow for varying porosity across the domain, one would need to:
1. Change the porousZone class a little bit, therefor one needs to make a new copy (say myPorousZone or varPorosityPorousZone) [Follow steps in chapter 3 of the user's manual]. Simply copy paste porousMedia directory rename every thing including the options & files inside the Make directory.

5. In myPorousZoneTemplates.C:
Code:

template<class Type>
00032 void Foam::myPorousZone::modifyDdt(fvMatrix<Type>& m) const
00033 {
              volScalarField myPorosity_
                (
                  IOobject
                    (
                      "myPorosity",
                        runTime.constant(), /* myPorosity file needed in constant directory */
                        mesh_,
                        IOobject::MUST_READ,
                        IOobject::AUTO_WRITE
                    ),
                    mesh_
                  );

             
00034    //if (porosity_ < 1)
00035    {
00036        forAll(cellZoneIds_, zoneI)
00037        {
00038            const labelList& cells = mesh_.cellZones()[cellZoneIds_[zoneI]];
00039
00040            forAll(cells, i)
00041            {
                          if(myPorosity_[i] < 0) {Info << "Fatal error: myPorosity_ < 0" << endl; exit(-1)}
00042                m.diag()[cells[i]]  *= myPorosity_[i];
00043                m.source()[cells[i]] *= myPorosity_[i];
00044            }
00045        }
00046    }
00047 }


Hope this helps! It is not tested so errors (bugs) will happen but they can be fixed! :)

The myPorosity file must be in the constant directory (you can try other options like the time directories)

You can set values in the myPorosity file using funkySetFields as mentioned above

Regards,
Hisham

r08n April 18, 2012 12:53

Quote:

Originally Posted by Hisham (Post 355424)

5. In myPorousZoneTemplates.C:
Code:

template<class Type>
00032 void Foam::myPorousZone::modifyDdt(fvMatrix<Type>& m) const
00033 {
              volScalarField myPorosity_
                (
                  IOobject
                    (
                      "myPorosity",
                        runTime.constant(), /* myPorosity file needed in constant directory */
                        mesh_,
                        IOobject::MUST_READ,
                        IOobject::AUTO_WRITE
                    ),
                    mesh_
                  );

             
00034    //if (porosity_ < 1)
00035    {
00036        forAll(cellZoneIds_, zoneI)
00037        {
00038            const labelList& cells = mesh_.cellZones()[cellZoneIds_[zoneI]];
00039
00040            forAll(cells, i)
00041            {
                          if(myPorosity_[i] < 0) {Info << "Fatal error: myPorosity_ < 0" << endl; exit(-1)}
00042                m.diag()[cells[i]]  *= myPorosity_[i];
00043                m.source()[cells[i]] *= myPorosity_[i];
00044            }
00045        }
00046    }
00047 }


Thanks for suggestion. This is a useful extension to the porousZone class -- setting porosity as a field rather than as a constant. This can be probably used for other relevant parameters, like Darcy-Forchheimer coefficients, etc.

santoo_cfd June 6, 2014 08:46

Porosity in OpenFOAM 2.3.0
 
Hi,

In the OpenFOAM 2.3.0, Where we can set the value of porosity.

If I am not wrong, whole porous media treatment is modified and I cannot see the modifyDdt in the source folder where it contained the "\gamma" term which denotes the porosity.

I tried mentioning the "\gamma" value in the constant/porosityProperties dictionary but doesn't seems to honored.

Is there any way to mention the porosity value in the OpenFOAM 2.3.0

Thanks in advance.


All times are GMT -4. The time now is 00:05.