CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   Counting number of times a particle hits a wall (https://www.cfd-online.com/Forums/fluent-udf/162407-counting-number-times-particle-hits-wall.html)

davidsq November 9, 2015 13:18

Counting number of times a particle hits a wall
 
I am trying to write a UDF which tracks how many times each particle hits a wall. I'm assuming that since the DEFINE_DPM_BC macro activates upon particle impact I should use this macro to begin. Additionally in the DEFINE_DPM_EROSION example in fluent help it shows how to track how many impacts occur on a specific face, however I cannot find an example regarding how many times a specific particle impacts the surface.

Any help or guidance for this UDF would be greatly appreciated - even if it's just pointing me in the right directions.

Thanks.

`e` November 9, 2015 15:28

Enable one user-defined value for the particles and increment this value each time the particle impacts a boundary. Use the P_USER_REAL macro for accessing this memory within a DEFINE_DPM_BC UDF.

davidsq November 9, 2015 16:15

Could it be something as simple as the following? I'm getting the error: P_USER_REAL: undeclared variable. I've included the udf.h and the dpm.h header files in the local folder. Not sure why this is happening. Thanks!

#include "udf.h"
#include "dpm.h"

int num_hits = 0;

DEFINE_DPM_BC(num_of_hits,p,t,f,f_normal,dim)
{
num_hits = num_hits+1;
P_USER_REAL(p,0) = num_hits;

}

`e` November 9, 2015 21:11

Yes, that UDF should work for counting a single particle in serial mode. However, you may encounter issues with tracking several particles (they're counting with the same num_hits variable) and in parallel (num_hits may be different on each compute node). I recommend updating the number of hits with:

Code:

P_USER_REAL(p,0) = P_USER_REAL(p,0) + 1.;
The dpm.h header file is already included in the udf.h header file. Enable the particle memory via Discrete Phase Model > UDF > User Variables > Number of Scalars: 1.


All times are GMT -4. The time now is 13:07.