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

Progamming issue: how do i get acces to the actual values of k-epsilon?

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 7, 2010, 13:18
Exclamation Progamming issue: how do i get acces to the actual values of k-epsilon?
  #1
Member
 
Sabin Ceuca
Join Date: Mar 2010
Location: Munich
Posts: 42
Rep Power: 16
sabin.ceuca is on a distinguished road
Hi,
after some struggling with the setup of OpenFOAM simulations, I have now started to write my own models. My first difficulties arose when i wanted to get access to the desired variables. What I actualy mean is lets take for example the density or the specific heat capacity which can be called using "twoPhaseProperties.variableName". Now I would like to have access to the actual values of for instance k-epsilon variables, but I would like to understand how do I generally find out where certain variables are computed and how to access them?
Greetings
Sabin
sabin.ceuca is offline   Reply With Quote

Old   July 8, 2010, 04:18
Default
  #2
Senior Member
 
Kathrin Kissling
Join Date: Mar 2009
Location: Besigheim, Germany
Posts: 134
Rep Power: 17
kathrin_kissling is on a distinguished road
Hello Sabin,

could you tell me which solver and which version you're using?
In your solver (interFoam.C) which might be for example rasInterFoam (older version) or now interFoam (actual version) you will find a line

turbulence->correct();
which will actually call the turbulence model.
the object turbulence is assigned in the createFields.H file in

00095 // Construct incompressible turbulence model
00096 autoPtr<incompressible::turbulenceModel> turbulence
00097 (
00098 incompressible::turbulenceModel::New(U, phi, twoPhaseProperties)
00099 );


There you can see where it comes from. It is an incompressible turbulenceModel, so you have to search in src/turbulenceModel/incompressible/turbulenceModel
or
src/turbulenceModel/RAS/incompressible/RASModel, depending on the version you're using.
.
There you will find the files turbulenceModel.C turbulenceModel.H and newTurbulenceModel.C
respectively RASModel.C RASModel.H and newRASModel.C
Here you will find the reading from your turbulence dictionary and the setting of the turbulence model.
From now on it depends which model you are using. If you give me more information I can try to help you figuring it out.

Best

Kathrin

Last edited by kathrin_kissling; July 8, 2010 at 07:25.
kathrin_kissling is offline   Reply With Quote

Old   July 8, 2010, 07:12
Default
  #3
Member
 
Sabin Ceuca
Join Date: Mar 2010
Location: Munich
Posts: 42
Rep Power: 16
sabin.ceuca is on a distinguished road
Morning Kathrin,
thanks for the answer

