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

Error: received a fatal signal (Segmentation fault).

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

Like Tree1Likes
  • 1 Post By MayTheFlowBeWithYou

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 13, 2017, 05:43
Unhappy Error: received a fatal signal (Segmentation fault).
  #1
Member
 
MayTheFlowBeWithYou's Avatar
 
I have to remain anonymous, I'm sorry.
Join Date: Jun 2017
Location: The Netherlands, Delft University of Technology
Posts: 48
Rep Power: 5
MayTheFlowBeWithYou is on a distinguished road
Dear CFD Online people,

In trying to run a simulation for a membrane (in 2D) I run into a problem when I try to use UDF's. Through commenting stuff out I have boiled the problem down to the following script (I have left everything else out for simplicity). The problem arises in the "Get_Domain" part:


#include "udf.h"

DEFINE_ON_DEMAND(get_coords)
{
Domain *domain;
domain = Get_Domain(1);
}


Interpreting this works perfectly, however, when I run it I get the following:

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

I can't figure out why and how to fix this, the rest of the simulation as of now consists of two laminar flow going in counter-current through a 2D "tube", separated by a wall along the length of the "tube".

I think it could be the domain ID being incorrect somehow, but I have no idea why it would be wrong.

I use Fluent R17.1

Thank you very much for helping me.
MayTheFlowBeWithYou is offline   Reply With Quote

Old   June 13, 2017, 06:19
Default
  #2
Senior Member
 
Join Date: Aug 2014
Location: Germany
Posts: 292
Rep Power: 9
BlnPhoenix is on a distinguished road
You should post your hole UDF. From this snippet alone nothing seems wrong for me at first glance.
BlnPhoenix is offline   Reply With Quote

Old   June 13, 2017, 06:55
Default
  #3
Member
 
MayTheFlowBeWithYou's Avatar
 
I have to remain anonymous, I'm sorry.
Join Date: Jun 2017
Location: The Netherlands, Delft University of Technology
Posts: 48
Rep Power: 5
MayTheFlowBeWithYou is on a distinguished road
Indeed, but what I did is literally run this snippet, and that already doesn't run. The rest of the code is something I took from an example from here somewhere.

#include "udf.h"

DEFINE_ON_DEMAND(Membraneror)
{
Domain *domain; /* Get the domain using Fluent utility, domain is declared as a variable */
face_t f;
cell_t c, c0;

Thread *t, *t0, *ct;

int Zone_ID = 3; /* Zone Id can be seen in the Boundary Condition Panel, for me 3 = Wall */
domain = Get_Domain(1); /* returns fluid domain pointer */

/* Initialize cells */
/* This loops over all cells and lets the UDM =0 */
thread_loop_c(ct,d)
{
begin_c_loop(c,ct)
{
C_UDMI(c,ct,0)=0.0;
}
end_c_loop(c,ct)
}

/* Loop over all faces on wall */
t = Lookup_Thread(d, Zone_ID);
begin_f_loop(f,t)
{
/* c0 and t0 identify the adjecent cell */
c0 = F_C0(f, t);
t0 = THREAD_T0(t);
/* This loops over all cells adjacent to the wall and lets the UDM = 2.0 */
C_UDMI(c0, t0, 0)=2.0;
}
end_f_loop(f,t)
}
MayTheFlowBeWithYou is offline   Reply With Quote

Old   June 13, 2017, 07:25
Default
  #4
Senior Member
 
Join Date: Aug 2014
Location: Germany
Posts: 292
Rep Power: 9
BlnPhoenix is on a distinguished road
I'm unfortunately no expert with UDFs but did you initialize the User Defined Memory?
BlnPhoenix is offline   Reply With Quote

Old   June 13, 2017, 07:28
Default
  #5
Member
 
MayTheFlowBeWithYou's Avatar
 
I have to remain anonymous, I'm sorry.
Join Date: Jun 2017
Location: The Netherlands, Delft University of Technology
Posts: 48
Rep Power: 5
MayTheFlowBeWithYou is on a distinguished road
I don't think so, I don't even know how to. I haven't done anything besides interpreting and executing the code.
MayTheFlowBeWithYou is offline   Reply With Quote

Old   June 14, 2017, 04:09
Question Sort of fixed...
  #6
Member
 
MayTheFlowBeWithYou's Avatar
 
