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

face loop on looked up thread within DEFINE_PROFILE causing error

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

Like Tree7Likes
  • 1 Post By PanPeter
  • 1 Post By KaLium
  • 1 Post By PanPeter
  • 1 Post By KaLium
  • 1 Post By PanPeter
  • 1 Post By PanPeter
  • 1 Post By PanPeter

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 13, 2017, 11:05
Default face loop on looked up thread within DEFINE_PROFILE causing error
  #1
Member
 
Fynn
Join Date: Feb 2016
Posts: 48
Rep Power: 5
PanPeter is on a distinguished road
Hi together,

I encountered a weird problem and hope somebody can give me someone hints as to how to solve this:

I want to define an inlet velocity profile which is related to the outlet velocity profile. My approach is to write an udf for the inlet:
The DEFINE_PROFILE loops over all faces of my inlet surface and assigns velocity values of my outlet surface to it. For that I have to create a loop over the outlet faces and that's where my problem arises. The values in my loop over the outlet values could not be read.

I reduced my problem to the following udf, in which I only count and print in my outlet loop. That triggers the "received a fatal signal (Segmentation fault)" error when the compiled library is loaded.
Interestingly, if the Message() command is left out, everything runs smoothly. How can the Message() command have such an effect?

Code:
DEFINE_PROFILE(x_velocity_inlet, thread, i) 
{
	face_t f;
	Domain *domain;
	Thread *t_out;

	int Zone_ID=3;
	domain=Get_Domain(1);
	t_out = Lookup_Thread(domain, Zone_ID);

	int counter = 0;
	begin_f_loop(f, t_out)
	{	
		counter = counter + 1;
		Message("hello %d\n", counter);
	}
	end_f_loop(f, t_out)

	begin_f_loop(f, thread)
	{
		F_PROFILE(f, thread, i)
			= 2.0;
	}
	end_f_loop(f, thread)
}
Светлана likes this.
PanPeter is offline   Reply With Quote

Old   June 14, 2017, 08:09
Default
  #2
Senior Member
 
KaLium's Avatar
 
Kal-El
Join Date: Apr 2017
Location: Finland
Posts: 150
Rep Power: 4
KaLium is on a distinguished road
Code:
begin_f_loop(f, thread)    
 {        
 F_PROFILE(f, thread, i)  = 2.0;    
 }     
end_f_loop(f, thread)
Why you are using thread here and not the t_out
Светлана likes this.
KaLium is offline   Reply With Quote

Old   June 14, 2017, 08:29
Default
  #3
Member
 
Fynn
Join Date: Feb 2016
Posts: 48
Rep Power: 5
PanPeter is on a distinguished road
Hi Kal-el,

In the second loop I define the velocity profile to the surface that the macro is called on. It is called thread here, in my simulation, it is the inlet boundary.

But the crucial part is the first face loop on the thread t_out:
The error is thrown when the Message() is defined. If the Message() function is not defined the counter is still not updated in the loop. Something is odd when looping over faces of an looked-up thread but I can't see why this shouldn't work.

cheers,
Fynn
Светлана likes this.
PanPeter is offline   Reply With Quote

Old   June 14, 2017, 08:31
Default
  #4
Senior Member
 
KaLium's Avatar
 
Kal-El
Join Date: Apr 2017
Location: Finland
Posts: 150
Rep Power: 4
KaLium is on a distinguished road
Have you tried Message0() ?

Are you sure that this loop does anything:

Code:
t_out = Lookup_Thread(domain, Zone_ID);
int counter = 0;
begin_f_loop(f, t_out)
{             
counter = counter + 1;         
Message("hello %d\n", counter);     
}     
end_f_loop(f, t_out)
https://www.sharcnet.ca/Software/Ans...e_profile.html
Quote:
The solver passes only the pointer to the thread associated with the boundary zone to the DEFINE_PROFILE macro.
note also:
Quote:
Note that unlike source term and property UDFs, profile UDFs (defined using DEFINE_PROFILE) are not called by ANSYS Fluent from within a loop on threads in the boundary zone.
Светлана likes this.
KaLium is offline   Reply With Quote

Old   June 14, 2017, 09:39
Default
  #5
