Fluids

Fluids

How to compare a variable for fixed “x/y” coordinates using UDF

    • datou
      Subscriber

      Hello, I am facing a big challenge when I use DEFINE_ADJUST. I want to use a "if" condition to compare the temperature to find out the maximum temperature for fixed "x" coordinates. Specifically,

      for y=y1, the UDF looping along x direction to find out the maximum temperature t1;

      for y=y2, the UDF looping along x direction again to find out the maximum temperature t2;

      ......

      all the domain will be looped, and finally I will get the max. temperature distribution along y axis.

      I have thought over this question for a long time. Could you give me some suggestions how to realize this function? Thank you very much. I appreciate your help.

    • Rob
      Ansys Employee
      Why do you want to use a UDF? A line (or rake) in Fluent reporting the maximum value will return the number you're after.
    • DrAmine
      Ansys Employee
      You know you can do that in Fluent and you can even access what you do in UDF. I will always avoid using UDF whenever it is possible.
    • datou
      Subscriber
      Dear Rob and dear DrAmine, thank you very much for your comments. However, as I mentioned above, I want to use the maximum value (for every fixed x) as a condition for every time step. The specific application is shown in the attached figure: there three types of gas interface:
      bulk gas-powder interface
      enclosed gas-powder interface
      enclosed gas-solid wall interface
      I want to loop the multiphase zone to find out 1. bulk gas-powder interface, where I give a source there. for the other twos, no source terms will be added. My idea is to loop every fixed coordinate (fixed x, y) of interface coordinate, and then find out the max. fixed x/y , which is the value I really want. Could you give me some suggestions? Thank you again for your kind help. I am looking forward to your reply.

    • Rob
      Ansys Employee
      What are you trying to do? If it's a sintering type process you may want to look at volume fraction and wall adjacent cells. We're very limited in how much advice we can give, especially in the physics sense.
    • datou
      Subscriber
      Dear Rob, thanks for your fast reply.
      It is a laser melting process. but it does not matter what the process is.
      As referred to the figure, how can I only get the top interface (bulk gas-powder interface), rather than the other twos. I try to use loop inside a DEFINE_SOURCE, but the computational load is really heavy. I don't like that.
      I wonder, is there a loop macro which loops only along a fixed direction? Or, do you have some experience for this kind of loop? thank you very much
    • Rob
      Ansys Employee
      Are you modelling the powder via Eulerian Granular models? IF statements within DEFINE_SOURCE aren't that costly so shouldn't be an issue. As Fluent is an unstructured solver directional loops won't work well as you'd need to tell the loop where the next cell was and that will get expensive.
    • datou
      Subscriber
      I am working with VOF model. I used c_face_loop embedded in DEFINE_SOURCE, I am not sure if it works ok?

    • Rob
      Ansys Employee
      How are you including the gaps between the particles? Or are you patching spheres of VOF into the domain?
    • datou
      Subscriber
      I used UDF to initialize the particle distribution, yes, patching the vof
    • Rob
      Ansys Employee
      OK, and did you use the solidification & melting model?
    • datou
      Subscriber
      Yes, I used the solidification and melting model, coupled with vof.
    • DrAmine
      Ansys Employee
      Do you want to start from a wall you maximum search along Y-directions so X-directions are something like Ray's parallel to X-axis?
    • datou
      Subscriber
      Hello DrAmine, thanks for your reply. Yes, I want to do such a search, so in the following "if" statement, I can use the results.
    • DrAmine
      Ansys Employee
      Then a lot of coding is required.
    • datou
      Subscriber
      Could you briefly introduce the general idea of coding structure? I appreciate your help.
    • DrAmine
      Ansys Employee
      You can start from the wall loop over its faces, get normal direction from there you start searching along this direction using some steps / distance to verify if you are now in a new cell if yes you get the value you want and then do a line average.
Viewing 16 reply threads
  • You must be logged in to reply to this topic.