CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM

Register Blogs Community New Posts Updated Threads Search

Like Tree33Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 21, 2007, 22:53
Default ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM
  #1
Rizwan
Guest
 
Posts: n/a
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.
  Reply With Quote

Old   March 27, 2007, 10:18
Default Re: ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM
  #2
Abdullah
Guest
 
Posts: n/a
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,

  Reply With Quote

Old   March 27, 2007, 17:27
Default Re: ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM
  #3
Rizwan
Guest
 
Posts: n/a
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

  Reply With Quote

Old   March 27, 2007, 17:32
Default Re: ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM
  #4
Rizwan
Guest
 
Posts: n/a
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

  Reply With Quote

Old   April 3, 2007, 11:16
Default Re: ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM
  #5
Abdullah
Guest
 
Posts: n/a
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,
  Reply With Quote

Old   April 4, 2007, 12:41
Default Re: ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM
  #6
Sangeeta
Guest
 
Posts: n/a
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
  Reply With Quote

Old   April 9, 2007, 05:25
Default Re: ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM
  #7
Abdullah
Guest
 
Posts: n/a
Thanks Rizwan,

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

Regards,

chaitanyaarige likes this.
  Reply With Quote

Old   April 10, 2007, 05:40
Default Re: ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM
  #8
Rizwan
Guest
 
Posts: n/a
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
  Reply With Quote

Old   April 16, 2007, 13:40
Default Re: ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM
  #9
Sangeeta
Guest
 
Posts: n/a
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
  Reply With Quote

Old   May 14, 2009, 01:02
Default Environment Variables
  #10
New Member
 
Muhammad Nadeem
Join Date: May 2009
Posts: 5
Rep Power: 17
Nadeem99 is on a distinguished road
Dear Rizwan
Can you provide the deatils (commands and variable name) to set the environment variables for MSVS

Nadeem
Nadeem99 is offline   Reply With Quote

Old   January 28, 2010, 08:57
Default Re: ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM
  #11
New Member
 
samt
Join Date: Jan 2010
Posts: 13
Rep Power: 16
tumble is on a distinguished road
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,
tumble is offline   Reply With Quote

Old   February 26, 2010, 07:32
Exclamation Errors with C++ compiler using VIsual Studio 2008
  #12
New Member
 
Michael McMaster
Join Date: May 2009
Posts: 29
Rep Power: 17
elmcmaster is on a distinguished road
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?
elmcmaster is offline   Reply With Quote

Old   February 26, 2010, 08:40
Default
  #13
Member
 
chétan
Join Date: May 2009
Location: Australia
Posts: 55
Rep Power: 17
coalgas is on a distinguished road
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
coalgas is offline   Reply With Quote

Old   February 26, 2010, 08:47
Default
  #14
New Member
 
Michael McMaster
Join Date: May 2009
Posts: 29
Rep Power: 17
elmcmaster is on a distinguished road
Great, thanks, just trying that now.

Michael
elmcmaster is offline   Reply With Quote

Old   February 26, 2010, 09:05
Exclamation Still error with Visual C++ express
  #15
New Member
 
Michael McMaster
Join Date: May 2009
Posts: 29
Rep Power: 17
elmcmaster is on a distinguished road
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
elmcmaster is offline   Reply With Quote

Old   July 19, 2010, 09:18
Default
  #16
New Member
 
teo wei how
Join Date: Jun 2010
Posts: 5
Rep Power: 16
Lightning is on a distinguished road
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'
Lightning is offline   Reply With Quote

Old   July 22, 2010, 18:21
Default UDF compilation on Windows and launcher
  #17
New Member
 
Join Date: Jul 2010
Posts: 5
Rep Power: 16
ecfd is on a distinguished road
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
ecfd is offline   Reply With Quote

Old   August 14, 2010, 16:45
Default
  #18
New Member
 
Alvin Simer
Join Date: Aug 2010
Posts: 2
Rep Power: 0
als_226 is on a distinguished road
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?
als_226 is offline   Reply With Quote

Old   September 19, 2010, 20:58
Default
  #19
srr
New Member
 
srr
Join Date: Feb 2010
Posts: 25
Rep Power: 16
srr is on a distinguished road
Thanks a lot, I tried with FLUENT 12 and MS VS 2008 and it worked perfectly
srr is offline   Reply With Quote

Old   October 7, 2010, 05:52
Default
  #20
New Member
 
asal
Join Date: Apr 2010
Posts: 11
Rep Power: 16
asaleghahreman is on a distinguished road
Quote:
Originally Posted by elmcmaster View Post
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
asaleghahreman is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help! Compiled UDF problem 4 Wave tank tutorial Shane FLUENT 1 September 3, 2010 03:32
Problem with my udf july Fluent UDF and Scheme Programming 3 June 20, 2010 07:56
Error compile file udf czfluent Fluent UDF and Scheme Programming 24 September 26, 2009 14:24
UDF compile problem ak6g08 Fluent UDF and Scheme Programming 2 June 25, 2009 07:56
dynamic mesh and udf problem boboroo FLUENT 1 January 20, 2008 22:26


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