Sorry that I forgot to mention which solver I am using (it's interFoam from OF 1.6) . By looking into this http://foam.sourceforge.net/doc/Doxygen/html/incompressible_2turbulenceModel_2turbulenceModel_8 H_source.html I would understand that if I need the turbulence kinetic energy (k) I should be able to call it by volScalarField turbKinEnergy = turbulence.k(); , because the turbulence kinetic energy is defined in the file turbulenceModel.H as:
virtual tmp<volScalarField>k() const = 0; But it's not working.. During the compilation I get the error ‘class Foam::autoPtr<Foam::incompressible::turbulenceMode l>’ has no member named ‘k’
Do you have an idea how I can access this variable?

Greetings
Sabin
sabin.ceuca is offline   Reply With Quote

Old   July 8, 2010, 07:39
Default
  #4
Member
 
Robertas N.
Join Date: Mar 2009
Location: Kaunas, Lithuania
Posts: 53
Rep Power: 17
r08n is on a distinguished road
Quote:
Originally Posted by sabin.ceuca View Post
I would understand that if I need the turbulence kinetic energy (k) I should be able to call it by [COLOR=royalblue]volScalarField turbKinEnergy = turbulence.k();
volScalarField turbKinEnergy = turbulence().k();

('turbulence' with parentheses).
r08n is offline   Reply With Quote

Old   July 8, 2010, 08:00
Thumbs up
  #5
Member
 
Sabin Ceuca
Join Date: Mar 2010
Location: Munich
Posts: 42
Rep Power: 16
sabin.ceuca is on a distinguished road
Thanks r08n and Kathrin for helping me out, within such a short time.
sabin.ceuca is offline   Reply With Quote

Old   August 29, 2012, 15:41
Default Could you please explain wht this works?
  #6
New Member
 
xinyu
Join Date: Apr 2010
Location: Connecticut
Posts: 9
Blog Entries: 1
Rep Power: 15
xinyu is on a distinguished road
Quote:
Originally Posted by r08n View Post
volScalarField turbKinEnergy = turbulence().k();

('turbulence' with parentheses).
I recently encountered the same problem and solved using this thread. Could you kindly explain why we need to add parentheses here? Is this something to do with the tmp type defined in the turbulence library?

Thanks a lot,

Xinyu
xinyu is offline   Reply With Quote

Old   March 14, 2013, 04:29
Default
  #7
Senior Member
 
sfigato's Avatar
 
Marco Longhitano
Join Date: Jan 2013
Location: Aachen
Posts: 103
Rep Power: 13
sfigato is on a distinguished road
Send a message via Skype™ to sfigato
Dear Foamers,

I recently encountered the same problem regarding the access to the turbulence kinetic energy! By follwing the advice of this thread

Quote:
volScalarField turbKinEnergy = turbulence().k();

('turbulence' with parentheses).
I added:
Quote:
.....

// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //

Foam:haseChangeTwoPhaseMixtures::SchnerrSauer::S chnerrSauer
(
const volVectorField& U,
const surfaceScalarField& phi,
const volScalarField& turbKinEnergy = turbulence().k(),
const word& alpha1Name
)

....
and I got this compiling error:

Quote:
....
phaseChangeTwoPhaseMixtures/SchnerrSauer/SchnerrSauer.C:54:54: error: ‘turbulence’ was not declared in this scope
phaseChangeTwoPhaseMixtures/SchnerrSauer/SchnerrSauer.C:50:1: error: prototype for ‘Foam:haseChangeTwoPhaseMixtures::SchnerrSauer:: SchnerrSauer(const volVectorField&, const surfaceScalarField&, const volScalarField&, const Foam::word&)’ does not match any in class ‘Foam:haseChangeTwoPhaseMixtures::SchnerrSauer’
In file included from phaseChangeTwoPhaseMixtures/SchnerrSauer/SchnerrSauer.C:26:0:
phaseChangeTwoPhaseMixtures/SchnerrSauer/SchnerrSauer.H:61:7: error: candidates are: Foam:haseChangeTwoPhaseMixtures::SchnerrSauer::S chnerrSauer(const Foam:haseChangeTwoPhaseMixtures::SchnerrSauer&)
phaseChangeTwoPhaseMixtures/SchnerrSauer/SchnerrSauer.H:101:9: error: Foam:haseChangeTwoPhaseMixtures::SchnerrSauer::S chnerrSauer(const volVectorField&, const surfaceScalarField&, const Foam::word&)
make: *** [Make/linux64GccDPOpt/SchnerrSauer.o] Fehler 1

Can anyone help me!?

Regards
Marco
sfigato is offline   Reply With Quote

Old   March 20, 2013, 21:50
Default
  #8
Senior Member
 
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 621
Rep Power: 0
chegdan will become famous soon enoughchegdan will become famous soon enough
Marco,

This is because you can't define a initialize a parameter in the constructor in the manner you are attempting.

Code:
const volScalarField& turbKinEnergy = turbulence().k(),
wont work. instead try just

Code:
const volScalarField& turbKinEnergy,
and when you initialize your constructor...make sure to pass the right argument i.e. the TKE.
chegdan is offline   Reply With Quote

Old   March 21, 2013, 02:18
Default
  #9
Senior Member
 
sfigato's Avatar
 
Marco Longhitano
Join Date: Jan 2013
Location: Aachen
Posts: 103
Rep Power: 13
sfigato is on a distinguished road
Send a message via Skype™ to sfigato
Hi Daniel,

First I thanks you for your reply!

I am dealing with another problem! I implement a homogenoeus multiphase problem using pimple loop! I add a new transport scalar equation with variable density and I want to update my density after tha computing of the scalar quantity!

Here is the code :

Quote:
// Solve Mass Fraction Equation for the Vapour
{

//Mass Fraction of Vapour and Air
Info<< "Calculating field fv\n" << endl;
volScalarField fv
(
IOobject
(
"fv",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
rho2*alpha2/rho
);

Info<< "Calculating field fg\n" << endl;
volScalarField fg
(
IOobject
(
"fg",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
rho3*alpha3/rho
);

//Turbulence Saturation Pressure
Info<< "Calculating field pV\n" << endl;
volScalarField pV
(
IOobject
(
"pV",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
(scalar(0.39)*rho1*turbulence->k()) + pSat
);


//Scalar Transport Equation for Mass Fraction
fvScalarMatrix fvEqn
(
fvm::ddt(rho, fv)
+ fvm::div(rhoPhi /*phi*/, fv)
- fvm::laplacian(Gammaf,fv)
==
- fvm::Sp(Ce*rho1*rho2*sqrt(2*(p-pV)/3/rho1)*sqrt(turbulence->k()/sigma),fv)
- fvm::Sp(Cc*rho1*rho1*sqrt(2*(p-pV)/3/rho1)*sqrt(turbulence->k()/sigma),fv)

);

fvEqn.relax();
solve( fvEqn == Ce*rho1*rho2*sqrt(2*(p-pV)/3/rho1)*sqrt(turbulence->k()/sigma)*(1-fg));


//Update of All Phases Coeffcients
rho == scalar(1)/((fv/rho2)+(fg/rho1)+((scalar(1)-fv-fg)/rho1));
alpha2 == fv*(rho/rho3);
alpha3 == fg*(rho/rho2);
alpha1 == (1- alpha2 -alpha3);
//rhoPhi == rho*phi;

}
In order to updatw my volum fraction coeffcients and the density, are the bold lines enough?

Moreover, what about the rhoPhi variable?
Here is the whole solver!

Thanks

Regards
Marco
Attached Files
File Type: gz ifasFCM.tar.gz (7.3 KB, 11 views)
sfigato is offline   Reply With Quote

Reply

Tags
programming

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
SimpleFoam k and epsilon bounded nedved OpenFOAM Running, Solving & CFD 16 March 4, 2017 09:30
k and epsilon Values for High Pressure Water nikhiljain.iitk FLUENT 0 March 12, 2010 07:06
SimpleFoam k and epsilon bounded nedved OpenFOAM Running, Solving & CFD 1 November 25, 2008 21:21
Modify, G_k,k and epsilon values on wall functions Javier Larrondo FLUENT 0 September 15, 2008 22:34
Values of k & epsilon in the moving wall ghlee Main CFD Forum 1 August 16, 1999 13:42


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