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

How to solve UDF compilation problems in Fluent.

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree10Likes
  • 10 Post By pakk

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 2, 2016, 04:37
Default How to solve UDF compilation problems in Fluent.
  #1
Senior Member
 
Join Date: Nov 2013
Posts: 1,769
Rep Power: 22
pakk will become famous soon enough
There are many threads on this forum about compilation problems. Many of those threads show that users have no idea how to start solving their problems related to compiling, so here a start. In red are the questions that you might ask yourself, and below that are solution methods.

I did not get any error when I compiled, but later I get "Error: The UDF library you are trying to load (libudf) is not compiled for 3d on the current platform (...)".
When I compile, I get the error "Error: The UDF library you are trying to load (libudf) is not compiled for 3d on the current platform (...)"

This error means that you are trying to load a UDF that was not compiled. Actually, that is even exactly what is written in the error message. Before you load the UDF, you have to compile it. In Fluent, this is done by clicking 'build'. Probably you did that, and think everything went fine. But it probably went wrong. If compiling goes wrong, you don't get an error message in a separate window, but the error message is written in the text user interface (the block with text normally on the bottom right of your screen). Check there which errors are showing when you click 'build'.

When I try to compile, I see the message "'nmake' is not recognized as an internal or external command, operable program or batch file."

The program "nmake" is the compiler. This message means that Fluent can not find the compiler, so it is unable to compile anything. This has nothing to do with the code you wrote, but with the installation/settings of Fluent.
Probably you have never been able to compile anything in Fluent. Follow the steps that Fluent advises to set up a compiler, and test it with one of the simple codes in their manual. (Somebody wrote a nice 'how-to-set-up-Fluent-with-compiler-post' on this forum, but I can not find it now.)

I get an error such as: ..\..\src\udfsource.c(102) : error C2065: 'mass' : undeclared identifier
Now we are really talking about code problems. There can be many more lines just like this, but generally it is best to start with the first one. Let's go through this step by step.
..\..\src\udfsource.c(102) : error C2065: 'mass' : undeclared identifier
  • "..\..\src\udfsource.c": This is the file that Fluent is trying to compile. It should be (a copy of) the file that you wrote. If it is not, you have different problems. If the problem is in "udfnames.h", you can probably ignore it, it looks like the Fluent coders made a small mistake in a macro.
  • "(102)": This is the number of the line where the problem is. So, open the file in a text editor, go to line 102, and see what is on that line. Even if you don't know anything about programming, do this. You might learn something just by reading the line.
  • "error": This could also say "warning". There is a slight difference between "error" and "warning": "warning" means that the compiler sees something is wrong, but will continue anyway, and "error" means that the compiler sees something is wrong and can not continue. Good code should have no errors and no warnings.
  • "C2065": This is the error code. You can look for this on internet. (Look for "Error C2065" in your favourite search engine.)
  • "'mass' : undeclared identifier": This is some more detail on your problem. In this case, it shows that you used the variable 'mass' before you defined it.
With this info, you might be able to solve the problem. Or you can ask for help on this forum. If you ask for help here, be as specific as you can: show the code you tried, and show the errors you get.

When I run the code, I get "FLUENT received fatal signal (ACCESS_VIOLATION)"
This is a nasty one. It means that you made a mistake in your code. But not a grammar mistake, but a logical mistake. You are trying to access (read or write) memory that does not exist. For example: you defined an array with 10 members, and now you are trying to write to the eleventh member. Or you are trying to read a temperature gradient from a face for which Fluent does not store the temperature gradient. It can be many things...
One of the annoying things is that you don't know where in the code this access violation happened. If you want to solve the problem, you first have to find out where the problem is. One way to do this: make your program write text.
Put somewhere in the middle of your code the following line:
Code:
Message("UDF got to here.\n");
Compile your code and run it again. You will probably again get the access violation. But do you see "UDF got to here." in the text user interface? If you did, it means the problem is below this line. If you did not, it means the problem is above this line. Move this line (or add additional lines with different texts) to get a better idea on where the access violation occurs. Hopefully you will get it pinned down to one single line. Look what is in this line: probably you are reading or writing information. What are you reading/writing? Are you sure that the location that you are reading/writing from exists?
You can always come to this forum to ask for help on this. But my experience is that people are better able (and willing) to help you if you already did your own investigation in the way I wrote here, and share your results.


