CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   udf segmentation violation when hooked (https://www.cfd-online.com/Forums/fluent-udf/68568-udf-segmentation-violation-when-hooked.html)

jjchristophe September 24, 2009 02:43

udf segmentation violation when hooked
 
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 October 22, 2009 05:14

solution and new pb
 
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?

t.krishnamohan October 26, 2009 21:36

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

jjchristophe October 26, 2009 23:37

Thank you, I have made the correction.
But I still have the segmentation violation message.

t.krishnamohan October 27, 2009 01:49

SQR(float) does'nt exist in C language. Use sqrt() to find square root.

jjchristophe October 27, 2009 02:36

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.

t.krishnamohan October 27, 2009 02:56

What is that you want to assign at the boundary? Write the expression and constraints.

jjchristophe October 27, 2009 03:39

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 October 29, 2009 06:09

it seems I solved the pb by using UDM instead of F_U_M1 functions.
thank you again for your help.

Rahul123 June 25, 2012 05:46

I have written the UDF for convective b.c using DEFINE_PROFILE.........Can any1 tell me how to apply it at outlet


All times are GMT -4. The time now is 01:49.