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

Error of UDF paralization (libudf.dll : fatal error LNK1120: 4 )

Register Blogs Community New Posts Updated Threads Search

Like Tree4Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 10, 2020, 23:01
Wink Error of UDF paralization (libudf.dll : fatal error LNK1120: 4 )
  #1
New Member
 
Steve
Join Date: Mar 2020
Location: Beijing
Posts: 17
Rep Power: 6
nimadeCFD is on a distinguished road
Hello everyone. This is my first thread to ask for help. I do appreciate any help from you. In fact, I tried to search any useful tips by searching relevant threads in cfdOnline as well as on Google, but I failed. Therefore, the question troubling me for a long time is posted here as bellows:
1. I wanna parallelize a piece UDF code (it can be interpreted/compiled in serial and is shown at the end) to enable it run in HPC environment. However, when I add '#if !RP_HOST and #endif' and open Fluent in parallel, I receive the notice on the TUI after compiling the UDF:
(chdir "libudf3")(chdir "win64\3ddp_host")# Linking libudf.dll because of makefile user_nt.udf udf_names.obj nanofluid-parallel.obj
Microsoft (R) Incremental Linker Version 10.00.40219.01
Copyright (C) Microsoft Corporation. All rights reserved.


udf_names.obj : error LNK2001:
udf_names.obj : error LNK2001:
udf_names.obj : error LNK2001:
udf_names.obj : error LNK2001:
libudf.dll : fatal error LNK1120: 4
udf_names.c and user_nt.udf files in 3ddp_node are upto date.
(system "copy "E:\ansys18\ANSYSI~1\v180\fluent"\fluent18.0.0\src \udf\makefile_nt.udf "libudf3\win64\3ddp_node\makefile" ")
1 file(s) copied.
(chdir "libudf3")(chdir "win64\3ddp_node")# Linking libudf.dll because of makefile user_nt.udf udf_names.obj nanofluid-parallel.obj
Microsoft (R) Incremental Linker Version 10.00.40219.01
Copyright (C) Microsoft Corporation. All rights reserved.


udf_names.obj : error LNK2001:
udf_names.obj : error LNK2001:
udf_names.obj : error LNK2001:
udf_names.obj : error LNK2001:
libudf.dll : fatal error LNK1120: 4
2. Then I tried to load it, and certainly got an error:
Error: The UDF library you are trying to load (libudf3) is not compiled for parallel use on the current platform (win64).\n\nThe system cannot find the file specified.
\n\nF:\...*\libudf3\win64\3ddp_host\libudf.dll
Error Object: #f
3. My code:
#include "udf.h"
#include "math.h"
DEFINE_PROFILE(flux_profile,t,i)
{
real x[ND_ND];
real z;
real y;
real xx;
real theta;
face_t f;
#if !RP_HOST
begin_f_loop(f,t)
{
F_CENTROID(x,f,t);
xx=x[0];
y=x[1];
z=x[2];
theta=atan(y/xx);
if(xx>0)
F_PROFILE(f,t,i)=960000*cos(theta);
}
end_f_loop(f,t)
#endif
}

Sincerely thank you for any favour.
Attached Files
File Type: c test.c (913 Bytes, 2 views)

Last edited by nimadeCFD; March 11, 2020 at 08:02. Reason: attach file
nimadeCFD is offline   Reply With Quote

Old   March 11, 2020, 02:53
Default Code
  #2
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
There are three simple changes required to be made

1. Remove math.h. It is is not required but is not the cause of error
2. Move #if !RP_HOST just after the opening brace. This is the root cause.
3. While using profile UDF for a boundary, the numbers are assigned only by the UDF. So, for any faces lying on negative x the field values could be very high because those are not being explicitly given in the code. So, add an else after the if and provide values accordingly. A better approach is to create a new real variable, assign value to this variable within if - else and then assign F_PROFILE to that variable. If there are no faces with negative x-coordinate then if condition is not required.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   March 11, 2020, 03:58
Default
  #3