If there are additions/changes, I might update this post.

Last edited by pakk; May 3, 2016 at 05:10.
pakk is offline   Reply With Quote

Old   May 2, 2016, 21:37
Default
  #2
Member
 
mimi
Join Date: Mar 2016
Posts: 33
Rep Power: 7
cik mimi is on a distinguished road
Thank you for the information. =)
Your description is highly appreciated
cik mimi is offline   Reply With Quote

Old   May 3, 2016, 05:07
Default
  #3
Senior Member
 
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 9
Bruno Machado is on a distinguished road
Great job, pakk. Hope that does help people in their UDF compilation problems and they come with real UDF related questions.

Once again, great job.
Bruno Machado is offline   Reply With Quote

Old   May 6, 2016, 11:27
Default
  #4
Senior Member
 
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 9
Bruno Machado is on a distinguished road
Hi pakk, I've just uploaded this tutorial from Ansys teaching how to compile for paralell and serial. Also covers the compiler, prompt, etc.. Have a look if it is worthy to add in your post.

Last edited by Bruno Machado; May 10, 2016 at 06:01.
Bruno Machado is offline   Reply With Quote

Old   May 10, 2016, 05:53
Default
  #5
Senior Member
 
Join Date: Nov 2013
Posts: 1,769
Rep Power: 22
pakk will become famous soon enough
Hi Bruno,

I am sure you have the best intents, but since you probably don't have permission from Ansys to distribute this document, it is probably a copyright violation to distribute this.
I respect that other persons have no problems with this (and I am not going to inform Ansys about this), but I choose not to get involved myself.
pakk is offline   Reply With Quote

Old   May 10, 2016, 06:01
Default
  #6
Senior Member
 
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 9
Bruno Machado is on a distinguished road
Quote:
Originally Posted by pakk View Post
Hi Bruno,

I am sure you have the best intents, but since you probably don't have permission from Ansys to distribute this document, it is probably a copyright violation to distribute this.
I respect that other persons have no problems with this (and I am not going to inform Ansys about this), but I choose not to get involved myself.
yes, you probably right. what I am going to do is to create my own document and share with others, so no copyright is violated.

I'll delete the link before to avoid any issues with Ansys.
Bruno Machado is offline   Reply With Quote

Old   December 7, 2017, 03:14
Default .dll file error while compiling code
  #7
New Member
 
Anony
Join Date: Dec 2017
Posts: 5
Rep Power: 5
ca716 is on a distinguished road
Hi pakk,
I am new to UDFs. I read fluent manual to get idea about udf. I learned something but i am unable to compile a udf.

I have one udf file named a.c. i put that file in a folder with my case file. I opened fluent from SDK and then went to user defined functions and then to compiled and then added my udf a.c. then i clicked build. It said something like generating io1.h.
Then i clicked load. Then i am gettingg an error that libudf.dll file is missing. What should i do?
Look at the photos i uploaded for exact error shown.
Attached Images
File Type: jpg IMG_20171207_120109.jpg (169.9 KB, 102 views)
File Type: jpg IMG_20171207_120102.jpg (141.1 KB, 57 views)
ca716 is offline   Reply With Quote

Old   December 7, 2017, 03:46
Default
  #8
Senior Member
 
Join Date: Nov 2013
Posts: 1,769
Rep Power: 22
pakk will become famous soon enough
One problem: your folder name has a space in it. This gives problems to the Fluent compiler. Do everything in a folder name without spaces.
pakk is offline   Reply With Quote

Old   December 8, 2017, 00:12
Default
  #9
New Member
 
Anony
Join Date: Dec 2017
Posts: 5
Rep Power: 5
ca716 is on a distinguished road
It seems like that is not the problem. (Have a look at image i attached)
I tried doing it by putting files in a folder without any spaces. It is showing the same error.
Not only this i tried many different ways told by different users in this forum. Everytime i am receiving this error. I am unable to find what is causing this error. So i want to start from scratch.
Could you tell me step by step what i have to do and i will do the same.
I want to learn how to compile any udf.
Attached Images
File Type: jpg 1.JPG (100.1 KB, 76 views)
ca716 is offline   Reply With Quote

Old   December 8, 2017, 06:50
Default
  #10
Senior Member
 
Join Date: Nov 2013
Posts: 1,769
Rep Power: 22
pakk will become famous soon enough
Check the first item (red text above). You have to look at what comes on your screen after you click "build".

