# UDF usage

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

 July 18, 2007, 09:16 UDF usage #1 cotket Guest   Posts: n/a I am new to UDF, this is basic question. I wrote a UDF function to calculate Wall shear stress. It is import successfully. I want to calculate wall shear stress of some specific faces.How can setup to get result of WSS?Thank you

 July 18, 2007, 13:12 Re: UDF usage #2 jasond Guest   Posts: n/a Well, assuming that you know the faces (as in you have the thread info, etc.), then DEFINE_ON_DEMAND is a good way to go. Wall shear is available from the solver, though, so I may not be answering your question. Are you asking how to access the specific faces? Jason

 July 18, 2007, 14:10 Re: UDF usage #3 cotket Guest   Posts: n/a Thank for your reply, my model is solving for unsteady stage with UDF function for velocity as boundary condition.The model run well but now I want to get WSS of some specific surfaces.Assuming that i have UDF code for calculating WSS and know the faces.But i don't know how to use this UDF to get WSS,Can you take a look following my UDF? /* ************************************************** */ /* Please make sure that at least 1 UDM is define */ #include "udf.h" DEFINE_ON_DEMAND(wall_shear_calc) { Domain *d; real wall_shear_force, area; face_t f; real A[ND_ND]; cell_t c, c0; Thread *t,*t0, *c_thread; int Zone_ID=6; /* Zone ID of the wall on which shear stress has to be calculated */ /* It can be obtained from the boundary condition panel.*/ d=Get_Domain(1); /* Initialize the UDM value to zero in complete domain */ thread_loop_c(c_thread,d) { begin_c_loop(c, c_thread) { C_UDMI(c,c_thread,0)= 0; } end_c_loop(c, c_thread) } /* Calculate wall shear stress and store them in UDM */ t=Lookup_Thread(d,Zone_ID); begin_f_loop(f, t) { F_AREA(A,f,t); area = NV_MAG(A); wall_shear_force = NV_MAG(F_STORAGE_R_N3V(f,t, SV_WALL_SHEAR)); c0 = F_C0(f,t); t0 = THREAD_T0(t); C_UDMI(c0,t0,0)= wall_shear_force/area; } end_f_loop(f, t) } /* *********************************************** */

 July 18, 2007, 14:40 Re: UDF usage #4 ledombo Guest   Posts: n/a Hello, If you have not compiled it yet you can do so by... define --> user defined --> functions --> compiled... Once you have done this you hook it to Fluent through.. define--> user defined --> functions --> execute-on-demand.. your define_on_demand "name" (in your case this is "wall_shear_calc") will appear under execute-on-demand for you to hook.

 July 18, 2007, 15:34 Re: UDF usage #5 jasond Guest   Posts: n/a Next time use the "pre" tag and your code will look a lot better (see below - I'm sorry to admit that I often just skip reading messages with badly formatted code). At any rate, your UDF computes the shear magnitude and stores it in a UDM location for the adjacent cell. It might be better to store it in the UDM location for the face, which should be available as long as the zone is a wall or flow boundary. So I would change things slightly (it compiles, but I can't test it right now because I am mid-calculation). You should be able to display contours on the face in question (which would hopefully match the results from Fluent's Wall Fluxes/Wall Shear plot). Other than that, as long as you have followed the other poster's steps, you should be good. In the past, I have written out face grid information along with the wall shear to plot in other programs (e.g. Tecplot). /* ************************************************** */ /* Please make sure that at least 1 UDM is define */ #include "udf.h" DEFINE_ON_DEMAND(wall_shear_calc2) { Domain *d; real wall_shear_force, area; face_t f; real A[ND_ND]; Thread *t; int Zone_ID=6; /* Zone ID of the wall on which shear stress has to be calculated */ /* It can be obtained from the boundary condition panel.*/ d=Get_Domain(1); t=Lookup_Thread(d,Zone_ID); /* Calculate wall shear stress and store them in UDM */ begin_f_loop(f, t) { F_AREA(A,f,t); area = NV_MAG(A); wall_shear_force = NV_MAG(F_STORAGE_R_N3V(f,t, SV_WALL_SHEAR)); F_UDMI(f,t,0)= wall_shear_force/area; } end_f_loop(f, t) } /* *********************************************** */

 July 18, 2007, 21:53 Re: UDF usage #6 cotket Guest   Posts: n/a I use new UDF code and do the Ledombo's instruction but once run "Execute on Demand" it occurs the following error: Error: FLUENT received fatal signal (ACCESS_VIOLATION) 1. Note exact events leading to error. 2. Save case/data under new name. 3. Exit program and restart to continue. 4. Report error to your distributor. Error Object: () Even i setup some options like Function hooks->adjust;number of UDM became 1. More detail my goal,i would like to compute WSS along perimeter of a specific surface. Please help me Thank you very much

 July 19, 2007, 10:27 Re: UDF usage #7 jasond Guest   Posts: n/a A possible cause: the UDM isn't actually allocated after you change the number of UDM's, and I am not aware of a way to tell if it is allocated via UDF. I know for sure that a UDM is allocated upon initialization, so try that and see if the problem goes away. You might need to restart Fluent before doing the initialization. Jason

 July 19, 2007, 11:17 Re: UDF usage #8 cotket Guest   Posts: n/a The problem is still the same after following your suggest. I am confused the "initialization",is it a option of "User-defined functions Hooks"? Can you tell me the detail of step to do it? Thank you so much

 July 19, 2007, 11:44 Re: UDF usage #9 jasond Guest   Posts: n/a Have you initialized the solution ("Solve->Initialize->Initialize...", then "Init" from the GUI) since you changed the number of UDM's? That is the initialization I am talking about. Also, the UDM will not be available for all surfaces, so make sure to check the zone ID you are using (in the boundary conditions dialog) Jason

 July 19, 2007, 13:41 Re: UDF usage #10 cotket Guest   Posts: n/a Hi Jason After initialization,there is no error for only steady case.But i am solving the problem with unsteady stage and still the same error.Is it possible to setup two UDF functions at the same time in one problem? about checking zone ID,If i want to compute WSS of another surface which ID not exist on boundary condition,how can i calculate WSS of this surface? Can you help me again? Thank you

 July 20, 2007, 12:35 Re: UDF usage #11 jasond Guest   Posts: n/a I'm not sure why steady would work and unsteady would not. I would try running in steady mode, check to see if it works, then change to unsteady mode (run a couple of timesteps) and then check again. You can have as many UDF's as you want (I have never encountered a limit). As for getting the wall shear on a surface that is not listed as a boundary condition - well, if it is not a boundary condition, then it is not a wall, so wall shear is not something you can compute. You'll have to explain more before I understand what you mean. Jason

 July 20, 2007, 13:38 Re: UDF usage #12 cotket Guest   Posts: n/a Hi Jason Well, i will explain more my problem.we probably get misunderstanding for this discussion. I am modeling a blood vessel, this model has one inlet and two outlets. I'll make some cross sections of blood and want to compute the WSS along perimeter of specific surface and show the WSS distribution of course. You know,it is difficult to get a lot of point along the outside of surface. Moreover this calculation is not accurate.That's all my problem. So can you give me any new suggestion? Thank you

 July 20, 2007, 15:08 Re: UDF usage #13 jasond Guest   Posts: n/a I guess it really depends upon the nature of the specific surface you mention. If your surface is planar, then the easiest UDF path is to loop over the wall boundary faces and write out the shear for each face that intersects the plane. I am not sitting a computer with Fluent on it, so I am not sure, but you should also be able to create your perimeter surface either in Fluent or at the grid generation step so that it is available to you within a UDF or with Fluent's standard postprocessing stuff. This is probably the best solution. Jason

 July 20, 2007, 21:53 Re: UDF usage #14 cotket Guest   Posts: n/a Can you tell me more detail how to create the perimeter surface? If get this circle i will compute WSS of desired surface without using UDF.There are some options that can display perimeter but i didn't know how to use this result to postprocessing step. Thank you

 July 24, 2007, 14:16 Re: UDF usage #15 jasond Guest   Posts: n/a I tried a few things over the last couple of days, but nothing has worked. It seems like I have done something like this before, but I can't recall the exact details. I would contact Fluent's support people - and be very specific. If I remember details or turn up anything I'll post it here. Jason

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post shankara.2 Fluent UDF and Scheme Programming 1 January 16, 2012 23:14 teguhtf Fluent UDF and Scheme Programming 1 December 3, 2010 23:14 Asghari FLUENT 5 July 27, 2006 09:46 sangamnath FLUENT 5 December 17, 2005 13:16 Luc SEMINEL Main CFD Forum 0 November 25, 2002 05:01

All times are GMT -4. The time now is 18:50.