CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > FLUENT

parallelization of a UDF

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

Reply
 
LinkBack Thread Tools Display Modes
Old   September 12, 2011, 11:54
Default parallelization of a UDF
  #1
New Member
 
Thomas
Join Date: Aug 2009
Location: France
Posts: 12
Rep Power: 7
lapin_tout_fou is on a distinguished road
Hi,

I wrote a UDF but don't know exatly how to parallelize it.
I should use some PRF_GRSUM1 or PRF_GRSUM2 but I don't know how exactly.
Thanks

Here is my serial UDF:

#include "udf.h"

#define tension 40

#define rtotal 1000000

FILE *fout;


real intensity;
real r1,r2;
real p1,p2;
real s1,s2;
real t1,t2;
real z1,z2;
real volume1;
real vol_tot1;
real tempo1;
real tavg1;
real rtot;
real val1,val2;
real vol1,vol2;
real moyenne(int id,Domain *domain);

/* global resistance */
real resistance(real a1,real a2)
{
real resist = 0;
resist = (a1+a2);
return resist;
}

/* initialization */
DEFINE_ON_DEMAND(reprise)
{
intensity = 5.5;
r1 = 0.;
r2 = 10.;
}

/* power sources */
DEFINE_SOURCE(tube_1_source, cell, thread, dS, eqn)
{
t1 = val1;
rtot = resistance(r1,r2);
intensity = tension/(rtot);
r1 = (vol1*rtotal)*((1+0.0045*(t1-293)));
z1 = (r1*intensity*intensity);
p1 = z1 /vol1;
return p1;
}
DEFINE_SOURCE(tube_2_source, cell, thread, dS, eqn)
{
t2 = val2;
rtot = resistance(r1,r2);
intensity = tension/(rtot);
r2 = (vol2*rtotal)*((1+0.0045*(t2-293)));
z2 = (r2*intensity*intensity);
p2 = z2 /vol2;
return p2;
}


/* mean temperature function */

real mean(int id,Domain *domain)

{
cell_t c;
Thread *t;
t = Lookup_Thread(domain,id);
tavg1 = 0.;
vol_tot1 = 0;
begin_c_loop(c,t)
{
volume1 = C_VOLUME(c,t);
tempo1 = C_T(c,t);
vol_tot1 += volume1;
tavg1 += tempo1*volume1;
}
end_c_loop(c,t)
tavg1 /= vol_tot1;
return tavg1;
}

/* volume function */

real volume(int id,Domain *domain)

{
cell_t c;
Thread *t;
t = Lookup_Thread(domain,id);
vol_tot1 = 0;
begin_c_loop(c,t)
{
volume1 = C_VOLUME(c,t);
vol_tot1 += volume1;
}
end_c_loop(c,t)
return vol_tot1;

}

/* display */
DEFINE_ADJUST(puissance,domain)
{
val1 = mean(10095,domain);
val2 = mean(10094,domain);
vol1 = volume(10095,domain);
vol2 = volume(10094,domain);

printf(" temperature1 :%g\n" , val1);
printf(" temperature2 :%g\n" , val2);
printf("power 1 :%g\n" , z1);
printf("power 2 :%g\n" , z2);
printf("tube1 resistance:%g\n" , r1);
printf("tube2 resistance:%g\n" , r2);

fout = fopen("case.txt","a+");
fprintf(fout,"%g %g \n", intensity, rtot);
fclose(fout);

printf("intensity : %g\n" , intensity);
}
lapin_tout_fou is offline   Reply With Quote

Reply

Thread Tools
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
UDF parallel error: chip-exec: function not found????? shankara.2 Fluent UDF and Scheme Programming 1 January 16, 2012 22:14
parallelization of serial Fluent UDF for surface reaction sri31049 FLUENT 0 September 8, 2010 14:15
Dynamic Mesh UDF Parallelization sy_aloy FLUENT 0 February 13, 2006 12:14
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 19:35.