|
[Sponsors] |
April 19, 2019, 02:30 |
UDF 覧wrong on the thread or cell loop?
|
#1 |
New Member
Steve Ying
Join Date: Apr 2019
Posts: 2
Rep Power: 0 |
Dear all,
I have been reading this forum for a while to find the answer of my question and failed. Now I would like to kindly ask for some help with a UDF that I am trying to write. I know how to use the DEFINE_PROPERTY macro and other macros like this, which I don't need to write thread, cell or face loop. My problem is that writing a Define on Demand macro in order to get the parameter on the boundary or interior face and execute the macro on demand. I have facing some problems when I execute the macro, and receive the error:received a fatal signal (Segmentation fault). I refer that something is wrong on the code:thread_loop_c(t,d),but I don't know exactly. PlZ give me some help, tnk! The UDF that I have written is shown next: DEFINE_ADJUST(adjust,d) { cell_t c, c0, c1 = -1; Thread *t, *t0, *t1 = NULL; face_t f; real x[ND_ND]; real NV_VEC(A); real NV_VEC(psi_vec); real dens = 0.0; real sum_T_A=0.0; real sum_A=0.0; real flux = 0.0; t=Lookup_Thread(d,11); /*11 is the fluid domain ID*/ thread_loop_c(t,d) { c0 = F_C0(f,t); t0 = F_C0_THREAD(f,t); F_CENTROID(x,f,t); F_AREA(A, f, t); 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_D(psi_vec, =, F_U(f,t), F_V(f,t), F_W(f,t)); flux = dens*fabs(NV_DOT(psi_vec, A)); /* flux through Face */ } } } |
|
April 20, 2019, 10:09 |
|
#2 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
You loop over threads t, but you forget to loop over faces f.
Currently, your program does never set any "value" for f, you only tell it that it is a face. Fluent does not know WHICH face. So it gives an error when you try to get the coordinates for that face. |
|
April 21, 2019, 22:39 |
|
#3 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
as Pakk said change
Code:
thread_loop_c(t,d) { Code:
thread_loop_f(t, domain) { begin_f_loop(f,t) { } end_f_loop(f, t) } best regards |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Divergence detected in AMG solver: k when udf loaded | google9002 | Fluent UDF and Scheme Programming | 3 | November 8, 2019 00:34 |
UDF for modifying density of mixture phase during the calculating process | sola86 | Fluent UDF and Scheme Programming | 2 | May 28, 2019 10:24 |
Fluent UDF wrong number of cells in parallel - correct in serial | dralexpe | Fluent UDF and Scheme Programming | 7 | May 17, 2018 09:26 |
UDF velocity profile | willroca | Fluent UDF and Scheme Programming | 2 | January 10, 2016 04:13 |
Phase locked average in run time | panara | OpenFOAM | 2 | February 20, 2008 15:37 |