Member
 
Fynn
Join Date: Feb 2016
Posts: 48
Rep Power: 5
PanPeter is on a distinguished road
Hi, I figured it out:
The problem was that I used a wrong zone id for my outlet thread.

But I still encounter problems looping through face elements:

Code:
DEFINE_EXECUTE_AT_END(meanVelOnSurface_atEnd)
{
	face_t f;
	Thread *thread;
	Domain *domain;
	domain = Get_Domain(1);
	int Zone_ID = 1;
	thread = Lookup_Thread(domain, Zone_ID);

	real vel = 0.0;
	begin_f_loop(f, thread){	
		vel += F_U(f, thread);
 	}end_f_loop(f, thread)

	Message("sum velocity = %g\n", vel );
}
This compiles and loads well but when it is executed, it throws a Segmentation fault error. Any idea what's odd about this?

cheers,
Fynn
Светлана likes this.
PanPeter is offline   Reply With Quote

Old   June 14, 2017, 09:54
Default
  #6
Member
 
Fynn
Join Date: Feb 2016
Posts: 48
Rep Power: 5
PanPeter is on a distinguished road
Also, when F_U() is not defined and I simply have a counter in the loop,
it seems to count through a different surface:

Code:
DEFINE_EXECUTE_AT_END(meanVelOnSurface_atEnd)
{
	face_t f;
	Thread *thread;
	Domain *domain;
	domain = Get_Domain(1);
	int Zone_ID = 1;
	thread = Lookup_Thread(domain, Zone_ID);

	real vel = 0.0;
	begin_f_loop(f, thread){	
		vel += 1.0;
 	}end_f_loop(f, thread)

	Message("sum velocity = %g\n", vel );
}
My surface list output is:
Code:
surface group name          id    points  0D facets   1D facets   2D facets
------------------------- ---- --------- ---------- ----------- -----------
inlet                        2        19          0          18           0
interior-channel             3      2268          0        4147           0
line                         4        19          0          18           0
outlet                       1        19          0          18           0
walls                        0       234          0         232           0
and my program produces as output, "sum velocity = 4147". But that's not the face number related to the surface with id = 1 (outlet).
Светлана likes this.
PanPeter is offline   Reply With Quote

Old   June 14, 2017, 10:11
Default
  #7
Member
 
Fynn
Join Date: Feb 2016
Posts: 48
Rep Power: 5
PanPeter is on a distinguished road
Ok, now I got it figured out:

It was again a wrong zone ID:
It was wrong to use surface IDs from surface list. They are different from the IDs that are stated in the boundary dialog box (as suggested in the documentation).
With the ID from the dialog box, which is for some reason 6, the program works fine.

Thanks for the help.
Fynn
Светлана likes this.
PanPeter is offline   Reply With Quote

Old   June 22, 2017, 11:51
Default
  #8
Member
 
Vedamt Chittlangia
Join Date: Feb 2016
Posts: 64
Rep Power: 4
vcvedant is an unknown quantity at this point
Hi PanPeter,

I am working on a turbulent flow problem to access TKE at the symmetry boundary condition and am using the face loop as you are using.
The problem is that I get segmentation fault when I try to access F_K(f,t). Though F_CENTROID(x,f,t) works fine. I think this is due to TKE not present at that boundary.
Any ideas to work it through?
vcvedant is offline   Reply With Quote

Reply

Tags
begin_f_loop, define_profile, lookup_thread, message passing

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Compile calcMassFlowC aurore OpenFOAM Programming & Development 13 March 23, 2018 08:43
[OpenFOAM] Native ParaView Reader Bugs tj22 ParaView 270 January 4, 2016 12:39
[OpenFOAM.org] Compile OF 2.3 on Mac OS X .... the patch gschaider OpenFOAM Installation 225 August 25, 2015 20:43
Ansys Fluent 13.0 UDF compilation problem in Window XP (32 bit) Yogini Fluent UDF and Scheme Programming 7 October 3, 2012 08:24
checking the system setup and Qt version vivek070176 OpenFOAM Installation 22 June 1, 2010 13:34


All times are GMT -4. The time now is 14:10.