CFD Online Discussion Forums

CFD Online Discussion Forums (
-   FLUENT (
-   -   UDF compile HELP!! (

Leigh July 18, 2006 04:05

UDF compile HELP!!
Hello all,

I am new to the world of compiling. I have to create a dynamic mesh to model a vibrating wall and need help in compiling the UDF. I have the UDF as follows;

#include "udf.h"

DEFINE_CG_MOTION(wave, dt, vel, omega, time, dtime) { vel[0]=0.001*sin(1099557.429*time); }

This works fine as far as im aware. My problem is that I do not know how to turn this into a compiled function so I can load it in Fluent. My knowledge of c++ is limited at best.

Any help would be much appreciated. Leigh

PAD July 18, 2006 07:51

Re: UDF compile HELP!!
If you have a C compiler installed it should be fairly easy. In Fluent just goto Define | User-defined | Functions... | Compiled... - select your c-files and compile...

Afterwards click load to load the udf library

Leigh July 18, 2006 08:02

Re: UDF compile HELP!!
Hello, thanks for your reply.

It is the selection of the c-files that confuses me. I have my UDF defining the motion as shown in my previous post but I dont know what other c files I need.


Fabrice July 18, 2006 08:38

Re: UDF compile HELP!!

You don't need any other C files, just write your UDF with a text editor and name it with the extension .c (for example "my_function.c").

Be aware to have your UDF in the same directory than your case and data file otherwise you will get an error message.

PAD's reply is quite correct about how to compile a UDF. For this purpose you need a C compiler such as Microsoft Visual C++.


Leigh July 18, 2006 08:49

Re: UDF compile HELP!!

Your advice is very helpful, I have Microsoft Visual C++, and I have tried to use the compile function in it without luck. It comes up with the error message

"Cannot open include file: 'udf.h': No such file or directory Error executing cl.exe."

I have also tried to load the udf in fluent then clicked build, i then get the error;

'nmake' is not recognized as an internal or external command, operable program or batch file.

Thanks for your help, Leigh

PAD July 18, 2006 08:58

Re: UDF compile HELP!!
Regarding "Cannot open include file...". Check that you have set the environment variables in Fluent using setenv.exe from folder \ntbin\ntx86.

'nmake' error is most likely also caused by missing environment variables. Fluent does not know where to find the exe-file if the variables are not set properly.

Hope this helps!

Regards, PAD

Leigh July 18, 2006 09:07

Re: UDF compile HELP!!
I think im getting there with your help!

I tried using setenv.exe and followed the modification successfuly although it has not changed the outcome from both error messages.


PAD July 18, 2006 12:40

Re: UDF compile HELP!!
The error containing cl.exe is related to the C compiler settings. Check your system environment variables for the correct settings with regards to the C compiler.

If the environment is correct setup you should be able to check it by typing nmake in a command prompt. This should run no matter which folder you are located in...

Hope this helps - otherwise I will check my PC tomorrow with regards to the different settings.

PAD July 18, 2006 12:43

Re: UDF compile HELP!!
Just a note:

As I read you post you have been trying to compile your code from C++ development environment. I don't think you can compile your UDFs from there - this has to be done in Fluent due to the relation with udf.h etc. Fluent knows the location of these files whereas MS C++ does not.

If I'm wrong please correct me anyone.

jasond July 18, 2006 15:14

Re: UDF compile HELP!!
The nmake error probably comes from command line compiler (and tools) installation. There are some workarounds, but your best bet is to check that the command line stuff was fully set up when VC++ was installed.


Albert Franco July 19, 2006 02:08

Re: UDF compile HELP!!
I have the same problem as you, I downloaded dev c++ but it continues like before. I'll try using UNIX, I've heard it has a C complier installed by default.

Leigh July 19, 2006 03:23

Re: UDF compile HELP!!
Thanks for all of your replies, I will check with the person who deals with the fluent and VC++ software at my uni to see how he/she installed it.

Cheers, Leigh

Albert Franco July 19, 2006 08:03

Re: UDF compile HELP!! *NM*

Albert Franco July 19, 2006 08:06

Re: UDF compile HELP!!
Ok, If you get the answer to your problem I would apreciate if you can post it here, I'm in the same situation as you, now I've tried with unix system but it continues without compiling the udf's.


jasond July 19, 2006 08:48

Re: UDF compile HELP!!
Has anyone asked Fluent (officially) if the free version of VC++ works with Fluent? I have read in this forum that it does, but I am not sure I have seen "proof". If it did, that would be great.

A prediction: the only way to get it working correctly is a reinstallation of VC++.


P.S. Even on Unix machines, if the setup is not done properly Fluent will not be able to find the C compiler.

PAD July 19, 2006 09:01

Re: UDF compile HELP!!
I have asked Fluent support regarding MS C++ Express Edition and it should work flawlessly. I'm using it myself without problems at least :)

Leigh August 2, 2006 07:40

Re: UDF compile HELP!!

I finally got the UDF in compile. I contacted my local computer servicing guy at the uni, and he was able to globalise a couple of files so that fluent could find them. Firstly the nmake.exe file which was located in Visual basic somewhere (just search) and then we got another error as it could not find another file, I cant remember its exact name but its a .dll file found in Fluent, and anyway when you try to compile it the error will say. Once these two were made globaly available it worked! I guess if you have acsess to your system environment settings you could do this yourself, but I did not have the access. Hope this helps, and thanks for the help everyone.


prasad August 22, 2006 13:17

Re: UDF compile HELP!!
Hi, when i try to compile a udf by calling nmake , fluent says the compiler cant parse. can you help me with this? thanks prasad

Albert F. August 23, 2006 02:42

Re: UDF compile HELP!!
Look at the post error while compiling udf. I don't know if it is what is happening to you but I explained how I solved the problems compiling the udf and one problem was that nmake mas not recognised.

Hope it helps.


kk August 27, 2006 23:03

Re: UDF compile HELP!!
If you are using windows version, check the path under DOS command window by typing 'path'. You have to set the path for FLUENT to locate the nmake.

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