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

Global Reductions

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 27, 2013, 18:02
Default Global Reductions
  #1
Senior Member
 
Andrew Kokemoor
Join Date: Aug 2013
Posts: 122
Rep Power: 13
Kokemoor is on a distinguished road
I'm trying to use a global reduction, specifically PRF_GRSUM1, in my parallel interpreted UDF. Seems that it should be pretty straightforward, but I'm getting errors.

Code:
Error: ... line 30: MPT_gdsum1: no function prototype
I went digging around to find how it's defined, and found that prf.h has
Code:
#define PRF_GRSUM1 MPT_GDSUM1
, but no prototype. reductions.h has a prototype, but if I include it, I get the following:

Code:
Error: C:\\PROGRA~1\\ANSYSI~1\\v145\\fluent\\fluent14.5.0/multiport/src/reductions.h: line 393: MPT_check has already been defined in the current frame
Does anyone know anything about how this is all put together? Why isn't this covered by including udf.h?
Kokemoor is offline   Reply With Quote

Old   November 27, 2014, 10:16
Default
  #2
New Member
 
Rudi
Join Date: Jun 2014
Posts: 14
Rep Power: 11
rudofly is on a distinguished road
Dear Andrew,

I am facing the same problem interpreting in Fluent's parallel mode. I have tried to avoid multiple definition by preprocessor statements in the usual pattern. But it didn't prevent reinterpreting of the files.
Code:
#ifndef SOMETHING
#include <udf.h>
#include <sg_ls.h>
#define SOMETHING
#endif
Have you been able to solve your problem?

Best regards,

Rudi
rudofly is offline   Reply With Quote

Old   December 1, 2014, 11:17
Default
  #3
Senior Member
 
Andrew Kokemoor
Join Date: Aug 2013
Posts: 122
Rep Power: 13
Kokemoor is on a distinguished road
In the end, I ended up compiling my UDF. Not sure if that's what fixed it, or if I did something else, but my final UDF #includes udf.h and nothing else.
Kokemoor is offline   Reply With Quote

Old   December 2, 2014, 09:34
Default
  #4
New Member
 
Rudi
Join Date: Jun 2014
Posts: 14
Rep Power: 11
rudofly is on a distinguished road
Upon your hint, I have removed sg_ls.h from includes. Instead I 'exported', which is to say I copied, the definition I needed into my file.

Interpreting it went through without redefinition error :-) Thanks!

Rudi
rudofly is offline   Reply With Quote

Old   September 16, 2019, 05:43
Default I met the same problem
  #5
New Member
 
WANG LU
Join Date: Sep 2019
Posts: 22
Rep Power: 6
smilingwl is on a distinguished road
I have found the reductions.h,but,I can't find the define of the MPT_GDSUM1,could you tell me the define of the MPT_GDSUM1
smilingwl is offline   Reply With Quote

Old   September 23, 2019, 06:23
Default
  #6
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 33
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
use PRF_GRSUM1 for global redution

read ansys fluent customization manual for more details

best regards
AlexanderZ is offline   Reply With Quote

Old   September 25, 2019, 04:55
Default
  #7
New Member
 
WANG LU
Join Date: Sep 2019
Posts: 22
Rep Power: 6
smilingwl is on a distinguished road
Dear AlexanderZ:

Thank you so much for your answer.
The advice you suggested I have tried, but it still goes wrong.
It shows MPT_gdsum1: no function prototype.
I have no idea how to adjust my UDF.
My code as follow, could you tell me what is going wrong?

#include "udf.h"
#include "prf.h"

