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

Smagorinsky LES: output and average k value

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

Like Tree3Likes
  • 3 Post By HanSolo123

Reply
 
LinkBack Thread Tools Display Modes
Old   August 21, 2013, 09:16
Default Smagorinsky LES: output and average k value
  #1
New Member
 
Fabio Pierella
Join Date: Aug 2013
Location: Trondheim
Posts: 4
Blog Entries: 1
Rep Power: 4
pierellozzo is on a distinguished road
Dear Foamers,

I am simulating a wind turbine in a wind tunnel, and I am performing a LES simulation using the Smagorinsky model and the pisoFoam solver.

I am also averaging the velocity, pressure and sub-grid scale kinetic energy ( p U k) by the use of the fieldAverage library.

While everything works fine for p and U, I cannot average the k and I get the following error:

Code:
--> FOAM FATAL ERROR: 
Requested field k does not exist in the database


    From function Foam::fieldAverage::initialize()
    in file fieldAverage/fieldAverage/fieldAverage.C at line 104.

FOAM exiting
If I run the simulation without averaging the k, everything runs fine, but I do not get any k file inside the time folders.

If I switch LES model to oneEqEddy f.ex., then everything runs smooth, I get all the averages including k and the k is written in the output time folders.

My question is: is there a way to force OF to write and average the k value when using the Smagorinsky model?

I have tried to use the swak4foam utility but did not get any luck.

Thanks in advance for your help!
Fabio
pierellozzo is offline   Reply With Quote

Old   August 21, 2013, 10:39
Default
  #2
Senior Member
 
Kent Wardle
Join Date: Mar 2009
Location: Illinois, USA
Posts: 201
Rep Power: 11
kwardle is on a distinguished road
Smagorinksy model does not use/write field k.
kwardle is offline   Reply With Quote

Old   August 21, 2013, 11:20
Default
  #3
Senior Member
 
Kent Wardle
Join Date: Mar 2009
Location: Illinois, USA
Posts: 201
Rep Power: 11
kwardle is on a distinguished road
Guess maybe I could be a little more helpful. The Smagorinsky is a zero-equation model so there is no additional transport eqn for k. You can compute this but it depends if you are looking for the resolved TKE or just the sub-grid TKE. Take a look here:
How to obtain turbulent kinetic energy data from LES model of Ansys CFX?

From that post (which is just a copy-paste from Pope, 2000) the total TKE is the sum of the resolved part:

k_res = 1/2 * avg(U) * avg(U)

and the SGS part

k_sgs = 1/2 * tau_ii_R = 1/2 * avg(U^2) * [avg(U) * avg(U)]

I think this is correct anyway. Hope this helps.
-Kent
kwardle is offline   Reply With Quote

Old   August 21, 2013, 19:14
Default
  #4
New Member
 
Fabio Pierella
Join Date: Aug 2013
Location: Trondheim
Posts: 4
Blog Entries: 1
Rep Power: 4
pierellozzo is on a distinguished road
Hello Kent,

thanks for your help, your solution is good enough for my case.
I can use swak4foam to output k at runtime according to the equations.

Anyway I'd like to know, out of curiosity/future need, one more thing.
From Smagorinsky.C,line 115, looks to me that k is actually calculated as:
Code:
  //- Return SGS kinetic energy
  //  calculated from the given velocity gradient

  tmp<volScalarField> k(const tmp<volTensorField>& gradU) const

      {
       return (2.0*ck_/ce_)*sqr(delta())*magSqr(dev(symm(gradU)));
       }

       //- Return SGS kinetic energy

       virtual tmp<volScalarField> k() const
       {
        return k(fvc::grad(U()));
       }
Therefore, I am wondering if there is a way that k can be "routed" to be an output of the calculations and not only an internally referenced value.

Fabio
pierellozzo is offline   Reply With Quote

Old   August 22, 2013, 06:33
Default
  #5
New Member
 
Fabio Pierella
Join Date: Aug 2013
Location: Trondheim
Posts: 4
Blog Entries: 1
Rep Power: 4
pierellozzo is on a distinguished road
I have been thinking over your answer, and I think that I cannot calculate the subgrid scale energy in that way, since it is impossible to calculate the average of the squared velocity field:

0.5*avg(U^2)

which is also one of the reasons why we need subgrid scale modeling, if I am not wrong?

Fabio
pierellozzo is offline   Reply With Quote

Old   August 24, 2013, 10:47
Default
  #6
New Member
 
Fabio Pierella
Join Date: Aug 2013
Location: Trondheim
Posts: 4
Blog Entries: 1
Rep Power: 4
pierellozzo is on a distinguished road
Any help with this issue would be greatly appreciated

Fabio
pierellozzo is offline   Reply With Quote

