|
[Sponsors] |
December 5, 2014, 06:26 |
UDF for particle velocity doesn't work !!
|
#1 |
Member
souria
Join Date: Mar 2013
Location: Nancy
Posts: 66
Rep Power: 13 |
Hey everyone,
I'm tracking particles (surface injection) in steady flow using DPM. I used this UDF to impose to particles the velocity of the flow when they will be injected(just for the initialisation). Herein the lines : #include "udf.h" #include "dpm.h" DEFINE_DPM_INJECTION_INIT(velocity_magnitude, I) { Particle *p; cell_t c; Thread *t; loop(p,I->p_init) /*Standard Fluent looping Macro to get particle streams in an inejction using unsteady particle tracking*/ { c = P_CELL(p); /*Get the cell that the particle is currently in*/ t = P_CELL_THREAD(p); /*Get the thread that the particle is currently in*/ P_VEL(p)[0] = C_U(c, t); /*Longitudinal velocity*/ P_VEL(p)[1] = C_V(c, t); /*Spanwise velocity*/ P_VEL(p)[2] = C_W(c, t); /*vertical velocity*/ } } But, when I check partciles velocity for the first step it gave me ( u = 0, v = 0 and w= 0). So, it didn't take in account the UDF !!! Please tell what it's wrong with my UDF !!! Thanks for your help |
|
December 5, 2014, 08:23 |
|
#2 |
Senior Member
Join Date: Nov 2010
Posts: 103
Rep Power: 16 |
might be silly, but did you remember to hook up the UDF?
and what if you use the very same code in a Code:
DEFINE_ADJUST |
|
December 8, 2014, 05:29 |
|
#3 | |
Member
souria
Join Date: Mar 2013
Location: Nancy
Posts: 66
Rep Power: 13 |
Quote:
But, in point properties the velocities still equal to 0 (second image), do you think that it comes from this ?? Thanks for your reply Souria |
||
December 8, 2014, 05:58 |
|
#4 |
Member
souria
Join Date: Mar 2013
Location: Nancy
Posts: 66
Rep Power: 13 |
I fund out that I have no access to the User-defined Functions Hooks !!!
Any help about this ??? |
|
December 8, 2014, 08:14 |
|
#5 |
Senior Member
Cees Haringa
Join Date: May 2013
Location: Delft
Posts: 607
Rep Power: 0 |
Hi Souria,
Do you only see the velocity 0 in the setup screen, or do you actually `measure' it to be 0 when iterating in particle tracks? |
|
December 8, 2014, 10:22 |
|
#6 | |
Member
souria
Join Date: Mar 2013
Location: Nancy
Posts: 66
Rep Power: 13 |
Quote:
any idea CeesH ?? |
||
December 8, 2014, 10:25 |
|
#7 |
Senior Member
Cees Haringa
Join Date: May 2013
Location: Delft
Posts: 607
Rep Power: 0 |
So far I don't see any error (I assume the flow is already steady at the point you inject the particles)
Are you sure the define_adjust function is properly compiled? It doesn't give any warnings or so? I've had some problems with mass transfer functions in which the function compiled properly, but a warning for udf_names.h was given and the function did not appear in the proper hook menu - nothing like that here? |
|
December 8, 2014, 10:30 |
|
#8 | |
Member
souria
Join Date: Mar 2013
Location: Nancy
Posts: 66
Rep Power: 13 |
Quote:
Yes, Im in steady flow but the DPM is unsteady. To be clear, for hooking the UDF, in my case, I just did it in the injection box (not in User defined Function Hooks), is it correct ? Thanks for your answers CeesH |
||
December 8, 2014, 10:35 |
|
#9 |
Senior Member
Cees Haringa
Join Date: May 2013
Location: Delft
Posts: 607
Rep Power: 0 |
Yes, the initialization is via the injection box. The define_adjust should be via function hooks. but it is weird the define_adjust doesn't pop up in the menu when you do compile it...
|
|
December 8, 2014, 10:40 |
|
#10 |
Member
souria
Join Date: Mar 2013
Location: Nancy
Posts: 66
Rep Power: 13 |
||
December 8, 2014, 10:50 |
|
#11 |
Senior Member
Cees Haringa
Join Date: May 2013
Location: Delft
Posts: 607
Rep Power: 0 |
As sun mentioned, maybe you can use define_adjust with a similar code (a loop over all particles to adjust their velocity in the 1st timestep) to achieve the same result as the particle initialization UDF. You do have to rewrite the code a little bit, it's a little less straightforward but the result should be the same: at the end of the 1st timestep the velocity of all particles is adjusted to the cell velocity. I guess it is most easy if you inject all particles in a single timestep. is this the case? If so, the pseudocode would look like:
if NStep = 1 (or flowtime is 1dt){ {- loop over all particles - set P_VEL(p)[i] = C_i(c,t)}} |
|
December 8, 2014, 11:14 |
|
#12 | |
Member
souria
Join Date: Mar 2013
Location: Nancy
Posts: 66
Rep Power: 13 |
Quote:
|
||
December 8, 2014, 11:27 |
|
#13 |
Senior Member
Cees Haringa
Join Date: May 2013
Location: Delft
Posts: 607
Rep Power: 0 |
do you get such an error for:
Code:
#include "udf.h" #include "dpm.h" DEFINE_ADJUST(whatever it needs here) { Injection *I; Injection *dpm_injections = Get_dpm_injections(); Particle *p; int T = N_TIME; if(T == 1) { loop(I,dpm_injections) { loop(p,I->p) { c = P_CELL(p); /*Get the cell that the particle is currently in*/ t = P_CELL_THREAD(p); /*Get the thread that the particle is currently in*/ P_VEL(p)[0] = C_U(c,t) P_VEL(p)[1] = C_V(c,t) P_VEL(p)[2] = C_W(c,t) }}}} |
|
December 8, 2014, 11:32 |
|
#14 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
I would be interested in what happens with the following code:
Code:
#include "udf.h" #include "dpm.h" DEFINE_DPM_INJECTION_INIT(velocity_magnitude, I) { Particle *p; cell_t c; Thread *t; loop(p,I->p_init) /*Standard Fluent looping Macro to get particle streams in an inejction using unsteady particle tracking*/ { c = P_CELL(p); /*Get the cell that the particle is currently in*/ t = P_CELL_THREAD(p); /*Get the thread that the particle is currently in*/ P_VEL(p)[0] =7; /*Longitudinal velocity*/ P_VEL(p)[1] = 8; /*Spanwise velocity*/ P_VEL(p)[2] = 9; /*vertical velocity*/ } } |
|
December 8, 2014, 11:46 |
|
#15 | |
Member
souria
Join Date: Mar 2013
Location: Nancy
Posts: 66
Rep Power: 13 |
Quote:
PS. In the Box Injection > Point Properties : the variables value of each velocity is "0" (I never change this box), did this affect the function of the UDF ? Or genrally, should I put other values, but which values, if I want to set the particles velocity to that of the flow at the injection ??? Thanks for your help |
||
December 8, 2014, 11:50 |
|
#16 | |
Member
souria
Join Date: Mar 2013
Location: Nancy
Posts: 66
Rep Power: 13 |
Quote:
|
||
December 8, 2014, 12:11 |
|
#17 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
||
December 8, 2014, 12:18 |
|
#18 |
Senior Member
Cees Haringa
Join Date: May 2013
Location: Delft
Posts: 607
Rep Power: 0 |
another one about the define_adjust; are you actually injecting in the first transient timestep?
what you could try is setting a small timestep, then adjusting the velocities in the first timestep after initializing, rather than the timestep of initializing. Yes, this is a very crude test, but maybe it helps. If it works, you can reset the timestep to the normal value and continue calculating. The one `fake' first step shouldn't make too much a difference. But of course, a working DPM initialization would be preferable. |
|
December 8, 2014, 12:37 |
|
#19 |
Member
souria
Join Date: Mar 2013
Location: Nancy
Posts: 66
Rep Power: 13 |
||
December 8, 2014, 12:39 |
|
#20 | |
Member
souria
Join Date: Mar 2013
Location: Nancy
Posts: 66
Rep Power: 13 |
Quote:
|
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
UDF Unsteady velocity parabolic profile | Rashad | FLUENT | 3 | October 1, 2018 16:27 |
Simulation with UDF for species mass fraction and velocity profile | virgy | Fluent UDF and Scheme Programming | 8 | February 7, 2012 05:30 |
the udf has been hooked to the fluent successfully,but it does not work! | hugeforest | Fluent UDF and Scheme Programming | 1 | July 8, 2011 05:31 |
UDF for wall slipping | HFLUENT | Fluent UDF and Scheme Programming | 0 | April 27, 2011 13:03 |
UDF velocity profile problem | Steve | FLUENT | 0 | January 18, 2005 13:11 |