|
[Sponsors] |
Error When Calling F_FLUX: received a fatal signal (segmentation fault) |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
November 18, 2020, 04:30 |
Error When Calling F_FLUX: received a fatal signal (segmentation fault)
|
#1 |
New Member
Zhang Haosen
Join Date: Jun 2020
Posts: 7
Rep Power: 6 |
Hello, everyone! I wrote an udf to compute the mass flow rate of the inlet surface, and the core code is simple, modified from another piece of code than can run normally in serial mode. The udf was compiled normally, but an “Segmentation fault” error was reported at runtime. After debugging, I think the bug appears in the process of calling F_FLUX, but I don't know how to modify it. Can anyone help me, Thanks! The code and debugging information are pasted below.
Code
Debugging information
|
|
November 18, 2020, 22:58 |
Code is correct
|
#2 |
New Member
Zhang Haosen
Join Date: Jun 2020
Posts: 7
Rep Power: 6 |
I didn't read in the .dat file...
|
|
November 19, 2020, 04:58 |
|
#3 | |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
Quote:
in addition, for parallel code I would use following code Code:
real compute_mass_flow(int zone_id) { face_t face; Thread* face_thread; real face_mass_flow = 0; real mass_flow = 0; Message0("\nbegin to compute mass flow 1\n"); if (face_thread = Lookup_Thread(domain, zone_id)) { Message0("\nface thread opened correctly\n"); Message0("\nface thread opened correctly\n"); } Message0("\nbegin to compute mass flow 2\n"); Message0("\ndomain = %d\n", domain); Message0("\nzone id = %d\n", zone_id); begin_f_loop(face, face_thread) { Message0("\ncheck f_flux\n"); face_mass_flow = F_FLUX(face, face_thread); mass_flow += face_mass_flow; mass_flow_cont += 1; Message0("\nmass_flow_cont = %d\n", mass_flow_cont); } end_f_loop(face, face_thread) #if RP_NODE mass_flow = PRF_GRSUM1(mass_flow); mass_flow_cont = PRF_GRSUM1(mass_flow_cont); #endif Message0(" \nmass flow computation ended\n"); return mass_flow; }
__________________
best regards ****************************** press LIKE if this message was helpful |
||
November 19, 2020, 10:44 |
|
#4 | |
New Member
Zhang Haosen
Join Date: Jun 2020
Posts: 7
Rep Power: 6 |
Quote:
Thanks for your reply! Using Message0 can effectively simplify the code, and I didn't take into consideration the situation of using density-based solver. But how can I get mass flow rate when using density-based solver, by multiplying C_R_G, delta_r and F_U? I seem to have seen related descriptions in the help documentation, that users can specify Fluent to save variables not saved originally, but I can't find these descriptions now. |
||
November 19, 2020, 22:07 |
|
#5 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
what I was trying to say, that F_flux should give you mass flow rate if all settings of case are correct.
Segmentation error comes out when you are asking for variables which are not allocated yet. So may be case was not initialized or anything else. in Ansys Fluent Customization manual there is a code to calculate flux through surface: Code:
#include "udf.h" DEFINE_UDS_FLUX(my_uds_flux,f,t,i) { cell_t c0, c1 = -1; Thread *t0, *t1 = NULL; real NV_VEC(psi_vec), NV_VEC(A), flux = 0.0; c0 = F_C0(f,t); t0 = F_C0_THREAD(f,t); F_AREA(A, f, t); /* If face lies at domain boundary, use face values; */ /* If face lies IN the domain, use average of adjacent cells. */ if (BOUNDARY_FACE_THREAD_P(t)) /*Most face values will be available*/ { real dens; /* Depending on its BC, density may not be set on face thread*/ if (NNULLP(THREAD_STORAGE(t,SV_DENSITY))) dens = F_R(f,t); /* Set dens to face value if available */ else dens = C_R(c0,t0); /* else, set dens to cell value */ NV_DS(psi_vec, =, F_U(f,t), F_V(f,t), F_W(f,t), *, dens); flux = NV_DOT(psi_vec, A); /* flux through Face */ } else { c1 = F_C1(f,t); /* Get cell on other side of face */ t1 = F_C1_THREAD(f,t); NV_DS(psi_vec, =, C_U(c0,t0),C_V(c0,t0),C_W(c0,t0),*,C_R(c0,t0)); NV_DS(psi_vec, +=, C_U(c1,t1),C_V(c1,t1),C_W(c1,t1),*,C_R(c1,t1)); flux = NV_DOT(psi_vec, A)/2.0; /* Average flux through face */ } /* ANSYS Fluent will multiply the returned value by phi_f (the scalar’s value at the face) to get the ‘‘complete’’ advective term. */ return flux; } change it to face/thread loop instead. define thread ID, cause you know where you would like to get mass flow rate (you may check ID in Fluent GUI)
__________________
best regards ****************************** press LIKE if this message was helpful |
|
Tags |
f_flux, mass flow rate, parallel |
|
|
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 |
Error: received a fatal signal (Segmentation fault). Error Object: #f | Naveen Kumar Gulla | FLUENT | 0 | May 18, 2018 15:12 |
received a fatal signal (Segmentation fault) using udf to reading node coordinate | f.yn | FLUENT | 1 | July 28, 2017 16:55 |
Error: received a fatal signal (Segmentation fault). | MayTheFlowBeWithYou | FLUENT | 12 | June 30, 2017 04:09 |
receive fluent received a fatal signal (Segmentation fault). | chenkaiqe | FLUENT | 2 | March 10, 2015 09:21 |