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

UDF Compilation Error - Loading Library - COMMON Problem! Help!

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By robtheslob

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 13, 2014, 16:03
Default UDF Compilation Error - Loading Library - COMMON Problem! Help!
  #1
New Member
 
Rob
Join Date: Apr 2014
Posts: 13
Rep Power: 12
robtheslob is on a distinguished road
Hello,

NOTE:
------------------------------------------------------------
This is a pretty long post... however, I PROMISE that if anyone can provide some insight into this problem, it will help a LOT of people! I see inquiries about this exact error message all over the internet...

...in fact, I considered posting this on one of the many related threads on this issue. However, all of the threads I found were either 1) very similar, but just different enough to warrant a new thread or 2) years old and abandoned before a satisfactory solution was suggested.

Hopefully my first post will guide others through the process of triaging their issue. Obviously, none of my steps successfully solved my problem... thus, this thread!
------------------------------------------------------------



ISSUE:
------------------------------------------------------------
After what appears to be a successful compilation (with some odd syntax errors in "math.h," which is very strange) I attempt to load the UDF library and receive this error message:

Quote:
Opening library "C:\PFMAN\PROJECTS\LIQUID COOLING STUDY\214000005_files\dp0\FLU-2\Fluent\libudf"...
Error: The UDF library you are trying to load (libudf) is not compiled for 3ddp on the current platform (win64).

The system cannot find the file specified.

C:\PFMAN\PROJECTS\LIQUID COOLING STUDY\214000005_files\dp0\FLU-2\Fluent\libudf\win64\3ddp\libudf.dll

Error: The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform (win64).

The system cannot find the file specified.

C:\PFMAN\PROJECTS\LIQUID COOLING STUDY\214000005_files\dp0\FLU-2\Fluent\libudf\win64\3ddp\libudf.dll
Error Object: #f
------------------------------------------------------------



ATTEMPT AT RESOLUTION:
------------------------------------------------------------
After this disappointing failure, I performed some Google searches and tried:
  1. Compiling and loading in Fluent Serial mode, and the results were identical EXCEPT that "3ddp" replaces "parallel use" in the emboldened portion of the error message above.
  2. Launching Fluent from the working directory using the Developer Command Prompt for VS2013, the VS2013 x64 Cross Tools Command Prompt, and the VS2013 x86 Native Tools Command Prompt. This is similar to the steps described in this FAQ. (Do I REALLY have to purchase MS VS Professional in order to download the SDK in order to properly compile ANSYS UDFs???)
  3. Setting up the Fluent environment (udf.bat) using this FAQ as a reference. I also confirmed that the correct arguments were being passed to the VS batch file. (You can edit these batch files using notepad, although you might need to run notepad as an administrator!)
  4. Generally yelling and getting mad at the computer

With the exception of 1, these steps did not alter the error message displayed in the TUI in any way.
------------------------------------------------------------



IS ANY OF THIS NECESSARY?
------------------------------------------------------------
The entire reason I decided to compile my (relatively simple) UDF over interpreting is because of an error message I kept receiving whenever I attempted to interpret my UDF source code in Fluent:

Quote:
cpp -I"C:\PROGRA~1\ANSYSI~1\v150\fluent\fluent15.0.0/src" -I"C:\PROGRA~1\ANSYSI~1\v150\fluent\fluent15.0.0/cortex/src" -I"C:\PROGRA~1\ANSYSI~1\v150\fluent\fluent15.0.0/client/src" -I"C:\PROGRA~1\ANSYSI~1\v150\fluent\fluent15.0.0/multiport/src" -I. -DUDF
ONFIG_H="<C:/Users/ansys/AppData/Local/Temp/udfconfig-5540-node7.h>" "C:/Users/ansys/AppData/Local/Temp/realpump.c.5540.7.c"
Error: C:/Users/ansys/AppData/Local/Temp/realpump.c.5540.7.c: line 48: parse error.
Error: C:/Users/ansys/AppData/Local/Temp/realpump.c.5540.7.c: line 54: outlet_thread: undeclared variable
Line 48 in my source defines the pointer "outlet_thread" using syntax I lifted directly from the UDF manual:

Code:
Thread *outlet_thread = Lookup_Thread(domain,ZONE_ID);
The Lookup_Thread macro was used in the context of a DEFINE_PROFILE macro.