DEFINE_EXECUTE_AT_END(centroid)
{
#if !RP_HOST
real wcx = 0.0;
real wcy = 0.0;
real va_liq = 0.0;
real cx, cy;
real x, y;
cell_t c;
real z[ND_ND];
Domain *subdomain= Get_Domain(3);
Thread *t;
#endif
#if !RP_NODE
FILE *fout1;
FILE *fout2;
#endif
#if !RP_HOST
thread_loop_c(t,subdomain)
{
begin_c_loop(c, t)
{
if(0.5<=C_VOF(c,t)&&C_VOF(c,t)<=1.0)
{
va_liq = va_liq + C_VOLUME(c,t);
C_CENTROID(z,c,t);
wcx = wcx + z[0]*C_VOLUME(c,t);
wcy = wcy + z[1]*C_VOLUME(c,t);
}
}
end_c_loop(c, t)
}
va_liq = PRF_GDSUM1(va_liq);
wcx = PRF_GDSUM1(wcx);
wcy = PRF_GDSUM1(wcy);
cx = wcx/va_liq;
cy = wcy/va_liq;
#endif
#if !RP_NODE
fout1 = fopen("X-centroid of liquid.txt","a");
fout2 = fopen("Y-centroid of liquid.txt","a");
#endif
node_to_host_real_2(cx, cy);
#if RP_HOST
fprintf(fout1,"%g,%g\n",CURRENT_TIME,cx);
fprintf(fout2,"%g,%g\n",CURRENT_TIME,cy);
#endif
#if !RP_NODE
fclose(fout1);
fclose(fout2);
Message("\n X-centroid of liquid = %g\n", cx);
Message("\n Y-centroid of liquid = %g\n", cy);
#endif

}
Thanks a lot.
Best regards.
Wang Lu
smilingwl is offline   Reply With Quote

Old   September 25, 2019, 06:09
Default
  #8
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 33
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
Code:
#include "udf.h"
#include "prf.h"

DEFINE_EXECUTE_AT_END(centroid) 
{
real wcx = 0.0; 
real wcy = 0.0;
real va_liq = 0.0; 
real cx, cy; 
real x, y;
cell_t c; 
real z[ND_ND]; 
Domain *subdomain= Get_Domain(3); 
Thread *t; 
#if !RP_NODE
FILE *fout1;
FILE *fout2;
#endif
#if !RP_HOST
thread_loop_c(t,subdomain) 
{
begin_c_loop(c, t) 
{ 
if(0.5<=C_VOF(c,t)&&C_VOF(c,t)<=1.0) 
{
va_liq = va_liq + C_VOLUME(c,t); 
C_CENTROID(z,c,t); 
wcx = wcx + z[0]*C_VOLUME(c,t); 
wcy = wcy + z[1]*C_VOLUME(c,t); 
}
} 
end_c_loop(c, t) 
}
va_liq = PRF_GDSUM1(va_liq);
wcx = PRF_GDSUM1(wcx);
wcy = PRF_GDSUM1(wcy);
cx = wcx/va_liq;
cy = wcy/va_liq;
#endif
#if !RP_NODE
fout1 = fopen("X-centroid of liquid.txt","a");
fout2 = fopen("Y-centroid of liquid.txt","a");
#endif
node_to_host_real_2(cx, cy);
#if RP_HOST
fprintf(fout1,"%g,%g\n",CURRENT_TIME,cx);
fprintf(fout2,"%g,%g\n",CURRENT_TIME,cy);
#endif
#if !RP_NODE
fclose(fout1);
fclose(fout2);
Message("\n X-centroid of liquid = %g\n", cx);
Message("\n Y-centroid of liquid = %g\n", cy);
#endif

}
this code is complied with no error

best regards
AlexanderZ is offline   Reply With Quote

Old   September 25, 2019, 08:23
Default
  #9
New Member
 
WANG LU
Join Date: Sep 2019
Posts: 22
Rep Power: 6
smilingwl is on a distinguished road
Dear AlexanderZ:
Thank you for your answer. But when I interpret it, it gets wrong,I don't know what is up. Can you try to interpret my code in your fluent?I know it's rude to ask that. But I really want to know what is going up,my system or something else.
Thank you a lot.
Best regards.
Wang Lu.
smilingwl is offline   Reply With Quote

Old   September 25, 2019, 22:35
Default
  #10
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 33
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
As I've told, compile this code and try to run it

best regards
AlexanderZ is offline   Reply With Quote

Old   September 25, 2019, 23:42
Default
  #11
New Member
 
