CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   Segmentation violation error (https://www.cfd-online.com/Forums/fluent/110799-segmentation-violation-error.html)

IndrajitW December 21, 2012 03:14

Segmentation violation error
 
Hi all,
I am using the user defined scalar equation in my case and I have written UDF for defining the specified flux boundary condition. The UDF compiles well and I am able to load the library and hook the boundary condition.But when I try to initialize it gives me a "fatal error:SEGMENTATION VIOLATION " error!!! Please let me know why could this happen.
Regards,
Indrajit

LuckyTran December 22, 2012 02:30

Have you tried running in Serial mode? Segmentation errors can happen when initializing in parallel mode. See if initializing in serial fixes the error. After the initialization you can then switch back to parallel.

Just my guess.

IndrajitW December 23, 2012 00:41

Hi LuckyTran,
I am already running it in serial mode.In fact when I hook the UDF on the wall boundary and then I try to initialize ,it gives me this error.Although my UDF compiles just fine, what could be the problem??
Regards,
Indrajit

LuckyTran December 23, 2012 00:56

I believe the segmentation violation is also part of the greater class of access errors. Something is wrong with your UDF, and it is impossible to debug it without getting into the details. It may compile,which means that your syntax is correct, but it may not perform any meaningful actions. Anyway, anything could be wrong.

My next guess:

You may be hooking the UDF too early and your UDF is unable to do whatever it is you are telling it to do. This may mean that the UDF does not have all the data it needs to perform its task. Try running a few iterations without the UDF and then hooking it after to make sure there is data for the UDF.

IndrajitW December 23, 2012 05:23

Hi Lucky Tran,
I am attaching the problematic part of my UDF the areas highlighted in red are my concern since w/o those the segmentation violation error is avoided, however i need to included these for my problem:
begin_f_loop(f,t)
{ c= F_C0(f,t);
t0=THREAD_T0(t);
pt=THREAD_SUB_THREAD(t0,1);
if(C_VOF(c,pt)==1)
{ a=1;
T=acos((LAMBDA*(x-1))-psg);
Ang[0]=cos(T);
Ang[1]=sin(T);
flux=NV_DOT(vel_val,Ang);
flux=2*flux;
if(m>0)
{ F_PROFILE(f,t,pos)=-((BETA*vel_val[0])+(SIGMA*z))*r/13;
r=r-1;
p=2;
}
else
{ F_PROFILE(f,t,pos)=((BETA*vel_val[0])+(SIGMA*z))*r/13;
r=r-1;
p=1;
}
}
parameter a is initialised before this f loop to 0 and x,y,z are also initialized to 0. After this "if" loop x,z,m and vel_val are calculated based on local values of velocity scalar, and gradient of scalar. The idea is for the first iteration C_VOF won't be 1 and so it won't enter if loop, instead it would go ahead to calculate x,m,z values for the cell (c,t0). When C_VOF =1 , these values would be of previous cell and would help calculation for the current cell.
Is the problem because my calculation is taking values from previous cell stored into x,z?? But m value is working fine.Also I tried C_UDMI to store and retrieve values for previous cell ,still got the same error.
Regards,
Indrajit


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