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

UDF 覧wrong on the thread or cell loop?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 19, 2019, 02:30
Smile UDF 覧wrong on the thread or cell loop?
  #1
New Member
 
Steve Ying
Join Date: Apr 2019
Posts: 2
Rep Power: 0
Steve-Tian is on a distinguished road
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 */
}
}
}
Steve-Tian is offline   Reply With Quote

Old   April 20, 2019, 10:09
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
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.
pakk is offline   Reply With Quote

Old   April 21, 2019, 22:39
Default
  #3
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
as Pakk said change
Code:
thread_loop_c(t,d)
{
to
Code:
thread_loop_f(t, domain)
{
begin_f_loop(f,t)
{

}
end_f_loop(f, t)
}
more information in Ansys Fluent Customization Manual

best regards
AlexanderZ is offline   Reply With Quote

Reply


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
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


All times are GMT -4. The time now is 16:00.