UDF – some macros are being called multiple times within a single iteration

    • rachels1001

      Hey guys,

      I have a kind of strange problem that has arisen recently. I have a UDF that is supposed to take boundary outlet conditions from one part of my simulation and use those flow and composition values as an inlet boundary profile on another part of my fluid body. There are quite a couple macros within my UDF because this flow distribution happens in multiple spots. 

      Most of my variables are defined as global variables because they are being defined in DEFINE_ADJUST macros, modified in separated DEFINE_ADJUST macros and then later being used in DEFINE_PROFILE macros. 

      My simulation results weren't making sense, and so I added "Message" queries throughout the macros of my UDF to monitor any issues with the values. Based on the message outputs I am getting each iteration, some of my macros aren't being called at all, not even an "undefined" variable" being outputted, but some of my macros are being called multiple times within a single iteration (because I see the same message pop up multiple times within a single iterations output). The same 3 or 4 macros are being called multiple times within the iteration as if in a loop and normally they are called 7 times. 


      I know this is kind of a difficult question to answer, but is there any reason why a DEFINE_ADJUST macro would be executing multiple times within a single iteration? Or why some of my DEFINE_PROFILE macros aren't even being called? I have double checked a couple times, and all of these profile macros are being called within the simulation as boundary conditions. Also if anyone has any additional tips on how to troubleshoot UDFs and macros / typical problems implementing global variables / typical problems using multiple adjust and profile macros within the same UDF, please let me know!

      Thanks, and again, sorry for the weird question,


    • BeginerModel

      I'm afraid without delving into your UDF's and how they are implemented I won't be able to provide any help for this particular issue. However, copying outlet conditions and using them as inlet conditions is something I have recently looked into and implemented into one of my models. 

      I did this through writing a profile at the outlet for whicher variable you are interested in (VOF for me), and then reading that profile as the boundary condition for the inlet. This is much easier to setup through the TUI and journal commands (I believe) than through the GUI but if that could be helpful to you then let me know.

    • yeoengchow
      Hey, I am experiencing the same issue. I have a DEFINE_CG_MOTION macro used in my UDF to simulate a rotating plate. I have written the UDF such that it writes the angle, velocity, time and acceleration of the plate at every time-step. However, the macro writes about 7-9 sets of data for each time-step, each with different velocity, time and acceleration data. I think this might be causing some issues with my results.nAny help/thoughts would be appreciated. Happy to keep providing more information as well. Thank you!n
    • YasserSelima
      Welcome!nProbably this is because of parallel processing. Can you post the message the printed message? the 7-9 linesnn
    • DrAmine
      Ansys Employee
      Also try to limit writing the messages either from host or just from node0. if node0 use Message0.nI think if you are using an Adjust, some parallelizing is required especially if you are garthering data over all nodes and trying to reduce or sum.n
Viewing 4 reply threads
  • You must be logged in to reply to this topic.