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

fluentError: received a fatal signal (Segmentation fault).

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree5Likes
  • 4 Post By polaritus
  • 1 Post By paoching

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 19, 2014, 22:50
Smile fluentError: received a fatal signal (Segmentation fault).
  #1
New Member
 
zj
Join Date: Jul 2014
Posts: 2
Rep Power: 0
thomaszhangjing is on a distinguished road
Im now simulating the gas-liquid two-phase flow in vertical pipe. I have written UDF including adjust function and diffusivity function. When i loaded the adjust function, the case can be calculated.However, once i added the diffusivity function, the error appeared as shown below:

Error: received a fatal signal (Segmentation fault).

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


The UDF is presented below, i couldn't find the reason for the error for a long time. Could anyone do me a favor? Thank you very much!!!


#include "udf.h"

/* Define which user-defined scalars to use. */
enum
{
MF=0,
N_REQUIRED_UDS
};

DEFINE_ADJUST(adjust_droplet_mass_fraction, mixture_domain)
{
cell_t c;
Thread **pt;
Thread *cell_threads;
/* Domain *mixture_domain; /* t is mixture_thread according to the definition of the ADJUST Macro */
mixture_domain = Get_Domain(1);

/* Make sure there are enough user defined-scalars. */
if (n_uds < N_REQUIRED_UDS)
Internal_Error("not enough user-defined scalars allocated");

/* Fill UDS with the variable. */
mp_thread_loop_c(cell_threads, mixture_domain, pt)
{
begin_c_loop (c,cell_threads)
{
C_UDSI(c,cell_threads,MF)= C_VOF(c,pt[1])*C_VOLUME(c,cell_threads)*C_R(c,pt[1])/(C_VOF(c,pt[1])*C_VOLUME(c,cell_threads)*C_R(c,pt[1])+C_VOF(c,pt[0])*C_VOLUME(c,cell_threads)*C_R(c,pt[0])); /*DEFINE the mass fraction of the droplet, the scalar*/
}
end_c_loop (c,cell_threads)
}
}



#include "udf.h"

DEFINE_DIFFUSIVITY(my_uds_diffusivity,c,t,i)
{
/*int phase_domain_index=0;*/
Thread **primary_t=THREAD_SUB_THREADS(t); /* primary phase pointer*/
return C_R(c,primary_t[0])*C_MU_EFF(c,primary_t[0])*C_R(c,primary_t[0])*C_K(c,t)*C_K(c,t)/C_D(c,t);
}
thomaszhangjing is offline   Reply With Quote

Old   September 11, 2014, 05:45
Default
  #2
New Member
 
Rita Szijarto
Join Date: Oct 2013
Posts: 3
Rep Power: 8
polaritus is on a distinguished road
The segmentation fault means that you try to access a variable, which is not saved.

The problem might be with the C_D turbulent kinetic energy dissipation rate. Do you use the k-epsilon model? If you use anything different, like k-omega, then the epsilon is not saved, and when you call C_D, you will have a segmentation fault.

Try to use epsilon = 0.09*omega * k instead.
zobekenobe, alinik, fyyuan and 1 others like this.

Last edited by polaritus; September 12, 2014 at 04:53.
polaritus is offline   Reply With Quote

Old   November 3, 2016, 12:12
Default
  #3
Senior Member
 
ali
Join Date: Oct 2009
Posts: 318
Rep Power: 13
alinik is on a distinguished road
Quote:
Originally Posted by polaritus View Post
The segmentation fault means that you try to access a variable, which is not saved.

The problem might be with the C_D turbulent kinetic energy dissipation rate. Do you use the k-epsilon model? If you use anything different, like k-omega, then the epsilon is not saved, and when you call C_D, you will have a segmentation fault.

Try to use epsilon = 0.09*omega * k instead.
Hi Rita,

Is there anyway to trace and find what variable is causing this error? Also what is the workaround to this problem?
alinik is offline   Reply With Quote

