|
[Sponsors] |
UDF about Searching the Adjacent cells: Please help me to find out the error |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
July 8, 2018, 04:58 |
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 |
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. |
|
July 8, 2018, 20:45 |
|
#2 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
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.
|
|
July 8, 2018, 21:01 |
|
#3 | |
New Member
Murray Lee
Join Date: Jul 2018
Posts: 4
Rep Power: 8 |
Quote:
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 |
||
July 8, 2018, 21:21 |
|
#4 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
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).
|
|
July 8, 2018, 22:05 |
|
#5 | |
New Member
Murray Lee
Join Date: Jul 2018
Posts: 4
Rep Power: 8 |
Quote:
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. |
||
July 9, 2018, 03:26 |
How to use the "F_C0" and "F_C1" macros?
|
#6 |
New Member
Murray Lee
Join Date: Jul 2018
Posts: 4
Rep Power: 8 |
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) } |
|
July 9, 2018, 20:37 |
|
#7 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
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).
|
|
Tags |
adjacent cell, fatal signal, udf |
|
|
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 |