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/)
-   -   Received a fatal signal (Segmentation fault) with UDF (https://www.cfd-online.com/Forums/fluent-udf/186898-received-fatal-signal-segmentation-fault-udf.html)

lisa_china April 25, 2017 02:17

Received a fatal signal (Segmentation fault) with UDF
 
Dear all,
Here is a error when iterates with UDF to solve extra transport equations of UDS.
The error is
Quote:

Error: received a fatal signal (Segmentation fault).
By the way, there is no compile error. I am a UDF fresher and the code is written in terms of the examples given in Fluent UDF manul:
Quote:

#include "D:\Program Files\ANSYS Inc\v150\fluent\fluent15.0.0\src\udf.h"
DEFINE_UDS_UNSTEADY(mfUnsteady,c,t,i,apu,su)
{
real physical_dt, vol, rho, phi_old;
physical_dt = RP_Get_Real("physical-time-step");
vol=C_VOLUME(c,t);
rho=C_R_M1(c,t);
*apu=-rho*vol/physical_dt;/*implicit part*/
phi_old=C_STORAGE_R(c,t,SV_UDSI_M1(i));
*su = rho*vol*phi_old/physical_dt;/*explicit part*/
//printf("no error!\n");
}
DEFINE_UDS_FLUX(mfFlux,f,t,i)
{
real NV_VEC(psi),NV_VEC(A);
NV_D(psi,=,F_U(f,t),F_V(f,t),F_W(f,t));
NV_S(psi,*=,F_R(f,t));
F_AREA(A,f,t);
return NV_DOT(psi,A);
//printf("no error!\n");
}
DEFINE_DIFFUSIVITY(mfDiff,c,t,i)
{
return C_MU_T(c,t)/0.85;/*diffusivity from Sct number, needed to be tuned accordingly*/
//printf("no error!\n");
}
DEFINE_SOURCE(mfSource,c,t,dS,eqn)
{
real sourcemf;
sourcemf=0.0;
dS[eqn]=0.0;
return sourcemf;
//printf("no error!\n");
}
DEFINE_SOURCE(vrSource,c,t,dS,eqn)
{
real sourcevr,s1,s2,s3;
s1=C_UDSI_G(c,t,0)[0];
s2=C_UDSI_G(c,t,0)[1];
s3=C_UDSI_G(c,t,0)[2];
sourcevr=2.86*C_MU_T(c,t)*(s1*s1+s2*s2+s3*s3)-2.0*C_R(c,t)*C_D(c,t)*C_UDSI(c,t,1)/C_K(c,t);
dS[eqn]=-2.0*C_R(c,t)*C_D(c,t)/C_K(c,t);
return sourcevr;
//printf("no error!\n");
}
DEFINE_PROFILE(mfprofile1,t,i)
{
face_t f;
begin_f_loop(f,t)
{
F_PROFILE(f,t,i)=1;
}
end_f_loop(f,t)
}
DEFINE_PROFILE(mfprofile0,t,i)
{
face_t f;
begin_f_loop(f,t)
{
F_PROFILE(f,t,i)=0;
}
end_f_loop(f,t)
}
So is there any error in the code? or could anybody tell me how to find the reason results in the error?
Thanks in advance.
Shan

lisa_china April 25, 2017 07:49

Quote:

Originally Posted by lisa_china (Post 646403)
Dear all,
Here is a error when iterates with UDF to solve extra transport equations of UDS.
The error is
By the way, there is no compile error. I am a UDF fresher and the code is written in terms of the examples given in Fluent UDF manul:

So is there any error in the code? or could anybody tell me how to find the reason results in the error?
Thanks in advance.
Shan

I debugged the code with "Message("**")" and found that the error occurred in the Define_UDS_Flux part:
Code:

DEFINE_UDS_FLUX(mfFlux,f,t,i)
{
real NV_VEC(psi),NV_VEC(A);
NV_D(psi,=,F_U(f,t),F_V(f,t),F_W(f,t));
NV_S(psi,*=,F_R(f,t));
F_AREA(A,f,t);
return NV_DOT(psi,A);
//printf("no error!\n");
}

However, this part was the same as the example in Fluent UDF manual, and I don't know why it doesn't work. Since I just wanna define a default mass flow rate, finally I just choose the "mass flow rate" when define scalars in Fluent. And now, it works.
I still wanna know why with the DEFINE_UDS_FLUX it doesn't work. Could anybody help me?
Thanks for any reply.
Shan

furqanrk June 30, 2017 03:07

Received a fatal Signal ( Segmentation fault )
 
Hi everyone !

I hope you are fine. I am using UDF in VOF model in ANSYS FLUENT, although, my VOF model without UDF is running fine. The UDF is written by my friend used it successfully. He has graduated last year after getting the results from same UDF. The UDF was working well on his server. He was using Fluent 6.3 on Linux system. When I am using same case, date and UDF on my laptop the case is not running, although UDF compilation is very fine. I also check it on Linux system too. During or after initialization, Error occurred segmentation fault error. It is very strange that same case and UDF is not working on his office now. Main error occurred when I am hooking ADJUST and EXECUTE-AT-END UDFs. May be there is some problem of writing/calling style is different in Windows and Linux system with 32bit and 64bit. ( this is just my opinion).

I hope you can understand the situation and have a try to fix the problem. I would be highly thankful if you guide me that where is the problem. I can send UDF by email if needed..

Thanks in Advance,
Regards,
M. F. ALi


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