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

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

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 23, 2017, 16:17
Default Fluent udf Error: received a fatal signal (Segmentation fault) Error Object: #f
  #1
New Member
 
dikme hs
Join Date: May 2017
Posts: 3
Rep Power: 9
dikmeha is on a distinguished road
Hi
I am trying to write a udf that calculates heat generation in fluid (W/cm3), however it gives an error such that:

p, li { white-space: pre-wrap; } Error: received a fatal signal (Segmentation fault).
Error Object: #f


This is my udf:


# include "udf.h"
DEFINE_SOURCE(energy_source,c,t,ds,eqn){
real x[ND_ND]; /*this will hold the position vector*/
real y1; /*x*/
real y2; /*y*/
real y3; /*z*/
real r1; /*radius*/
real v_c;
real source;
real pi=3.1415926535897932384626433832795;
C_CENTROID(x,c,t);
y1=x[0];
y2=x[1];
y3=x[2];
r1=sqrt(y1*y1+y2*y2);
v_c=pi*1.1275*1.1275*2.255;
if(r1<(1.1275)){
source=(3E+9)/(v_c)*sin(pi*0.35*(y3-2.65))*log(r1/1.1275);
ds[eqn]=(3E+9)/(v_c)*pi*0.35*cos(pi*0.35*(y3-2.65))*log(r1/1.1275)/1.1275;
}
else{
source=0.0;
ds[eqn]=0.0;
}
}

Does anybody of you understand the error message and can tell me how I can solve the problem? Thanks in advance!
dikmeha is offline   Reply With Quote

Old   May 25, 2017, 21:53
Default
  #2
Senior Member
 
Svetlana Tkachenko
Join Date: Oct 2013
Location: Australia, Sydney
Posts: 416
Rep Power: 15
Svetlana is on a distinguished road
Try const, return.

That is, set the heat generation rate to a constant value, maybe like below? I couldn't figure out whether the dS is required or optional.

You are also required to write 'return source' at the end of the subroutine.

Official documentation for an old version: here.



# include "udf.h"
DEFINE_SOURCE(energy_source,c,t,ds,eqn){
real x[ND_ND]; /*this will hold the position vector*/
C_CENTROID(x,c,t);
source=100.0;
//ds[eqn]=100.0;
return source;
}

Last edited by Svetlana; May 25, 2017 at 21:53. Reason: added missing " C_CENTROID(x,c,t); " line
Svetlana is offline   Reply With Quote

Old   May 26, 2017, 21:58
Default
  #3
New Member
 
dikme hs
Join Date: May 2017
Posts: 3
Rep Power: 9
dikmeha is on a distinguished road
Thx. I have a new question. I want to define heat generation in a small portion of whole fluid zone. How can I do it? Dou you have any idea?
dikmeha is offline   Reply With Quote

Old   May 28, 2017, 19:58
Default program it
  #4
Senior Member
 
Svetlana Tkachenko
Join Date: Oct 2013
Location: Australia, Sydney
Posts: 416
Rep Power: 15
Svetlana is on a distinguished road
You would have to program a boolean which checks whether the current point should have the heat generation or not. For example if heat generation is only active when x is less than 0.34, you would write something to the effect of this:

real myrate;
if (x[0]<0.34){
myrate=100.0;
} else{
myrate=0.0;
}
Svetlana is offline   Reply With Quote

Old   June 30, 2017, 04:06
Default Received a fatal Signal ( Segmentation fault )
  #5
Member
 
Muhammad Furqan Ali
Join Date: Oct 2014
Location: beijing
Posts: 53
Rep Power: 12
furqanrk is on a distinguished road
Send a message via Skype™ to furqanrk
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
Svetlana likes this.
furqanrk is offline   Reply With Quote

Old   July 3, 2017, 23:35
Default Simplify, show code
  #6
Senior Member
 
Svetlana Tkachenko
Join Date: Oct 2013
Location: Australia, Sydney
Posts: 416
Rep Power: 15
Svetlana is on a distinguished road
Hi furqanrk,

- Fluent 6.3 is a very old version.
- One could suggest to simplify the UDF following, say, the same approach as what I demonstrated by me earlier, Problem with UDF - DEFINE_SPECIFIC_HEAT macro — do not use any code from this example, it only demonstrates the approach. You would be able to dumbify the function to the point of it being senseless, and then add complexity gradually in small steps.
- If you show your code, someone may be able to try it on their FLUENT instance and troubleshoot it further if they can see a problem.
Svetlana is offline   Reply With Quote

