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/)
-   -   adapting "debuggedPorousInterFoam" to OF version 2.1 (http://www.cfd-online.com/Forums/openfoam-programming-development/117850-adapting-debuggedporousinterfoam-version-2-1-a.html)

Natalie2210 May 16, 2013 05:36

adapting "debuggedPorousInterFoam" to OF version 2.1
 
Hi!

First of all, I want to give a short overview over the problem I'm facing.

The porousInterFoam solver shipped with OF 2.1.1 does not take the porosity into account. Therefore, the solution the solver computes does not coincide with the (analytical) solution of the corresponding problem, i.e. the penetration of a porous medium by a liquid. This fact is known and a corresponding bug report has been filed at

http://openfoam.org/mantisbt/view.php?id=477.

However, a debugged version of porousInterFoam has been published at
http://sourceforge.net/apps/mantisbt...iew.php?id=129
by Niels which differs from the "original" porousInterFoam version by the construction of the porosity field and the corresponding integration of the porosity in the alpha-Equation. However, this code has been written to be integrated into the OpenFoam 1.6-ext version and so I face certain compatibility problems.

The first major problem I encounter is that in the file "createPorousZones.H" the porosity field is created by

Code:

volScalarField porosity
    (
 IOobject
        (
    "porosity",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::NO_WRITE
        ),
        mesh,
        dimensionedScalar("NULL", dimless, 1.0),
        "zeroGradient"
    );
    forAll( pZones, zoneI )
    {
        const label & zoneId( pZones[zoneI].zoneId() );
 
        const labelList & cells(mesh.cellZones()[cellZoneIds_[zoneI]]);
        const scalar & zonePorosity( pZones[zoneI].porosity() );
        forAll( cells, cellI )
        {
        porosity[cells[cellI]] = zonePorosity;
        }
    }
    porosity.write();

The first part of the code is not problematic, in the second half of the code above, starting with "forAll( pZones, zoneI).." I run into problems. It seems that this piece of code attaches the porosity to the cells belonging to the porous cell zone, however, in OF 2.1 the variable "zoneId" is no longer a member of the porousZone class. Does anyone have an idea how to rewrite this piece of code OF 2.1- conform? Maybe there is some piece of code in another solver attaching some property to a certain cell zone which uses a loop similar to this one?


Then I have another question, mainly to Niels if he is somewhere around :-)
The same piece of code I posted above - the creation of the porosity field - is not only found in createPorousZones.H but also in the file alphaEqn.H - why is it defined doubly?
Furthermore, I found no difference in the UEqn.H to the original file ../multiphase/interFoam/porousInterFoam.H/UEqn.H . However, I believe that in the volume-averaged Navier-Stokes equation describing the flow through porous media the porosity also enters the time derivative? I.e. the NS-equation goes

d/dt(rho * U * gamma) = ...

where gamma denotes the porosity. However, this does not enter the calculation even in debuggedPorousInterFoam?


I hope anyone reads this although its quite a long post :-))

Kind regards,
Natalie

ngj May 16, 2013 06:39

Hi Natalie,

Let me try to answer your questions one-by-one.

1. Compilation problems. The following bit of code is written from the top of my head without compilation (targeted for 2.1), so it might not be completely successful. I have modified the code, which you posted, as it differs a bit from the debugged version. However, try the following:

Code:

forAll( pZones, zoneI )
{
    const labelList & zoneIds( pZones[zoneI].zoneIds() );

    const scalar poro( pZones[zoneI].porosity() );

    forAll( zoneIds, zi )
    {
        const labelList & cells( mesh.cellZones()[zoneIds[zi]] );

        forAll( cells, celli )
        {
            porosity[cells[celli]] = poro;
        }
    }
}
porosity.correctBoundaryConditions();

porosity.write();

2. The code was probably also added in alphaEqn.H, to take changes in porosity with time into account.

3. With respect to adding a constant on the temporal derivative, yes, it is true that there should be a correction. We came across this fact after the debugged version was submitted, and since no one responded to the bug report, we left it at the most significant problem.
Please note that the correction in OF-2.1 might not be correct, however, I cannot remember, if we did something different in the end.

Good luck

Niels

Natalie2210 May 16, 2013 07:09

It compiles!! Great, thank you so much!

What do you mean by

Quote:

Please note that the correction in OF-2.1 might not be correct
?

ngj May 16, 2013 07:33

Good.

I meant that

Code:

pZones.ddt(rho, U)
might not be correctly implementation. I cannot remember, whether we ended up making some corrections or not, though we discussed it a lot.

Kind regards

Niels

ngj May 16, 2013 07:34

P.S. Remember to visualise the porosity field written in the first time folder. This will help you to check, whether the code works.

Phicau May 16, 2013 09:59

Hi Natalie,

may I suggest you a reference?

http://www.sciencedirect.com/science...78383912000245

In this paper you can find a very comprehensive review of the porous media equations.

Best,

Pablo

santoo_cfd June 9, 2014 04:47

Quote:

Originally Posted by Natalie2210 (Post 427979)
It compiles!! Great, thank you so much!


?

Hi Natalie,

Is it possible for you share the debuggedPorousInterFoam solver you have modified for the 2.1.0 version.

I started modifying the original version from Mantis to able to work with version 2.2.0, and landed up with same compilation trouble you have posted above in createPorousZones.H file. I tried with above suggested modification as well, but still facing compilation errors.

Code:

createPorousZones.H: In function ‘int main(int, char**)’:
createPorousZones.H:20:5: error: request for member ‘size’ is ambiguous
/opt/openfoam230/src/OpenFOAM/lnInclude/PtrListI.H:34:20: error: candidates are: Foam::label Foam::PtrList<T>::size() const [with T = Foam::porosityModel, Foam::label = int]



All times are GMT -4. The time now is 12:22.