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

fatal signal segmentation fault

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By pakk
  • 1 Post By pakk

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 7, 2016, 13:02
Default fatal signal segmentation fault
  #1
Member
 
ERMACORA Florian
Join Date: May 2016
Posts: 39
Rep Power: 10
flo90000 is on a distinguished road
Hello,

when I want to run a simulation in transient with some UDFs and 6DOF in Fluent 17. 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 access some internal variables of FLUENT solver in the UDF. I don't know why or where there are some errors because it used in a tutorial and it works well. There are the modified UDFs which I use.


Code:
#include "udf.h"
#define X_MAX 0.0575
#define X_MIN 0.05732
#define Y_MAX 0.0554
#define Y_MIN 0.05524 
#define C2 50000.0
DEFINE_SOURCE(xmom_source_2,c,t,dS,eqn)
 {
    real pos[ND_ND];
    real con, source, x, y;
    int i;
	C_CENTROID(pos,c,t);
	x = pos[0];
	y = pos[1];
	i = 0;
	if (x > X_MIN) i++;
	if (x < X_MAX) i++;
	if (y > Y_MIN) i++;
	if (y < Y_MAX) i++;
	if (i == 4)
		{con = C2*0.5*C_R(c,t);
		source = -con*fabs(C_U(c, t))*C_U(c,t);
		dS[eqn] = -2.*con*fabs(C_U(c,t));}
	else
		source=0;
	C_UDMI(c,t,0)=source;
	return source;
 } 
DEFINE_SOURCE(ymom_source_2,c,t,dS,eqn)
 {
    real pos[ND_ND];
    real con, source, x, y;
    int i;
	C_CENTROID(pos,c,t);
	x = pos[0];
	y = pos[1];
	i = 0;
	if (x > X_MIN) i++;
	if (x < X_MAX) i++;
	if (y > Y_MIN) i++;
	if (y < Y_MAX) i++;
	if (i == 4)
		{con = C2*0.5*C_R(c,t);
		source = -con*fabs(C_V(c, t))*C_V(c,t);
		dS[eqn] = -2.*con*fabs(C_V(c,t));}
	else
		source=0;
	C_UDMI(c,t,1)=source;
	return source;
 }
Code:
#include "udf.h"

DEFINE_SDOF_PROPERTIES(Clapet_1, prop, dt, time, dtime)
{
	
	prop[SDOF_MASS] = 1.067e-7;
	prop[SDOF_IZZ] = 5,33e-11;
	prop[SDOF_ZERO_TRANS_X] = TRUE;
	prop[SDOF_ZERO_TRANS_Y] = TRUE;
	prop[SDOF_ZERO_TRANS_Z] = TRUE;
	prop[SDOF_ZERO_ROT_X] = TRUE;
	prop[SDOF_ZERO_ROT_Y] = TRUE;
	prop[SDOF_ZERO_ROT_Z] = FALSE;
		
}

DEFINE_SDOF_PROPERTIES(Clapet_2, prop, dt, time, dtime)
{
	
	prop[SDOF_MASS] = 1.067e-7;
	prop[SDOF_IZZ] = 5,33e-11;
	prop[SDOF_ZERO_TRANS_X] = TRUE;
	prop[SDOF_ZERO_TRANS_Y] = TRUE;
	prop[SDOF_ZERO_TRANS_Z] = TRUE;
	prop[SDOF_ZERO_ROT_X] = TRUE;
	prop[SDOF_ZERO_ROT_Y] = TRUE;
	prop[SDOF_ZERO_ROT_Z] = FALSE;
		
}



Thank you in advance for your help.
flo90000 is offline   Reply With Quote

Old   June 7, 2016, 13:17
Default
  #2
Senior Member
 
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 13
Bruno Machado is on a distinguished road
Quote:
Originally Posted by flo90000 View Post
Hello,

when I want to run a simulation in transient with some UDFs and 6DOF in Fluent 17. 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 access some internal variables of FLUENT solver in the UDF. I don't know why or where there are some errors because it used in a tutorial and it works well. There are the modified UDFs which I use.


Code:
#include "udf.h"
#define X_MAX 0.0575
#define X_MIN 0.05732
#define Y_MAX 0.0554
#define Y_MIN 0.05524 
#define C2 50000.0
DEFINE_SOURCE(xmom_source_2,c,t,dS,eqn)
 {
    real pos[ND_ND];
    real con, source, x, y;
    int i;
	C_CENTROID(pos,c,t);
	x = pos[0];
	y = pos[1];
	i = 0;
	if (x > X_MIN) i++;
	if (x < X_MAX) i++;
	if (y > Y_MIN) i++;
	if (y < Y_MAX) i++;
	if (i == 4)
		{con = C2*0.5*C_R(c,t);
		source = -con*fabs(C_U(c, t))*C_U(c,t);
		dS[eqn] = -2.*con*fabs(C_U(c,t));}
	else
		source=0;
	C_UDMI(c,t,0)=source;
	return source;
 } 
