# Problems with UDF in parallel mode

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

 October 2, 2015, 08:48 Problems with UDF in parallel mode #1 New Member   Rikard Join Date: Sep 2015 Posts: 4 Rep Power: 3 Sponsored Links Hi! I have written a UDF to calculate the average value of a passive scalar at the outlet boundary to use it as a prescribed value at the inlet. The code works fine when in serial mode but not in parallel. seems like only one of the cores got the right value!? or how to express it. Would be very pleased if someone knows what's wrong or could guide me in right direction! see code below #include "udf.h" #include "mem.h" real concavg, concavg1; real conc; DEFINE_EXECUTE_AT_END(out_ave) { Domain *d; real area, real area_tot; real A[ND_ND]; Thread *t; face_t f; d=Get_Domain(1); t=Lookup_Thread(d,5); area=0; area_tot=0; conc=0; concavg=0; concavg1=0; begin_f_loop(f,t) { F_AREA(A,f,t); area=NV_MAG(A); area_tot+=area; conc=F_UDSI(f, t, 0); concavg += conc*area; concavg1=concavg/area_tot; printf("\n area_tot = %f\n",area_tot); /*print once for every cell face on outlet, counts to the right area, OK!*/ printf("\n concavg = %f\n",concavg1); /*print once for every cell face on outlet, right value, OK!*/ } end_f_loop(f,t) printf("\n area_tot2 = %f\n",area_tot);/* Print once for every core, first one OK the other three =0??!*/ printf("\n concavg2 = %f\n",concavg1); } DEFINE_PROFILE ( inl_uds, t, i) { face_t face; face_t f; real flow_time, inlvalue; flow_time=RP_Get_Real("flow-time"); if(flow_time<0.5) { begin_f_loop(face, t) { F_PROFILE(face, t, i)=1; } end_f_loop(face, t) } else { begin_f_loop(face, t) { inlvalue=concavg1;/*F_UDMI(f,t,0);*/ F_PROFILE(face, t, i)=inlvalue; } end_f_loop(face, t) } }

 October 6, 2015, 11:17 #2 Senior Member   Bruno Join Date: Mar 2009 Location: Brazil Posts: 279 Rep Power: 14 The documentation has a section about parallelizing UDFs. You can't just use the version you use in serial, since part of the information can't be accessed by all compute nodes. For instance, the averaging procedure you're doing won't work since some of the compute nodes might not have any cells on the zone you're looking for. That is why you're getting a null area on some partitions. Search for Global Reduction Macros in the doc and make the appropriate corrections (but read the entire parallel section to know other things you'll need to change). Cheers.

 Tags parallel, scalar, udf

 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 chem engineer Fluent UDF and Scheme Programming 11 June 29, 2015 06:23 whk1992 OpenFOAM Pre-Processing 8 March 7, 2015 08:53 vespa50l Fluent UDF and Scheme Programming 3 September 22, 2014 11:11 shankara.2 Fluent UDF and Scheme Programming 1 January 16, 2012 23:14 EllenW Fluent UDF and Scheme Programming 5 July 10, 2009 04:31