|
[Sponsors] |
January 10, 2017, 09:57 |
fatal signal segmentation fault in a UDF
|
#1 |
New Member
mohamed hares
Join Date: Nov 2015
Posts: 17
Rep Power: 11 |
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 |
|
January 11, 2017, 08:08 |
|
#2 |
New Member
mohamed hares
Join Date: Nov 2015
Posts: 17
Rep Power: 11 |
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. |
|
January 11, 2017, 12:36 |
|
#3 |
Member
Join Date: Sep 2016
Posts: 33
Rep Power: 10 |
I think you need to add the mem.h header to access C_UDSI_G ( I mean put #include "mem.h" on top)
|
|
January 12, 2017, 05:47 |
|
#4 |
Member
Join Date: Jun 2016
Posts: 66
Rep Power: 11 |
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. |
|
January 12, 2017, 08:11 |
|
#5 | |
New Member
mohamed hares
Join Date: Nov 2015
Posts: 17
Rep Power: 11 |
Quote:
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 |
||
January 20, 2017, 17:41 |
|
#6 |
Senior Member
ali
Join Date: Oct 2009
Posts: 318
Rep Power: 18 |
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 |
|
January 21, 2017, 04:26 |
|
#7 | |
New Member
mohamed hares
Join Date: Nov 2015
Posts: 17
Rep Power: 11 |
Quote:
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 |
||
|
|
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 17:57 |
Fluent udf Error: received a fatal signal (Segmentation fault) | syble | FLUENT | 3 | December 9, 2016 17:28 |
Erron: FLUENT received fatal signal (ACCESS_VIOLATION) in DPM Heat and Mass Transfer | Melvin | FLUENT | 2 | November 17, 2016 02:06 |
segmentation fault when installing OF-2.1.1 on a cluster | Rebecca513 | OpenFOAM Installation | 9 | July 31, 2012 16:06 |
Segmentation fault in interFoam run through openMPI | voingiappone | OpenFOAM | 16 | November 2, 2011 07:49 |