I have to remain anonymous, I'm sorry.
Join Date: Jun 2017
Location: The Netherlands, Delft University of Technology
Posts: 48
Rep Power: 5
MayTheFlowBeWithYou is on a distinguished road
I had re-installed fluent 17.1, because I believed the installation was not good, since it literally sais in the manual that wat I was doing should work.

I have also tried running the thing on fluent 15.1 and it sort of worked there (sometimes it worked, sometimes it gave the same error)

I have now installed fluent 18.1 and so far it seems to work on there. I changed nothing to the script or the way I execute it at all.

I still think something must have been wrong in the installation of fluent, I just don't know what.
MayTheFlowBeWithYou is offline   Reply With Quote

Old   June 14, 2017, 04:18
Default
  #7
Senior Member
 
Join Date: Aug 2014
Location: Germany
Posts: 292
Rep Power: 9
BlnPhoenix is on a distinguished road
Uhm, sounds weird.

What i orignally meant with initialzing the User Defined Memory is that u use the Macro "C_UDMI" in your UDF. Therfore before running you need to allocate it first.

From the UDF Manual:

"3.2.10. User-Defined Memory (UDM) Macros
This section contains macros that access user-defined memory (UDM) and user-defined node memory
(UDNM) variables in ANSYS Fluent.
Before you can store variables in memory using the macros provided below, you will first need to allocate
the appropriate number of memory location(s) in the User-Defined Memory dialog box in ANSYS Fluent.
Define 􀀀 User-Defined 􀀀 Memory...
Important
Note that if you try to use F_UDMI, C_UDMI, or N_UDMI before you have allocated memory,
then an error will result.
"


I've not yet used C_UDMI myself. But maybe that could cause the problem.

UDF's should work in general with FLUENT 17.1, 18.1 equally...
BlnPhoenix is offline   Reply With Quote

Old   June 14, 2017, 04:31
Default
  #8
Member
 
MayTheFlowBeWithYou's Avatar
 
I have to remain anonymous, I'm sorry.
Join Date: Jun 2017
Location: The Netherlands, Delft University of Technology
Posts: 48
Rep Power: 5
MayTheFlowBeWithYou is on a distinguished road
hmmm, yes, that could be something as well, I didn't attempt to run the whole script yet all I did so far was:

#include "udf.h"

DEFINE_ON_DEMAND(get_coords)
{
Domain *domain;
domain = Get_Domain(1);
}

Because that already caused problems under 17.1, but now seems to be just fine, so that's at least one step forward.

For now, I first want to make an entirely new project in 18.1 and draw a new geometry (they actually changed the geometry software in this version so it might take some time to do it), because I'm scared of running into wierd compatibility issues or something.

I'll update here once I run the complete script.
MayTheFlowBeWithYou is offline   Reply With Quote

Old   June 14, 2017, 05:15
Default
  #9
D.M
Member
 
Davoud Malekian
Join Date: Jan 2016
Posts: 53
Rep Power: 6
D.M is on a distinguished road
Quote:
Originally Posted by MayTheFlowBeWithYou View Post
Indeed, but what I did is literally run this snippet, and that already doesn't run. The rest of the code is something I took from an example from here somewhere.

#include "udf.h"

DEFINE_ON_DEMAND(Membraneror)
{
Domain *domain; /* Get the domain using Fluent utility, domain is declared as a variable */
face_t f;
cell_t c, c0;

Thread *t, *t0, *ct;

int Zone_ID = 3; /* Zone Id can be seen in the Boundary Condition Panel, for me 3 = Wall */
domain = Get_Domain(1); /* returns fluid domain pointer */

/* Initialize cells */
/* This loops over all cells and lets the UDM =0 */
thread_loop_c(ct,d)
{
begin_c_loop(c,ct)
{
C_UDMI(c,ct,0)=0.0;
}
end_c_loop(c,ct)
}

/* Loop over all faces on wall */
t = Lookup_Thread(d, Zone_ID);
begin_f_loop(f,t)
{
/* c0 and t0 identify the adjecent cell */
c0 = F_C0(f, t);
t0 = THREAD_T0(t);
/* This loops over all cells adjacent to the wall and lets the UDM = 2.0 */
C_UDMI(c0, t0, 0)=2.0;
}
end_f_loop(f,t)
}