WANG LU
Join Date: Sep 2019
Posts: 22
Rep Power: 6
smilingwl is on a distinguished road
Thanks a lot for your answer.
Best regards!
Wang Lu
smilingwl is offline   Reply With Quote

Old   September 26, 2019, 04:54
Default
  #12
New Member
 
WANG LU
Join Date: Sep 2019
Posts: 22
Rep Power: 6
smilingwl is on a distinguished road
Dear AlexanderZ:
Thank you for your answer.
I still can not compile my code.
When I compile my code ,it shows error like "The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform (win64)".
Do you know what's wrong?
Beat regards!
Wang Lu
smilingwl is offline   Reply With Quote

Old   September 26, 2019, 21:11
Default
  #13
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 33
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
this code, which I've attached, is compiled well

to compile code:
run fluent from visual studio command prompt (or SDK command prompt) -> user defined -> functions -> compiled -> BUILD

best regards
AlexanderZ is offline   Reply With Quote

Old   September 27, 2019, 09:48
Default
  #14
New Member
 
WANG LU
Join Date: Sep 2019
Posts: 22
Rep Power: 6
smilingwl is on a distinguished road
Dear AlexanderZ:
Thank you for your answer.I just did what you have told,but it still shows wrong.I made a video which recorded what I did and upload on the website as follow,so that you can know what I have done.

https://user.qzone.qq.com/651668162/main
Best regards!
Wang Lu
smilingwl is offline   Reply With Quote

Old   September 27, 2019, 10:17
Default
  #15
New Member
 
WANG LU
Join Date: Sep 2019
Posts: 22
Rep Power: 6
smilingwl is on a distinguished road
Dear AlexanderZ

I need to change the website to
https://user.qzone.qq.com/651668162

Best regards!
Wang Lu
smilingwl is offline   Reply With Quote

Old   September 28, 2019, 10:04
Default
  #16
New Member
 
WANG LU
Join Date: Sep 2019
Posts: 22
Rep Power: 6
smilingwl is on a distinguished road
Dear AlexanderZ
Today,I try to compile my UDF,and run my Fluent. The UDF can be compiled,but it can't output the file, and the case interrupt.I think my UDF still have the coding error. Could you help me correct my UDF.
Blessing to you.
WangLu
smilingwl is offline   Reply With Quote

Old   September 28, 2019, 10:32
Default
  #17
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Show what is written on your screen after you click "build". (not what happens after you click "load").

It might be in your video, but I am not going to watch a video.
pakk is offline   Reply With Quote

Old   September 28, 2019, 22:00
Default
  #18
New Member
 
WANG LU
Join Date: Sep 2019
Posts: 22
Rep Power: 6
smilingwl is on a distinguished road
Dear pakk:
Thank you for your answer.It shows as follow:
Copied F:\wldaoliuban\case\25_4/F:\wldaoliuban\case\25_4\centroid_parallel_wl.c to libudf\src
Copied F:\wldaoliuban\case\25_4/F:\wldaoliuban\case\25_4\udf.h to libudf\src
Creating user_nt.udf file for 3ddp_host ...
(system "copy "D:\ANSYS\ANSYS Inc\v180\fluent"\fluent18.0.0\src\udf\makefile_nt. udf "libudf\win64\3ddp_host\makefile" ")
已复制 1 个文件。
(chdir "libudf")(chdir "win64\3ddp_host")# Generating ud_io1.h
centroid_parallel_wl.c
# Generating udf_names.c because of makefile centroid_parallel_wl.obj
udf_names.c
# Linking libudf.dll because of makefile user_nt.udf udf_names.obj centroid_parallel_wl.obj
Microsoft (R) Incremental Linker Version 12.00.21005.1
Copyright (C) Microsoft Corporation. All rights reserved.

