Ansys Assistant will be unavailable on the Learning Forum starting January 30. An upgraded version is coming soon. We apologize for any inconvenience and appreciate your patience. Stay tuned for updates.
Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

Gradient of UDS

TAGGED: 

    • ehsan.sadeghi
      Subscriber

      I 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

    • Rob
      Forum Moderator

      There'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. 

      • ehsan.sadeghi
        Subscriber

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

    • Rob
      Forum Moderator

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

      • ehsan.sadeghi
        Subscriber

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

    • Rob
      Forum Moderator

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

       

      • ehsan.sadeghi
        Subscriber

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

    • Rob
      Forum Moderator

      Yes, 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. 

Viewing 4 reply threads
  • The topic ‘Gradient of UDS’ is closed to new replies.
[bingo_chatbox]