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

Running UDF in Parallel Mode

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By AlexanderZ

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 22, 2020, 18:39
Default Running UDF in Parallel Mode
  #1
New Member
 
sina hassanpoor
Join Date: Jun 2019
Posts: 4
Rep Power: 7
sinaited is on a distinguished road
Hi everyone, hope you be healthy!
i wrote this udf for calculating the average pressure on a wall, but i think it only can be interpret in serial and i should rewrite this code for parallel or linux node, anyone can help me or rerwite it?




#include "udf.h"
real pavg;
DEFINE_EXECUTE_AT_END(average_pressure)
{
Domain *d;
face_t f;
real pressure = 0.0;
real A[ND_ND];
real area = 0.0;
real area_tot = 0.0;
int ID = 7; /*this is the ID of the boundary wall that I want to get the temperature from*/
Thread *t;
int zone_ID;
d = Get_Domain(1);
t = Lookup_Thread(d,ID);
pavg = 0.0;
begin_f_loop(f,t)
{
F_AREA(A,f,t);
area = NV_MAG(A)*2.0*M_PI; /*AREA*/
area_tot += area;
pressure = F_P(f,t); pavg += pressure*area;
Message ("Text %g \n", pavg);
}
end_f_loop(f,t)
pavg /= area_tot;
printf("Pavg = %g area_tot = %g\n",pavg,area_tot);
Message ("Text %g \n", pavg);
}

DEFINE_CG_MOTION(move_body, dt, vel,omega, time, dtime)
{
real ome,Ra,A,B;
/* reset velocities */
NV_S(vel,=,0.0);
NV_S(omega,=,0.0);
/* motion */
ome=pavg / 1000;
vel[0] = 0.0;
vel[1] = ome;
vel[2] = 0.0;
omega[0] = 0.0;
omega[1] = 0.0;
omega[2] = 0.0;
}
sinaited is offline   Reply With Quote

Old   July 26, 2020, 22:47
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
compile the code
Code:
#include "udf.h"
real pavg;
DEFINE_EXECUTE_AT_END(average_pressure)
{
Domain *d;
face_t f;
real pressure = 0.0;
real A[ND_ND];
real area = 0.0;
real area_tot = 0.0;
int ID = 7; /*this is the ID of the boundary wall that I want to get the temperature from*/
Thread *t;
int zone_ID;
d = Get_Domain(1);
t = Lookup_Thread(d,ID);
pavg = 0.0;
begin_f_loop(f,t)
{
F_AREA(A,f,t);
area = NV_MAG(A)*2.0*M_PI; /*AREA*/
area_tot += area;
pressure = F_P(f,t); pavg += pressure*area;
Message0("Text %g \n", pavg);
}
end_f_loop(f,t)
#if RP_NODE
	area_tot = PRF_GRSUM1(area_tot);
#endif
pavg /= area_tot;
Message0("Pavg = %g area_tot = %g\n",pavg,area_tot);
Message0("Text %g \n", pavg);
}

DEFINE_CG_MOTION(move_body, dt, vel,omega, time, dtime)
{
real ome,Ra,A,B;
/* reset velocities */
NV_S(vel,=,0.0);
NV_S(omega,=,0.0);
/* motion */
ome=pavg / 1000;
vel[0] = 0.0;
vel[1] = ome;
vel[2] = 0.0;
omega[0] = 0.0;
omega[1] = 0.0;
omega[2] = 0.0;
}
sinaited likes this.
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   July 27, 2020, 06:15
Default
  #3
New Member
 
sina hassanpoor
Join Date: Jun 2019
Posts: 4
Rep Power: 7
sinaited is on a distinguished road
Thanks a lot alexander, it worked for area and based on that, i corrected it for pressure
sinaited 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
parallel implementation of DEFINE_INIT UDF not working eml51 Fluent UDF and Scheme Programming 1 January 28, 2019 22:26
Running parallel case after parallel meshing with snappyHexMesh? Adam Persson OpenFOAM Running, Solving & CFD 0 August 31, 2015 23:04
simpleFoam parallel AndrewMortimer OpenFOAM Running, Solving & CFD 12 August 7, 2015 19:45
problem with compiling boundary condition udf in parallel mode chem engineer Fluent UDF and Scheme Programming 11 June 29, 2015 07:23
[PyFoam] Problems with the new PyFoam release zfaraday OpenFOAM Community Contributions 13 December 9, 2014 19:58


All times are GMT -4. The time now is 15:58.