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

UDF about Searching the Adjacent cells: Please help me to find out the error

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 8, 2018, 04:58
Question UDF about Searching the Adjacent cells: Please help me to find out the error
  #1
New Member
 
Murray Lee
Join Date: Jul 2018
Posts: 4
Rep Power: 8
Hotpig1100 is on a distinguished road
I complied UDF about searching the adjacent cells of specific cells (cells of gas-liquid interface) and then read data from the adjacent cells. When I run the simulation, there is an error said "received a fatal signal (segementation fault)" occurred. I have debugged for a long time but didn't solve it. As a greenhand, I don't know whether there is a logical error in my UDF or wrongly used some Macros.
Please help me! Thanks!

My UDF (Part):

DEFINE_ADJUST(adjacent,domain)
{
cell_t c,c0,c1;
face_t f;
int n;
Thread *mix_th,*gas_th,*liq_th;

mix_th=Lookup_Thread(domain,2);
gas_th=THREAD_SUB_THREAD(mix_th,1);
liq_th=THREAD_SUB_THREAD(mix_th,0);

begin_c_loop(c,mix_th)
{
if(C_VOF(c,gas_th)<=0.999 && C_VOF(c,gas_th)>=0.001)
{
c_face_loop(c,mix_th,n)
{
f=C_FACE(c,mix_th,n);
c0=F_C0(f,gas_th);
c1=F_C1(f,liq_th);
}
}

if(C_VOF(c0,gas_th)<=0.999 && C_VOF(c0,gas_th)>=0.001 && C_VOF(c1,gas_th)<=0.001)
{
C_UDMI(c,gas_th,0)=C_UDSI(c0,gas_th,1);
C_UDMI(c,liq_th,1)=C_UDSI(c1,liq_th,0);
}
if(C_VOF(c1,gas_th)<=0.999 && C_VOF(c1,gas_th)>=0.001 && C_VOF(c0,gas_th)>=0.999)
{
C_UDMI(c,gas_th,2)=C_UDSI(c0,gas_th,1);
C_UDMI(c,liq_th,3)=C_UDSI(c1,liq_th,0);
}
}
end_c_loop(c,mix_th)
}

Last edited by Hotpig1100; July 8, 2018 at 05:16. Reason: The Title is unclear about my question.
Hotpig1100 is offline   Reply With Quote

Old   July 8, 2018, 20:45
Default
  #2
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
The segmentation fault often occurs when you are trying to access data that does not exist. Are you sure that there are at least two UDS, four cell UDM and two phases defined? Otherwise, try removing chunks of code until it works in order to determine the source of the error.
`e` is offline   Reply With Quote

Old   July 8, 2018, 21:01
Smile
  #3
New Member
 
Murray Lee
Join Date: Jul 2018
Posts: 4
Rep Power: 8
Hotpig1100 is on a distinguished road
Quote:
Originally Posted by `e` View Post
The segmentation fault often occurs when you are trying to access data that does not exist. Are you sure that there are at least two UDS, four cell UDM and two phases defined? Otherwise, try removing chunks of code until it works in order to determine the source of the error.
Dear 'e',
Thank you very much for your reply. I'm sure that the there are more than 4 cell UDM and two UDS. The two phases are also defined. I debugged the code and find that the reason of the error is caused by the following codes:

c_face_loop(c,mix_th,n)
{
f=C_FACE(c,mix_th,n);
c0=F_C0(f,gas_th);
c1=F_C1(f,liq_th);
}

If I replace these codes by others, the simulation can be operated without errors. Though I know where error happens, I still have not solved the problem. Maybe there is a logical mistake. I hope you can reply to me again. Thanks again.

Yours sincerely,
Lee
Hotpig1100 is offline   Reply With Quote

Old   July 8, 2018, 21:21
Default
  #4
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
What is your main goal for this UDF? Why are you looping over cells, then their faces, and then their neighbouring cells? Note: F_C0 and F_C1 correspond to different computational cells and F_C1 may not exist (i.e. when there is no adjacent cell; which would cause this segmentation fault).
`e` is offline   Reply With Quote

Old   July 8, 2018, 22:05
Default
  #5
New Member
 
