enquire explanation of the code
Here is an example from ANSYS help, tracking particle's reflections at walls.
Code:
/* reflect boundary condition for inert particles */ Code:
for (i=0; i<idim; i++) |
for (i=0; i<idim; i++)
normal[i] = f_normal[i]; int idim=dim, where dim is argument in DEFINE_DPM_BC, which stands for the dimension of the flow problem. The value is 2 in 2d, for 2d-axisymmetric and 2d-axisymmetric-swirling flow, while it is 3 in 3d flows. You are looping through the components for the vector "normal" and setting an equivalence between "normal" and "f_normal", which this last one is another argument of DEFINE_DPM_BC that contains the unit vector which is normal to the face (the boundary condition where DEFINE_DPM_BC is hooked to). if ((NNULLP(t)) && (THREAD_TYPE(t) == THREAD_F_WALL)) F_CENTROID(x,f,t); (Copied from the udf guide): You can use the NULLP and NNULLP functions to check whether storage has been allocated for userdefined scalars. NULLP returns TRUE if storage is not allocated, and NNULLP returns TRUE if storage is allocated. If you are not using UDS, I guess you can omit it. (THREAD_TYPE(t) == THREAD_F_WALL) is used to check if you are in a wall F_CENTROID(x,f,t) sets the array "x" as the coordinates of the face centroid of the wall. Cheers |
Quote:
1. So u mean dim is argument in DEFINE_DPM_BC, but why don't we just use dim then, why we need to define dim as idim? 2. Similarly, what is the purpose to define normal[i] = f_normal[i]? 3. What does the statement "F_CENTROID(x,f,t)" do? it calls the controid if statement "((NNULLP(t)) && (THREAD_TYPE(t) == THREAD_F_WALL))" is true, but why do we need the centroid? I'm new to UDF so I have a lot of silly questions. Really appreciate! |
Quote:
Quote:
Quote:
Quote:
|
Quote:
Code:
dim=idim; Cheers! |
This code is a boundary condition. So the code is only run when a particle has reached a wall. And the steps that are taken then, are in the code. Look at the comments!
Code:
/* Compute normal velocity. */ |
Quote:
|
All times are GMT -4. The time now is 22:38. |