CFD Online Discussion Forums

CFD Online Discussion Forums (
-   Fluent UDF and Scheme Programming (
-   -   UDF for a velocity profile: some errors/doubts (

HHOS September 13, 2013 04:59

UDF for a velocity profile: some errors/doubts

I am running a case in fluent with a UDF defining the Velocity_inlet profile and I have some problems with it.

First of all, it took me some time to compile the C file in W7-64bits, but thanks to this forum I managed to do it :)

I am able to run the case and I even get good results, but if I save case and data, close Fluent and open it again to continue with the same case, it gives me the error:

Divergence detected in AMG solver. Error object: #f
I have checked the forums and change the solution methods to the simplest ones, but I get a similar error like:

Divergence detected in AMG x-momentum.
So I wonder if the problem is related to the .c file. I have no idea about programming, but when I saw that I achieved the velocity profile, I let it be as it was.


UDF for specifying steady-state velocity profile boundary condition
#include "udf.h"
DEFINE_PROFILE(wind_velocity_inlet, thread, position)
face_t f;
real x[ND_ND];
real z;

F_PROFILE(f, thread, position) = 5*log(z/0.2)/log(50);
end_f_loop(f, thread)

I read that when I hook the profile to Fluent and save the case, it keep the information about it; but I am not so sure about it because I tried to read another mesh in a loaded case and it didn't work.

Should I always keep the folder "libudf" that is created next to the case file when I compile the velocity_profile or I can embed it somehow in the case file??

I am really confused about the way the UDFs work... So, any help would be great!

Thank you very much!

kornetka September 16, 2013 17:39

From my (very little) experience with Fluent and UDF:
Doubt no 2: I did replaced meshes in a case with hooked functions and it all went smoothly - all hooks were saved. I have no idea why it doesn't work for you, but I didn't have any similar problem.
Doubt no 3: As far as I'm concerned you have to keep whole libudf. It has to be compiled and present for every calculations you are performing.
Doubt no 1: Absolutely no reasonable idea what is happening. Since nobody has responded yet I'll try to write some ideas, but don't rely on them too much. 1. Wild guess: Are the results from reloaded case identical to the results you saved? 2. As far as I'm concerned you can also try lowering Under-relaxation factors for momentum (Solution/Solution Controls).

HHOS September 19, 2013 07:07

Hey Kornetka;

Thank you for the reply.

Trying different things I have realized that the UDF libraries make trouble if I create them in a parallel case and load the case later in serial (or in the other way around)...

So, what I do always now if I need to use a UDF function, is to run always in parallel, even if I choose just one core.

All times are GMT -4. The time now is 09:56.