Hi,
i have checked all the lines of your code, and it is completely right, i even compiled it and used it without any error, just change the Domain *domain; to Domain *d; (where ever u see domain change it to d)(cause u have used "d" in the line 16 of your code and not "domain") , and before starting your calculation, go to Define......User-Defined......memory and change the number of the user defined memory locations to 2.
D.M is offline   Reply With Quote

Old   June 14, 2017, 05:56
Thumbs up
  #10
Member
 
MayTheFlowBeWithYou's Avatar
 
I have to remain anonymous, I'm sorry.
Join Date: Jun 2017
Location: The Netherlands, Delft University of Technology
Posts: 48
Rep Power: 5
MayTheFlowBeWithYou is on a distinguished road
When I first ran it, I had the same error again, but I figured out that now it was caused by the Zone_ID for the wall being incorrect (it changed because I re-drew the entire geometry). Anyway, thanks a lot for your help, I guess we'll never know why it didn't run on 17.1 for me (I had already fixed the things you said on there).

For anyone ending up here by searching this problem perhaps years later:

I still think something must have went wrong in installing it, even though I have done it 3 times over. This is because I also tried it on an old ANSYS 15.1 and it ran on there just fine. Also when I tried to open things I made in ANSYS 15.1 with ANSYS 17.1 it said I was missing modules:




Some other causes for segmentation errors I found are incorrect Zone_ID (see the code underneath) and forgetting to allocate "user defined memory locations".

For completion, here is the correct code:

#include "udf.h"

DEFINE_ON_DEMAND(Wall_Identification)
{
Domain *d; /* Get the domain using Fluent utility, domain is declared as a variable */
face_t f;
cell_t c, c0;

Thread *t, *t0, *ct;

int Zone_ID = 2; /* Zone Id can be seen in the Boundary Condition Panel, for me 2 = Wall */
d = Get_Domain(1); /* returns fluid domain pointer */

/* Initialize cells */
/* This loops over all cells and lets the UDM =0 */
thread_loop_c(ct,d)
{
begin_c_loop(c,ct)
{
C_UDMI(c,ct,0)=0.0;
}
end_c_loop(c,ct)
}

/* Loop over all faces on wall */
t = Lookup_Thread(d, Zone_ID);
begin_f_loop(f,t)
{
/* c0 and t0 identify the adjecent cell */
c0 = F_C0(f, t);
t0 = THREAD_T0(t);
/* This loops over all cells adjacent to the wall and lets the UDM = 2.0 */
C_UDMI(c0, t0, 0)=2.0;
}
end_f_loop(f,t)
}

Also I found that allocating 1 user defined memory location is enough.
D.M likes this.

Last edited by MayTheFlowBeWithYou; June 14, 2017 at 09:35.
MayTheFlowBeWithYou is offline   Reply With Quote

Old   June 15, 2017, 00:11
Default
  #11
Senior Member
 
Lucky Tran
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 4,007
Rep Power: 48
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
A segmentation fault is always because you tried to access a memory location that doesn't exist.
You tried to use the define on demand macro but didn't allocate memory for your define on demand. Nothing special here.

You only need 1 UDM because you only have 1 UDM.

C_UDMI(c,ct,0) means put the values in UDM 0
LuckyTran is offline   Reply With Quote

Old   June 15, 2017, 03:16
Default
  #12
Member
 
MayTheFlowBeWithYou's Avatar
 
I have to remain anonymous, I'm sorry.
Join Date: Jun 2017
Location: The Netherlands, Delft University of Technology
Posts: 48
Rep Power: 5
MayTheFlowBeWithYou is on a distinguished road
I did in fact allocate memory, that was not the problem.
MayTheFlowBeWithYou is offline   Reply With Quote

Old   June 30, 2017, 03:09
Default Received a fatal Signal ( Segmentation fault )
  #13
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

Reply

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
fluentError: received a fatal signal (Segmentation fault). thomaszhangjing Fluent UDF and Scheme Programming 10 September 6, 2018 18:57
Fluent udf Error: received a fatal signal (Segmentation fault) Error Object: #f dikmeha Fluent UDF and Scheme Programming 20 April 13, 2018 04:06
a fatal signal (segmentation fault) Turbo_hrf Fluent UDF and Scheme Programming 4 September 14, 2017 09:35
Received a fatal signal (Segmentation fault) with UDF lisa_china Fluent UDF and Scheme Programming 2 June 30, 2017 03:07
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 15:52.