CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

UDF for particle velocity doesn't work !!

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 5, 2014, 06:26
Default UDF for particle velocity doesn't work !!
  #1
Member
 
souria
Join Date: Mar 2013
Location: Nancy
Posts: 66
Rep Power: 13
souria is on a distinguished road
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
souria is offline   Reply With Quote

Old   December 5, 2014, 08:23
Default
  #2
Sun
Senior Member
 
Sun's Avatar
 
Join Date: Nov 2010
Posts: 103
Rep Power: 16
Sun is on a distinguished road
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
macro to check if you can get the velocity for time steps other than the first one.
Sun is offline   Reply With Quote

Old   December 8, 2014, 05:29
Default
  #3
Member
 
souria
Join Date: Mar 2013
Location: Nancy
Posts: 66
Rep Power: 13
souria is on a distinguished road
Quote:
Originally Posted by Sun View Post
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
macro to check if you can get the velocity for time steps other than the first one.
Hey Sun, Yes I load and built the UDF and put it in initialization case (image1 : inisialization)
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
Attached Images
File Type: jpg initialization.jpg (41.3 KB, 102 views)
File Type: jpg point-properties.jpg (49.5 KB, 76 views)
souria is offline   Reply With Quote

Old   December 8, 2014, 05:58
Default
  #4
Member
 
souria
Join Date: Mar 2013
Location: Nancy
Posts: 66
Rep Power: 13
souria is on a distinguished road
I fund out that I have no access to the User-defined Functions Hooks !!!

Any help about this ???
Attached Images
File Type: jpg hook.jpg (50.8 KB, 70 views)
souria is offline   Reply With Quote

Old   December 8, 2014, 08:14
Default
  #5
Senior Member
 
Cees Haringa
Join Date: May 2013
Location: Delft
Posts: 607
Rep Power: 0
CeesH is on a distinguished road
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?
CeesH is offline   Reply With Quote

Old   December 8, 2014, 10:22
Default
  #6
Member
 
souria
Join Date: Mar 2013
Location: Nancy
Posts: 66
Rep Power: 13
souria is on a distinguished road
Quote:
Originally Posted by CeesH View Post
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?
Yes, Ceesh, after the dpm iterations I get "0" for the first step !!! So, it didn't intialize the velocity of particle to these of the flow !!

any idea CeesH ??
souria is offline   Reply With Quote

Old   December 8, 2014, 10:25
Default
  #7
Senior Member
 
Cees Haringa
Join Date: May 2013
Location: Delft
Posts: 607
Rep Power: 0
CeesH is on a distinguished road
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?
CeesH is offline   Reply With Quote

Old   December 8, 2014, 10:30
Default
  #8
Member
 
souria
Join Date: Mar 2013
Location: Nancy
Posts: 66
Rep Power: 13
souria is on a distinguished road
Quote:
Originally Posted by CeesH View Post
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?
It gives no error or warning when I complied and built the UDF !
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
souria is offline   Reply With Quote

Old   December 8, 2014, 10:35
Default
  #9
Senior Member
 
Cees Haringa
Join Date: May 2013
Location: Delft
Posts: 607
Rep Power: 0
CeesH is on a distinguished road
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...
CeesH is offline   Reply With Quote

Old   December 8, 2014, 10:40
Default
  #10
Member
 
souria
Join Date: Mar 2013
Location: Nancy
Posts: 66
Rep Power: 13
souria is on a distinguished road
Quote:
Originally Posted by CeesH View Post
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...
"the define-adjust" ? what's it's role, here?
souria is offline   Reply With Quote

Old   December 8, 2014, 10:50
Default
  #11
Senior Member
 
Cees Haringa
Join Date: May 2013
Location: Delft
Posts: 607
Rep Power: 0
CeesH is on a distinguished road
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)}}
CeesH is offline   Reply With Quote

Old   December 8, 2014, 11:14
Default
  #12
Member
 
souria
Join Date: Mar 2013
Location: Nancy
Posts: 66
Rep Power: 13
souria is on a distinguished road
Quote:
Originally Posted by CeesH View Post
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)}}
I tried to do this but it gave this message : 'time_step : is not a member of particle_struct' !
souria is offline   Reply With Quote

Old   December 8, 2014, 11:27
Default
  #13
Senior Member
 
Cees Haringa
Join Date: May 2013
Location: Delft
Posts: 607
Rep Power: 0
CeesH is on a distinguished road
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)
}}}}
(note, I did not run or debug this)
CeesH is offline   Reply With Quote

Old   December 8, 2014, 11:32
Default
  #14
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
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*/
}
}
Do you see velocities (0,0,0) or (7,8,9)?
pakk is offline   Reply With Quote

Old   December 8, 2014, 11:46
Default
  #15
Member
 
souria
Join Date: Mar 2013
Location: Nancy
Posts: 66
Rep Power: 13
souria is on a distinguished road
Quote:
Originally Posted by pakk View Post
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*/
}
}
Do you see velocities (0,0,0) or (7,8,9)?
Pakk, Weird weird !! I got (0,0,0)
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
souria is offline   Reply With Quote

Old   December 8, 2014, 11:50
Default
  #16
Member
 
souria
Join Date: Mar 2013
Location: Nancy
Posts: 66
Rep Power: 13
souria is on a distinguished road
Quote:
Originally Posted by CeesH View Post
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)
}}}}
(note, I did not run or debug this)
Results : I could pop up the "adjust fuction" (in User defined Function Hooks) but still get (0,0,0) for the fisrt step !!
souria is offline   Reply With Quote

Old   December 8, 2014, 12:11
Default
  #17
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Quote:
Originally Posted by souria View Post
Pakk, Weird weird !! I got (0,0,0)
What if you replace
Code:
loop(p,I->p_init)
by
Code:
loop(p,I->p)
?


About your DEFINE_ADJUST code: I thought T_INIT would be 0 in the first iteration step, not 1.
pakk is offline   Reply With Quote

Old   December 8, 2014, 12:18
Default
  #18
Senior Member
 
Cees Haringa
Join Date: May 2013
Location: Delft
Posts: 607
Rep Power: 0
CeesH is on a distinguished road
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.
CeesH is offline   Reply With Quote

Old   December 8, 2014, 12:37
Cool
  #19
Member
 
souria
Join Date: Mar 2013
Location: Nancy
Posts: 66
Rep Power: 13
souria is on a distinguished road
Quote:
Originally Posted by pakk View Post
What if you replace
Code:
loop(p,I->p_init)
by
Code:
loop(p,I->p)
?


About your DEFINE_ADJUST code: I thought T_INIT would be 0 in the first iteration step, not 1.
I's great PAKKKkkkkk, it works, Ive just changed loop(p,I->p_init to loop(p,I->p) !!

Thanks a lot
souria is offline   Reply With Quote

Old   December 8, 2014, 12:39
Default
  #20
Member
 
souria
Join Date: Mar 2013
Location: Nancy
Posts: 66
Rep Power: 13
souria is on a distinguished road
Quote:
Originally Posted by CeesH View Post
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.
Thanks a lot CeesH for all your replies (I learned so much thing). Right Now, it works and gave me the result I'm expected
souria is offline   Reply With Quote

Reply


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 Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 21:03.