Old   December 9, 2016, 16:14
Default
  #4
Senior Member
 
ali
Join Date: Oct 2009
Posts: 318
Rep Power: 13
alinik is on a distinguished road
Thomas, did you solve this?

Quote:
Originally Posted by thomaszhangjing View Post
Im now simulating the gas-liquid two-phase flow in vertical pipe. I have written UDF including adjust function and diffusivity function. When i loaded the adjust function, the case can be calculated.However, once i added the diffusivity function, the error appeared as shown below:

Error: received a fatal signal (Segmentation fault).

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


The UDF is presented below, i couldn't find the reason for the error for a long time. Could anyone do me a favor? Thank you very much!!!


#include "udf.h"

/* Define which user-defined scalars to use. */
enum
{
MF=0,
N_REQUIRED_UDS
};

DEFINE_ADJUST(adjust_droplet_mass_fraction, mixture_domain)
{
cell_t c;
Thread **pt;
Thread *cell_threads;
/* Domain *mixture_domain; /* t is mixture_thread according to the definition of the ADJUST Macro */
mixture_domain = Get_Domain(1);

/* Make sure there are enough user defined-scalars. */
if (n_uds < N_REQUIRED_UDS)
Internal_Error("not enough user-defined scalars allocated");

/* Fill UDS with the variable. */
mp_thread_loop_c(cell_threads, mixture_domain, pt)
{
begin_c_loop (c,cell_threads)
{
C_UDSI(c,cell_threads,MF)= C_VOF(c,pt[1])*C_VOLUME(c,cell_threads)*C_R(c,pt[1])/(C_VOF(c,pt[1])*C_VOLUME(c,cell_threads)*C_R(c,pt[1])+C_VOF(c,pt[0])*C_VOLUME(c,cell_threads)*C_R(c,pt[0])); /*DEFINE the mass fraction of the droplet, the scalar*/
}
end_c_loop (c,cell_threads)
}
}



#include "udf.h"

DEFINE_DIFFUSIVITY(my_uds_diffusivity,c,t,i)
{
/*int phase_domain_index=0;*/
Thread **primary_t=THREAD_SUB_THREADS(t); /* primary phase pointer*/
return C_R(c,primary_t[0])*C_MU_EFF(c,primary_t[0])*C_R(c,primary_t[0])*C_K(c,t)*C_K(c,t)/C_D(c,t);
}
alinik is offline   Reply With Quote

Old   June 3, 2017, 06:27
Default Doubt regarding UDF
  #5
New Member
 
Ravi
Join Date: May 2017
Posts: 7
Rep Power: 5
raviramesh10 is on a distinguished road
Hello everyone,

I am simulating the behaviour of the non-Newtonian fluid, Colgate on top of a vibrating membrane of a speaker. I have been working on a UDF to apply on a vibrating membrane, giving it a sinusoidal input velocity, i.e.,
v =v0* cos(pi*x/L)*sin(2*pi*f*t)

Where v0 is the maximum velocity achieved by the vibrating membrane and pi is already defined. f is the input frequency which I have obtained from previous experiments.

The code I have written is as follows, but it shows a segmentation error:

#include "udf.h"
#include "dynamesh_tools.h"
#define pi 22/7
DEFINE_GRID_MOTION(inlet_y_velocity,d,dt,time,dtim e)
{
Thread *t;
real y[ND_ND];
real x_c;
face_t f;
int n;
begin_f_loop(f,t,n)
{
x_c=y[0];
y[0]=.2*cos((pi*x_c)/.08)*sin(2*pi*120*time);
}
end_f_loop(f,t)
}

I would be highly grateful if somebody could help me on the same.
raviramesh10 is offline   Reply With Quote

Old   June 4, 2017, 03:02
Default
  #6
Member
 
Quang Le Dang
Join Date: Jun 2012
Posts: 61
Rep Power: 10
SPH_CFD is on a distinguished road
Quote:
Originally Posted by raviramesh10 View Post
Hello everyone,