Old   July 4, 2017, 02:45
Default
  #7
New Member
 
Nitesh
Join Date: Jul 2017
Posts: 5
Rep Power: 9
...n... is on a distinguished road
Hello! I need help with my udf. My udf gets interpreted but when I try to initialize it, i get this error "Error: received a fatal signal (Segmentation fault).
Error Object: #f " . I noticed one thing that if i use a constant numerical value instead of C_T(c,t), the udf works but i don't want a constant value. My udf is given below:

#include "udf.h"

DEFINE_PROFILE(c_velocity,t,i)
{
cell_t c;
real x[ND_ND];
real beta=5.0;
real Ic_ref=10000.0;
real F=96485.3;
real R=8.314;
real P=101325.0;
real mf_o2=0.21;
real A=2*100;
real Ac=1*1;

begin_c_loop(c,t)
{
C_CENTROID(x,c,t);
F_PROFILE(c,t,i)=(beta*Ic_ref*R*C_T(c,t)*A)/(4*F*P*Ac*mf_o2);
}

end_c_loop(c,t)
}

...n... is offline   Reply With Quote

Old   July 4, 2017, 03:28
Default
  #8
Senior Member
 
KaLium's Avatar
 
Kal-El
Join Date: Apr 2017
Location: Finland
Posts: 150
Rep Power: 9
KaLium is on a distinguished road
Quote:
Originally Posted by ...n... View Post
Hello! I need help with my udf. My udf gets interpreted but when I try to initialize it, i get this error "Error: received a fatal signal (Segmentation fault).
Error Object: #f " . I noticed one thing that if i use a constant numerical value instead of C_T(c,t), the udf works but i don't want a constant value. My udf is given below:

#include "udf.h"

DEFINE_PROFILE(c_velocity,t,i)
{
cell_t c;
real x[ND_ND];
real beta=5.0;
real Ic_ref=10000.0;
real F=96485.3;
real R=8.314;
real P=101325.0;
real mf_o2=0.21;
real A=2*100;
real Ac=1*1;

begin_c_loop(c,t)
{
C_CENTROID(x,c,t);
F_PROFILE(c,t,i)=(beta*Ic_ref*R*C_T(c,t)*A)/(4*F*P*Ac*mf_o2);
}

end_c_loop(c,t)
}

Try face-macros instead of cell-macros.

http://jullio.pe.kr/fluent6.1/help/html/udf/node71.htm

https://www.sharcnet.ca/Software/Flu...udf/node91.htm
KaLium is offline   Reply With Quote

Old   July 4, 2017, 03:50
Default
  #9
New Member
 
Nitesh
Join Date: Jul 2017
Posts: 5
Rep Power: 9
...n... is on a distinguished road
Quote:
Originally Posted by KaLium View Post
I used face macros as you instructed but I'm still getting the same error.
...n... is offline   Reply With Quote

Old   July 4, 2017, 03:52
Default
  #10
Senior Member
 
KaLium's Avatar
 
Kal-El
Join Date: Apr 2017
Location: Finland
Posts: 150
Rep Power: 9
KaLium is on a distinguished road
try also face-loop
KaLium is offline   Reply With Quote

Old   July 4, 2017, 04:11
Default
  #11
New Member
 
Nitesh
Join Date: Jul 2017
Posts: 5
Rep Power: 9
...n... is on a distinguished road
Quote:
Originally Posted by KaLium View Post
try also face-loop
I replaced all the cell variable with face and i'm still getting the error. For some reason it's not getting the value of temperature.

#include "udf.h"

DEFINE_PROFILE(c_velocity,t,i)
{
face_t f;
real x[ND_ND];
real beta=5.0;
real Ic_ref=10000.0;
real F=96485.3;
real R=8.314;
real P=101325.0;
real mf_o2=0.21;
real A=2*100;
real Ac=1*1;

begin_f_loop(f,t)
{
F_CENTROID(x,f,t);
F_PROFILE(f,t,i)=(beta*Ic_ref*R*F_T(f,t)*A)/(4*F*P*Ac*mf_o2);
}

end_f_loop(f,t)
}


can you please edit the udf? I'm modelling air flow through a rectangular cross section tube of dimension 100*1*1 mm.
...n... is offline   Reply With Quote

Old   July 4, 2017, 06:13
Default
  #12
Senior Member
 
KaLium's Avatar
 
