|
[Sponsors] |
May 18, 2015, 08:49 |
How to calculate tke?
|
#1 |
Member
Lourenço SM
Join Date: Jul 2014
Location: Lisboa, Portugal
Posts: 40
Rep Power: 11 |
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; ^ |
|
May 18, 2015, 09:44 |
|
#2 | |
Senior Member
Join Date: Sep 2010
Posts: 226
Rep Power: 16 |
Hi lourencosm,
You should do: scalarField Tke (rho*mesh.V().field()*k.value()); Best Regards, GoodLuck ! T.D. Quote:
|
||
May 18, 2015, 10:06 |
|
#3 |
Member
Lourenço SM
Join Date: Jul 2014
Location: Lisboa, Portugal
Posts: 40
Rep Power: 11 |
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; ^ |
|
May 18, 2015, 10:45 |
|
#4 |
Senior Member
|
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. |
|
May 18, 2015, 10:56 |
|
#5 |
Member
Lourenço SM
Join Date: Jul 2014
Location: Lisboa, Portugal
Posts: 40
Rep Power: 11 |
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; |
|
May 18, 2015, 11:12 |
|
#6 |
Senior Member
|
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())); |
|
May 18, 2015, 11:49 |
|
#7 |
Member
Lourenço SM
Join Date: Jul 2014
Location: Lisboa, Portugal
Posts: 40
Rep Power: 11 |
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; |
|
|
|
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 |