CFD Online Logo CFD Online URL
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

UDF gradient

Register Blogs Members List Search Today's Posts Mark Forums Read

LinkBack Thread Tools Search this Thread Display Modes
Old   September 7, 2023, 14:01
Default UDF gradient
New Member
Join Date: Aug 2023
Posts: 9
Rep Power: 2
emmakateh is on a distinguished road
Hi, I am having trouble getting a gradient to work properly with UDSI. I have a calculation to calculate Hmag of a magnetic field. and then I am trying to get the gradient of this USDI in the x, y, z, directions. The simulation will run without throwing errors, but the gradient returns zeros for everywhere in my mesh. I found this setup on 8.2.5 User-Defined Scalars of UDF manual

#include "udf.h"
#include "sg.h"
#include <math.h>

Thread *t;
cell_t c;
face_t f;
real pos[ND_ND];

thread_loop_c(t,domain) /* loops over all cell threads in domain */
begin_c_loop_all(c,t) /* loop over cells in a thread to get information stored in cells */
Hmag = sqrt(Hz*Hz + Hx*Hx + Hy*Hy) ; /* (A/m) Magnetic Field Strength */
C_UDSI(c,t,HMAG) = Hmag;
end_c_loop_all(c,t) /* END: Looping over all cells */

thread_loop_c (t,domain)
begin_c_loop (c,t)
C_UDSI(c,t,HGRADX) = C_UDSI_G(c,t,HMAG)[0];
end_c_loop (c,t)
emmakateh is offline   Reply With Quote


ansys, fluent, gradient, udf, udf manual

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
UDF for zero pressure gradient at BC outlet ghordog Fluent UDF and Scheme Programming 1 April 28, 2022 05:12
time-averaged wall shear stress gradient udf Azi Lotfi FLUENT 3 April 16, 2020 15:57
Using Cell gradient Variables in UDF avd28 Fluent UDF and Scheme Programming 8 March 14, 2020 06:26
UDF gradient of time qkhanh189 Fluent UDF and Scheme Programming 0 November 28, 2019 16:15
The gradient of void fraction in UDF summer FLUENT 2 May 20, 2011 03:34

All times are GMT -4. The time now is 20:31.