Assuming there is no issue with that line (and there certainly could be) my assumption was that the error resulted from the need to compile my source code over interpret... although the manual wasn't specific enough about the interpreter limitations for me to be certain that that was the case. (This is probably because it is written for those that know C fairly well, and I'm no more than an amateur.)

And as long as we're talking amateurism, it's also possible (likely?) that my code is a mess. As you already know, I'm new to UDFs, and I have yet to get a chance to debug my code and learn about the Fluent macros from experience... once it's compiled, I shall be happy to learn more on my own! My point is this: if you think my code is nonsense, don't hesitate to tell me.

Although getting my code to work without compiling would be great for now - if that's even an option - the larger compiler issue is still important to resolve so that I (and anyone else with the same issue) can work on UDFs in the future!
------------------------------------------------------------



REFERENCE: MY UDF SO FAR
------------------------------------------------------------
Code:
/******************************************************************************
 DESCRIPTION:	UDF for determining real inlet conditions based on pump curve
 				data (hard-coded) and the system demand curve (geometry in
 				ANSYS)
 AUTHOR:	Robert * *****
 CREATED:	5/9/2014
 LAST CHANGED:	5/13/2014
******************************************************************************/

#include "udf.h"		//Required for all Fluent UDFs

#define INLET_AREA 0.0001		//Inlet cross-sectional area in m^2
#define HEIGHT 0.0001	//Height of inlet to be addded to 
							//position vector in m
#define ZONE_ID 14		//Zone ID for outlet

/*-----------------------------------------------------------------------------
	*Adjusts BC using ANSYS compiler macro
	*Uses value of pressure difference to adjust flow velocity
	*Flow velocity is considered in 1 dimension
	*t is pointer to thread on which BC is applied
	*i is index that identifies variable that is set when UDF is hooked
-----------------------------------------------------------------------------*/
DEFINE_PROFILE(pump_curve,t,i)	
{
	/*-------------------------------------------------------------------------
		*Global variable initialization
	-------------------------------------------------------------------------*/
	face_t f;		//Declare a special variable structure to store face data
	real outlet_pressure,pressure_drop;		//Pressure variables
	real face_num,pressure = 0;		//Storage variables for calculations
									//face_num sums number of faces in loop
									//pressure sums pressure in loop

	/*-------------------------------------------------------------------------
		*First, the domain must be retrieved
		*Required because it was not passed in define macro
	-------------------------------------------------------------------------*/
	Domain *domain;		//Domain is declared as a variable
	domain = Get_Domain(1);		//Returns fluid domain pointer

	/*-------------------------------------------------------------------------
		*Next, we must obtain the outlet thread
		*The inlet thread is passed vis the define macro, not outlet
		*We need outlet thread to determine outlet pressure
		*Outlet pressure is used to determine pressure drop later
	-------------------------------------------------------------------------*/
	Thread *outlet_thread = Lookup_Thread(domain,ZONE_ID);

	/*-------------------------------------------------------------------------
		*Outlet pressure must now be obtained
		*Outlet pressure is used to determine pressure drop later
	-------------------------------------------------------------------------*/
	begin_f_loop(f, outlet_thread)
	{
		pressure += F_P(f,outlet_thread);		//F_P gets face pressure
												//The += sums values in loop
		face_num++;		//Inrement number of faces by one for each loop
	}
	end_f_loop(f,outlet_thread)

	outlet_pressure = pressure/face_num;		//Average outlet pressure
	pressure = 0;		//Reset pressure
	face_num = 0;		//Reset number of faces

	Message("The outlet pressure is calculated to be %g/n",outlet_pressure);

	/*-------------------------------------------------------------------------
		*This loop will apply the new velocity boundary condition
	-------------------------------------------------------------------------
	begin_f_loop(f,t)
	{
		F_CENTROID(x,f,t);		//Find and store position vector for face
		y = x[1]		//Second value (y) in position vector array
		F_PROFILE(f,t,i) = f(pressure_drop)		//This sets the new velocity
		//^^^ FEED PRESSURE DROP INTO PUMP CURVE FUNCTION
	}
	end_f_loop(f,t)

	*/

}
------------------------------------------------------------



