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

Local porosity

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree2Likes
  • 1 Post By r08n
  • 1 Post By Hisham

Reply
 
LinkBack Thread Tools Display Modes
Old   January 26, 2010, 04:09
Default Local porosity
  #1
New Member
 
Sergei D.
Join Date: Mar 2009
Posts: 4
Rep Power: 8
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, 07:31
Default
  #2
Member
 
Robertas N.
Join Date: Mar 2009
Location: Kaunas, Lithuania
Posts: 52
Rep Power: 8
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, 11:24
Default
  #3
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: http://olesenm.github.io/
Posts: 777
Rep Power: 18
olesen will become famous soon enough
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: 52
Rep Power: 8
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 likes this.
r08n is offline   Reply With Quote

Old   June 29, 2010, 02:53
Default
  #5
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: http://olesenm.github.io/
Posts: 777
Rep Power: 18
olesen will become famous soon enough
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: Finland
Posts: 18
Rep Power: 6
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 El Safti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 247
Blog Entries: 10
Rep Power: 8
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: 52
Rep Power: 8
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 El Safti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 247
Blog Entries: 10
Rep Power: 8
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 likes 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: 52
Rep Power: 8
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.
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: pune, India
Posts: 67
Rep Power: 8
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

Reply

Thread Tools
Display Modes

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 On
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
BlockMeshmergePatchPairs hjasak OpenFOAM Native Meshers: blockMesh 11 August 15, 2008 07:36
Convergence moving mesh lr103476 OpenFOAM Running, Solving & CFD 30 November 19, 2007 15: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 19:07


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