CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Local porosity

Register Blogs Community New Posts Updated Threads Search

Like Tree5Likes
  • 2 Post By r08n
  • 2 Post By Hisham
  • 1 Post By r08n

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 26, 2010, 03:09
Default Local porosity
  #1
New Member
 
Sergei D.
Join Date: Mar 2009
Posts: 4
Rep Power: 0
Se9a is on a distinguished road
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.
Se9a is offline   Reply With Quote

Old   March 22, 2010, 06:31
Default
  #2
Member
 
Robertas N.
Join Date: Mar 2009
Location: Kaunas, Lithuania
Posts: 53
Rep Power: 17
r08n is on a distinguished road
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.
r08n is offline   Reply With Quote

Old   March 23, 2010, 10:24
Default
  #3
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,684
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by r08n View Post
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.
olesen is offline   Reply With Quote

Old   June 28, 2010, 12:05
Default
  #4
Member
 
Robertas N.
Join Date: Mar 2009
Location: Kaunas, Lithuania
Posts: 53
Rep Power: 17
r08n is on a distinguished road
Looking at the implementation of Foam:orousZone::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.
mm.abdollahzadeh and ashvinc9 like this.
r08n is offline   Reply With Quote

Old   June 29, 2010, 02:53
Default
  #5
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,684
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by r08n View Post
Looking at the implementation of Foam:orousZone::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.
olesen is offline   Reply With Quote

Old   April 15, 2012, 16:26
Default
  #6
New Member
 
Honey
Join Date: Mar 2011
Location: Dmg
Posts: 23
Rep Power: 15
Honey is on a distinguished road
Quote:
Originally Posted by r08n View Post
Looking at the implementation of Foam:orousZone::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.
Honey is offline   Reply With Quote

Old   April 15, 2012, 17:22
Default
  #7
Senior Member
 
Hisham's Avatar
 
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17
Hisham is on a distinguished road
Hi

Quote:
Originally Posted by Honey View Post
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 View Post
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
Hisham is offline   Reply With Quote

Old   April 18, 2012, 08:51
Default
  #8
Member
 
Robertas N.
Join Date: Mar 2009
Location: Kaunas, Lithuania
Posts: 53
Rep Power: 17
r08n is on a distinguished road
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.
r08n is offline   Reply With Quote

Old   April 18, 2012, 10:43
Default
  #9
Senior Member
 
Hisham's Avatar
 
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17
Hisham is on a distinguished road
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
mm.abdollahzadeh and manuc like this.
Hisham is offline   Reply With Quote

Old   April 18, 2012, 12:53
Default
  #10
Member
 
Robertas N.
Join Date: Mar 2009
Location: Kaunas, Lithuania
Posts: 53
Rep Power: 17
r08n is on a distinguished road
Quote:
Originally Posted by Hisham View Post

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.
manuc likes this.
r08n is offline   Reply With Quote

Old   June 6, 2014, 08:46
Default Porosity in OpenFOAM 2.3.0
  #11
Member
 
santhosh
Join Date: Apr 2009
Location: India
Posts: 70
Rep Power: 17
santoo_cfd is on a distinguished road
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.
santoo_cfd is offline   Reply With Quote

Old   April 8, 2016, 19:37
Default
  #12
New Member
 
Vitor Geraldes
Join Date: Dec 2009
Location: Lisbon, Portugal
Posts: 26
Rep Power: 16
vitor.geraldes@ist.utl.pt is on a distinguished road
Taking intro account the vectorial nature of fvVectorMatrix, why tmp_ddt().diag() is a scalar instead of a vector?
Is there also a simple way to incorporate directly in the matrix a local anisotropic permeability?
vitor.geraldes@ist.utl.pt is offline   Reply With Quote

Old   April 10, 2016, 00:11
Default
  #13
Member
 
santhosh
Join Date: Apr 2009
Location: India
Posts: 70
Rep Power: 17
santoo_cfd is on a distinguished road
I realized that porosity is included in the D term. It is the ratio of porosity to the permeability. Also, fvPatch functionality is very generic to add source term to most of the openfoam solvers. Currently I have used interfoam along with fvPatch to simulate Multiphase flow through porous media.
santoo_cfd is offline   Reply With Quote

Old   May 18, 2020, 10:05
Default
  #14
Senior Member
 
Alejandro
Join Date: Jan 2014
Location: Argentina
Posts: 128
Rep Power: 12
ancolli is on a distinguished road
Quote:
Originally Posted by r08n View Post
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.
Can u share your implementation? Do u have it for a newer version of OpenFOAM?
ancolli is offline   Reply With Quote

Old   July 19, 2020, 10:31
Default
  #15
New Member
 
Armin Alavi
Join Date: May 2019
Location: Tehran
Posts: 22
Rep Power: 6
ArminAlavi is on a distinguished road
Hello Foamers
I used explicitPorosity fvOption to model porous media in compresibleInterFoam solver. I wonder how I could define D (Darcy coefficient) so that it is a function of alpha.liquid. Technically I want D coefficient to be different in cells that contain liquid from ones that contain gas.
Any suggestions would be highly appreciated.

Armin
ArminAlavi is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to write k and epsilon before the abnormal end xiuying OpenFOAM Running, Solving & CFD 8 August 27, 2013 15:33
[blockMesh] BlockMeshmergePatchPairs hjasak OpenFOAM Meshing & Mesh Conversion 11 August 15, 2008 07:36
Convergence moving mesh lr103476 OpenFOAM Running, Solving & CFD 30 November 19, 2007 14:09
IcoFoam parallel woes msrinath80 OpenFOAM Running, Solving & CFD 9 July 22, 2007 02:58
Could anybody help me see this error and give help liugx212 OpenFOAM Running, Solving & CFD 3 January 4, 2006 18:07


All times are GMT -4. The time now is 04:18.