# UDF Problem

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

 March 4, 2004, 12:51 UDF Problem #1 ozgur Guest   Posts: n/a Hi all, I have written an UDF (attached below) in order to calculate the volume weighted falling velocity of my free falling droplet, and use this velocity as the velocity inlet boundary condition. With this UDF, I hope to fix my falling drop in the calculation domain, so I can use a smaller domain, which is refined at the 2-phase interface on the drop. The UDF is interpreted succesfully, but the problem is, when I try to hook it at the velocity inlet BC panel, the program hangs like it gets into an infinite loop. So I have to kill the fluent session. Does any one have a suggestion about that? Thanks in advance, here is the UDF: #include "udf.h" #include "sg_mphase.h" DEFINE_PROFILE(fall_velocity,thread,nv) { real fall_vel_drop; real fall_vel_volweighted; real vol_tot; face_t f; cell_t c; Thread *t_phase2=THREAD_SUB_THREAD(thread,1); begin_c_loop(c, t_phase2) { fall_vel_volweighted += C_V(c,t_phase2)*C_VOLUME(c,t_phase2); vol_tot += C_VOLUME(c,t_phase2); } end_c_loop(c, t_phase2) fall_vel_drop=fall_vel_volweighted/vol_tot; printf("Volume average y_velocity of drop: %g\n",fall_vel_drop); begin_f_loop(f,thread) { F_PROFILE(f,thread,nv)=fall_vel_volweighted/vol_tot; } end_f_loop(f,thread) }

 March 5, 2004, 05:28 Re: UDF Problem #4 ozgur Guest   Posts: n/a Thanks Thomas, I've tried your suggestion. But the problem still exist. When I hook it after I initilize and patch my drop, I get the following output (at least something): Volume average y_velocity of drop:0 Volume average y_velocity of drop:0 which is correct for the beginning, but then the fluent hanged again. When I hook the UDF before I initialize and patch the drop, then I am able to hook it at velocity inlet BC without any failure, but then, when I try to initialize the solution, the same problem comes again, and fluent is hanged. Program seems to get into an endless loop, and I don't understand why! here is the corrected UDF once again: #include "udf.h" #include "sg_mphase.h" DEFINE_PROFILE(fall_velocity,thread,nv) { real fall_vel_drop; real fall_vel_volweighted; real vol_tot; face_t f; cell_t c; Thread *t_phase2=THREAD_SUB_THREAD(THREAD_T0(thread),1); begin_c_loop(c, t_phase2) { fall_vel_volweighted += C_V(c,t_phase2)*C_VOLUME(c,t_phase2); vol_tot += C_VOLUME(c,t_phase2); } end_c_loop(c, t_phase2) fall_vel_drop=fall_vel_volweighted/vol_tot; printf("Volume average y_velocity of drop: %g\n",fall_vel_drop); begin_f_loop(f,thread) { F_PROFILE(f,thread,nv)=fall_vel_volweighted/vol_tot; } end_f_loop(f,thread) }

 March 5, 2004, 06:40 Re: UDF Problem #5 thomas Guest   Posts: n/a which model are you using ?

 March 5, 2004, 07:03 Re: UDF Problem #6 ozgur Guest   Posts: n/a hi, My model is: 2D dp, segregated, VOF, laminar, unsteady.

 March 5, 2004, 08:04 Re: UDF Problem #7 ozgur Guest   Posts: n/a I have tried it on 3D case, and it did not work either.

 March 5, 2004, 09:58 Re: UDF Problem #9 ozgur Guest   Posts: n/a I really appreciate that you give your time and help me. I have almost 1 month left to deadline of my ms. thesis, and still fighting with fluent! I've tried your suggestions. I've recognised that I was hooking it to "velocity magnitude" in the velocity inlet panel. Since I am intersted only with the velocity component in the direction of the falling drop (-y direction), I try to hook it to "y-velocity" using the velocity specification method of "components". Now it is not hanged, but it causes SEGMENTATION VIOLATION error. I feel that it tries to get or access a parameter, that it should not or not allowed to. But, I feel that I am getting closer to the solution, with your support

 March 5, 2004, 10:21 Re: UDF Problem #10 thomas Guest   Posts: n/a SEGMENTATION VIOLATION error CAN be due to UDMI undeclared. Go to DEFINE > UDF > memory and declare your UDMI number. I confirm that depending on your number of cells and your number of iteration per time step, the way you programm your UDF will be very demanding in computation time. Do not hesitate to ask if you want a better way asking for less computation time. thomas

 March 5, 2004, 10:58 Re: UDF Problem #11 ozgur Guest   Posts: n/a But I did not use User Defined Memory macros in my UDF. Why should I initialize UDMI? Do you mean that there is a more efficient way to do the same task, that is, to calculate the falling velocity of my drop, and to use it in a way to fix the drop in the calculation domain? I have thought of directing my UDF to "moving ref. frame", in the fluid zone BC panel, but unfortunately it is not possibble. I can't think of any other way. Do you have an idea?

 March 5, 2004, 11:13 Re: UDF Problem #12 thomas Guest   Posts: n/a My idea would be to update your inlet BC not each iteration but every 2 or 3 time step (less at the beginning). This is possible using the macro DEFINE_EXECUTE_END and an euclidian division. thomas

 March 5, 2004, 12:01 Re: UDF Problem #13 ozgur Guest   Posts: n/a well, if I can fix my UDF problem, a mesh having not more than 20k cells would be enough for my single drop problem. But the overall calculation time may anyway increase, just because that with the much more refined cells at the interphase, then I would probably need much smaller time steps in VOF algorithm. According to my experience, it is not easy to deal with VOF when you have cells on the order of microns!

 March 11, 2004, 12:52 Re: UDF Problem #16 ozgur Guest   Posts: n/a Hi Thomas, Thanks for giving your time for my problem. I implemented a similar IF caluse to my UDF, as I posted as a new thread yesterday, but a "not a number" error appears this time. Anyway, I am still not sure about how to implement DEFINE_EXECUTE_END into my existing UDF, and how to hook it. Even apart from all those, I have strong doubts about the method I am using to fix my drop in the domain. I am actually trying to do a kind of coordinate transformation(from non-inertial to inertial-ref. frame moving with the same velocity of my drop) artificially, since it is not possible to define UDF in the Moving Ref. Frame Panel. But when I change the cell values in the fluid domain (with 2nd loop), then in those cells, the momentum equations are not solved anymore, but just the value I've given is assumed. Therefore, I am not sure that this way will work. What the most of the people are doing is, they are solving for modified N-S equations defined w.r.t. a non-inertial ref. frame. Thanks again for your contribution to my problem. Regards, Özgür

 January 16, 2016, 16:25 #17 New Member   sepideh Join Date: Mar 2014 Posts: 3 Rep Power: 12 dear Ozgur, my phd thesis is about rising droplet, but due to long rise time, i have to shift it to moving frame, can you tell me have you obtained the true code format or any reference? thenk you

