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

fatal signal segmentation fault in a UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 10, 2017, 08:57
Default fatal signal segmentation fault in a UDF
  #1
New Member
 
mohamed hares
Join Date: Nov 2015
Posts: 17
Rep Power: 10
hares is on a distinguished road
Hello,

when I want to run a simulation with a UDF Fluent 16. I have this error which appears

Error: received a fatal signal (Segmentation fault).
Error Object: #f

After some research on this error, I have found that this error appears when we are trying to Hook the adjust function in FLUENT solver . I don't know why this error appeared -- If I unhook this function - it works well- and if I delete the equations inside the adjust function it also works well

the code :


#include "udf.h"
#include "math.h"
#include "sg_udms.h"
#define rhomax 0.0008
#define phimax 5000
#define debye 0.001
#define rhomax 0.0008
#define phimax 5000
#define sigma 0.003
#define rholoc 0.0005

num {
phi,
rho
};
enum {
Ex,
Ey,
Fx,
Fy,
Fm
};

DEFINE_SOURCE(rho_source, c, t, dS, eqn)
{
real source;
source=-pow(debye,-2)*C_UDSI(c,t,rho);
dS[eqn]=-pow(debye,-2);
return source;
}


DEFINE_PROFILE(rho_profile,thread,i)
{
float r[3];
float x;
real xloc;
face_t f;
begin_f_loop(f,thread)
{
F_CENTROID(r,f,thread);
xloc = r[0];
F_PROFILE(f,thread,i)=exp(-pow((xloc-rholoc),2)/(2*pow(sigma,2)));
}
end_f_loop(f,thread)
}





DEFINE_ADJUST(udf_adjust, domain)
{
Thread *t;
cell_t c;
thread_loop_c(t,domain)
{
begin_c_loop(c,t)
{
C_UDMI(c,t,Ex)=-C_UDSI_G(c,t,phi)[0];
C_UDMI(c,t,Ey)=-C_UDSI_G(c,t,phi)[1];
}
end_c_loop(c,t)
}
}


DEFINE_SOURCE(X_Source, c, t, dS, eqn)
{
real Sourcex;
Sourcex=-rhomax*phimax*C_UDSI(c,t,rho)*C_UDSI_G(c,t,phi)[0];
dS[eqn]=-rhomax*phimax;
C_UDMI(c,t,Fx)=Sourcex;
return Sourcex;

}



DEFINE_SOURCE(Y_Source, c, t, dS, eqn)
{
real Sourcey;
Sourcey=-rhomax*phimax*C_UDSI(c,t,rho)*C_UDSI_G(c,t,phi)[1];
dS[eqn]=-rhomax*phimax;
C_UDMI(c,t,Fy)=Sourcey;
C_UDMI(c,t,Fm)=sqrt(C_UDMI(c,t,Fx)*C_UDMI(c,t,Fx)+ C_UDMI(c,t,Fy)*C_UDMI(c,t,Fy));
return Sourcey;
}

and all memory are located - and all other functions works well
the error just in the udf
hares is offline   Reply With Quote

Old   January 11, 2017, 07:08
Default
  #2
New Member
 
mohamed hares
Join Date: Nov 2015
Posts: 17
Rep Power: 10
hares is on a distinguished road
Hello!

Now I just follow A.Bouchmal's MS thesis "Modeling of Dielectric-Barrier Discharge Actuator".

http://www.lr.tudelft.nl/fileadmin/F...l_Bouchmal.pdf

However, the code which he atteched doesn't works.

I compiled the code and input conditions but when I start calculate, the error "FLUENT recieved fatal signal [segmentation fault] occurs.

after alloct all memory and user define scalar and hooking it
it works well
but at hooking the adjust function the error occurs

Please help me to solve the problem.
hares is offline   Reply With Quote

Old   January 11, 2017, 11:36
Default
  #3
Boh
Member
 
