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

Something is wrong with DEFINE_EXECUTE_AT_END in my parallel UDF (attached pictured)

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By DungPham

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 16, 2014, 21:43
Smile Something is wrong with DEFINE_EXECUTE_AT_END in my parallel UDF (attached pictured)
  #1
New Member
 
Dustin
Join Date: Sep 2011
Location: Earth
Posts: 23
Rep Power: 14
DungPham is on a distinguished road
Please help me fix this code (the serial process give a true value, but wrong and strange in the parallel processes):


PHP Code:
#include "udf.h"
#include "math.h"
#include "metric.h"
#include "stdio.h"
#include "time.h"
#include "sg_mphase.h"

DEFINE_EXECUTE_AT_END(liquid_holdup)
{
    
    
real liquid_vol 0.cell_vol 0.;
#if !RP_HOST
    
Domain *mix_domain Get_Domain(1);
    
Thread *t;
    
Thread **pt;
    
cell_t c;
#endif

#if !RP_HOST
    
mp_thread_loop_c (tmix_domain,pt)
    if (
FLUID_THREAD_P(t))
    {
        
begin_c_loop_int (c,t)
            {
                
liquid_vol += C_VOF(c,pt[0])*C_VOLUME(c,t); /*pt[0] is primary phase*/
                
cell_vol += C_VOLUME(c,t);
                
C_UDMI(c,t,1) = liquid_vol/cell_vol/*storage the liquid holdup*/
            
}
        
end_c_loop_int (c,t)
    }
#endif

#if !RP_HOST
    
Message("\n_____________The liquid holdup = %g / %g = %g___________\n\n"liquid_volcell_volliquid_vol/cell_vol);
#endif


Parallel:




Serial:



Thank for reading!
Attached Images
File Type: jpg parallel.jpg (51.4 KB, 117 views)
File Type: jpg serial.jpg (39.4 KB, 115 views)
DungPham is offline   Reply With Quote

Old   February 17, 2014, 11:14
Default
  #2
New Member
 
Dustin
Join Date: Sep 2011
Location: Earth
Posts: 23
Rep Power: 14
DungPham is on a distinguished road
Woa!

I fixed it successfully!

This is new code:

PHP Code:
DEFINE_EXECUTE_AT_END(liquid_holdup)
{
    
int thread_id=0;
    
real liquid_vol 0.cell_vol 0.;
#if !RP_HOST
    
Domain *mix_domain Get_Domain(1);
    
Thread *t;
    
Thread **pt;
    
cell_t c;
#endif

#if !RP_NODE /* SERIAL or HOST */
    
thread_id RP_Get_Integer("thread-id");
    
Message("\nCalculating on Thread # %d\n",thread_id);
#endif /* !RP_NODE */

host_to_node_int_1(thread_id);

#if RP_NODE 
    //Message("\nNode %d is calculating on thread # %d\n",myid,thread_id);
#endif /* RP_NODE */

#if !RP_HOST
    
Lookup_Thread(mix_domain,thread_id);
    
mp_thread_loop_c (tmix_domain,pt)
    if (
FLUID_THREAD_P(t))
        {
            
begin_c_loop_int (c,t)
                {
                    
liquid_vol += C_VOF(c,pt[0])*C_VOLUME(c,t); /*pt[0] is primary phase*/
                    
cell_vol += C_VOLUME(c,t);
                }
            
end_c_loop_int (c,t)
                
//Message("____liquid_vol: %f\n",liquid_vol);
                //Message("____cell_vol: %f\n",cell_vol);
        
}
    
# if RP_NODE 
        /* Perform node synchronized actions here.Does nothing in Serial */
        
liquid_vol PRF_GRSUM1(liquid_vol);
        
cell_vol PRF_GRSUM1(cell_vol);
    
# endif /* RP_NODE */
#endif

node_to_host_real_2(liquid_vol,cell_vol);

#if !RP_HOST
    
Lookup_Thread(mix_domain,thread_id);
    
mp_thread_loop_c (tmix_domain,pt)
    if (
FLUID_THREAD_P(t))
        {
            
begin_c_loop_int (c,t)
                {
                    
C_UDMI(c,t,1) = liquid_vol/cell_vol/*storage the liquid holdup*/
                
}
            
end_c_loop_int (c,t)
        }
#endif

#if !RP_NODE
    
Message("\n_____________The liquid holdup = %g / %g = %g___________\n\n",liquid_vol,cell_vol,liquid_vol/cell_vol);
#endif

macfly likes this.
DungPham 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
UDF for linear temperature profile on horizontal parallel surfaces. Chirag2302 Fluent UDF and Scheme Programming 0 February 4, 2012 00:44
Parallel UDF sham83 Fluent UDF and Scheme Programming 5 May 31, 2011 07:55
problem to make a UDF parallel pilou Fluent UDF and Scheme Programming 0 March 9, 2011 06:35
Parallel UDF ccc FLUENT 0 December 3, 2004 22:17
What's wrong with my UDF? olivia FLUENT 1 June 23, 2001 17:06


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