TAGGED: udf
-
-
January 24, 2023 at 7:02 pm
ehsan.sadeghi
SubscriberI want to calculate the gradient of UDS0 and save it in a UDMI to later use it in the UDF. I calculate the cell values of gradient of UDS0 by using C_UDSI_G macro and save it to UDMI. i.e.:
C_UDMI(c,t,0) = -1.*C_UDSI_G(c,t,0)[0]; //Ex
Based on UDF manual tha face value of an scalar is calculated by:As there are no macros (as far as I know) to give me the face values of scalar so I do the next for boundary faces:
BOUNDARY_FACE_GEOMETRY(f,t,A,ds,es,A_by_es,dr0)
F_UDMI(f,t,0) = C_UDMI(c,t0,0) + (C_UDSI_G(c0,t0,0)[0]*dr0[0]);Is it a correct way of calculating the gradient? my code compiles corrrectly but after one iteration fluent gives me an error message like this:
Node 0 Fatal signal raised sig = Segmentation fault
-
January 25, 2023 at 11:10 am
Rob
Forum ModeratorThere's a flag in the code to retain gradient data after it's used in the solver. If you don't some of the gradients aren't there to use in UDFs.Â
/solve/set/advanced/retain-temporary-solver-mem  and "yes" when asked.Â
This assumes you have sufficient UDM and UDS assigned in the case.Â
-
January 26, 2023 at 8:51 am
ehsan.sadeghi
SubscriberThanks Rob. It was memory related issue. I retained the memory from freeing. One question more: is it the correct way of calculating gradient? comparing electric field (i.e. gradient of UDS0 or gradient of potential) with MHD module I get slightly different results .
-
-
January 26, 2023 at 4:41 pm
Rob
Forum ModeratorI tend to use the Fluent macros. Remember scalars diffuse so depending on how the MHD module is coded up (UDM rather than UDS) there may be a difference.Â
-
January 26, 2023 at 7:04 pm
ehsan.sadeghi
SubscriberI didn´t get exactly what you mean. Considering that the potential equation or Poisson´s equation take diffusion coefficient of 1 (depending on how you incorporate source term), do you mean that partly the result accuracy will depend on discretization scheme of UDS? second order schemes should minimize false diffusion no?
-
-
January 27, 2023 at 1:13 pm
Rob
Forum Moderator2.2.1.4 Â https://ansyshelp.ansys.com/account/Secured?returnurl=/Views/Secured/corp/v231/en/flu_udf/flu_udf_GeneralSolverDEFINE.html
A UDS is a scalar, similar to species, so as well as convection it'll diffuse with the flow. A UDM is a calculated value in a cell, it can only "move" based on what maths creates it.Â
Â
-
January 27, 2023 at 5:12 pm
ehsan.sadeghi
SubscriberBut it doesn´t explain why there are differences in MHD and UDS for potential equation. With same diffusivity and BC it should produce same results. That is why I am suspecting that the way that I am calculating gradient is not correct, perhaps gradient on faces. Fleunt´s MHD documentation is very breif and there are no macros related to MHD in the manual.Â
-
-
January 30, 2023 at 11:13 am
Rob
Forum ModeratorYes, we tend not to share everything, and I can't comment other than to refer to the manual(s). Look for [123] or similar in the documentation, that'll be a reference to the theory. If the results are close, you may be right, but I suspect you've missed something more significant.Â
-
- The topic ‘Gradient of UDS’ is closed to new replies.
-
5849
-
1906
-
1420
-
1305
-
1021
© 2026 Copyright ANSYS, Inc. All rights reserved.