DEFINE_SOURCE(ymom_source_2,c,t,dS,eqn)
 {
    real pos[ND_ND];
    real con, source, x, y;
    int i;
	C_CENTROID(pos,c,t);
	x = pos[0];
	y = pos[1];
	i = 0;
	if (x > X_MIN) i++;
	if (x < X_MAX) i++;
	if (y > Y_MIN) i++;
	if (y < Y_MAX) i++;
	if (i == 4)
		{con = C2*0.5*C_R(c,t);
		source = -con*fabs(C_V(c, t))*C_V(c,t);
		dS[eqn] = -2.*con*fabs(C_V(c,t));}
	else
		source=0;
	C_UDMI(c,t,1)=source;
	return source;
 }
Code:
#include "udf.h"

DEFINE_SDOF_PROPERTIES(Clapet_1, prop, dt, time, dtime)
{
	
	prop[SDOF_MASS] = 1.067e-7;
	prop[SDOF_IZZ] = 5,33e-11;
	prop[SDOF_ZERO_TRANS_X] = TRUE;
	prop[SDOF_ZERO_TRANS_Y] = TRUE;
	prop[SDOF_ZERO_TRANS_Z] = TRUE;
	prop[SDOF_ZERO_ROT_X] = TRUE;
	prop[SDOF_ZERO_ROT_Y] = TRUE;
	prop[SDOF_ZERO_ROT_Z] = FALSE;
		
}

DEFINE_SDOF_PROPERTIES(Clapet_2, prop, dt, time, dtime)
{
	
	prop[SDOF_MASS] = 1.067e-7;
	prop[SDOF_IZZ] = 5,33e-11;
	prop[SDOF_ZERO_TRANS_X] = TRUE;
	prop[SDOF_ZERO_TRANS_Y] = TRUE;
	prop[SDOF_ZERO_TRANS_Z] = TRUE;
	prop[SDOF_ZERO_ROT_X] = TRUE;
	prop[SDOF_ZERO_ROT_Y] = TRUE;
	prop[SDOF_ZERO_ROT_Z] = FALSE;
		
}



Thank you in advance for your help.
check if it works with/without the momentum source terms. so them you can eliminate parts of your code that are not causing the problem.

other suggestion is to add couple of printing messages in your code so then you can see up to which part it works and locate the error easily. try to use
add this to different parts of your code.

Message("1");
Message("2");
Message("3");
Message("...");
Bruno Machado is offline   Reply With Quote

Old   June 7, 2016, 19:09
Default
  #3
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Use decimal places instead of commas in numbers:

Code:
prop[SDOF_IZZ] = 5,33e-11;
`e` is offline   Reply With Quote

Old   June 8, 2016, 10:30
Default
  #4
Member
 
ERMACORA Florian
Join Date: May 2016
Posts: 39
Rep Power: 10
flo90000 is on a distinguished road
Quote:
Originally Posted by Bruno Machado View Post
check if it works with/without the momentum source terms. so them you can eliminate parts of your code that are not causing the problem.

other suggestion is to add couple of printing messages in your code so then you can see up to which part it works and locate the error easily. try to use
add this to different parts of your code.

Message("1");
Message("2");
Message("3");
Message("...");

I changed the decimal places instead of commas and added some messages in the UDFs as you said. When I run without the momentum source terms, it doesn't work too. But it is writen "6DOF angular has not converged" after the message for the update of properties.
flo90000 is offline   Reply With Quote

Old   June 8, 2016, 11:44
Default
  #5
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Did you add a user defined memory?
pakk is offline   Reply With Quote

Old   June 8, 2016, 12:38
Default
  #6
Member
 
ERMACORA Florian
Join Date: May 2016
Posts: 39
Rep Power: 10
flo90000 is on a distinguished road
Quote:
Originally Posted by pakk View Post
Did you add a user defined memory?
No, I didn't add a user defined memory. How do we know the number of UDM and UDNM locations. Does a macro exist to modify them automatically?
flo90000 is offline   Reply With Quote

Old   June 8, 2016, 14:51
Default
  #7
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Quote:
Originally Posted by flo90000 View Post
No, I didn't add a user defined memory. How do we know the number of UDM and UDNM locations. Does a macro exist to modify them automatically?
I saw in your code that you use one user defined memory:

Code:
C_UDMI(c,t,0)=source;
This should ideally be mentioned somewhere where you found this code. But try what happens after you add one user defined memory location.
pakk is offline   Reply With Quote

Old   June 9, 2016, 05:25
Default
  #8