I am simulating the behaviour of the non-Newtonian fluid, Colgate on top of a vibrating membrane of a speaker. I have been working on a UDF to apply on a vibrating membrane, giving it a sinusoidal input velocity, i.e.,
v =v0* cos(pi*x/L)*sin(2*pi*f*t)

Where v0 is the maximum velocity achieved by the vibrating membrane and pi is already defined. f is the input frequency which I have obtained from previous experiments.

The code I have written is as follows, but it shows a segmentation error:

#include "udf.h"
#include "dynamesh_tools.h"
#define pi 22/7
DEFINE_GRID_MOTION(inlet_y_velocity,d,dt,time,dtim e)
{
Thread *t;
real y[ND_ND];
real x_c;
face_t f;
int n;
begin_f_loop(f,t,n)
{
x_c=y[0];
y[0]=.2*cos((pi*x_c)/.08)*sin(2*pi*120*time);
}
end_f_loop(f,t)
}

I would be highly grateful if somebody could help me on the same.
Firstly, I think definition of Pi should be
#define pi 3.1416

Secondly, what is your output? Because in your code, you write
x_c=y[0];
y[0]=.2*cos((pi*x_c)/.08)*sin(2*pi*120*time);

Don't have any initialization

y[0] don't have any value and after that you insert into x_c. And then use x_c to calculate y[0]. It means that you only calculate null ???
SPH_CFD is offline   Reply With Quote

Old   June 4, 2017, 05:42
Default
  #7
New Member
 
Ravi
Join Date: May 2017
Posts: 7
Rep Power: 5
raviramesh10 is on a distinguished road
Quote:
Originally Posted by SPH_CFD View Post
Firstly, I think definition of Pi should be
#define pi 3.1416

Secondly, what is your output? Because in your code, you write
x_c=y[0];
y[0]=.2*cos((pi*x_c)/.08)*sin(2*pi*120*time);

Don't have any initialization

y[0] don't have any value and after that you insert into x_c. And then use x_c to calculate y[0]. It means that you only calculate null ???
OK, sir, I will do the needful.
My output is supposed to be the vibrating membrane vibrating with a sinusoidal velocity input given. I understood the error there.
But doesn't y[0] imply that I am initializing the y-velocity component?

I have done some editing. Does the below code make more sense?