Old   August 26, 2013, 16:35
Question
  #7
Senior Member
 
Join Date: Nov 2012
Posts: 168
Rep Power: 4
hz283 is on a distinguished road
Hello,

About obtaining the k_sgs, why not directly use the following?

turbulence->k();



Quote:
Originally Posted by kwardle View Post
Guess maybe I could be a little more helpful. The Smagorinsky is a zero-equation model so there is no additional transport eqn for k. You can compute this but it depends if you are looking for the resolved TKE or just the sub-grid TKE. Take a look here:
How to obtain turbulent kinetic energy data from LES model of Ansys CFX?

From that post (which is just a copy-paste from Pope, 2000) the total TKE is the sum of the resolved part:

k_res = 1/2 * avg(U) * avg(U)

and the SGS part

k_sgs = 1/2 * tau_ii_R = 1/2 * avg(U^2) * [avg(U) * avg(U)]

I think this is correct anyway. Hope this helps.
-Kent
hz283 is offline   Reply With Quote

Old   November 28, 2013, 05:38
Default mistake
  #8
New Member
 
Giulio S
Join Date: Oct 2013
Location: Italy
Posts: 4
Rep Power: 3
GiulioS is on a distinguished road
I would like to report a mistake:

k_sgs== 1/2 * tau_ii_R = 1/2 * filtered(U U) - [filtered(U) * filtered(U)]
But you don't know the filtered(U U) so perhaps you have to use:
return (2.0*ck_/ce_)*sqr(delta())*magSqr(dev(symm(gradU)))
which is very similar to the rate of transfer energy yo the residual motion:
Pr=2*nuSgs* filtered(Sij) * filtered (Sij)
But I attend any suggestion
Best Regard
Giulio


Quote:
Originally Posted by kwardle View Post
Guess maybe I could be a little more helpful. The Smagorinsky is a zero-equation model so there is no additional transport eqn for k. You can compute this but it depends if you are looking for the resolved TKE or just the sub-grid TKE. Take a look here:
How to obtain turbulent kinetic energy data from LES model of Ansys CFX?

From that post (which is just a copy-paste from Pope, 2000) the total TKE is the sum of the resolved part:

k_res = 1/2 * avg(U) * avg(U)

and the SGS part

k_sgs = 1/2 * tau_ii_R = 1/2 * avg(U^2) * [avg(U) * avg(U)]

I think this is correct anyway. Hope this helps.
-Kent
GiulioS is offline   Reply With Quote

Old   March 8, 2014, 09:41
Default
  #9
New Member
 
Zhong, Hong Min
Join Date: Oct 2012
Location: UESTC, Chengdu in China
Posts: 8
Rep Power: 4
iamacloud is on a distinguished road
Dear OFers, for kinetic energy K in LES, my understanding is (maybe not correct),
1. Note that if u = Filtered(u) + uprime, then resolved velocity vector Filtered(u) is not usually equal to Filter(Filter(u)), while Filtered(uprime) isn't equal to zero, where u is turbulence instantaneous velocity field, or u = u(x, t). However, <uprime> maybe is equal to zero under the isotropic assumptions, <.> denotes Reynolds averaging or time averaging.
2. According to Giulio and Pope, kinetic energy K_total = k_res + k_sgs, where k_res is the resolved kinetic energy and k_sgs the subgrid kinetic energy. Firstly, for k_sgs, if Smagorinsky model, then k_sgs = (2.0*ck_/ce_)*sqr(delta())*magSqr(dev(symm(gradU))), note that it is obtained by the resolved velocity field Filtered(u) (=U). So k_sgs can be got easily. Secondly, k_res = 0.5*Filtered(u)_i*Filtered(u)_i = 0.5U_i*U_i, note also that it is instantaneous or is at current timestep, obviously,we can get it. However, most of the cases, we hope to get <K_total> because we simply concern a equilibrium flow rather than a evolutive flow. If really so, we can ignore <k_sgs> and the reason is that the scale of the subgrid energy vortex (k_sgs) is much smaller than the resolved vortex scale (k_res) based on the Kolmogorov energy cascade.
In brief, for OFers we can get <K-total> = <k_res> by the "UprimeMean" in the on-the-fly-processing founction "fieldAverage" specified in controlDict file.

if any wrong , don't hesitate to correct me please

Last edited by iamacloud; March 19, 2014 at 11:20.
iamacloud is offline   Reply With Quote

Old   June 16, 2014, 04:28
Default
  #10
New Member
 
