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

gradient of temperature

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 1, 2016, 12:45
Default gradient of temperature
  #1
New Member
 
kelita
Join Date: May 2011
Posts: 4
Rep Power: 15
tilek is on a distinguished road
Dear all,

I was trying to write a udf that calculates the gradient of the temperature field using "Green-Gauss Cell-Based Gradient Evaluation" of each cell as in below. Even if the code compiles with no error, I get segmentation error just before it evaluates the line "c0 = F_C0(f,t);". Can someone give me insights where I went wrong. My approach used nested loop (calling c_face_loop(c,t,i) while inside begin_c_loop (c,t)). Also, I know the gradient of a scalar, eg. C_T_G, is accessible if needed to be used - but I didn't want to use that - as the idea was to get myself an in-depth insight into Fluent udf writing. Thankyou.

/************************************************** *********************/
/* UDF for computing gradT using "Green-Gauss Cell-Based Gradient Evaluation" of each cell.
==> structured mesh */
/************************************************** *********************/
#include "udf.h"
#include "sg.h"
#include "flow.h"
#include "mem.h"
#include "metric.h"
DEFINE_ADJUST(adjust_fcn, domain)
{
Thread *t, *t0, *t1 = NULL;
cell_t c, c0, c1 = -1;
face_t f;
int i = 0;
real area = 0.0, A[ND_ND], phi_fA[ND_ND], zro = 0.0, phi_f;
thread_loop_c (t,domain)
{
if (NULL != THREAD_STORAGE(t,SV_T) &&
NULL != T_STORAGE_R_NV(t,SV_T_G))
{
begin_c_loop (c,t)
{
i = 0;
F_AREA(A,C_FACE(c,t,i), C_FACE_THREAD(c,t,i)); /*Get the area vector*/
NV_VS(phi_fA, =, A,*,zro);
c_face_loop(c,t,i)
{
F_AREA(A,C_FACE(c,t,i), C_FACE_THREAD(c,t,i)); /*Get the area vector*/
if (BOUNDARY_FACE_THREAD_P(t)) /*Most face values will be available*/
{
/*Nothing to do since adiabatic wall assumed*/
}
else
{
c0 = F_C0(f,t);
t0 = F_C0_THREAD(f,t);
c1 = F_C1(f,t);
t1 = F_C1_THREAD(f,t);
phi_f=(C_T(c,t0)+C_T(c,t1))/2.;//eq. 20:30 tg
NV_VS(phi_fA, +=, A,*,phi_f);
}
}
C_UDSI(c,t,0) = NV_MAG(phi_fA)/C_VOLUME(c,t); //gradT
}
end_c_loop (c,t)
}
}

}

Last edited by tilek; July 2, 2016 at 22:08.
tilek 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
How to create a temperature gradient in thin wall and two dimensions leggman7 Main CFD Forum 0 October 30, 2013 00:21
How to get temperature gradient in dat.file jason feng FLUENT 0 September 30, 2013 00:39
Wall correction for the temperature gradient Hagen OpenFOAM 0 March 7, 2011 21:04
temperature normal gradient on a boundary Sandrine Main CFD Forum 2 June 10, 2009 17:34
Direct calculation of temperature gradient J.W.Ryu FLUENT 5 December 27, 2001 07:39


All times are GMT -4. The time now is 22:17.