Kal-El
Join Date: Apr 2017
Location: Finland
Posts: 150
Rep Power: 9
KaLium is on a distinguished road
Have you used this profile with initialized field or have you first started the simulation without DEFINE_PROFILE (with constant velocity and temperature)?

btw. I don't think you need x[ND_ND] or F_CENTROID(x,f,t) in your code

Last edited by KaLium; July 4, 2017 at 09:38.
KaLium is offline   Reply With Quote

Old   July 4, 2017, 07:25
Default
  #13
New Member
 
Nitesh
Join Date: Jul 2017
Posts: 5
Rep Power: 9
...n... is on a distinguished road
Quote:
Originally Posted by KaLium View Post
Have you used this profile with initialized field or have you first started the simulation without DEFINE_PROFILE (with constant velocity and temperature)?

btw. I don't you need x[ND_ND] or F_CENTROID(x,f,t) in your code
I tried to initialize it.

Is it possible to assign the value of 300. to C_T(c,t) using DEFINE_INIT? This is the udf i wrote before you told me to use face macro and face loop.

#include "udf.h"

DEFINE_INIT(init_temp,d)
{
Thread *t;
cell_t c;
thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
if(THREAD_ID(t)==2) // 2 is the ID i got in the cell zone condition for my mesh body//
{
C_T(c,t) = 353.0;
}
end_c_loop(c,t)
}
}
}


DEFINE_PROFILE(c_velocity,t,i) /*inlet velocity profile*/
{

cell_t c;
real beta=5.0;
real Ic_ref=10000.0;
real F=96485.3;
real R=8.314;
real P=101325.0;
real mf_o2=0.21;
real A=2*100;
real Ac=1*1;

begin_c_loop(c,t)
{

F_PROFILE(c,t,i)=(beta*Ic_ref*R*C_T(c,t)*A)/(4*F*P*Ac*mf_o2);

}

end_c_loop(c,t)
}

I am trying to set the entire tube temp as 353 kelvin and let the operating condition(atmospheric condition) be 298 kelvin. I want C_T to read the value 353 k .

P.S. I'm new to udf, forgive me if i say something wrong.

Last edited by ...n...; July 4, 2017 at 10:01.
...n... is offline   Reply With Quote

Old   July 4, 2017, 09:37
Default
  #14
Senior Member
 
KaLium's Avatar
 
Kal-El
Join Date: Apr 2017
Location: Finland
Posts: 150
Rep Power: 9
KaLium is on a distinguished road
In my understanding, you can not give any value to F_T or C_T. They only read values from fluent.

You can also patch values in Fluent: https://www.sharcnet.ca/Software/Fluent6/html/ug/node1384.htm.

Idea: Patch correct temperature to UDM-0 and then replace F_T(c,t) from your code with F_UDMI(c,t,0). Does that work?
KaLium is offline   Reply With Quote

Old   July 4, 2017, 10:20
Default
  #15
New Member
 
Nitesh
Join Date: Jul 2017
Posts: 5
Rep Power: 9
...n... is on a distinguished road
Quote:
Originally Posted by KaLium View Post
In my understanding, you can not give any value to F_T or C_T. They only read values from fluent.

You can also patch values in Fluent: https://www.sharcnet.ca/Software/Fluent6/html/ug/node1384.htm.

Idea: Patch correct temperature to UDM-0 and then replace F_T(c,t) from your code with F_UDMI(c,t,0). Does that work?
I'll try it out.

But according to this: https://www.sharcnet.ca/Software/Flu...udf/node26.htm

C_T has been assigned values.
...n... is offline   Reply With Quote

Old   July 4, 2017, 10:34
Default
  #16
Senior Member
 
KaLium's Avatar
 
Kal-El
Join Date: Apr 2017
Location: Finland
Posts: 150
Rep Power: 9
KaLium is on a distinguished road
That is interesting
KaLium is offline   Reply With Quote

Old   July 23, 2017, 12:24
Default Error in fluent
  #17
New Member
 
Prashanth
Join Date: Jun 2016
Posts: 20
Rep Power: 10
pachi is on a distinguished road
Hii to all..

am working on fluid structure interaction in the flexible pipe..

FSI is working for low magnitude of pressure (0 to 12Pa) UDF boundary condition in the fluent. however when i define higher pressure in the UDF file FSI fails to work.

Getting error like..

1) "Update failed for the Solution component in System Coupling. The coupled update for System, Fluid Flow (Fluent), threw an exception".

