CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Community Contributions (https://www.cfd-online.com/Forums/openfoam-community-contributions/)
-   -   [swak4Foam] funkySetFields (https://www.cfd-online.com/Forums/openfoam-community-contributions/76855-funkysetfields.html)

Chrisi1984 June 7, 2010 06:07

funkySetFields
 
Hi,

I discovered the lib funkySetFields to define nonconformal initial conditions.

I would like to know, if it is possible to set for one zone of the mesh a initial condition with fixed value (k=0) with funkySetFields.

Therby I want to define a porous zone as a laminar zone.

If you have an other idea to define a laminar zone without using mutliRegion, I would be glad about.

Best regards

Chrisi

gschaider June 7, 2010 07:16

Quote:

Originally Posted by Chrisi1984 (Post 261909)
Hi,

I discovered the lib funkySetFields to define nonconformal initial conditions.

I would like to know, if it is possible to set for one zone of the mesh a initial condition with fixed value (k=0) with funkySetFields.

Therby I want to define a porous zone as a laminar zone.

If you have an other idea to define a laminar zone without using mutliRegion, I would be glad about.

Best regards

Chrisi

Have a look at the end of section 4 of http://openfoamwiki.net/index.php/Co...funkySetFields . Use the function described there in the -contition-option and you should be set (BTW: k=0 is not a good idea in my opinion. You'll get a divison by zero)

Bernhard

Chrisi1984 June 7, 2010 08:13

Thank you,

I understood right, it is possible to define fixed values as initial conditon, but k=0 is bad?

Would mut=0 be a better definition?

Regards

Chrisi

gschaider June 9, 2010 04:31

Quote:

Originally Posted by Chrisi1984 (Post 261930)
Thank you,

I understood right, it is possible to define fixed values as initial conditon, but k=0 is bad?

No. k will only be set as an initial condition. It will be calculated in later time-steps.

k=0 anywhere usually results in a divisionByZero-error (try it).

Quote:

Originally Posted by Chrisi1984 (Post 261930)
Would mut=0 be a better definition?

No. That is calculated from other values.

herbert June 9, 2010 05:22

Hi Chrisi,

if you only want your porous zones to be treated as laminar, I would suggest to use mut=0 is this region. Because can't be done directly, I'd suggest the following workaround.

Just replace your UEqn

Code:

tmp<fvVectorMatrix> UEqn
(
    fvm::div(phi, U)
  - fvm::Sp(fvc::div(phi), U)
  + turbulence->divDevRhoReff(U)
);

by

Code:

volScalarField muEff = turbulence->muEff();
volScalarField muLam = turbulence->mu();

forAll(mesh.cellZones(), iZone)
{
    //if this is a porousZone
    forAll(mesh.cellZones()[iZone], iCell)
    {
        label actualCell = mesh.cellZones()[iZone][iCell];
        //replace effective viscosity by the molecular one
        muEff[actualCell] = muLam[actualCell];
    }
}

tmp<fvVectorMatrix> UEqn
(
    fvm::div(phi, U)
  - fvm::Sp(fvc::div(phi), U)
  - fvm::laplacian(muEff, U) - fvc::div(muEff*dev2(fvc::grad(U)().T()))
);

Please tell me, if it works.

Regards,
Stefan

Chrisi1984 June 11, 2010 03:18

Hi,

Thank you for your suggestion.
I tried solving with this, but I did not get a laminar zone.
Perhabs I have to define somewhere in the code you gave me the name of my porous zone, haven't I?
I tried solving with exactly your posted code.

Or should I personalize your code in a different way for my case?

Thanks in advance!

Regards Chrisi

herbert June 11, 2010 03:58

Hi Chrisi,

yes indeed, you might add some code at
Code:

//if this is a porous zone
My code actually goes through all cells included in any cell Zone and replaces the effective viscosity by the molecular (laminar) one. If there is a cell Zones that isn't a porous zone you have to exlude it from the loop via in if statement (e.g. by its name).

One more thing I have forgotten: You will have to do the same thing for alphaEff used in hEqn, because the changes in mut are not reported back to the turbulence model and therefore won't effect calculation of alphaEff from mut.

BTW: Maybe there is still a more elegant way to solve your problem. Keep on trying...

Regards,
Stefan

Chrisi1984 June 11, 2010 08:08

Hi Herbert,

thanks for your efforts.

But I 'm sorry I dont know how to put in this if statement. Because I have only one porous zone inside my mesh, it would be easier not to exclude all other zones I think.

How can I make an if statement to call different cell zones.

Can you translate your code for me?

That would be so nice of you.

Regards
Chrisi

herbert June 14, 2010 04:30

Hi Chrisi,

I thought about something like this:
Code:

forAll(mesh.cellZones(), iZone) //loop over all cellZones
{
    if (mesh.cellZones()[iZone].name() == "bla") //with bla being name of porous cellZone
    {
        forAll(mesh.cellZones()[iZone], iCell) //loop over all cells in Zone
        {
              label actualCell = mesh.cellZones()[iZone][iCell]; //"global" cell index of actual cell
              //replace effective viscosity by the molecular (laminar) one
              muEff[actualCell] = muLam[actualCell];
          }
      }
}

BTW: What do you mean talking about "laminar"? If you want the flow to have a certain direction (e.g. in x-direction) you can influence by the loss coefficients. Just set the coefficients in the directions you want to have zero velocity to -1000. Then it should be 1000 times higher than in the specified flow direction. In this case you won't have to manipulate code.

Regards,
Stefan

Chrisi1984 June 15, 2010 02:21

Hi,

thank you again.

At the moment your suggestions did not change really much, but it can be right anyhow.

So now why what I want to do: I want to find an equivalent for the laminar zone for porous regions like in Fluent. That there are no turbulent swirls in my porous zone.

I must check with an other case, if your code allow exactly this.

Best regards

Chrisi

Chrisi1984 June 17, 2010 03:26

Hi,

Is it possible to call setFields during the calculation to overwirte mut only in my porous zone with zero in every time step?

Regards
Chrisi


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