REFERENCE: "BUILD" OUTPUT BEFORE LOADING LIBRARY
------------------------------------------------------------
Quote:
Copied C:\PFMAN\PROJECTS\LIQUID COOLING STUDY\214000005_files\dp0\FLU-2\Fluent/C:\PFMAN\PROJECTS\LIQUID COOLING STUDY\214000005_files\dp0\FLU-2\Fluent\realpump.c to libudf\src
udf_names.c and user_nt.udf files in 3ddp_host are upto date.
(system "copy "C:\PROGRA~1\ANSYSI~1\v150\fluent"\fluent15.0.0\sr c\makefile_nt.udf "libudf\win64\3ddp_host\makefile" ")
1 file(s) copied.
(chdir "libudf")(chdir "win64\3ddp_host")# Generating ud_io1.h
realpump.c
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(482) : error C2059: syntax error : ','
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(482) : error C2143: syntax error : missing ')' before 'constant'
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(482) : error C2143: syntax error : missing '{' before 'constant'
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(482) : error C2059: syntax error : 'constant'
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(482) : error C2059: syntax error : ')'
udf_names.c and user_nt.udf files in 3ddp_node are upto date.
(system "copy "C:\PROGRA~1\ANSYSI~1\v150\fluent"\fluent15.0.0\sr c\makefile_nt.udf "libudf\win64\3ddp_node\makefile" ")
1 file(s) copied.
(chdir "libudf")(chdir "win64\3ddp_node")# Generating ud_io1.h
realpump.c
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(482) : error C2059: syntax error : ','
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(482) : error C2143: syntax error : missing ')' before 'constant'
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(482) : error C2143: syntax error : missing '{' before 'constant'
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(482) : error C2059: syntax error : 'constant'
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(482) : error C2059: syntax error : ')'
------------------------------------------------------------



Thank you all for your help in advance!

Rob
robtheslob is offline   Reply With Quote

Old   May 14, 2014, 09:38
Default
  #2
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17
macfly is on a distinguished road
Hi,

I didn't read closely all your post but I have some advice:

