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

C_UDMI function causing SIGSEGV error

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 22, 2020, 22:17
Default C_UDMI function causing SIGSEGV error
  #1
New Member
 
Hosea Chan
Join Date: Nov 2018
Posts: 4
Rep Power: 8
Hosea_Chan is on a distinguished road
Dear forum users,

I am working on a DEFINE_ADJUST function to compute the average velocity at the inlet of the cell zone and store the average velocity in the cells with C_UDMI function, which will be used to compute the momentum source term later. The code is as follows:
Code:
DEFINE_ADJUST(update,d)
{

	int id_a[cell_zones] = {17,21}; /* get zone id of channel-in later, need input */
	int id_v[cell_zones] = {6,7}; /* get zone id of channel volume later, need input */

	int i;
	for (i=0;i<2;i++) {
		
		#if !RP_HOST
			real A[ND_ND];
			real tfa = 0.0;
			real tfi = 0.0;
			real Ux = 0.0;
			face_t f;
			cell_t c;


			Thread* t1=Lookup_Thread(d,id_a[i]);
			Thread* t2 = Lookup_Thread(d,id_v[i]);


			begin_f_loop(f, t1)
			{
				if PRINCIPAL_FACE_P(f,t1)
				{				
					F_AREA(A,f,t1);
					tfa += NV_MAG(A); 
					/* summing the x-velocity of face */
					tfi += F_U(f,t1)*NV_MAG(A);
				}
			}
			end_f_loop(f, t1)

			tfi=PRF_GRSUM1(tfi);
			tfa=PRF_GRSUM1(tfa);
			Ux = tfi / tfa;
			Message0("Average zone %d U:%12.4e\n",i, Ux);
			Message0("Begin store c loop %d.\n",i);
			begin_c_loop(c,t2)
			{
				if (FLUID_THREAD_P(t2) && NNULLP(THREAD_STORAGE(t2, SV_UDM_I)))
				{
					C_UDMI(c,t2,1) = Ux;
				}
			}
			end_c_loop(c,t2)
			Message0("End store c loop %d.\n",i);
		#endif		
	} 
}
However, I get a SIGSEGV error when I run the code. After isolating the code part by part, it seems that the line "C_UDMI(c,t2,1) = Ux;" is causing the problem as the code runs fine if I commented the line. I have reserved UDM slots in the Fluent GUI. I also used C_UDMI(c,t2,0) for storing the total volume in the DEFINE_INIT code earlier:

Code:
DEFINE_INIT(initialize,d)


{
	#if !RP_HOST
		real total_volume[cell_zones];
		//Domain* d;
		
		int i;
		d = Get_Domain(1);
	
		for (i=0; i<2 ; i++) 
		{
			cell_t c;
			Thread* t2 = Lookup_Thread(d,id_v[i]);
			begin_c_loop(c, t2)
			Message0("Begin volume c loop %d\n",i);
			{
				total_volume[i] += C_VOLUME(c,t2);
			}
			end_c_loop(c, t2)
			#if RP_NODE
				total_volume[i] = PRF_GRSUM1(total_volume[i]);
				
			#endif
			
			Message0("Begin store c loop %d\n",i);
			begin_c_loop(c,t2)
			{
				if (FLUID_THREAD_P(t2) && NNULLP(THREAD_STORAGE(t2, SV_UDM_I)))
				{
					C_UDMI(c,t2,0) = total_volume[i];
				}
			}
			end_c_loop(c,t2)
			
			Message0("total_volume of zone %d: %12.4e\n", i,total_volume[i]);
			
		}

		
	#endif /* !RP_HOST */
	
}
It used to cause SIGSEGV as well, but with reference to another post with similar issue, the line "if (FLUID_THREAD_P(t2) && NNULLP(THREAD_STORAGE(t2, SV_UDM_I)))" seem to have solved the problem in the DEFINE_INIT code but not the DEFINE_ADJUST code. A link to the refered post is here: Segmentation fault error in User defined memory UDF

Thank you for your help in advance!

Best regards,
Hosea
Hosea_Chan is offline   Reply With Quote

Old   December 13, 2020, 19:22
Default
  #2
New Member
 
amine
Join Date: Dec 2020
Posts: 7
Rep Power: 6
djendara is on a distinguished road
usefully you have to lunch the computation without hook the function for one iteration and after hook your udf and try it !
djendara 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
Building OpenFOAM1.7.0 from source ata OpenFOAM Installation 46 March 6, 2022 14:21
[OpenFOAM.org] Compile OF 2.3 on Mac OS X .... the patch gschaider OpenFOAM Installation 225 August 25, 2015 20:43
[swak4Foam] GroovyBC the dynamic cousin of funkySetFields that lives on the suburb of the mesh gschaider OpenFOAM Community Contributions 300 October 29, 2014 19:00
How to install CGNS under windows xp? lzgwhy Main CFD Forum 1 January 11, 2011 19:44
[blockMesh] Axisymmetrical mesh Rasmus Gjesing (Gjesing) OpenFOAM Meshing & Mesh Conversion 10 April 2, 2007 15:00


All times are GMT -4. The time now is 21:08.