Access to turbulence values in my own solver
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 |
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 |
2 Attachment(s)
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 |
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"); |
Thanks for the quick reply!
I add the line in this way: Quote:
Quote:
Regards Marco |
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?
|
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 |
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.
|
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 |
Quote:
Code:
95 k_ 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 Code:
FoamFile This all is by the way relatively straightforward C++. I encourage you to learn the C++ (until you understand classes and pointers) |
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! |
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. |
All times are GMT -4. The time now is 11:55. |