# Inhomogeneous Porous Media

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

 November 10, 2014, 12:03 Inhomogeneous Porous Media #1 New Member   Marco Join Date: Nov 2014 Location: Germany Posts: 14 Rep Power: 11 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?

 March 3, 2015, 10:52 #2 New Member   Marco Join Date: Nov 2014 Location: Germany Posts: 14 Rep Power: 11 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.

 March 3, 2015, 10:59 #3 New Member   Marco Join Date: Nov 2014 Location: Germany Posts: 14 Rep Power: 11 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 void Foam::porosityModels::DarcyForchheimer::apply tensorField& AU, const RhoFieldType& rho, const scalarField& mu, const vectorField& U )```

July 16, 2016, 15:05
#4
New Member

exw599
Join Date: Jan 2016
Posts: 6
Rep Power: 10
Quote:
 Originally Posted by mkiewat 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

 December 16, 2020, 13:33 #5 Senior Member   alberto Join Date: Apr 2016 Location: Mexico Posts: 117 Rep Power: 10 Hi, Did you find a way to use a permeability dependent position?

 Tags fvoptions, porous domain, porous media, porous modellling