CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM (http://www.cfd-online.com/Forums/fluent-udf/44201-attn-all-soluton-udf-compile-problem.html)

Rizwan March 21, 2007 22:53

ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM
 
Good Morning Dear All,

I am happy to put forward solution to resolve the difficulty to compile udf. As I myself have gone through it resolving for long time, I like to share the solution with u.

I request to put off all your defensive mechanisms from minds and hearts that dealing with udf's is a tough problem, infact they r easy and most helpful shoud we undrstand wat all udf's logic is about and how grid is represented in terms of co-ords and so on. the most basic and fundamental programming knowledge is desired but not essential to write udf.

First and foremost, this method is specifically applicable to the problem of getting any of the statements below wen u try to BUILD the udf and subsequently load it.

'CANT FIND NMAKE' , 'CHNG DIRC' (chdir "libudf")() (chdir "ntx86\\2ddp")() 'nmake' is not recognized as an internal or external command, operable program or batch file. 'nmake' is not recognized as an internal or external command, operable program or batch file.

I have come accross many proposals by my seniors and on forums and help files etc etc but none worked out to a general logical solution to the problem, for example the most general solution i found on forums is unistall fluent first, then install vc++ then again install fluent then set environment etc... (for people using unix operating system, go to the last lines of the post.). One more Example: First you have read ur case/mesh file before u compile it.....etc etc. there is no need for that. first u can compile then read ur case file and hook ur udf's.

there is no need to do all the stuff like the above ones stated above. im putting forward the procedure and possible pit falls we generally do when we try to compile a udf. I am putting forward detailed steps understandable for a novice fluent/udf user too. experienced users may ignore a few of the comments below without getting bored.

Step 1. if fluent is already intalled, the default folder is C:\FLUENT.INC if you dint change it when u install it on your computer. there is nothing to disturb fluent. leave it as it is.

Step 2a. Install Microsoft Visual Studio (written MSVS from now on) (with all components including MSDN and .net, .bat and not just VC++ I repeat not JUST VC++. the express edition of MSVC++ has only debugger and not compiler and will not serve the purpose of compiling fluent udf's). MSVS will take around 500 to 700 mb space of ur hard disk but its worth.

Step 2b. But the default folder will be C:\Program files\Microsoft Visual studio (x.x edition)\...., change this to C:\Microsoft Visual studio (x.x edition)\.....

Step 3. While u r installing, a promt is displayed asking to chek an option if you want to have command line comiler etc..., chek the box (MOST IMPORTANT chek the box). Doing this enables command line compiler and Fluent needs and searches only for this. It has to find this command line compiler to compile udfs.

Step 4. If the system asks for rebooting/restarting the system for the setup to take effect, do it.

Step 5. Now after the system reboots, right click my computer ---> properties ----> advanced tab. on the bottom part u have environment variables and system variables.

Step 5a. In the environment vairable add the variable for MSVS along wiht the fluent, and add path (same as that set in step 2b) also along with fluent path separtated by a semicolon.

Step 5b. To carry out this step, u need to have administrative rights for the computer u r using. In the system variables panel add the same path (generally on installing this is added for MSVC, chek to make sure that this is added). In the system varaibles path also follwo step 5a.

Step 6: Reset environment variables for fluent once again. (Start Menu ---- > Program Files----> Fluent.Inc----->Set environment)

That's it and u r done with this..

Remember, If you are using a unix based computer, then a udf compiled on 1 pc may not work with other unix pc as, in case of unix based systems, the system C compiler is invoked and there is no need to install MSVC.

Thanks for your patience of reading a lenghthy post and I hope it may be benficial for u. If you dont understand any of the steps, I advice read the steps again and again at the same time practically implementing each step.

If you have difficulty still to compile a udf in syntax, u may send it to me directly.

All the best Regards Rizwan.

Abdullah March 27, 2007 09:18

Re: ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM
 
Dear Sir,

I wrote a udf function by MSVS C++ 2005 to calculate temperature-dependent viscosity as follows;

#include "udf.h" DEFINE_PROPERTY(cell_viscosity, c, t) { real mu_lam; real temp = C_T(c, t); real a, b, tempo, muo; a = 0.000178; b = 0.0542; tempo = 323.0; muo = 0.142; mu_lam = muo*exp(a*(temp-tempo)-(b*(temp-tempo))); return mu_lam; } ------------- i go a massage ' the system cannot find the file specified'.

(system "copy c:\Fluent.Inc\Fluent6.216\src\makefile_nt.udf libudf\ntx86\2ddp\makefile") 1 file copied. (chdir "libudf")() (chdir "ntx86\2ddp")() 'nmake' is not recognized as an internal or external command, operabe program or batch file.

I made a diectory name thin_film, and i put my case file and cell_viscosity.c file in this directory.

please help. I need this urgent.

Regards,


Rizwan March 27, 2007 16:27

Re: ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM
 
is this your entire udf? u need to chek the looping through cells as far as i guess. r u changing viscotiy of a single cell or a group of cells ??? once you complete this part then go to the compile udf part. also if its not necessary, then i suggest that u go for interpreted udfs as both serve the same purpose except tht things are done differntly in either case and flexibility of dealing with problem.

If compiled udf is mandatory, Did you go through all the steps I stated in my above post? chek with your environment variables, ask your adimistrator to copy the enviornment variables and give it to you and u too define ur environment variables same as that of yours/. Regards


Rizwan March 27, 2007 16:32

Re: ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM
 
Also Please be adviced that if u r using udf to modify properties of only single cell, i tested ur udf and its working absolutely fine till compiling and loading state. i dont know tha result provided by it but programming aspect is absolutely correct FOR A SINGLE CELL ONLY. I repeat FOR A SINGLE CELL ONLY not for a group of cells. U need to chek with the installation of MSVS, esp i suggest u use MSVS 6 PRO and modify the environment varialbes properly and set path.

Regards


Abdullah April 3, 2007 10:16

Re: ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM
 
Dear Razwan,

I have MS Visual Studio C++ 2007 express. I am looking for the full package, then, i will try your steps. I have Fluent in my computer and i am the administrator.

I need to calculate the viscosity for each cell as it is temperature-dependet. the udf should take cell-temperture to calculate the viscosity.

I am happy that it is working with you.

When i use interpreted udf, it is working ok, but very slow. there is massage 'temp definition shadows previous definition' what does this mean?

Regards,

Sangeeta April 4, 2007 11:41

Re: ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM
 
Ya Rizwan, I too am not able to get full package. and i too use interpret and get the same message 4 times. let me know.

Thanks Rizwan

Abdullah April 9, 2007 04:25

Re: ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM
 
Thanks Rizwan,

I got Visual C++ full package, and i have gotten good result.

Regards,


Rizwan April 10, 2007 04:40

Re: ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM
 
I dint get you. Can u please explain a bit more clearly? Also i want to mention is that there installing MSDN documentation library eats up computer memory terribly. Just add to my first post on wednesday 21, March that, even without documentation MSVC works fine and I have tested it.

Regards Rizwan

Sangeeta April 16, 2007 12:40

Re: ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM
 
The message that i had got while interpreting the UDF was,

temp definition shadows previous definition.

that also 4 times and then the file got interpreted. I wanted to know what does this mean?

With regards, Sangeeta

Nadeem99 May 14, 2009 00:02

Environment Variables
 
Dear Rizwan
Can you provide the deatils (commands and variable name) to set the environment variables for MSVS

Nadeem

tumble January 28, 2010 08:57

Re: ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM
 
Dear Rizwan
I have installed Install Microsoft Visual Studio, I followed all your steps but when I want compiled udf, I got the following error :
{
1 fichier(s) copi‚(s).
1 fichier(s) copi‚(s).
(system "copy C:\Fluent.Inc\fluent6.3.26\src\makefile_nt.udf libudf\ntx86\2ddp\makefile")
1 fichier(s) copi‚(s).
(chdir "libudf")()
(chdir "ntx86\2ddp")()
Done.
"c:/documents and settings/administrateur/bureau/mywork"
Opening library "libudf"...
Error: open_udf_library: Le fichier spécifié est introuvable.
Error Object: ()
}
Knowing that I used the same UDF in function interpreted Udfs . It works very well. Just to ensure the smooth operation of the function compiled UDFs.
Please help. I need this urgent.
Regards,

elmcmaster February 26, 2010 07:32

Errors with C++ compiler using VIsual Studio 2008
 
Hi, i have followed the steps above, but when i try to compile and example UDFfrom the Fluent UDF manual, i get an error that the Microsoft Visual C++ compiler has stopped working. I dont know what to do now, getting Compiled UDFs to work is essential for progress in my PhD, any help would be greatly appreciated. Also when i start the Command line compiler of C++ in visual studio, at the top it says "vcvars32.bat is not recognised as an internal or external command, operable program or batch file" would this have anything to do with it?

coalgas February 26, 2010 08:40

Hello everyone,
I saw some of our friends are looking for complete Visual Studio. I am using Visual C++ 2008 Express Edition, which is available for free and works perfect to compile UDF's.

regards
Chetan

elmcmaster February 26, 2010 08:47

Great, thanks, just trying that now.

Michael

elmcmaster February 26, 2010 09:05

Still error with Visual C++ express
 
Hi all, i still get the same error that the C++ compiler stops working when i try to build the UDF. I have set the environment variable as suggested, has anyone else had this problems, does anyone know how this can be solved?

Thanks
Michael:)

Lightning July 19, 2010 08:18

guys....i'm trying to compile my udf n i getting this error....any1 can help ??? ihave set environment variable and everything according to the steps explained...

LINK : fatal error LNK1104: cannot open file 'kernel32.lib'

ecfd July 22, 2010 17:21

UDF compilation on Windows and launcher
 
If you are using FLUENT12.0 and newer, compilation of UDF is lot easier.

1. install FLUENT

2. install MS Visual Studio 2005 or 2008

There is no order who is first installed, FLUENT or Compiler

3. launch FLUENT with the FLUENT launcher, with the proper current working directory, where you have the C files. Compiler path should have been setup automatically

4. do your normal compilation

als_226 August 14, 2010 15:45

Followed the step above, but getting this error,

"Error: open_udf_library: %1 is not a valid Win32 application.

Error Object: ()"

Please, can anyone help me?

srr September 19, 2010 19:58

Thanks a lot, I tried with FLUENT 12 and MS VS 2008 and it worked perfectly

asaleghahreman October 7, 2010 04:52

Quote:

Originally Posted by elmcmaster (Post 247621)
Hi all, i still get the same error that the C++ compiler stops working when i try to build the UDF. I have set the environment variable as suggested, has anyone else had this problems, does anyone know how this can be solved?

Thanks
Michael:)

hi,I dont know how to set the environment variable?can u explain me more about it??which varriable??I want the details of it..
tanx


All times are GMT -4. The time now is 17:04.