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

How to calculate tke?

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

Reply
 
LinkBack Thread Tools Display Modes
Old   May 18, 2015, 08:49
Default How to calculate tke?
  #1
New Member
 
Lourenço SM
Join Date: Jul 2014
Location: Lisboa, Portugal
Posts: 16
Rep Power: 2
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
Location: France
Posts: 184
Rep Power: 6
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
New Member
 
Lourenço SM
Join Date: Jul 2014
Location: Lisboa, Portugal
Posts: 16
Rep Power: 2
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,088
Rep Power: 19
alexeym will become famous soon enoughalexeym will become famous soon enough
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
New Member
 
Lourenço SM
Join Date: Jul 2014
Location: Lisboa, Portugal
Posts: 16
Rep Power: 2
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,088
Rep Power: 19
alexeym will become famous soon enoughalexeym will become famous soon enough
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
New Member
 
Lourenço SM
Join Date: Jul 2014
Location: Lisboa, Portugal
Posts: 16
Rep Power: 2
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
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
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 10:51
How to calculation TKE in LES lizzy0zhou Main CFD Forum 4 February 11, 2011 14: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 05:53


All times are GMT -4. The time now is 02:55.