#include "udf.h"
#include "dynamesh_tools.h"
#define pi 3.1416
DEFINE_GEOM(plane,domain,dt,position)
{
position[1]=0.001;
}
DEFINE_GRID_MOTION(inlet_y_velocity,d,dt,time,dtim e)
{
Thread *t;
real y[ND_ND];
real x_c;
face_t f;
real v;
Node *w;
int n;
SET_DEFORMING_THREAD_FLAG(THREAD_TO(t));

begin_f_loop(f,t)
{
f_node_loop(f,t)
{
w = F_NODE(f,t,n);
if (NODE_X(v)>0 && NODE_X(v)<0.08 && NODE_Y(v)==0 && NODE_POS_NEED_UPDATE(v))
{
NODE_POS_UPDATED(v);
v=.2*cos((pi*x_c)/.08)*sin(2*pi*120*time);
}
end_f_loop(f,t)
}
}

Last edited by raviramesh10; June 4, 2017 at 08:24.
raviramesh10 is offline   Reply With Quote

Old   June 19, 2017, 05:11
Default
  #8
New Member
 
Shravan
Join Date: Mar 2017
Posts: 4
Rep Power: 5
Severus is on a distinguished road
Hello,
Usually we get segmentation error in UDM when we have used it in a UDF but havent set the number of UDMs in fluent GUI.

When we compile a UDF in which we use a UDM, before compiling we should go to DEFINE->User Defined->Memory and Set the number as you wish

Hope this helps
Severus is offline   Reply With Quote

Old   June 19, 2017, 05:17
Default
  #9
New Member
 
Shravan
Join Date: Mar 2017
Posts: 4
Rep Power: 5
Severus is on a distinguished road
Quote:
Originally Posted by Severus View Post
Hello,
Usually we get segmentation error in UDM when we have used it in a UDF but havent set the number of UDMs in fluent GUI.

When we compile a UDF in which we use a UDM, before compiling we should go to DEFINE->User Defined->Memory and Set the number as you wish

Hope this helps
Sorry by mistake posted in this Forum, and unable to delete
Severus is offline   Reply With Quote

Old   June 30, 2017, 03:05
Default Received a fatal Signal ( Segmentation fault )
  #10
Member
 
Muhammad Furqan Ali
Join Date: Oct 2014
Location: beijing
Posts: 53
Rep Power: 7
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
furqanrk is offline   Reply With Quote

Old   September 6, 2018, 18:57
Default Please have a look at my UDF and let me know what could be causing Segmentation error
  #11
New Member
 
Paul Lee
Join Date: Jun 2018
Location: Vancouver
Posts: 14
Rep Power: 4
paoching is on a distinguished road
Hi all, I'm writing a udf for galvanic corrosion damage. Below is my code. I was able to compile and load it, but ran into segmentation fault when I tried to run it. Please take a look and give me some ideas on how to fix it.
Code:
/**********************************************************
 node motion based on corrosion rate calculated from electric
 current density compiled UDF
 **********************************************************/
#include "udf.h"
#include "metric.h"
#include "mem.h"
#include "sg_udms.h"
#include "sg.h"
#include "models.h"
#include "dynamesh_tools.h"
DEFINE_GRID_MOTION(corrosion_rate,domain,dt,time,dtime)
{	
	Thread	*tf = DT_THREAD(dt);
	face_t	f;
	cell_t	c;
	Node	*v;
	real	y;
	int		n;
	real	F=96485.34;		//Faraday's constant C/mol or A*s/mol
	real	MWT=26.981539;	//molecular weight
	int		z=3;			//al ion charge#
	real	RHO=2700000;	//Al density g/m^3
	real	sigma=5;
	real	k=(-sigma*MWT/(z*F*RHO));
	thread_loop_c (tf,domain)
	{
		begin_c_loop (c,tf)
		{
			C_UDMI(c,tf,0) = k*C_PHI_1_G(c,tf)[1];
		}
		end_c_loop (c,tf)
	}
	/* set deforming flag on adjacent cell zone */
	SET_DEFORMING_THREAD_FLAG(THREAD_T0(tf));
	Message ("time = %f, Cr = %f\n", time);
	begin_f_loop(f,tf)
		{
			f_node_loop(f,tf,n)
			{
				v = F_NODE(f,tf,n);
				if (NODE_POS_NEED_UPDATE (v))
				{
					/* indicate that node position has been update
					so that it's not updated more than once */
					NODE_POS_UPDATED(v);
					NODE_Y(v) -= C_UDMI(c,tf,0)*dtime;	//new y position
				}
			}
		}
	end_f_loop(f,tf);
}
Here is the error message I get:
Quote:
Error: received a fatal signal (Segmentation fault).
Error Object: #f
djamila77 likes this.
paoching is offline   Reply With Quote

Reply

Tags
adjust function, udf, udsi

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
VOF model error:Cortex received a fatal signal (SEGMENTATION VIOLATION) Sdezmond Fluent Multiphase 4 July 20, 2017 03:03
Fluent15: received a fatal signal (Segmentation fault) lcg44 FLUENT 4 August 29, 2016 12:19
A fatal signal (segmentation violation) sutthinan Fluent UDF and Scheme Programming 6 March 16, 2011 18:35
Fluent.6.2.received a fatal signal (SEGMENTATION ) Jungfeng FLUENT 0 October 8, 2007 11:05
error while compiling the USER Sub routine CFD user CFX 3 November 25, 2002 15:16


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