Hans Barósz
Join Date: May 2014
Posts: 18
Rep Power: 3
HanSolo123 is on a distinguished road
Quote:
Originally Posted by iamacloud View Post
However, most of the cases, we hope to get <K_total> because we simply concern a equilibrium flow rather than a evolutive flow. If really so, we can ignore <k_sgs> and the reason is that the scale of the subgrid energy vortex (k_sgs) is much smaller than the resolved vortex scale (k_res) based on the Kolmogorov energy cascade.
In brief, for OFers we can get <K-total> = <k_res> by the "UprimeMean" in the on-the-fly-processing founction "fieldAverage" specified in controlDict file.

if any wrong , don't hesitate to correct me please
I dont agree with that, The SGS are indeed much smaller than the GS, but not that small that we can ignore it in a classic LES, where ~ 80% of the total kinetic energy should be resolved. That means, that 20% remains in the SGS part which cannot be ignored!

Especially around y+=11 the sgs energy rises, in my case to nearly 50% of the resolved kinetic energy.

Just my thoughts. Any suggestions?
HanSolo123 is offline   Reply With Quote

Old   December 23, 2014, 19:57
Default
  #11
Member
 
Join Date: Feb 2014
Posts: 30
Rep Power: 3
Uyan is on a distinguished road
Hi All,

I am also in this problem of calculating Ksgs and Kres. But i am unable to get K field as an output from Smagorinsky Model. Could anyone help me out there??

I agree with HanSolo.

I think that instantaneous Ktotal = 1/2(u^2 v^2 w^2) , and Ksgs is calculated from the LES model. Kres = Ktotal - Ksgs.

Last edited by Uyan; January 13, 2015 at 16:01.
Uyan is offline   Reply With Quote

Old   December 25, 2014, 10:12
Default
  #12
New Member
 
Hans Barósz
Join Date: May 2014
Posts: 18
Rep Power: 3
HanSolo123 is on a distinguished road
Quote:
Originally Posted by Uyan View Post
Hi All,

I am also in this problem of calculating Ksgs and Kres. But i am unable to get K field as an output from Smagorinsky Model. Could anyone help me out there??
You have to modify your solver to get k_sgs. k_sgs is just calculated temporarily inside the Smagorinsky model and then disappears after each timestep because the closure problem was solved.

To do so, create a new field in createFields.H, for example:

Code:
volScalarField ksgs_
(
    IOobject
    (
        "ksgs",
        runTime.timeName(),
        mesh,
        IOobject::NO_READ,
        IOobject::AUTO_WRITE
    ),
    mesh,
    dimensionedScalar("ksgs", dimVelocity*dimVelocity, 0.0)
);
Then in your solver, for example pimpleFoam, you have to write out the modeled k (=k_sgs) before the runtime-command. So in pimpleFoam.C it should be:

Code:
while (runTime.run())
    {
        #include "readTimeControls.H"
        #include "CourantNo.H"
        #include "setDeltaT.H"

        runTime++;

        Info<< "Time = " << runTime.timeName() << nl << endl;

        // --- Pressure-velocity PIMPLE corrector loop
        while (pimple.loop())
        {
            #include "UEqn.H"

            // --- Pressure corrector loop
            while (pimple.correct())
            {
                #include "pEqn.H"
            }

            if (pimple.turbCorr())
            {
                turbulence->correct();
            }
        }

        ksgs_ = turbulence->k();
        runTime.write();

        Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
            << "  ClockTime = " << runTime.elapsedClockTime() << " s"
            << nl << endl;
    }
This way, the solver creates a new field called ksgs each time step, which contains the subgridscale energy from your turbulence model. (I've just worked with pimpleFoam+Smagorinsky/oneEq so not sure about other combinations).
With that new field, you can and of course have to average to get proper results. So in your /systems/controlDict inside the functions>fieldAverage use
Code:
ksgs
            {
            mean      on;
            prime2Mean  off;
            base        time;
          }
This will average your subgridscale energy. For easy postprocessing and if you do the channelflow, I recommend you to modify the postChannel utility, so it will output your k_sgs over y (wallnormal distance).

I got very good results with this procedure. Dont forget to rename your utilities!
cfdonline2mohsen, ezekiel and Uyan like this.
HanSolo123 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
outputTime in Swak function immortality OpenFOAM Post-Processing 8 June 28, 2015 16:25
y+ and u+ values with low-Re RANS turbulence models: utility + testcase florian_krause OpenFOAM 108 June 9, 2015 08:13
Utilities: post average turbulence fields and create turbulence fields for LES Hanzo OpenFOAM Running, Solving & CFD 3 November 26, 2014 17:14
RNG diverged during the analysis the flow over a multi element airfoil, why? s.m OpenFOAM Running, Solving & CFD 0 August 5, 2013 08:39
average weighted area of volume fraction at output umar959 Main CFD Forum 0 January 20, 2012 03:47


All times are GMT -4. The time now is 03:47.