January 16, 2016, 16:29
#18
New Member

sepideh
Join Date: Mar 2014
Posts: 3
Rep Power: 12
Quote:
 Originally Posted by ozgur ;111021 Hi Thomas, Thanks for giving your time for my problem. I implemented a similar IF caluse to my UDF, as I posted as a new thread yesterday, but a "not a number" error appears this time. Anyway, I am still not sure about how to implement DEFINE_EXECUTE_END into my existing UDF, and how to hook it. Even apart from all those, I have strong doubts about the method I am using to fix my drop in the domain. I am actually trying to do a kind of coordinate transformation(from non-inertial to inertial-ref. frame moving with the same velocity of my drop) artificially, since it is not possible to define UDF in the Moving Ref. Frame Panel. But when I change the cell values in the fluid domain (with 2nd loop), then in those cells, the momentum equations are not solved anymore, but just the value I've given is assumed. Therefore, I am not sure that this way will work. What the most of the people are doing is, they are solving for modified N-S equations defined w.r.t. a non-inertial ref. frame. Thanks again for your contribution to my problem. Regards, Özgür
can any body help me in this regard? i have the same problem too.

 January 17, 2016, 14:40 #19 Senior Member   B_Kia Join Date: May 2014 Location: Ir Posts: 123 Rep Power: 12 hi , can you give a little detail about your problem ?