正在创建库 libudf.lib 和对象 libudf.exp
Creating user_nt.udf file for 3ddp_node ...
(system "copy "D:\ANSYS\ANSYS Inc\v180\fluent"\fluent18.0.0\src\udf\makefile_nt. udf "libudf\win64\3ddp_node\makefile" ")
已复制 1 个文件。
(chdir "libudf")(chdir "win64\3ddp_node")# Generating ud_io1.h
centroid_parallel_wl.c
# Generating udf_names.c because of makefile centroid_parallel_wl.obj
udf_names.c
# Linking libudf.dll because of makefile user_nt.udf udf_names.obj centroid_parallel_wl.obj
Microsoft (R) Incremental Linker Version 12.00.21005.1
Copyright (C) Microsoft Corporation. All rights reserved.

正在创建库 libudf.lib 和对象 libudf.exp

Done.
Best regards!
WangLu
smilingwl is offline   Reply With Quote

Old   September 29, 2019, 22:44
Default
  #19
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 33
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
try to run this code
Code:
#include "udf.h"
#include "prf.h"

DEFINE_EXECUTE_AT_END(centroid) 
{
real wcx = 0.0; 
real wcy = 0.0;
real va_liq = 0.0; 
real cx, cy; 
real x, y;
cell_t c; 
real z[ND_ND]; 
Domain *subdomain= Get_Domain(3); 
Thread *t; 
#if !RP_NODE
FILE *fout1;
FILE *fout2;
#endif
#if !RP_HOST
thread_loop_c(t,subdomain) 
{
begin_c_loop(c, t) 
{ 
if(0.5<=C_VOF(c,t)&&C_VOF(c,t)<=1.0) 
{
va_liq = va_liq + C_VOLUME(c,t); 
C_CENTROID(z,c,t); 
wcx = wcx + z[0]*C_VOLUME(c,t); 
wcy = wcy + z[1]*C_VOLUME(c,t); 
}
} 
end_c_loop(c, t) 
}
va_liq = PRF_GISUM1(va_liq);
wcx = PRF_GISUM1(wcx);
wcy = PRF_GISUM1(wcy);
cx = wcx/va_liq;
cy = wcy/va_liq;
Message0("cx cy where calculated successfully\n");
#endif
#if !RP_NODE
fout1 = fopen("X-centroid of liquid.txt","a");
fout2 = fopen("Y-centroid of liquid.txt","a");
Message0("store files where opened \n");
#endif
node_to_host_real_2(cx, cy);
#if RP_HOST
fprintf(fout1,"%g,%g\n",CURRENT_TIME,cx);
fprintf(fout2,"%g,%g\n",CURRENT_TIME,cy);
Message0("data stored successfully \n\n");
#endif
#if !RP_NODE
fclose(fout1);
fclose(fout2);
Message0("\n X-centroid of liquid = %g\n", cx);
Message0("\n Y-centroid of liquid = %g\n", cy);
#endif

}
if there still be problems -> show you console output

best regards
AlexanderZ is offline   Reply With Quote

Old   October 3, 2019, 00:43
Default
  #20
New Member
 
WANG LU
Join Date: Sep 2019
Posts: 22
Rep Power: 6
smilingwl is on a distinguished road
Dear AlexanderZ:
Thank you so much to help me correct my UDF. I am so happy to see my case run well with the UDF. But it still has a little error. The result in the text the case output is different with the result in the serial veision.
It shows :"0.01,-1.#IND"
In the serial version, it shows:"0.01,0.053456"
Do you know what's wrong?
Thank you again.
Best Regards!
Wanglu
smilingwl 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
AMI interDyMFoam for mixer nu problem danny123 OpenFOAM Programming & Development 8 September 6, 2013 03:34
How to write k and epsilon before the abnormal end xiuying OpenFOAM Running, Solving & CFD 8 August 27, 2013 16:33
Upgraded from Karmic Koala 9.10 to Lucid Lynx10.04.3 bookie56 OpenFOAM Installation 8 August 13, 2011 05:03
IcoFoam parallel woes msrinath80 OpenFOAM Running, Solving & CFD 9 July 22, 2007 03:58
Could anybody help me see this error and give help liugx212 OpenFOAM Running, Solving & CFD 3 January 4, 2006 19:07


All times are GMT -4. The time now is 02:09.