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

"Segmentation fault" when using UDFs in Fluent

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 2, 2022, 09:54
Question "Segmentation fault" when using UDFs in Fluent
  #1
New Member
 
Join Date: Nov 2022
Posts: 10
Rep Power: 4
hsze is on a distinguished road
Hello!
I'm modeling an airflow through a heated pipe in Fluent 18 and would like to recalculate the pipe wall temperature dependiong on the flow exit temperature at every iteration.
I've tried familarizing with UDFs to solve this issue. I'm able to recalculate the wall temperature with constants and set a profile with the define_profile function.
When I try accessing flow variables (after sucessfully interpreting and hooking the UDFs) with F_T(T(f,t) or when I try to access the geometry with F_AREA(A,f,t) I get a fatal signal everytime I try to run the simulation with a "segmentation fault".
Error: received a fatal signal (Segmentation fault).

Can you please tell me how to debugg this error?
I've also tried using F_UDMI(f,t,0) to save the temperature I want to access but I get the same error. (I thought it might be a memory problem?)

I'll post a few UDFs I've tried and sucesfully interpreted below.
Is this an approach or user issue from my side?

Thanks in advance!

First UDF (Temperature):
#include "udf.h"
/* Compute face temperature and store in user-defined memory */

DEFINE_EXECUTE_AT_END(t_out)
{
Domain *d;
Thread *t;
face_t f;
real temp;

d = Get_Domain(6);
t = Lookup_Thread(d, 11);


begin_f_loop(f,t)
{
temp = F_T(f,t);
F_UDMI(f,t,0) = (temp-923) / (1023-923);
}
end_f_loop(f,t)
}

Second UDF (Area):
#include "udf.h"
DEFINE_EXECUTE_AT_END(area_calculation)
{
Domain *d;
face_t f;
real A[ND_ND];
real area=0;
int ID = 11; /*this is the ID of the boundary wall that I want to get the temperature from*/
Thread *t;
int zone_ID;
d = Get_Domain(6);
t = Lookup_Thread(d,ID);
begin_f_loop(f,t)
{
F_AREA(A,f,t);
area = NV_MAG(A);
}
end_f_loop(f,t)
printf("area = %g\n",area);
}

Third UDF (Adjust to then set profile):
#include "udf.h"

Thread *out_surface_T;
face_t face;
real t_out=0.00;
real area_out=0.00;
real out_face;
real NV_VEC(area);



DEFINE_ADJUST(adjust,d)
{
d = Get_Domain(6);
out_surface_T=Lookup_Thread(d,11);
begin_f_loop(face,out_surface_T)
{
F_AREA(area,face,out_surface_T);
area_out+=NV_VEC(area);
t_out+=F_T(face,out_surface_T)*NV_VEC(area);
}
end_f_loop(face,out_surface_T)
out_face=t_out/area_out;
printf("after adjust %d/n", out_face);
}


DEFINE_PROFILE(inet_T,t,i)
{
face_t f;
begin_f_loop(f,t)
{
F_PROFILE(f,t,i)=out_face;
}
end_f_loop(f,thread)
printf("after profile %d/n", out_face);
}
hsze is offline   Reply With Quote

Old   November 3, 2022, 04:03
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
was
d = Get_Domain(6);
to be
Code:
d = Get_Domain(1);
hsze likes this.
__________________
best regards


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

Old   November 3, 2022, 04:09
Default
  #3
New Member
 
Join Date: Nov 2022
Posts: 10
Rep Power: 4
hsze is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
was
d = Get_Domain(6);
to be
Code:
d = Get_Domain(1);
Thank you AlexanderZ!!
It works perfecclty now!
hsze is offline   Reply With Quote

Reply

Tags
ansys 18.0, fluent - udf, fluent 18, segmentation error, segmentation fault


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
how to run fluent from matlab without using aas toolbox? artemis96 ANSYS 7 May 23, 2022 13:16
How to change the type of a cell in FLUENT with UDFs? husywfl Fluent UDF and Scheme Programming 3 November 3, 2017 05:48
Fluent UDFs Repository bbmorales Fluent UDF and Scheme Programming 1 February 22, 2013 11:36
FLUENT UDFs saisanthoshm88 Fluent UDF and Scheme Programming 22 January 16, 2013 12:59
how to upload mutiple UDFs in FLUENT. shunahshep FLUENT 8 March 2, 2005 22:56


All times are GMT -4. The time now is 13:34.