2) "System coupling run completed with errors. Transient Structural (Solution 1) reported: One or more elements have become highly distorted. Excessive distortion of elements is usually a symptom indicating the need for corrective action elsewhere. Try ramping the load up instead of step applying the load (KBC,1). Please do not save the project if you would like to recover to the last saved state".

Thank You
pachi is offline   Reply With Quote

Old   April 12, 2018, 10:40
Default
  #18
New Member
 
yanghai
Join Date: Mar 2018
Posts: 16
Rep Power: 8
yanghai is on a distinguished road
Quote:
Originally Posted by ...n... View Post
Hello! I need help with my udf. My udf gets interpreted but when I try to initialize it, i get this error "Error: received a fatal signal (Segmentation fault).
Error Object: #f " . I noticed one thing that if i use a constant numerical value instead of C_T(c,t), the udf works but i don't want a constant value. My udf is given below:

#include "udf.h"

DEFINE_PROFILE(c_velocity,t,i)
{
cell_t c;
real x[ND_ND];
real beta=5.0;
real Ic_ref=10000.0;
real F=96485.3;
real R=8.314;
real P=101325.0;
real mf_o2=0.21;
real A=2*100;
real Ac=1*1;

begin_c_loop(c,t)
{
C_CENTROID(x,c,t);
F_PROFILE(c,t,i)=(beta*Ic_ref*R*C_T(c,t)*A)/(4*F*P*Ac*mf_o2);
}

end_c_loop(c,t)
}

hello, i met the same problem like you, i want to set the temperature profile to a wall, the value is include the pressure of the wall, the equation is :T=100+ln(p). the below is my udf, the error is just like you said. so how do you solve it ? please help me. thank you.

#include "udf.h"
#include <math.h>
DEFINE_PROFILE(eva_temperature,t,i)
{
face_t f;

begin_f_loop(f,t)
{
F_PROFILE(f,t,i)=100+log(F_P(f,t)+RP_Get_Real("ope rating-pressure"));
}
end_f_loop(f,t)
}
yanghai is offline   Reply With Quote

Old   April 13, 2018, 03:51
Default
  #19
Senior Member
 
Join Date: Sep 2017
Posts: 246
Rep Power: 12
obscureed is on a distinguished road
Hello Yanghai,

I cannot see any immediate problem with your UDF, so I think you will have to debug it, either by starting very simple and adding elements, or by removing elements from your current UDF:
F_PROFILE(f,t,i)=100;
F_PROFILE(f,t,i)=100+log(101325.);
F_PROFILE(f,t,i)=100+log(RP_Get_Real("operating-pressure"));F_PROFILE(f,t,i)=100+log(F_P(f,t)+RP_G et_Real("operating-pressure"));

Looking up an RP value has a cost, so if the model is large enough that the UDF execution time matters, it would be better to define a variable p_op, assign to p_op the RP value before the face loop, then use p_op inside the loop.

Please can you describe when the error occurs, and specify the error message? (This is one difficulty with re-using an old thread: it is difficult for us to know which of the past situations resembles your situation.)

The temperature here is in Kelvin -- are temperatures around 110K correct for your model?

If your model is massively disrupted by the UDF (or any other influence) such that F_P goes below -p_op, then the log() will be given a negative value, which will cause trouble. It might or might not be worth guarding against this kind of catastrophic error, depending on the probability of the disruption and how much you care about a crash.

Good luck!
Ed
obscureed is offline   Reply With Quote

Old   April 13, 2018, 04:42
Default
  #20
Senior Member
 
Join Date: Sep 2017
Posts: 246
Rep Power: 12
obscureed is on a distinguished road
Hello Yanghai,

I now see that you have posted the same question elsewhere ((ask) temperature profile that include the pressure), and pakk has given you some good advice. We should focus one on the question in one place only.

Ed
obscureed is offline   Reply With Quote

Reply

Tags
error, fluent - udf


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
Fatal signal in fluent 6.3.26 NewFluent Fluent UDF and Scheme Programming 5 July 24, 2017 03:08
Fluent15: received a fatal signal (Segmentation fault) lcg44 FLUENT 4 August 29, 2016 13:19
Running UDF with Supercomputer roi247 FLUENT 4 October 15, 2015 14:41
fluent 13.0.0 received a fatal signal (SEGMENTATION VIOLATION)) alinik FLUENT 1 January 9, 2014 11:21
A fatal signal (segmentation violation) sutthinan Fluent UDF and Scheme Programming 6 March 16, 2011 19:35


All times are GMT -4. The time now is 21:34.