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/)
-   -   Fluent udf Error: received a fatal signal (Segmentation fault) Error Object: #f (https://www.cfd-online.com/Forums/fluent-udf/188129-fluent-udf-error-received-fatal-signal-segmentation-fault-error-object-f.html)

dikmeha May 23, 2017 15:17

Fluent udf Error: received a fatal signal (Segmentation fault) Error Object: #f
 
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!

Светлана May 25, 2017 20:53

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;
}

dikmeha May 26, 2017 20:58

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?

Светлана May 28, 2017 18:58

program it
 
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;
}

furqanrk June 30, 2017 03:06

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

Светлана July 3, 2017 22:35

Simplify, show code
 
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, https://www.cfd-online.com/Forums/fl...tml#post653270 — 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.

...n... July 4, 2017 01:45

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)
}


KaLium July 4, 2017 02:28

Quote:

Originally Posted by ...n... (Post 655738)
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

...n... July 4, 2017 02:50

Quote:

Originally Posted by KaLium (Post 655746)

I used face macros as you instructed but I'm still getting the same error. :(

KaLium July 4, 2017 02:52

try also face-loop

...n... July 4, 2017 03:11

Quote:

Originally Posted by KaLium (Post 655750)
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.

KaLium July 4, 2017 05:13

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

...n... July 4, 2017 06:25

Quote:

Originally Posted by KaLium (Post 655773)
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.

KaLium July 4, 2017 08:37

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?

...n... July 4, 2017 09:20

Quote:

Originally Posted by KaLium (Post 655801)
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.

KaLium July 4, 2017 09:34

That is interesting :eek:

pachi July 23, 2017 11:24

Error in fluent
 
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

yanghai April 12, 2018 09:40

Quote:

Originally Posted by ...n... (Post 655738)
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)
}

obscureed April 13, 2018 02:51

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 April 13, 2018 03:42

Hello Yanghai,

I now see that you have posted the same question elsewhere (https://www.cfd-online.com/Forums/fl...-pressure.html), and pakk has given you some good advice. We should focus one on the question in one place only.

Ed


All times are GMT -4. The time now is 09:54.