CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

How to calculate tke?

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 18, 2015, 08:49
Default How to calculate tke?
  #1
Member
 
Lourenço SM
Join Date: Jul 2014
Location: Lisboa, Portugal
Posts: 40
Rep Power: 11
lourencosm is on a distinguished road
Hello,

I'm trying to calculate the tke in interfoam but I can't call k.
This file goes next to the Courant calculation in the solver structure.
Can anybody help me to call k? Thank you.

This is the code:
Code:
scalar TkeSum = 0.0;

if (mesh.nInternalFaces())
{
    scalarField Tke (rho*mesh.V().field()*k);
    TkeSum = gSum(Tke);
}

Info<< "All phases tke: " << TkeSum << endl;
Info<< "tke units: kg*m^2/s^2" << endl;
Info<< "  " << endl;

I get this error:
Code:
allTke.H: In function ‘int main(int, char**)’:
allTke.H:39:43: error: ‘k’ was not declared in this scope
     scalarField Tke (rho*mesh.V().field()*k);
                                           ^
allTke.H:39:43: note: suggested alternative:
In file included from /opt/OpenFOAM/OpenFOAM-2.2.2/src/OpenFOAM/lnInclude/constants.H:46:0,
                 from /opt/OpenFOAM/OpenFOAM-2.2.2/src/finiteVolume/lnInclude/fvCFD.H:17,
                 from ihFoamLSM.C:69:
/opt/OpenFOAM/OpenFOAM-2.2.2/src/OpenFOAM/lnInclude/fundamentalConstants.H:79:36: note:   ‘Foam::constant::physicoChemical::k’
     extern const dimensionedScalar k;
                                    ^
lourencosm is offline   Reply With Quote

Old   May 18, 2015, 09:44
Smile
  #2
Senior Member
 
Join Date: Sep 2010
Posts: 226
Rep Power: 16
T.D. is on a distinguished road
Hi lourencosm,

You should do: scalarField Tke (rho*mesh.V().field()*k.value());


Best Regards,

GoodLuck !

T.D.

Quote:
Originally Posted by lourencosm View Post
Hello,

I'm trying to calculate the tke in interfoam but I can't call k.
This file goes next to the Courant calculation in the solver structure.
Can anybody help me to call k? Thank you.

This is the code:
Code:
scalar TkeSum = 0.0;

if (mesh.nInternalFaces())
{
    scalarField Tke (rho*mesh.V().field()*k);
    TkeSum = gSum(Tke);
}

Info<< "All phases tke: " << TkeSum << endl;
Info<< "tke units: kg*m^2/s^2" << endl;
Info<< "  " << endl;
I get this error:
Code:
allTke.H: In function ‘int main(int, char**)’:
allTke.H:39:43: error: ‘k’ was not declared in this scope
     scalarField Tke (rho*mesh.V().field()*k);
                                           ^
allTke.H:39:43: note: suggested alternative:
In file included from /opt/OpenFOAM/OpenFOAM-2.2.2/src/OpenFOAM/lnInclude/constants.H:46:0,
                 from /opt/OpenFOAM/OpenFOAM-2.2.2/src/finiteVolume/lnInclude/fvCFD.H:17,
                 from ihFoamLSM.C:69:
/opt/OpenFOAM/OpenFOAM-2.2.2/src/OpenFOAM/lnInclude/fundamentalConstants.H:79:36: note:   ‘Foam::constant::physicoChemical::k’
     extern const dimensionedScalar k;
                                    ^
T.D. is offline   Reply With Quote

Old   May 18, 2015, 10:06
Default
  #3
Member
 
Lourenço SM
Join Date: Jul 2014
Location: Lisboa, Portugal
Posts: 40
Rep Power: 11
lourencosm is on a distinguished road
Thank you T.B. but it still no working.

(k is meant to be from the k-epsilon turbulent model)
Now I get this error:
Code:
allTke.H: In function ‘int main(int, char**)’:
allTke.H:40:43: error: ‘k’ was not declared in this scope
     scalarField Tke (rho*mesh.V().field()*k.value());
                                           ^
allTke.H:40:43: note: suggested alternative:
In file included from /opt/OpenFOAM/OpenFOAM-2.2.2/src/OpenFOAM/lnInclude/constants.H:46:0,
                 from /opt/OpenFOAM/OpenFOAM-2.2.2/src/finiteVolume/lnInclude/fvCFD.H:17,
                 from ihFoamLSM.C:69:
/opt/OpenFOAM/OpenFOAM-2.2.2/src/OpenFOAM/lnInclude/fundamentalConstants.H:79:36: note:   ‘Foam::constant::physicoChemical::k’
     extern const dimensionedScalar k;
                                    ^
Thank you.
lourencosm is offline   Reply With Quote

Old   May 18, 2015, 10:45
Default
  #4
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

@lourencosm

Where do you try to add this code? Inside the solver, inside the turbulence model, somewhere else?

Compiler tried to do its best to guess what you are trying to say, but was not successful as he suggested you Boltzmann constant instead of kinetic turbulent energy.
alexeym is offline   Reply With Quote

Old   May 18, 2015, 10:56
Default
  #5
Member
 
Lourenço SM
Join Date: Jul 2014
Location: Lisboa, Portugal
Posts: 40
Rep Power: 11
lourencosm is on a distinguished road
In the interfoam.C file, therefore the solver main file.

Code:
int main(int argc, char *argv[])
{
    #include "setRootCase.H"
    #include "createTime.H"
    #include "createMesh.H"

    pimpleControl pimple(mesh);

    #include "initContinuityErrs.H"
    #include "createFields.H"
    #include "readTimeControls.H"
    #include "correctPhi.H"
    #include "CourantNo.H"
    #include "setInitialDeltaT.H"


    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

    Info<< "\nStarting time loop\n" << endl;

    while (runTime.run())
    {
        #include "readTimeControls.H"
        #include "CourantNo.H"
        #include "alphaCourantNo.H"
        #include "allTke.H"                            //-------------------here!!
        #include "setDeltaT.H"

        runTime++;

        Info<< "Time = " << runTime.timeName() << nl << endl;
lourencosm is offline   Reply With Quote

Old   May 18, 2015, 11:12
Default
  #6
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

In this case you have turbulence variable of type autoPtr<incompressible::turbulenceModel> turbulence, which is created in createFields.H file. incompressible::turbulenceModel class has k method which returns TKE.

So finally your code should be something like:

Code:
dimensionedScalar totalTKE(fvc::domainIntegrate(rho*turbulence->k()));
alexeym is offline   Reply With Quote

Old   May 18, 2015, 11:49
Default
  #7
Member
 
Lourenço SM
Join Date: Jul 2014
Location: Lisboa, Portugal
Posts: 40
Rep Power: 11
lourencosm is on a distinguished road
Thank you very much alexeym!

I was driving nuts!
I had already tried RASModel->k() and turbulenceModel->k() with no result. Thank you.

I ended up by using this function because I need the air, water and interface values as well:
Code:
scalar waterTkeSum = 0.0;
scalar airTkeSum = 0.0;
scalar interfaceTkeSum = 0.0;
scalar TkeSum = 0.0;

if (mesh.nInternalFaces())
{
    scalarField Tke(rho*turbulence->k());

    scalarField water (neg(0.99 - alpha1));
    scalarField waterTke(water*Tke);

    scalarField air (neg(alpha1 - 0.01));
    scalarField airTke (air*Tke);

    scalarField interface (pos(alpha1 - 0.01)*pos(0.99 - alpha1));
    scalarField interfaceTke (interface*Tke);

    waterTkeSum = gSum(waterTke);
    airTkeSum = gSum(airTke);
    interfaceTkeSum = gSum(interfaceTke);
    TkeSum = gSum(Tke);
}

Info<< "All phases tke: " << TkeSum << endl;
Info<< "Water tke : " << waterTkeSum << endl;
Info<< "Air tke : " << airTkeSum << endl;
Info<< "Interface tke : " << interfaceTkeSum << endl;
Info<< "tke units: kg*m^2/s^2" << endl;
Info<< "  " << endl;
lourencosm is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tke and Tdr goes sky high? Here is a differnt view to it. feafan STAR-CCM+ 3 July 23, 2014 01:15
Tke pike rg12g09 STAR-CCM+ 0 December 6, 2011 09:51
How to calculation TKE in LES lizzy0zhou Main CFD Forum 4 February 11, 2011 13:05
calculate values for eps and k from Re or u????? sbar OpenFOAM Pre-Processing 5 August 16, 2010 04:10
How CFX calculate TKE and Epsilon from intensity? David CFX 0 November 24, 2005 04:53


All times are GMT -4. The time now is 13:58.