# Pass variable from one udf to another

 Register Blogs Members List Search Today's Posts Mark Forums Read

 September 3, 2019, 04:58 Pass variable from one udf to another #1 New Member   Spyros Join Date: Jul 2019 Posts: 6 Rep Power: 2 Hello everyone! I have created a UDF that calculates the velocity (variable name vel) from a heat transfer function. I need to pass this variable (vel) which changes value every time step to another UDF in order to link that UDF with the movement of a interface. Is there any way I can make this? I know that with UDM one can store a value to a memory slot but dont know if I can retrieve it and use it in another UDF. Any help would be much appreciated!

 September 3, 2019, 06:24 #2 Member   Mattia Join Date: Mar 2018 Posts: 44 Rep Power: 4 HI, would'nt be possible to create just one UDF instead of two?

 September 3, 2019, 15:49 #4 Senior Member   Lucky Tran Join Date: Apr 2011 Location: Orlando, FL USA Posts: 3,980 Rep Power: 47 I can't follow the logic of what you are trying to do to tell you how to do it (sorry I just can't make sense out of it). You can certainly have more than one DEFINE macro in a single UDF. You can also access a UDM using the C_UDMI(c,t,0) or F_UDMI(f,t,0) macros (where the 0 is the 0th or first UDM).

 September 4, 2019, 00:50 #5 Senior Member   Alexander Join Date: Apr 2013 Posts: 1,206 Rep Power: 20 as LuckyTran mentioned Code: /* moving grid */ #include "udf.h" DEFINE_CG_MOTION(interf_move_1, dt, vel, omega, time, dtime) { double velocity; {...} vel[1]=velocity; } DEFINE_CG_MOTION(interf_move_2, dt, vel, omega, time, dtime) { double velocity; {...} vel[1]=-velocity; // negative, because you want to move OPPOSITE direction } best regards

 September 4, 2019, 08:43 #6 New Member   Spyros Join Date: Jul 2019 Posts: 6 Rep Power: 2 Let me elaborate on my problem I have a fluid domain and a solid body and the interface between them is coupled, from a heat transfer function [velocity=f(boundary_heat_flux)] ,I calculate the velocity with which the solid side interface should move and need to move the fluid side of the interface with the same velocity so that they always remain in contact. I understand that I don't need to have 2 separate UDFs and I also found out that since the interface would move down (negative Y axis) the whole sign convention doesn't need to be taken into account, both sides must move with negative velocity with respect to the global coordinate system. So the variable velocity should be calculated only in the first DEFINE_CG_MOTION (interf_move1, ..) and then passed to the second DEFINE_CG_MOTION (interf_move2, ..) in order to move the latter with the same velocity. I think this is the best way to explain it. I've tried the code provided by AlexanderZ but fluent warms me that the variable vel[1] is not used in the second DEFINE MACRO and as unticipated one side of the interface is not moving

 September 4, 2019, 21:40 #7 Senior Member   Alexander Join Date: Apr 2013 Posts: 1,206 Rep Power: 20 wall between fluid and solid has coupled boundary condition, does it really needed to move both of them separately? regarding your request Code: /* moving grid */ #include "udf.h" double velocity; DEFINE_CG_MOTION(interf_move_1, dt, vel, omega, time, dtime) { {...} vel[1]=velocity; } DEFINE_CG_MOTION(interf_move_2, dt, vel, omega, time, dtime) { {...} vel[1]=velocity; } best regards

 September 5, 2019, 12:09 #8 New Member   Spyros Join Date: Jul 2019 Posts: 6 Rep Power: 2 Yes because either wise the one side of the interface moves and not both. I will provide the code and explain the procedure I am following

 Tags dynamic mesh, fluent, udf, udm