New Member
 
Steve
Join Date: Mar 2020
Location: Beijing
Posts: 17
Rep Power: 6
nimadeCFD is on a distinguished road
Thank you, vinerm.
I modify the UDF as follow. However, the error still exist. Now I am wondering there is something wrong in the fluent software. I use Fluent 18.0 in Windows 10.

Code:

#include "udf.h"

DEFINE_PROFILE(flux_profile,t,i)
{
#if !RP_HOST
real x[ND_ND];
real z;
real y;
real xx;
real theta;
face_t f;
begin_f_loop(f,t)
{
F_CENTROID(x,f,t);
xx=x[0];
y=x[1];
z=x[2];
theta=atan(y/xx);
if(xx>0)
F_PROFILE(f,t,i)=960000*exp(-18*pow((z-0.5),2))*cos(theta);
else
F_PROFILE(f,t,i)= 0.;
}
end_f_loop(f,t)
#endif
}
nimadeCFD is offline   Reply With Quote

Old   March 11, 2020, 04:07
Default Linker Error
  #4
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
The error being shown is related to linking, i.e., it is unable to find the references for the functions used. Can you attach your C file in the post instead?
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   March 11, 2020, 04:40
Default
  #5
New Member
 
Steve
Join Date: Mar 2020
Location: Beijing
Posts: 17
Rep Power: 6
nimadeCFD is on a distinguished road
Thank you for your prompt reply.
I will attach C files here. But I don't know what specific files I need to submit. Sorry. Are the header files like udfconfig or udfconfig-host I should attach? which I find exist in the same directory except the UDF code attached in the former answer.

Apologize again since I don't know how and what need to be attached.
nimadeCFD is offline   Reply With Quote

Old   March 11, 2020, 04:48
Default C source
  #6
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
Only the C file. And also a snapshot of the window where you build the library, i.e., the window where you have Build Icon.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   March 11, 2020, 05:25
Default
  #7
New Member
 
Steve
Join Date: Mar 2020
Location: Beijing
Posts: 17
Rep Power: 6
nimadeCFD is on a distinguished road
C code shown as below:
#include "udf.h"

DEFINE_PROFILE(flux_profile,t,i)
{
#if !RP_HOST
real x[ND_ND];
real z;
real y;
real xx;
real theta;
face_t f;
begin_f_loop(f,t)
{
F_CENTROID(x,f,t);
xx=x[0];
y=x[1];
z=x[2];
theta=atan(y/xx);
if(xx>0)
F_PROFILE(f,t,i)=960000*exp(-18*pow((z-0.5),2))*cos(theta);
else
F_PROFILE(f,t,i)= 0.;
}
end_f_loop(f,t)
#endif
}

I paste the snipped capture here. But I doubt whether it is successful or not.

Thank you again
nimadeCFD is offline   Reply With Quote

Old   March 11, 2020, 05:26
Default
  #8
New Member
 
Steve
Join Date: Mar 2020
Location: Beijing
Posts: 17
Rep Power: 6
nimadeCFD is on a distinguished road
nimadeCFD is offline   Reply With Quote

Old   March 11, 2020, 05:42
Default The file
  #9
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
Could you attach .c file instead of copying the code in the post? It makes a difference.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   March 11, 2020, 07:18
Default
  #10
New Member
 
Steve
Join Date: Mar 2020
Location: Beijing
Posts: 17
Rep Power: 6
nimadeCFD is on a distinguished road
Thank you, Vinerm.

I cost about one and half hour, but I still don't know how to upload a file in CFDonline.

I am a rookie.

Sincerely apologize.
nimadeCFD is offline   Reply With Quote

Old   March 11, 2020, 07:23
Default
  #11
New Member
 
Steve
Join Date: Mar 2020
Location: Beijing
Posts: 17
Rep Power: 6
nimadeCFD is on a distinguished road
https://pan.baidu.com/s/1efBlb7hTzMijEzcVOO84rw
nimadeCFD is offline   Reply With Quote

