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. |
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.
|
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; } |
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.; |
All times are GMT -4. The time now is 13:07. |