# How to convert my UDF to parallel?

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

 September 12, 2011, 05:37 How to convert my UDF to parallel? #1 New Member   Thomas Join Date: Aug 2009 Location: France Posts: 12 Rep Power: 10 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. 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); }

 September 13, 2011, 08:23 #2 New Member   Thomas Join Date: Aug 2009 Location: France Posts: 12 Rep Power: 10 Can anyone help me???

 September 22, 2011, 03:51 #3 Member   john Join Date: Nov 2010 Posts: 50 Rep Power: 8 Hi Thomas you have to add #if !RP_HOST and #endif at appropriate places. Dealing with print statement bit tricky. For example i modified your code below. DEFINE_SOURCE(tube_1_source, cell, thread, dS, eqn) { #if !RP_HOST 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; #endif #if RP_HOST return 0.0; #endif Follow something similar for the rest Good luck John

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Lindsay FLUENT 4 June 20, 2016 09:37 Lucy Fluent UDF and Scheme Programming 3 May 28, 2013 13:14 Mahesh FLUENT 2 August 7, 2007 05:34 Haoyin FLUENT 1 August 6, 2007 13:53 yobee FLUENT 0 August 17, 2004 04:12

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