Join Date: Sep 2016
Posts: 33
Rep Power: 9
Boh is on a distinguished road
I think you need to add the mem.h header to access C_UDSI_G ( I mean put #include "mem.h" on top)
Boh is offline   Reply With Quote

Old   January 12, 2017, 04:47
Default
  #4
Member
 
Join Date: Jun 2016
Posts: 66
Rep Power: 11
Zbynek is on a distinguished road
mem.h is sourced through udf.h so that should not be the trouble.

I suppose that num{phi, rho} at the beginning should be enum{phi, rho}, possibly just a typo. A critical one if that were the case though.

Another thing that comes to my mind - if you are using more than one UDF library, you should use Reserve_User_Memory_Vars function.
Zbynek is offline   Reply With Quote

Old   January 12, 2017, 07:11
Default
  #5
New Member
 
mohamed hares
Join Date: Nov 2015
Posts: 17
Rep Power: 10
hares is on a distinguished road
Quote:
Originally Posted by Zbynek View Post
mem.h is sourced through udf.h so that should not be the trouble.

I suppose that num{phi, rho} at the beginning should be enum{phi, rho}, possibly just a typo. A critical one if that were the case though.

Another thing that comes to my mind - if you are using more than one UDF library, you should use Reserve_User_Memory_Vars function.
Thank for reply
and it is already enum{phi, rho}, , but it was my mistake at coping the code to you
------
I do not know how to use Reserve_User_Memory_Vars function .
Thank you again
hares is offline   Reply With Quote

Old   January 20, 2017, 16:41
Default
  #6
Senior Member
 
ali
Join Date: Oct 2009
Posts: 318
Rep Power: 17
alinik is on a distinguished road
Hares,

Did you solve the problem?
I am having this problem in my own udf. I traced it and it is caused when I want to use C_UDSI_G(c,t,0).
If instead of this I use some constant value, the udf runs well.
Apparently C_UDSI_G is not saved in the memory and thus is not accessible. I tried including mem.h in the header but that did not change anything.
I saw other people in this forum are also having this problem but I could not find any solution.
Have you?

Thanks,
Ali
alinik is offline   Reply With Quote

Old   January 21, 2017, 03:26
Default
  #7
New Member
 
mohamed hares
Join Date: Nov 2015
Posts: 17
Rep Power: 10
hares is on a distinguished road
Quote:
Originally Posted by alinik View Post
Hares,

Did you solve the problem?
I am having this problem in my own udf. I traced it and it is caused when I want to use C_UDSI_G(c,t,0).
If instead of this I use some constant value, the udf runs well.
Apparently C_UDSI_G is not saved in the memory and thus is not accessible. I tried including mem.h in the header but that did not change anything.
I saw other people in this forum are also having this problem but I could not find any solution.
Have you?

Thanks,
Ali
it is solved with me.
the error that I hook adjust in the beginning and I tried hooking it after 1 or 2 iteration ......
my advice for you that if you allocate the memory well
do unhook for the C_UDSI_G in the first iteration because if the value of the scalar did not be solved . so the Gradient of it ( C_UDSI_G ) will have an error
Good Luck
hares is offline   Reply With Quote

Reply


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
ABL use of fixed shear stress leads to segmentation fault 11 cristopf OpenFOAM Running, Solving & CFD 1 December 23, 2016 16:57
Fluent udf Error: received a fatal signal (Segmentation fault) syble FLUENT 3 December 9, 2016 16:28
Erron: FLUENT received fatal signal (ACCESS_VIOLATION) in DPM Heat and Mass Transfer Melvin FLUENT 2 November 17, 2016 01:06
segmentation fault when installing OF-2.1.1 on a cluster Rebecca513 OpenFOAM Installation 9 July 31, 2012 15:06
Segmentation fault in interFoam run through openMPI voingiappone OpenFOAM 16 November 2, 2011 06:49


All times are GMT -4. The time now is 02:06.