Member
 
ERMACORA Florian
Join Date: May 2016
Posts: 39
Rep Power: 10
flo90000 is on a distinguished road
Quote:
Originally Posted by pakk View Post
I saw in your code that you use one user defined memory:

Code:
C_UDMI(c,t,0)=source;
This should ideally be mentioned somewhere where you found this code. But try what happens after you add one user defined memory location.
I add the user defined location necessary but i have the same error of convergence.
flo90000 is offline   Reply With Quote

Old   June 9, 2016, 05:28
Default
  #9
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
The change I suggested does not affect convergence issues, only segmentation faults. Your original question was about segmentation faults.
pakk is offline   Reply With Quote

Old   June 9, 2016, 05:31
Default
  #10
Senior Member
 
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 13
Bruno Machado is on a distinguished road
Quote:
Originally Posted by flo90000 View Post
I add the user defined location necessary but i have the same error of convergence.
convergence or segmentation fault?
Bruno Machado is offline   Reply With Quote

Old   June 9, 2016, 05:45
Default
  #11
Member
 
ERMACORA Florian
Join Date: May 2016
Posts: 39
Rep Power: 10
flo90000 is on a distinguished road
Quote:
Originally Posted by pakk View Post
I saw in your code that you use one user defined memory:

Code:
C_UDMI(c,t,0)=source;
This should ideally be mentioned somewhere where you found this code. But try what happens after you add one user defined memory location.
Quote:
Originally Posted by pakk View Post
The change I suggested does not affect convergence issues, only segmentation faults. Your original question was about segmentation faults.
Quote:
Originally Posted by Bruno Machado View Post
convergence or segmentation fault?
Sorry, I thought these two problems were linked.
flo90000 is offline   Reply With Quote

Old   June 9, 2016, 06:01
Default
  #12
Senior Member
 
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 13
Bruno Machado is on a distinguished road
Quote:
Originally Posted by flo90000 View Post
Sorry, I thought these two problems were linked.
segmentation fault is related to he request of some information that is not available.

convergence is due to something wrong in the code that returns an unrealistic value. try to plot the values after initializing and see if they are what you expect.
Bruno Machado is offline   Reply With Quote

Old   October 20, 2017, 09:48
Default
  #13
New Member
 
Hooman
Join Date: Jan 2016
Posts: 19
Rep Power: 10
hooman.esl is on a distinguished road
Quote:
Originally Posted by Bruno Machado View Post
segmentation fault is related to he request of some information that is not available.

convergence is due to something wrong in the code that returns an unrealistic value. try to plot the values after initializing and see if they are what you expect.
Hi Bruno,
I have written this code for momentum source term for a two-phase VOF model but I faced this error:
Error: received a fatal signal (Segmentation fault).
what wrong is with it?
do you have any idea which parameter is undefined?
thank you.

Quote:
#include "udf.h"
#define porosity 0.183 /*soil property porosity*/
#define sat_0_w 0.3 /*soil property residual water saturation*/
#define sat_0_g 0.1 // *************************shahab gerami page 134(table)**************************************** ******
#define k_abs 0.9671e-13 /* k: (intrinsic) permeability [L2] K: hydraulic conductivity [l/T ]=k rho gravity/nu */
DEFINE_SOURCE(source,c,t,dS,eqn)
{
Thread *mix_th, *water_th;
real k_avrg, rel_k_m, source, sat_w, relsat_w, rel_k_w;
mix_th = THREAD_SUPER_THREAD(t);
water_th = THREAD_SUB_THREAD(mix_th, 0);
sat_w = C_VOF(c,water_th);
relsat_w = (sat_w-sat_0_w)/(1-sat_0_g-sat_0_w);
rel_k_w = pow(relsat_w,4);
rel_k_m = (1-pow(relsat_w,2))*pow((1-relsat_w),(2));
k_avrg = rel_k_w*sat_w+rel_k_m*(1-sat_w);
source = -1*C_U(c,t)*C_MU_L(c,t)/(k_abs*k_avrg);
dS[eqn] = -1*C_MU_L(c,t)/(k_abs*k_avrg);
return source;
}
hooman.esl is offline   Reply With Quote

Old   October 23, 2017, 05:40
Default
  #14
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
C_U(c,t) or C_MU_L(c,t) (velocity or viscosity)

You try to define a source that needs information on velocity and viscosity. But apparently Fluent calculates this source before it calculates velocity and/or viscosity.

Solution: initialize your simulation without this UDF, and load the UDF afterwards.
hooman.esl likes this.
pakk is offline   Reply With Quote

Old   October 23, 2017, 10:39
Default received a fatal signal (Segmentation fault).
  #15
New Member
 