Old   March 11, 2020, 07:29
Default
  #12
New Member
 
Steve
Join Date: Mar 2020
Location: Beijing
Posts: 17
Rep Power: 6
nimadeCFD is on a distinguished road
Dear Vinerm,

I doubt whether the file I attached is not what you want to see. For convenience, I will send you the C file via email if you permit.
nimadeCFD is offline   Reply With Quote

Old   March 11, 2020, 07:35
Default Attachment
  #13
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
Instead of using third party links, I'd suggest you to use the option within the post. Look for pin symbol adjacent to the Smiley when you are writing a post. That option is to be used to attach a C file. I am afraid I won't be able to access baidu.com due to security reasons.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   March 11, 2020, 08:03
Default
  #14
New Member
 
Steve
Join Date: Mar 2020
Location: Beijing
Posts: 17
Rep Power: 6
nimadeCFD is on a distinguished road
Dear Vinerm,
I get it. Now I‘ve edited the post and attached the C file. Thank you for your tips.
nimadeCFD is offline   Reply With Quote

Old   March 11, 2020, 08:17
Default The precompiler directives
  #15
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
That's why it is important to look at the file. You have space before precompiler directives. You cannot use space before #if and #endif. They should start from first column.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   March 11, 2020, 08:42
Default
  #16
New Member
 
Steve
Join Date: Mar 2020
Location: Beijing
Posts: 17
Rep Power: 6
nimadeCFD is on a distinguished road
Dear Vinerm,
I modify the UDF code by deleting the space. Unfortunately, the error still exists.



I attach the snipped pictures of the setting of the fluent launch interface for your perusal.
This problem is troublesome for me. Thank you for your constant help.
nimadeCFD is offline   Reply With Quote

Old   March 11, 2020, 08:55
Default Fluent launch
  #17
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
I was able to compile it. It appears that you are starting Fluent directly. Instead, start Fluent using command from the Developer command prompt of VS. Go to Start and then search for Developer command prompt. Start Fluent from there and then compile.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   March 11, 2020, 09:16
Default
  #18
New Member
 
Steve
Join Date: Mar 2020
Location: Beijing
Posts: 17
Rep Power: 6
nimadeCFD is on a distinguished road
Dear Vinerm,
I opened the VS 2010, and click the ->file->new project->search' Developer command prompt'. But it shows this item doesn't exist. Then I open the control panel and search whole applications. There isn't developer command prompt app, which means I don't install this app. So is it right that I have to install this and relevant Net. frame?
Thank you.
nimadeCFD is offline   Reply With Quote

Old   March 11, 2020, 09:21
Default
  #19
New Member
 
Steve
Join Date: Mar 2020
Location: Beijing
Posts: 17
Rep Power: 6
nimadeCFD is on a distinguished road
Hi Vinerm,
Meanwhile, I interpret and compile a same UDF in a simple 2D model in serial. However, I find the difference, though the UDF can be implemented by two different ways. On other word, the result related to the compiled UDF is wrong. Maybe I need to rebuild the compile environment.
nimadeCFD is offline   Reply With Quote

Old   March 11, 2020, 09:22
Default Not within VS
  #20
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
You do not need to open VS. Just go to Start Menu in Windows and find Developer or x64 or x86 command prompt. This is different from general command prompt.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Reply

Tags
error, libudf, paralization, udf


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
Dynamic Mesh UDF Qureshi FLUENT 7 March 23, 2017 07:37
How to add a UDF to a compiled UDF library kim FLUENT 3 October 26, 2011 21:38
UDF problems...FATAL ERROR! Paolo Lampitella FLUENT 1 September 8, 2005 10:07
UDF...UDF...UDF...UDF Luc SEMINEL FLUENT 0 November 25, 2002 04:03
UDF, UDF, UDF, UDF Luc SEMINEL Main CFD Forum 0 November 25, 2002 04:01


All times are GMT -4. The time now is 20:28.