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/)
-   -   Inhomogeneous Porous Media (https://www.cfd-online.com/Forums/openfoam-solving/144219-inhomogeneous-porous-media.html)

mkiewat November 10, 2014 12:03

Inhomogeneous Porous Media
 
I want to define a source term field via the fvOptions on the rhs of a momentum equation. I know my porous intertial and viscous resistance tensor as a function of space dimensions: D_.value(x,y) and F_.value(x,y), so in each cell, the resulting resistance tensor has different values. How could I create a tensor field, that I can hand over to the momentum equation? Is it possible to create a function that will fill the tensorField? E.g. where could I define something like this, preferably without having to recompile the solver:

Code:

porosity1
{
    type          explicitPorositySource;
    active        yes;
    selectionMode cellZone;
    cellZone      porosity;

    explicitPorositySourceCoeffs
    {
        type DarcyForchheimer;

        DarcyForchheimerCoeffs
        { 
        forAll(cells,i)
            {
            d.value[i].xx = 12.34*cells[i].coordinates.x
            d.value[i].yy = 43.21*cells[i].coordinates.y+2
            d.value[i].zz = 1e6
            f.value[i].xx = 4.567*cells[i].coordinates.x
            f.value[i].yy = 654.3*cells[i].coordinates.y+6
            f.value[i].zz = 1e6
            }
     
        coordinateSystem
              {
              e1    (1 0 0);
              e2    (0 1 0);
              }
        }
    }
}

any ideas? :rolleyes:

mkiewat March 3, 2015 10:52

Ok, i found the solution to my problem. I modified the original DarcyForchheimerTemplates.C file and added a function that returns the coefficients based on some of the flow parameters in each cell (http://foam.sourceforge.net/docs/cpp/a04765_source.html).

Code:

forAll(cellZoneIDs_, zoneI)
{
        const labelList& cells = mesh_.cellZones()[cellZoneIDs_[zoneI]];
        forAll(cells, i)
      {
            const label cellI = cells[i];
            //coordinates of the cell
            const scalar params.xCoor = mesh_.C().component(vector::X)()[cellI];
            const scalar params.yCoor = mesh_.C().component(vector::Y)()[cellI];
            //Volume averaged velocity of the cell
            const scalar params.ux = mag(Uv.internalField()[cellI].x())*alphav.internalField()[cellI] + mag(Ul.internalField()[cellI].x())*(1-alphav.internalField()[cellI]);
            const scalar params.uy = mag(Uv.internalField()[cellI].y())*alphav.internalField()[cellI] + mag(Ul.internalField()[cellI].y())*(1-alphav.internalField()[cellI]);
 
            const tensor Cd = Functions::calcCd(params);
            const scalar isoCd = tr(Cd);
            Udiag[cellI] += V[cellI]*isoCd;
            Usource[cellI] -= V[cellI]*((Cd - I*isoCd) & U[cellI]);
      }
}

Maybe this is helpful for someone else that is trying to do the same kind of stuff.

mkiewat March 3, 2015 10:59

Now, another thing that I dont't really understand:
Can someone explain what the sense behind this method of adding the source term is?
Code:

Udiag[cellI] += V[cellI]*isoCd;
Usource[cellI] -= V[cellI]*((Cd - I*isoCd) & U[cellI]);

Also from DarcyForchheimerTemplates.C (http://foam.sourceforge.net/docs/cpp/a04765_source.html). Can anybody tell what this second function "apply" is for and what the tensor field "AU" is?
Code:

(template<class RhoFieldType>
void Foam::porosityModels::DarcyForchheimer::apply
 
tensorField& AU,
const RhoFieldType& rho,
const scalarField& mu,
const vectorField& U
)


exw599 July 16, 2016 15:05

Quote:

Originally Posted by mkiewat (Post 534182)
Ok, i found the solution to my problem. I modified the original DarcyForchheimerTemplates.C file and added a function that returns the coefficients based on some of the flow parameters in each cell (http://foam.sourceforge.net/docs/cpp/a04765_source.html).

Code:

forAll(cellZoneIDs_, zoneI)
{
        const labelList& cells = mesh_.cellZones()[cellZoneIDs_[zoneI]];
        forAll(cells, i)
      {
            const label cellI = cells[i];
            //coordinates of the cell
            const scalar params.xCoor = mesh_.C().component(vector::X)()[cellI];
            const scalar params.yCoor = mesh_.C().component(vector::Y)()[cellI];
            //Volume averaged velocity of the cell
            const scalar params.ux = mag(Uv.internalField()[cellI].x())*alphav.internalField()[cellI] + mag(Ul.internalField()[cellI].x())*(1-alphav.internalField()[cellI]);
            const scalar params.uy = mag(Uv.internalField()[cellI].y())*alphav.internalField()[cellI] + mag(Ul.internalField()[cellI].y())*(1-alphav.internalField()[cellI]);
 
            const tensor Cd = Functions::calcCd(params);
            const scalar isoCd = tr(Cd);
            Udiag[cellI] += V[cellI]*isoCd;
            Usource[cellI] -= V[cellI]*((Cd - I*isoCd) & U[cellI]);
      }
}

Maybe this is helpful for someone else that is trying to do the same kind of stuff.

Hi mkiewat,

I am facing a similar problem like you, I need to simulate the flow past the porous media where permeability is not uniform over space. "DarcyForchheimerTemplates.C" is in src folder, are there any other solutions to this problem? Because as I know if you change the source code you have to recompile it which is not so easy for me.

Cheers

dewey December 16, 2020 13:33

Hi,


Did you find a way to use a permeability dependent position?


All times are GMT -4. The time now is 10:26.