|
[Sponsors] |
face loop on looked up thread within DEFINE_PROFILE causing error |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
June 13, 2017, 11:05 |
face loop on looked up thread within DEFINE_PROFILE causing error
|
#1 |
Member
Fynn
Join Date: Feb 2016
Posts: 48
Rep Power: 10 |
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) } |
|
June 14, 2017, 08:09 |
|
#2 |
Senior Member
Kal-El
Join Date: Apr 2017
Location: Finland
Posts: 150
Rep Power: 9 |
Code:
begin_f_loop(f, thread) { F_PROFILE(f, thread, i) = 2.0; } end_f_loop(f, thread) |
|
June 14, 2017, 08:29 |
|
#3 |
Member
Fynn
Join Date: Feb 2016
Posts: 48
Rep Power: 10 |
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 |
|
June 14, 2017, 08:31 |
|
#4 | ||
Senior Member
Kal-El
Join Date: Apr 2017
Location: Finland
Posts: 150
Rep Power: 9 |
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) Quote:
Quote:
|
|||
June 14, 2017, 09:39 |
|
#5 |
Member
Fynn
Join Date: Feb 2016
Posts: 48
Rep Power: 10 |
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 ); } cheers, Fynn |
|
June 14, 2017, 09:54 |
|
#6 |
Member
Fynn
Join Date: Feb 2016
Posts: 48
Rep Power: 10 |
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 ); } 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 |
|
June 14, 2017, 10:11 |
|
#7 |
Member
Fynn
Join Date: Feb 2016
Posts: 48
Rep Power: 10 |
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 |
|
June 22, 2017, 11:51 |
|
#8 |
Member
Vedamt Chittlangia
Join Date: Feb 2016
Posts: 64
Rep Power: 9 |
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? |
|
Tags |
begin_f_loop, define_profile, lookup_thread, message passing |
|
|
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 |