|
[Sponsors] |
March 14, 2013, 05:19 |
Access to turbulence values in my own solver
|
#1 |
Senior Member
|
Dear Foamers,
I am building my own OpenFOAM solver by modifing the interPhaseChangeFoam. I want to add a new model. I want to get acces to the value of turbulence kinetic energy inside that model. In order to fix this issue, I have tried to follow many threads as: http://www.cfd-online.com/Forums/ope...k-epsilon.html http://www.cfd-online.com/Forums/ope...-low-re-3.html Nevertheless, noone of them helped me to fix it! I would like to have access to the actual values of for instance k-omega SST variables, but I would like to understand how do I generally find out where certain variables are computed and how to access them? Can anyone explain me this issue? Regards Marco |
|
March 14, 2013, 05:49 |
|
#2 |
Senior Member
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 22 |
This link may be helpful:
http://openfoamwiki.net/index.php/Op...objectRegistry Also, I think this post covers your basic needs: http://www.cfd-online.com/Forums/ope...tml#post254591 |
|
March 14, 2013, 06:08 |
|
#3 | ||
Senior Member
|
Dear Bernhard,
I have already read these links! Since I am quite new with OpenFoam programming I could not fix my problem! I try to explain it in deepen it : I would like to use the value of turbulence kinetic energy in my model SchnerrSauer.C (interPhaseChangeFoam)..so I have tried to add to SchnerrSauer.C the following lines: Quote:
Quote:
Thanks in advance Regards Marco |
|||
March 14, 2013, 06:15 |
|
#4 |
Senior Member
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 22 |
First you get an error because of the return above the bold line.
Following the second link, I would guess that you can access k by: Code:
const volScalarFieldField& k = db().lookupObject<volScalarField>("k"); |
|
March 14, 2013, 06:22 |
|
#5 | ||
Senior Member
|
Thanks for the quick reply!
I add the line in this way: Quote:
Quote:
Regards Marco |
|||
March 14, 2013, 06:27 |
|
#6 |
Senior Member
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 22 |
Probably you need to include a few files in the header of your files. I am not exactly sure which, but maybe you can find it in a few examples?
|
|
March 14, 2013, 06:32 |
|
#7 |
Senior Member
|
Dear Bernhard,
sorry but I had a type mistake. It is working in your way! How can I be sure that this 'k' is the turbulence kinetic energy? The code compiles for another variable name too (for example if I reply 'k' with 'm') Regards Marco |
|
March 14, 2013, 06:36 |
|
#8 |
Senior Member
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 22 |
Try to run it with both variables names. Also, you can copy the contents to a new volScalarField and write it to disk, then compare.
|
|
March 14, 2013, 07:36 |
|
#9 |
Senior Member
|
I am pretty sure that turbulence kinetic energy is named by turbulence->k()...the question is How can I use it inside my model (which is used to get the source term in a n equation inside the solver)!
I obviously include #include "turbulenceModel.H". I am sorry again if i do not understand but I do not know so well C++! Greets Marco |
|
March 14, 2013, 07:58 |
|
#10 | |
Senior Member
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 22 |
Quote:
Code:
95 k_ 96 ( 97 IOobject 98 ( 99 "k", 100 runTime_.timeName(), 101 mesh_, 102 IOobject::NO_READ, 103 IOobject::AUTO_WRITE 104 ), 105 autoCreateK("k", mesh_) 106 ), turbulence->k() is just to call the member function k() of your object turbulence (which via an intelligent way is of the class kEpsilon). It does not do a lot more than returning this volScalarField. Code:
137 //- Return the turbulence kinetic energy 138 virtual tmp<volScalarField> k() const 139 { 140 return k_; 141 } Code:
FoamFile { version 2.0; format ascii; class volScalarField; location "0"; object k; } This all is by the way relatively straightforward C++. I encourage you to learn the C++ (until you understand classes and pointers) |
||
March 14, 2013, 08:18 |
|
#11 | ||
Senior Member
|
Dear Bernhard,
First of all, thanks for the reply. If I understand from your post the name 'k' refers to the turbulence kinetic energy. Moreover, the only way tu use it in my model is what you have adviced to me: Quote:
The last question and I promis that I do not disturb you anymore.. It is enough the line that I added to use the turbulence kinetic energy or I must modify somelse in side the ScnerrSauer.H file or inside the model itself? For example to use pressure value inside the model*1..it is by default: Quote:
I thank you for you kindness. Greets Marco *1 Maybe it si not true! |
|||
March 14, 2013, 08:21 |
|
#12 |
Senior Member
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 22 |
Yes, that is the only. You do not have an object turbulence inside the model. This is only constructed in the solver.
In the other case, a pointer to the pressurefield is passed to the model via constructor functions. If you want to change that, you also have to change the way that the constructor is called. In general, this is not what you want to do. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
thobois class engineTopoChangerMesh error | Peter_600 | OpenFOAM | 4 | August 2, 2014 10:52 |
Divergence problem | Smaras | FLUENT | 13 | February 21, 2013 06:03 |
ATTENTION! Reliability problems in CFX 5.7 | Joseph | CFX | 14 | April 20, 2010 16:45 |
CFX solver workspace properties: modify default values | zboud | CFX | 2 | March 8, 2010 09:10 |
Discussion: Reason of Turbulence!! | Wen Long | Main CFD Forum | 3 | May 15, 2009 10:52 |