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

parallel UDF issue in multiphase modeling

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By AlexanderZ

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 28, 2022, 09:59
Default parallel UDF issue in multiphase modeling
  #1
New Member
 
Prasant
Join Date: Sep 2020
Location: India
Posts: 13
Rep Power: 5
PKP_India is on a distinguished road
Hi ...

I need to count the solid cells in the domain and assign the numbers to the solid cells. While running the UDF in series the solid cells are numbered consecutively. but while parallelising the udf to count the solid cells, the count always starts with zero for every comupter node. Due to this the solid cell count assignment stored in UDMI always begins with zero for every comupter node.

I have attached the udf for reference and the udf results. I want to assign the max_count initial value for NODE-1= max_count final value in NODE-0. But in UDF results the max_count initialises always to zero for every NODE. Please suggest me how to assign the max_value before going through every NODE to non-zero value.
Attached Images
File Type: png printf.PNG (79.9 KB, 10 views)
File Type: jpg UDMI-0 data.jpg (67.2 KB, 10 views)
File Type: jpg UDMI-2 data.jpg (79.7 KB, 7 views)
Attached Files
File Type: c UDF.c (1.3 KB, 4 views)
PKP_India is offline   Reply With Quote

Old   November 28, 2022, 19:12
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
Code:
#include "udf.h"
#include "mem.h" 
#include "prf.h"  /// for global sum in parallel udf //
#include "sg_mem.h"  
#include "sg_mphase.h"
#include "para.h"


DEFINE_ADJUST(solid_segregation,mix_domain)
{
	int max_count,shift;
		
	#if !RP_HOST
		
		Domain *meltjet_domain;
		Thread *meltjet_thread;	// meltjet thread pointer //
		cell_t cm;	// melt jet cell identifier //
		meltjet_domain = Get_Domain(3); /* melt jet domain if multiphase */	
		
		thread_loop_c(meltjet_thread, meltjet_domain)  //loops over all cell threads in domain//
		{
			begin_c_loop_int(cm, meltjet_thread)
			{
				shift+=1.0;
			}
			end_c_loop_int(cm, meltjet_thread)
		}
		
		thread_loop_c(meltjet_thread, meltjet_domain)  //loops over all cell threads in domain//
		{
			Message("I am in the node process: %d\n", myid);
			Message("max_count at beginning of loop: %d\n", max_count);
			begin_c_loop_int(cm, meltjet_thread)
			{
				max_count+=1.0;
				if (C_VOF(cm,meltjet_thread) >= 0.5 && C_LIQF(cm, meltjet_thread) <= 0.90)
				{
					C_UDMI(cm, meltjet_thread,0)=1.0; // identify the solid cell: assign as 1 //
					C_UDMI(cm, meltjet_thread,2)= max_count+shift*myid; // numbering solid cells //
				}
				else
				{
					C_UDMI(cm, meltjet_thread,0)=0.0;  // identify the liquid cell: assign as 0 //
					C_UDMI(cm, meltjet_thread,2)=0.0;  // identify the liquid cell: assign as 0 //
				}	
			}
			end_c_loop_int(cm, meltjet_thread)
			Message("max_count at end of loop: %d\n", max_count);
		}
		max_count = PRF_GISUM1(max_count);
		Message0("Real max_count at end: %d\n", max_count);
	#endif //* !RP_HOST */		
}
PKP_India likes this.
__________________
best regards


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

Old   November 29, 2022, 02:14
Default
  #3
New Member
 
Prasant
Join Date: Sep 2020
Location: India
Posts: 13
Rep Power: 5
PKP_India is on a distinguished road
Hi.

Thanks for the response.

I have modified the udf based on your suggestion to do numbering the solid cells in every computer NODE.

The shift variable just multiplied to myid does not give the intended results as expected. I tried with the static variable option too, for the max_count variable. It still gives the zero value for the max_count for every computer NODE. How can I assign the max_count value of previous NODE to initialize the max_count during next NODE calculation instead of zero?
Attached Images
File Type: png printf 2.PNG (98.7 KB, 4 views)
Attached Files
File Type: c UDF 2.c (1.9 KB, 4 views)
PKP_India is offline   Reply With Quote

Old   November 29, 2022, 03:50
Default
  #4
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
try this
Code:
#include "udf.h"
#include "mem.h" 
#include "prf.h"  /// for global sum in parallel udf //
#include "sg_mem.h"  
#include "sg_mphase.h"
#include "para.h"

DEFINE_ADJUST(solid_segregation,mix_domain)
{
	int max_count,shift,i;
	int max_shift[compute_node_count];	
	#if !RP_HOST
		
		Domain *meltjet_domain;
		Thread *meltjet_thread;	// meltjet thread pointer //
		cell_t cm;	// melt jet cell identifier //
		meltjet_domain = Get_Domain(3); /* melt jet domain if multiphase */	
		
		thread_loop_c(meltjet_thread, meltjet_domain)  //loops over all cell threads in domain//
		{
			begin_c_loop_int(cm, meltjet_thread)
			{
				if (C_VOF(cm,meltjet_thread) >= 0.5 && C_LIQF(cm, meltjet_thread) <= 0.90)
				{
					shift+=1.0;
					max_shift[myid] = shift;
				}
				
			}
			end_c_loop_int(cm, meltjet_thread)
			Message("shift index at NODE: %d\n", shift);
		}
		
		for(i=0; i<compute_node_count; i++)
			{if myid == i 
				{shift += max_shift[myid]}
			}
		
		thread_loop_c(meltjet_thread, meltjet_domain)  //loops over all cell threads in domain//
		{
			Message("I am in the node process: %d\n", myid);
			Message("max_count at beginning of loop: %d\n", max_count);
			Message("total sum count at beginning of loop: %d\n", (max_count+shift));
			begin_c_loop_int(cm, meltjet_thread)
			{
					
				if (C_VOF(cm,meltjet_thread) >= 0.5 && C_LIQF(cm, meltjet_thread) <= 0.90)
				{
					max_count+=1.0;
					C_UDMI(cm, meltjet_thread,0)=1.0; // identify the solid cell: assign as 1 //
					C_UDMI(cm, meltjet_thread,2)= (max_count+shift)); // numbering solid cells //
				}
				else
				{
					C_UDMI(cm, meltjet_thread,0)=0.0;  // identify the liquid cell: assign as 0 //
					C_UDMI(cm, meltjet_thread,2)=0.0;  // identify the liquid cell: assign as 0 //
				}	
			}
			end_c_loop_int(cm, meltjet_thread)
			Message("total sum count at end of loop: %d\n", (max_count+shift));
		}
		max_count = PRF_GISUM1(max_count);
		Message0("Real max_count at end: %d\n", max_count);
	#endif //* !RP_HOST */		
}
however, I don't see the reason to do that, as you have UDM value and node value
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ 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
Issue with UDF in parallel processing MC1 FLUENT 5 August 29, 2017 03:17
Viscous dissipation UDF for multiphase DDPM (Divergence problem) bhargavbharathan FLUENT 0 November 30, 2016 12:23
Viscous dissipation UDF for multiphase DDPM bhargavbharathan Fluent Multiphase 0 November 30, 2016 12:17
Identifying cell in parallel UDF upeksa Fluent UDF and Scheme Programming 0 July 24, 2013 11:27
Help: how to realize UDF on parallel cluster? Haoyin FLUENT 1 August 6, 2007 13:53


All times are GMT -4. The time now is 07:26.