Hooman
Join Date: Jan 2016
Posts: 19
Rep Power: 10
hooman.esl is on a distinguished road
Quote:
Originally Posted by pakk View Post
C_U(c,t) or C_MU_L(c,t) (velocity or viscosity)

You try to define a source that needs information on velocity and viscosity. But apparently Fluent calculates this source before it calculates velocity and/or viscosity.

Solution: initialize your simulation without this UDF, and load the UDF afterwards.
Hi Pakk,
thank you for the reply.
i did it as you said and also i run the simulation for a second without the UDF that fluent calculate that parameters but, the error appeared again.
hooman.esl is offline   Reply With Quote

Old   October 24, 2017, 05:40
Default
  #16
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Then find out what it by making a minimal example.

In the example below, I replaced C_U and C_MU_L by constants. Does it work now? Then the problem is in one of these two. Does it still not work? Then your problem is somewhere else.

Code:
#include "udf.h"
#define porosity 0.183 /*soil property porosity*/
#define sat_0_w 0.3 /*soil property residual water saturation*/
#define sat_0_g 0.1 // *************************shahab gerami page 134(table)**************************************** ******
#define k_abs 0.9671e-13 /* k: (intrinsic) permeability [L2] K: hydraulic conductivity [l/T ]=k rho gravity/nu */
DEFINE_SOURCE(source,c,t,dS,eqn)
{
Thread *mix_th, *water_th;
real k_avrg, rel_k_m, source, sat_w, relsat_w, rel_k_w;
mix_th = THREAD_SUPER_THREAD(t);
water_th = THREAD_SUB_THREAD(mix_th, 0);
sat_w = C_VOF(c,water_th);
relsat_w = (sat_w-sat_0_w)/(1-sat_0_g-sat_0_w);
rel_k_w = pow(relsat_w,4);
rel_k_m = (1-pow(relsat_w,2))*pow((1-relsat_w),(2));
k_avrg = rel_k_w*sat_w+rel_k_m*(1-sat_w);
source = -1e-6/(k_abs*k_avrg);
dS[eqn] = -1e-6*/(k_abs*k_avrg);
return source;
}
Find the simplest code that fails, and then you know where the problem is.
hooman.esl likes this.
pakk is offline   Reply With Quote

Old   October 26, 2017, 19:28
Default
  #17
New Member
 
Hooman
Join Date: Jan 2016
Posts: 19
Rep Power: 10
hooman.esl is on a distinguished road
Quote:
Originally Posted by pakk View Post
Then find out what it by making a minimal example.

In the example below, I replaced C_U and C_MU_L by constants. Does it work now? Then the problem is in one of these two. Does it still not work? Then your problem is somewhere else.

Code:
#include "udf.h"
#define porosity 0.183 /*soil property porosity*/
#define sat_0_w 0.3 /*soil property residual water saturation*/
#define sat_0_g 0.1 // *************************shahab gerami page 134(table)**************************************** ******
#define k_abs 0.9671e-13 /* k: (intrinsic) permeability [L2] K: hydraulic conductivity [l/T ]=k rho gravity/nu */
DEFINE_SOURCE(source,c,t,dS,eqn)
{
Thread *mix_th, *water_th;
real k_avrg, rel_k_m, source, sat_w, relsat_w, rel_k_w;
mix_th = THREAD_SUPER_THREAD(t);
water_th = THREAD_SUB_THREAD(mix_th, 0);
sat_w = C_VOF(c,water_th);
relsat_w = (sat_w-sat_0_w)/(1-sat_0_g-sat_0_w);
rel_k_w = pow(relsat_w,4);
rel_k_m = (1-pow(relsat_w,2))*pow((1-relsat_w),(2));
k_avrg = rel_k_w*sat_w+rel_k_m*(1-sat_w);
source = -1e-6/(k_abs*k_avrg);
dS[eqn] = -1e-6*/(k_abs*k_avrg);
return source;
}
Find the simplest code that fails, and then you know where the problem is.
I did that and found out that the problem is the part that i want to access the volume fraction of the primary phase( C_VOF(c,water_th)).
i dont know what to do with that.
hooman.esl 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
fluentError: received a fatal signal (Segmentation fault). thomaszhangjing Fluent UDF and Scheme Programming 11 January 13, 2021 10:37
a fatal signal (segmentation fault) Turbo_hrf Fluent UDF and Scheme Programming 4 September 14, 2017 10:35
Fluent udf Error: received a fatal signal (Segmentation fault) syble FLUENT 3 December 9, 2016 17:28
receive fluent received a fatal signal (Segmentation fault). chenkaiqe FLUENT 2 March 10, 2015 09:21
error while compiling the USER Sub routine CFD user CFX 3 November 25, 2002 16:16


All times are GMT -4. The time now is 11:56.