CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Running, Solving & CFD (
-   -   Define non uniform TKE boundary condition in simpleFOAM (

qtian July 26, 2007 18:34

Dear all, I am trying to mo
Dear all,

I am trying to modify the inlet boundary condition for simpleFoam. I have no problem to add non uniform velocities. I also want to add non uniform tke also. For some reason, I keep getting this error message when I compile my code.

bump1BC.C:63: error: 'k' was not declared in this scope

line 63: fvPatchScalarField& inletK = k.boundaryField()[inletPatchID];

Is this because I miss some head file? I am new to C++ and OpenFoam, please give me some help. Thanks.


qtian July 27, 2007 11:37

Is there nobody who is able or
Is there nobody who is able or want to answer my question? I am really stuck here. Please give me some suggestions.

alberto July 27, 2007 11:54

No, you didn't miss any header
No, you didn't miss any header file. The k field is defined inside the turbulence model class, so you can't access to it in that way.

Do you need to specify a profile for k with a knows mathematical expression? If so, I did something like that for my work starting from the parabolic velocity profile provided by Hrvoje and adapting it to scalar fields.

If you're interested, I can provide the source to you.


qtian July 27, 2007 12:43

Alberto, Thank you very muc

Thank you very much for your information. As you know, I am really a newbie to OpenFoam. I tried to search for answers in the message board and sometime like this have no success. Answers from experts like you really mean a ton to us and save us time and energy.

Of course, I am very interested in your code. At least I can have something working to start with. Please send me your source. I really appreciate your help and sharing your information with me.


alberto July 27, 2007 13:03

If you can share the profile y
If you can share the profile you need to implement, I can adapt the code.


qtian July 27, 2007 14:36

Dear Alberto, Here is a pr
Dear Alberto,

Here is a profile for U, k and epsilon with the interploated mathematical expression based on experimental data. Thanks for your help.

y=[0.133 100]


U = 0.0174*y1.^6-0.5742*y1.^5-0.3304*y1.^4+4.0521*y1.^3-1.8319*y1.^2+4.8145*y1+14.91 62;

K = 0.3918*y1.^6-0.0334*y1.^5-3.0332*y1.^4+2.5104*y1.^3+0.9672*y1.^2-2.0524*y1+4.861 2;

epsilon = 529.7*y1.^6-657.7*y1.^5-4164*y1.^4+8177.8*y1.^3-793.4*y1.^2-5507.8*y1+2714.1;

qtian July 27, 2007 16:35

Dear all Will funkySetFields
Dear all
Will funkySetFields do the job for me, if I have a formula for velocity and tke? I saw several cases for initial conditions, not sure that it will work for patches. Thanks.


alberto July 28, 2007 13:00

Hi Quinn, sorry yesterday I wa
Hi Quinn, sorry yesterday I was busy. I'm adapting the code for you right now.

Do you need "symmetric" profiles or do you use axial symmetry conditions?


qtian July 30, 2007 09:59

Alberto, Sorry that I missed
Sorry that I missed your message. After reading your suggestion last Friday, I did a few search for parabolic velocity profile and found out that funkySetFields did the exact same things you mentioned.

I used matlab curve fittling tool box to get the formular and have defined my non uniform inlet boundary with funkySetFields. Thanks for your suggestion and help. By the way, may I ask you one more question, why I can not use pow(pos().y,-1.29)in the formular?



alberto July 30, 2007 14:54

Hi Quinn, what error do you g
Hi Quinn,
what error do you get? In your post in the funkySetField thread, it seems you have a segmentation fault error (sigfpe), so y is zero somewhere.


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