- the comments at the end of lines (//blablabla) are probably causing the syntax errors, always use /*blablabla*/

- To get acquainted with udf compiling, you should try to compile a very simple udf (copy pasted from UDF Manual) within a very simple 2D model (e.g. 2D heat conduction problem).

Last edited by macfly; May 14, 2014 at 11:37.
macfly is offline   Reply With Quote

Old   May 14, 2014, 11:23
Default
  #3
Senior Member
 
Andrew Kokemoor
Join Date: Aug 2013
Posts: 122
Rep Power: 14
Kokemoor is on a distinguished road
3ddp means 3d, double precision. When you compile your UDF, it only compiles for the version (2d or 3d, single or double precision, serial or parallel) that it's currently running. If you're going to run your UDF in 3d double precision parallel, it needs to be compiled when Fluent is launched in 3d double precision parallel.

Exactly how you do this depends on how you compile. If you're using the launcher, each of these is an option in the launcher. If you're running from a command prompt, you'll need to use the proper flags.

Check out your 'libudf' folder. Inside 'win64' should be another folder. Its name will tell you what you've compiled it in. '3d' would be 3d single precision serial, '3ddp_host' and '3ddp_node' would be the folders for double precision parallel. If 'win32' is there instead of 'win64', then you've compiled in 32 bits and are trying to run on 64 bits.

Quote:
Originally Posted by macfly View Post
- the comments at the end of lines are probably causing problems (//blablabla), always use /*blablabla*/
For what it's worth, I use // comments without any problems.

Quote:
Originally Posted by robtheslob
Assuming there is no issue with that line (and there certainly could be) my assumption was that the error resulted from the need to compile my source code over interpret... although the manual wasn't specific enough about the interpreter limitations for me to be certain that that was the case.
The manual is definitely not complete about which functions need to be compiled, but I'm pretty sure Lookup_Thread() is fine. I think the issue is that you're declaring a new variable (*outlet_thread) after a non-declaration (domain = Get_Domain(1); ). Try just tossing 'Thread *outlet_thread' as a declaration at the top of your definge macro. If that is the problem, then it won't compile either, in which case you'd get the same errors you're seeing. Are you sure that it is in fact compiling without errors?
Kokemoor is offline   Reply With Quote

Old   May 14, 2014, 11:35
Default
  #4
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17
macfly is on a distinguished road
Quote:
Originally Posted by Kokemoor View Post
For what it's worth, I use // comments without any problems.
In my case, //comments didn't cause any problem for interpreted UDF, but it caused syntax errors for compiled ones.

I think it depends if you compile in Windows or Linux: http://msdn.microsoft.com/en-us/library/wfwda74e.aspx
It's better to stick with /* comments */ since it's not OS dependent.
macfly is offline   Reply With Quote

Old   May 14, 2014, 14:36
Default
  #5
New Member
 
Rob
Join Date: Apr 2014
Posts: 13
Rep Power: 12
robtheslob is on a distinguished road
Thank you all for the responses!

I've made a service request through ANSYS support and just received a response. I wanted to respond to everyone in this thread quickly and then digest the information they sent me. If the information proves to be useful, I will be sure to report back once I've gotten something out of it.

Quote:
Originally Posted by macfly View Post
To get acquainted with udf compiling, you should try to compile a very simple udf (copy pasted from UDF Manual) within a very simple 2D model (e.g. 2D heat conduction problem).
Wise advice. I might give this a shot if I continue to fail miserably much longer.

Quote:
Originally Posted by Kokemoor View Post
3ddp means 3d, double precision. When you compile your UDF, it only compiles for the version (2d or 3d, single or double precision, serial or parallel) that it's currently running. If you're going to run your UDF in 3d double precision parallel, it needs to be compiled when Fluent is launched in 3d double precision parallel.

Exactly how you do this depends on how you compile. If you're using the launcher, each of these is an option in the launcher. If you're running from a command prompt, you'll need to use the proper flags.

Check out your 'libudf' folder. Inside 'win64' should be another folder. Its name will tell you what you've compiled it in. '3d' would be 3d single precision serial, '3ddp_host' and '3ddp_node' would be the folders for double precision parallel. If 'win32' is there instead of 'win64', then you've compiled in 32 bits and are trying to run on 64 bits.
win64 > 3ddp_host & 3ddp_node. This looks correct to me.

I've been compiling by virtue of the GUI. I select double precision and parallel via the Fluent launcher. I've done this through the Workbench as well as through stand-alone Fluent, if that matters.

I've also launched Fluent through the command prompt, but I didn't include any extra flags. I assumed that - because the Fluent setup window appeared normally with all of the configurable options - I configured setup after launching Fluent, and flags weren't necessary. Feel free to disabuse!

Quote:
Originally Posted by Kokemoor View Post
The manual is definitely not complete about which functions need to be compiled, but I'm pretty sure Lookup_Thread() is fine. I think the issue is that you're declaring a new variable (*outlet_thread) after a non-declaration (domain = Get_Domain(1); ). Try just tossing 'Thread *outlet_thread' as a declaration at the top of your definge macro. If that is the problem, then it won't compile either, in which case you'd get the same errors you're seeing. Are you sure that it is in fact compiling without errors?
So... all I need to do is declare my variables at the top? Why is this a requirement?

Still being new to UDFs and this method of compilation, I suppose I can't tell you that I'm certain, beyond a shadow of a doubt, that everything is compiling properly. I did make sure to include a copy of the TUI output of the "Build" function in my first post. Does it look correct? Is that ALL of the information necessary to determine if compilation was successful?

Quote:
Originally Posted by macfly View Post
I think it depends if you compile in Windows or Linux: http://msdn.microsoft.com/en-us/library/wfwda74e.aspx
It's better to stick with /* comments */ since it's not OS dependent.
I'll be sure to switch my comments to the OS-independent type.

------------------------------------------------------------

Thanks again, everyone. I will report back soon. Any other ideas are still welcome.
robtheslob is offline   Reply With Quote

Old   May 16, 2014, 11:46
Default
  #6
Senior Member
 
Andrew Kokemoor
Join Date: Aug 2013
Posts: 122
Rep Power: 14
Kokemoor is on a distinguished road
Quote:
Originally Posted by robtheslob View Post
So... all I need to do is declare my variables at the top? Why is this a requirement?
Some newer languages, including C++, let you declare anywhere, but C requires all declarations at the top.

I can't say much from the build output, but it does have errors, so I'd venture to guess it isn't compiling. Your UDF looks like it should be able to be interpreted, so I'd suggest focusing on that and using errors there to debug.
Kokemoor is offline   Reply With Quote

Old   June 18, 2014, 04:43
Default
  #7
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Were you able to finish this and get it stable?

I tried to model a pump curve boundary condition, but in the opposite way that you did: I calculated the mass flux through the boundary, looked up the corresponding pressure, and applied that as a pressure outlet.
However, during simulation the values (both pressure and mass flux) start oscillating until the simulation diverges. I am considering changing to your approach, but it would be helpful to me to know if you found similar problems.
pakk is offline   Reply With Quote

Old   June 18, 2014, 11:05
Default
  #8
New Member
 
Rob
Join Date: Apr 2014
Posts: 13
Rep Power: 12
robtheslob is on a distinguished road
Hello all,

I just returned after nearly five weeks travelling abroad, and I've been away from ANSYS the entire time. I wanted to make a post about how this issue may be resolved. It's quite simple, really.

Basically, VS 2013 will not work. There was a change in the libraries with 2013. ANSYS has addressed this in Ansys 15.0.7, which is due out in June with some changes to how Fluent finds these new library locations.

If you don't want to wait for the update, you will have to uninstall 2013 and use 2012. This is basically what I did to solve the problem.

For your convenience, I would have loved to attach the document that explains all of the minor steps in detail. However, it appears that it exceeds the forum file size limits at ~300kb. Oh well. Here's what you can search to find the article in ANSYS knowledge resources:

Quote:
Originally Posted by ANSYS Knowledge Resources: Solutions
#2035158
Compiling and Loading User Defined Functions using FLUENT 14.5 or 15.0 and Microsoft Visual Studio 2012 Express (free) Edition running ANSYS Fluent in Serial and Parallel
Feel free to post any other issues you may have and I'll try to help out.

Quote:
Originally Posted by pakk View Post
Were you able to finish this and get it stable?

I tried to model a pump curve boundary condition, but in the opposite way that you did: I calculated the mass flux through the boundary, looked up the corresponding pressure, and applied that as a pressure outlet.
However, during simulation the values (both pressure and mass flux) start oscillating until the simulation diverges. I am considering changing to your approach, but it would be helpful to me to know if you found similar problems.
Hello, pakk.

That's an interesting approach. As I mentioned earlier, I just got back from five weeks of travel. I haven't touched my UDF since I left. Considering I was brand new to them before I left, I have to relearn a bit before I make headway again. However, I will be posting code regularly to this thread. Feel free to ask any questions there, where the pump BC is the topic of discussion.

No, my code wasn't stable when I left; that is, it wasn't exactly doing what I wanted it to, but it did run without issues. I'm having problems that I believe are associated with parallel programming considerations. I have great ANSYS support and will be reaching out to them to get some answers. I will post the short version of what I hear to the pump BC thread when I get more information.
souza.emer likes this.
robtheslob is offline   Reply With Quote

Old   July 24, 2015, 01:53
Default
  #9
New Member
 
Amit soni
Join Date: Jul 2015
Posts: 10
Rep Power: 11
Amit soni is on a distinguished road
Opening library "E:\case run amit\2d\libudf"...
Error: The UDF library you are trying to load (libudf) is not compiled for 3ddp on the curent platform (win64).

The system cannot find the file specified.

I tried all the possible ways, do I have to check the boundary condition?
#include "udf.h"
#include "stdio.h"
#include "stdlib.h"
#include "math.h"
#include "dynamesh_tools.h"
#include "storage.h"
DEFINE_CG_MOTION(object_mov , dt , vel , omega ,time , dtime)
{
real v,a,w,pi;
pi = 3.1415;
a = 0.05;
w = 2*pi*2;
v = 0;
v = -a*w*sin(w*time);
vel[0] = 0;
vel[1] = v;
vel[2] = 0;
}
I tried this simple example as suggested in CFD online forum
Amit soni is offline   Reply With Quote

Reply

Tags
compile, parallel, platform, udfs, win64


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
ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM Rizwan Fluent UDF and Scheme Programming 40 March 18, 2018 07:05
A problem about 'printf' and 'Message' in UDF. LICH Fluent UDF and Scheme Programming 2 May 2, 2013 03:45
Help! Compiled UDF problem 4 Wave tank tutorial Shane FLUENT 1 September 3, 2010 03:32
parallel UDF problem kerem FLUENT 2 June 20, 2006 07:56
problem with running UDF in batch mode James FLUENT 0 June 6, 2006 07:49


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