What you show was what comes on your screen after you click "load". That does not help.
pakk is offline   Reply With Quote

Old   January 3, 2018, 08:35
Default
  #11
New Member
 
Anony
Join Date: Dec 2017
Posts: 5
Rep Power: 5
ca716 is on a distinguished road
Hi Pak,
the error was exactly the same error which came before(the one in my previous reply), except the change in name of folder.
As you said, i didnt put any spaces in the folder name and file name.
ca716 is offline   Reply With Quote

Old   January 3, 2018, 08:47
Default
  #12
Senior Member
 
Join Date: Nov 2013
Posts: 1,769
Rep Power: 22
pakk will become famous soon enough
OK. Start a new Fluent, and load your model.

Then: Go to "user defined", "functions", "manage", and if there is any udf loaded, unload it.
Then: go to "user defined", "functions", "compiled", add the source file that you want.
Don't click 'build' yet, but look what is currently on your screen.

Now click 'build'.

Which text was added to your screen after you clicked 'build'? (Don't describe it, but just copy it letter by letter.)
pakk is offline   Reply With Quote

Old   January 4, 2018, 00:45
Default
  #13
New Member
 
Anony
Join Date: Dec 2017
Posts: 5
Rep Power: 5
ca716 is on a distinguished road
The following message was added when i clicked BUILD.

Copied D:\UDF\FYP\fyp_files\dp0\FFF\Fluent/D:\UDF\FYP\fyp_files\dp0\FFF\Fluent\1.c to libudf\src
Creating user_nt.udf file for 2ddp ...
(system "copy "C:\PROGRA~1\ANSYSI~1\v160\fluent"\fluent16.0.0\sr c\udf\makefile_nt.udf "libudf\win64\2ddp\makefile" ")
1 file(s) copied.
(chdir "libudf")(chdir "win64\2ddp")# Generating ud_io1.h

Done.


I am also attaching screenshots to make things easier for you.
Attached Images
File Type: jpg Screenshot (14).jpg (73.6 KB, 60 views)
File Type: jpg Screenshot (15).jpg (77.2 KB, 52 views)
File Type: jpg Screenshot (17).jpg (130.2 KB, 51 views)
File Type: jpg Screenshot (18).jpg (126.1 KB, 50 views)
File Type: jpg Screenshot (19).jpg (141.1 KB, 50 views)
ca716 is offline   Reply With Quote

Old   January 4, 2018, 02:46
Default
  #14
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 1,616
Rep Power: 23
AlexanderZ will become famous soon enough
Mb I'm wrong

but it seems, that Fluent doesn't compile your source file, he thinks libudf library is up to date.
Solutions:
1. You may use other name of library (other than libudf, for instance myudf)
2. Once fluent is opened, open your source file, and imitate change: type space, than delete it and save. Now you can compile with the same library name libudf.

Best regards
AlexanderZ is offline   Reply With Quote

Old   January 4, 2018, 07:54
Default
  #15
New Member
 
Anony
Join Date: Dec 2017
Posts: 5
Rep Power: 5
ca716 is on a distinguished road
Hey AlexanderZ,
Thanks for reply.
Out if two solutions you suggested, i tried first one and it was unsuccessful. I already tried many times giving it many different library names.
And as for the 2nd one, I am not getting what you are saying. Can you elaborate what you want me to do?.
ca716 is offline   Reply With Quote

Old   January 4, 2018, 20:01
Default
  #16
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 1,616
Rep Power: 23
AlexanderZ will become famous soon enough
Are you sure that your SDK's version is win64 ?
AlexanderZ is offline   Reply With Quote

Old   September 10, 2018, 02:48
Default
  #17
Senior Member
 
Join Date: Feb 2010
Posts: 164
Rep Power: 14
gearboy is on a distinguished road
Use the compiling/debugging tool, UDF will be very easy.
https://vcudfstudio.bitbucket.io/


Quote:
Originally Posted by pakk View Post
There are many threads on this forum about compilation problems. Many of those threads show that users have no idea how to start solving their problems related to compiling, so here a start. In red are the questions that you might ask yourself, and below that are solution methods.

I did not get any error when I compiled, but later I get "Error: The UDF library you are trying to load (libudf) is not compiled for 3d on the current platform (...)".
When I compile, I get the error "Error: The UDF library you are trying to load (libudf) is not compiled for 3d on the current platform (...)"

This error means that you are trying to load a UDF that was not compiled. Actually, that is even exactly what is written in the error message. Before you load the UDF, you have to compile it. In Fluent, this is done by clicking 'build'. Probably you did that, and think everything went fine. But it probably went wrong. If compiling goes wrong, you don't get an error message in a separate window, but the error message is written in the text user interface (the block with text normally on the bottom right of your screen). Check there which errors are showing when you click 'build'.

When I try to compile, I see the message "'nmake' is not recognized as an internal or external command, operable program or batch file."

The program "nmake" is the compiler. This message means that Fluent can not find the compiler, so it is unable to compile anything. This has nothing to do with the code you wrote, but with the installation/settings of Fluent.
Probably you have never been able to compile anything in Fluent. Follow the steps that Fluent advises to set up a compiler, and test it with one of the simple codes in their manual. (Somebody wrote a nice 'how-to-set-up-Fluent-with-compiler-post' on this forum, but I can not find it now.)

I get an error such as: ..\..\src\udfsource.c(102) : error C2065: 'mass' : undeclared identifier
Now we are really talking about code problems. There can be many more lines just like this, but generally it is best to start with the first one. Let's go through this step by step.

..\..\src\udfsource.c(102) : error C2065: 'mass' : undeclared identifier
  • "..\..\src\udfsource.c": This is the file that Fluent is trying to compile. It should be (a copy of) the file that you wrote. If it is not, you have different problems. If the problem is in "udfnames.h", you can probably ignore it, it looks like the Fluent coders made a small mistake in a macro.
  • "(102)": This is the number of the line where the problem is. So, open the file in a text editor, go to line 102, and see what is on that line. Even if you don't know anything about programming, do this. You might learn something just by reading the line.
  • "error": This could also say "warning". There is a slight difference between "error" and "warning": "warning" means that the compiler sees something is wrong, but will continue anyway, and "error" means that the compiler sees something is wrong and can not continue. Good code should have no errors and no warnings.
  • "C2065": This is the error code. You can look for this on internet. (Look for "Error C2065" in your favourite search engine.)
  • "'mass' : undeclared identifier": This is some more detail on your problem. In this case, it shows that you used the variable 'mass' before you defined it.
With this info, you might be able to solve the problem. Or you can ask for help on this forum. If you ask for help here, be as specific as you can: show the code you tried, and show the errors you get.

When I run the code, I get "FLUENT received fatal signal (ACCESS_VIOLATION)"
This is a nasty one. It means that you made a mistake in your code. But not a grammar mistake, but a logical mistake. You are trying to access (read or write) memory that does not exist. For example: you defined an array with 10 members, and now you are trying to write to the eleventh member. Or you are trying to read a temperature gradient from a face for which Fluent does not store the temperature gradient. It can be many things...
One of the annoying things is that you don't know where in the code this access violation happened. If you want to solve the problem, you first have to find out where the problem is. One way to do this: make your program write text.
Put somewhere in the middle of your code the following line:
Code:
Message("UDF got to here.\n");
Compile your code and run it again. You will probably again get the access violation. But do you see "UDF got to here." in the text user interface? If you did, it means the problem is below this line. If you did not, it means the problem is above this line. Move this line (or add additional lines with different texts) to get a better idea on where the access violation occurs. Hopefully you will get it pinned down to one single line. Look what is in this line: probably you are reading or writing information. What are you reading/writing? Are you sure that the location that you are reading/writing from exists?
You can always come to this forum to ask for help on this. But my experience is that people are better able (and willing) to help you if you already did your own investigation in the way I wrote here, and share your results.


If there are additions/changes, I might update this post.
gearboy is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
A Problem of Fluent Interpreted UDF: parse error knight Fluent UDF and Scheme Programming 25 August 16, 2018 10:26
UDF Compilation Error for Fluent 12.1 carteblanche Fluent UDF and Scheme Programming 8 July 16, 2015 01:48
Fluent UDF for thermal NOx larsschwarzer Fluent UDF and Scheme Programming 1 July 18, 2014 08:39
is it possible to solve mass transfer problems in FLUENT travikiran FLUENT 2 August 11, 2010 04:46
Fluent 5.5 can't solve Multiphase+Multicomponent? Thitikorn FLUENT 8 March 27, 2002 22:57


All times are GMT -4. The time now is 22:43.