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

udf segmentation violation when hooked

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

Reply
 
LinkBack Thread Tools Display Modes
Old   September 24, 2009, 02:43
Default udf segmentation violation when hooked
  #1
New Member
 
christophe
Join Date: Aug 2009
Posts: 24
Rep Power: 8
jjchristophe is on a distinguished road
I am using Fluent 6.3 under linux.
I wrote udf in order to simulate specific boundary conditions.
For one of my udf, I can compil it (as compiled udf) and load it without problem. But when I select it in the boundary condition window, I have the following message:
"fluent.6.3.26 received a fatal signal (SEGMENTATION VIOLATION)"
does any body have a clue?
here is my udf's code:

#include "udf.h"
#include "unsteady.h"
DEFINE_PROFILE(pressure_outlet_S,thread,i)
{
real A[ND_ND]; /* face's area */
real Q=0.; /* volume flow rate @ thread @ previous time step */
real t=CURRENT_TIME; /* current time */
face_t f;
float u,v,w,vn,R;
/* output of pressure outlet for 1st time step */
if (t=0.)
{
begin_f_loop(f,thread)
{
F_PROFILE(f,thread,i)=200.;
}
end_f_loop(f,thread)
}
else
{
/* computation of thread's flow rate @ previous time step */
begin_f_loop(f,thread)
{
u=F_U_M1(f,thread);
v=F_V_M1(f,thread);
w=F_W_M1(f,thread);
vn=u*u+v*v+w*w;
vn=SQR(vn);
F_AREA(A,f,thread);
Q=Q+NV_MAG(A)*vn;
}
end_f_loop(f,thread)
/* computation of thread's resistance @ current time step */
R = 0.5+(15.5/Q);
Q=0.;
begin_f_loop(f,thread)
{
u=F_U_M1(f,thread);
v=F_V_M1(f,thread);
w=F_W_M1(f,thread);
vn=u*u+v*v+w*w;
vn=SQR(vn);
F_AREA(A,f,thread);
Q=Q+NV_MAG(A)*vn;
/* output of pressure outlet @ current time step */
F_PROFILE(f,thread,i)=100*R*Q;
}
end_f_loop(f,thread)

}
}
jjchristophe is offline   Reply With Quote

Old   October 22, 2009, 05:14
Default solution and new pb
  #2
New Member
 
christophe
Join Date: Aug 2009
Posts: 24
Rep Power: 8
jjchristophe is on a distinguished road
I realized that, in the last part,

u=F_U_M1(f,thread);
v=F_V_M1(f,thread);
w=F_W_M1(f,thread);

should become

u=F_U(f,thread);
v=F_V(f,thread);
w=F_W(f,thread);

By correcting this mistake, I have no more segmentation violation message when hooking the UDF, but I have one when initializing.
Anybody got a clue why?
jjchristophe is offline   Reply With Quote

Old   October 26, 2009, 22:36
Default
  #3
Member
 
Krishna
Join Date: Oct 2009
Posts: 34
Rep Power: 8
t.krishnamohan is on a distinguished road
I have'nt gone through the code properly but their is a mistake in the if statement. if(t=0) should be replaced by if(t==0).
regards
t.krishnamohan is offline   Reply With Quote

Old   October 27, 2009, 00:37
Default
  #4
New Member
 
christophe
Join Date: Aug 2009
Posts: 24
Rep Power: 8
jjchristophe is on a distinguished road
Thank you, I have made the correction.
But I still have the segmentation violation message.
jjchristophe is offline   Reply With Quote

Old   October 27, 2009, 02:49
Default
  #5
Member
 
Krishna
Join Date: Oct 2009
Posts: 34
Rep Power: 8
t.krishnamohan is on a distinguished road
SQR(float) does'nt exist in C language. Use sqrt() to find square root.
t.krishnamohan is offline   Reply With Quote

Old   October 27, 2009, 03:36
Default
  #6
New Member
 
christophe
Join Date: Aug 2009
Posts: 24
Rep Power: 8
jjchristophe is on a distinguished road
Thank you for your comment.
with the correction things are in progress: I can go through the initialize step.
But then, when I start to iterate, I have again a segmentation violation message.
jjchristophe is offline   Reply With Quote

Old   October 27, 2009, 03:56
Default
  #7
Member
 
Krishna
Join Date: Oct 2009
Posts: 34
Rep Power: 8
t.krishnamohan is on a distinguished road
What is that you want to assign at the boundary? Write the expression and constraints.
t.krishnamohan is offline   Reply With Quote

Old   October 27, 2009, 04:39
Default
  #8
New Member
 
christophe
Join Date: Aug 2009
Posts: 24
Rep Power: 8
jjchristophe is on a distinguished road
I have created 2 udfs to express inlet and outlet conditions. The udf at the inlet provides the velocity (it's a pulsatile flow, the aim is to model blood flow in pulmonary artery). I tested it separately, no pb.
The second one (the one shown here) is aimed at expressing a pressure boundary condition at the outlets.
By getting the volume flow rate Q at the outlet at the former time step (that's why I need to separate t=0) I want to compute the pulmonary vascular resistance R by using the formula based on experimental results:
R = 0.5+(15.5/Q)
as Fluent cannot interpret directly this resistance, I compute the pressure p at the outlets by using the formula:
p=RxQ
where this time Q is the current volume flow rate at the outlets.
I think the pb come from the fact that I am requesting a data from a former time step (Q).
jjchristophe is offline   Reply With Quote

Old   October 29, 2009, 07:09
Default
  #9
New Member
 
christophe
Join Date: Aug 2009
Posts: 24
Rep Power: 8
jjchristophe is on a distinguished road
it seems I solved the pb by using UDM instead of F_U_M1 functions.
thank you again for your help.
jjchristophe is offline   Reply With Quote

Old   June 25, 2012, 05:46
Default
  #10
Member
 
Satish Gupta
Join Date: Jun 2012
Posts: 30
Rep Power: 6
Rahul123 is on a distinguished road
I have written the UDF for convective b.c using DEFINE_PROFILE.........Can any1 tell me how to apply it at outlet
Rahul123 is offline   Reply With Quote

Reply

Thread Tools
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
udf wall distance segmentation violation gento FLUENT 1 April 15, 2016 15:59
DPM UDF - Segmentation Violation & Stack Backtrace Prashanth Fluent UDF and Scheme Programming 4 July 10, 2012 10:39
Segmentation Violation Corentin FLUENT 1 February 13, 2011 02:07
[UDF] Segmentation violation visuja Fluent UDF and Scheme Programming 0 April 23, 2009 22:23
segmentation violation wasan FLUENT 0 December 23, 2008 12:37


All times are GMT -4. The time now is 04:46.