Murray Lee
Join Date: Jul 2018
Posts: 4
Rep Power: 8
Hotpig1100 is on a distinguished road
Quote:
Originally Posted by `e` View Post
What is your main goal for this UDF? Why are you looping over cells, then their faces, and then their neighbouring cells? Note: F_C0 and F_C1 correspond to different computational cells and F_C1 may not exist (i.e. when there is no adjacent cell; which would cause this segmentation fault).
Final goal of the UDF is to realize the mass transfer of CO2 bubble (which is patched at the bottom of the computation domain) in water. I want to study the mass transfer process based on both the liquid side and the gas side. I discussed with my professor and we determined that we should do the following works. First of all, we need to search the adjacent cells of interfacial cells and read the data such as mass fraction. So, the UDF I uploaded in this post is the first part.
I loop over cells to find out which of them belong to interface and then find their faces and adjacent cells in order to read the data on them. Based on the above description, I think F_C1 exists because the interfacial cells are not boundary cells.
Hotpig1100 is offline   Reply With Quote

Old   July 9, 2018, 03:26
Default How to use the "F_C0" and "F_C1" macros?
  #6
New Member
 
Murray Lee
Join Date: Jul 2018
Posts: 4
Rep Power: 8
Hotpig1100 is on a distinguished road
Hi everybody,
Yesterday I posted a thread about "How to search the adjacent cells". I test the codes and find that the error (segamentation fault) is caused by the two lines started with "c0=F_C0" and "c1=F_C1". The codes are shown as following. "ae" is used to test the codes and it can return the message when the simulation is ran. If I use "/* */" to the two lines, the simulation is ok. But if I let the two lines work, the segamentation fault occurred. I speculate that I haven't understand the usage of "F_C0" and "F_C1" though I read the UDF mannual several times. I hope somebady can point out where the mistakes occurred. Thanks.

DEFINE_ADJUST(adjacent,domain)
{
real ae;
cell_t c,c0,c1;
face_t f;
int n;
Thread *mix_th,*gas_th,*liq_th;

mix_th=Lookup_Thread(domain,2);
gas_th=THREAD_SUB_THREAD(mix_th,1);
liq_th=THREAD_SUB_THREAD(mix_th,0);

ae=0.;

begin_c_loop(c,mix_th)
{
if(C_VOF(c,gas_th)<=0.999 && C_VOF(c,gas_th)>=0.001)
{
c_face_loop(c,mix_th,n)
{
f=C_FACE(c,mix_th,n);
ae=F_R(c,mix_th);
Message("density is %g", ae);
c0=F_C0(f,gas_th);
c1=F_C1(f,liq_th);
}
}

if(C_VOF(c0,gas_th)<=0.999 && C_VOF(c0,gas_th)>=0.001 && C_VOF(c1,gas_th)<=0.001)
{
C_UDMI(c,gas_th,0)=C_UDSI(c0,gas_th,1);
C_UDMI(c,liq_th,1)=C_UDSI(c1,liq_th,0);
}
if(C_VOF(c1,gas_th)<=0.999 && C_VOF(c1,gas_th)>=0.001 && C_VOF(c0,gas_th)>=0.999)
{
C_UDMI(c,gas_th,2)=C_UDSI(c0,gas_th,1);
C_UDMI(c,liq_th,3)=C_UDSI(c1,liq_th,0);
}
}
end_c_loop(c,mix_th)
}
Hotpig1100 is offline   Reply With Quote

Old   July 9, 2018, 20:37
Default
  #7
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Quote:
Originally Posted by Hotpig1100 View Post
I think F_C1 exists because the interfacial cells are not boundary cells.
You've mentioned that the bubble is located at the bottom of the computational domain, is there no boundary there? Perhaps find exactly where the cells that fulfil your interface criteria are located, and check if they are neighbouring a boundary. Regardless, there should be a conditional statement in your UDF to handle the edge case of boundaries (because c1 is undefined for an external face).
`e` is offline   Reply With Quote

Reply

Tags
adjacent cell, fatal signal, 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
[OpenFOAM.org] compile error in dynamicMesh and thermophysicalModels libraries NickG OpenFOAM Installation 3 December 30, 2019 01:21
Undeclared Identifier Errof UDF SteveGoat Fluent UDF and Scheme Programming 7 October 15, 2014 08:11
Compiling dynamicTopoFvMesh for OpenFOAM 2.1.x Saxwax OpenFOAM Installation 25 November 29, 2013 06:34
Errors in UDF shashank312 Fluent UDF and Scheme Programming 6 May 30, 2013 21:30
Errors running allwmake in OpenFOAM141dev with WM_COMPILE_OPTION%3ddebug unoder OpenFOAM Installation 11 January 30, 2008 21:30


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