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/)
-   -   DEFINE_DPM_BC simple reflect at wall (https://www.cfd-online.com/Forums/fluent-udf/143409-define_dpm_bc-simple-reflect-wall.html)

junz October 23, 2014 16:31

DEFINE_DPM_BC simple reflect at wall
 
Hi,
I just can't understand several code lines when studying the example in udf manual.

1. why need special treatment for 2d axisymmetric and swirl flows
and the code has if (R>1.e-20) {idim=3; normal[0]=f_normal[0];...}
why is 1.e-20?and why dimension changed to 3?

2. if (p->type==DPM_TYPE_INERT) what is the symbol ->?

I am new to udf and forget some C programming. Any help is greatly appreciated.
Thanks

pakk October 27, 2014 11:38

1. If you are calculating 2d axisymmetric and swirl flows, your geometry is 2-dimensional (so variable "dim" is 2), but the velocity vector is 3-dimensional (so "idim" is defined as 3).
In the calculation of normal, you divide by the radius R. But if the radius is zero, this will give an error, because you can not divide by zero. If the radius is too close to zero, the result can be too big to store for the program. So to avoid these problems, the calculation of the normal is not done if you are close to the origin. 1e-20 is an arbitrary small value, it could also have been 1e-19 or 1e-21, I think.

2. About the symbol ->: "p->a" is short for "(*p).a". See this wikipedia page for more info.

junz October 30, 2014 10:02

Thanks a lot. If I want to extract particle impact angle and velocity. How should I realize this?

pakk October 30, 2014 10:37

Code:

DEFINE_DPM_BC(example,p,t,f,f_normal,dim)
{
 // P_VEL(p) is the velocity vector of the particle
 // f_normal is the normal vector of the cell face that your particle hits
 //  (not of unit length, be careful)
}

So you need to do some basic trigonometry to get the angle.

junz October 30, 2014 23:24

Oh, I got it. Thanks. One more question...is there any difference between use of position vector and use of velocity vector to get the impact angle? which is preferred?

pakk October 31, 2014 03:12

I don't see how you can use the position vector (you mean the particle position vector?) to get the impact angle. So I would use the particle velocity vector and the face normal vector. You'll need both of them.

junz November 8, 2014 14:03

Hello, I have another problem now. How can I export the particle position data to an excel? And how can I get to know the number of impacts of particles?
For both situations, do I need to write a udf? Thanks very much


All times are GMT -4. The time now is 22:10.