|
[Sponsors] |
September 7, 2023, 15:01 |
UDF gradient
|
#1 |
New Member
EmmaKate
Join Date: Aug 2023
Posts: 11
Rep Power: 3 |
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> DEFINE_INIT(HFIELD, domain) { Thread *t; cell_t c; face_t f; real pos[ND_ND]; thread_loop_c(t,domain) /* loops over all cell threads in domain */ { if (NULL != THREAD_STORAGE(t,SV_UDS_I(HMAG))) { begin_c_loop_all(c,t) /* loop over cells in a thread to get information stored in cells */ { C_CENTROID(pos,c,t); . . . 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) { if (NULL != THREAD_STORAGE(t,SV_UDS_I(HMAG)) && NULL != T_STORAGE_R_NV(t,SV_UDSI_G(HMAG))) { begin_c_loop (c,t) { C_UDSI(c,t,HGRADX) = C_UDSI_G(c,t,HMAG)[0]; } end_c_loop (c,t) } } } |
|
Tags |
ansys, fluent, gradient, udf, udf manual |
|
|
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 06:12 |
time-averaged wall shear stress gradient udf | Azi Lotfi | FLUENT | 3 | April 16, 2020 16:57 |
Using Cell gradient Variables in UDF | avd28 | Fluent UDF and Scheme Programming | 8 | March 14, 2020 07:26 |
UDF gradient of time | qkhanh189 | Fluent UDF and Scheme Programming | 0 | November 28, 2019 17:15 |
The gradient of void fraction in UDF | summer | FLUENT | 2 | May 20, 2011 04:34 |