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/)
-   -   UDF about boundary condition (https://www.cfd-online.com/Forums/fluent-udf/218500-udf-about-boundary-condition.html)

CrystalEternity June 23, 2019 02:27

UDF about boundary condition
 
The following program is an example from the help document.When I wanted to use it, some problems bothered me.
1.f_normal contains the unit vector which is normal to the face,but in or out?(maybe it doesn't matter,I just want to know it)
2.if(p->type==DPM_TYPE_INERT)
I know: #define DPM_TYPE_INERT 1(from dpm_types.h)
P-> structural member (the number"1" passed by FLUENT
indicates the particle type, only in my opinion)
So,Is the particle type only for INERT particles to execute the program?
To "p->type" ,is it assigned to 1?
3.if ((NNULLP(t)) && (THREAD_TYPE(t) == THREAD_F_WALL))
F_CENTROID(x,f,t);
how to understand it?

Maybe my problem will be naive, but for me as a beginner, it is really important.I hope to get help, but whatever the result, I appreciate your browsing and thinking.
Thanks again!


/* reflect boundary condition for inert particles */
#include "udf.h"
DEFINE_DPM_BC(bc_reflect,p,t,f,f_normal,dim)
{
real alpha; /* angle of particle path with face normal */
real vn=0.;
real nor_coeff = 1.;
real tan_coeff = 0.3;
real normal[3];
int i, idim = dim;
real NV_VEC(x);

#if RP_2D
/* dim is always 2 in 2D compilation. Need special treatment for 2d
axisymmetric and swirl flows */
if (rp_axi_swirl)
{
real R = sqrt(P_POS(p)[1]*P_POS(p)[1] +
P_POS(p)[2]*P_POS(p)[2]);
if (R > 1.e-20)
{
idim = 3;
normal[0] = f_normal[0];
normal[1] = (f_normal[1]*P_POS(p)[1])/R;
normal[2] = (f_normal[1]*P_POS(p)[2])/R;
}
else
{
for (i=0; i<idim; i++)
normal[i] = f_normal[i];
}
}
else
#endif
for (i=0; i<idim; i++)
normal[i] = f_normal[i];

if(p->type==DPM_TYPE_INERT)
{
alpha = M_PI/2. - acos(MAX(-1.,MIN(1.,NV_DOT(normal,P_VEL(p))/
MAX(NV_MAG(P_VEL(p)),DPM_SMALL))));
if ((NNULLP(t)) && (THREAD_TYPE(t) == THREAD_F_WALL))
F_CENTROID(x,f,t);

/* calculate the normal component, rescale its magnitude by
the coefficient of restitution and subtract the change */

/* Compute normal velocity. */
for(i=0; i<idim; i++)
vn += P_VEL(p)[i]*normal[i];

/* Subtract off normal velocity. */
for(i=0; i<idim; i++)
P_VEL(p)[i] -= vn*normal[i];

/* Apply tangential coefficient of restitution. */
for(i=0; i<idim; i++)
P_VEL(p)[i] *= tan_coeff;

/* Add reflected normal velocity. */
for(i=0; i<idim; i++)
P_VEL(p)[i] -= nor_coeff*vn*normal[i];

/* Store new velocity in P_VEL0 of particle */
for(i=0; i<idim; i++)
P_VEL0(p)[i] = P_VEL(p)[i];

return PATH_ACTIVE;
}
return PATH_ABORT;
}

gearboy June 23, 2019 21:47

You can use "VC++ Udf Studio" to debug this macro, then you can see any variable value in the macro, including p structure, p->type, etc.

Quote:

Originally Posted by CrystalEternity (Post 736995)
The following program is an example from the help document.When I wanted to use it, some problems bothered me.
1.f_normal contains the unit vector which is normal to the face,but in or out?(maybe it doesn't matter,I just want to know it)
2.if(p->type==DPM_TYPE_INERT)
I know: #define DPM_TYPE_INERT 1(from dpm_types.h)
P-> structural member (the number"1" passed by FLUENT
indicates the particle type, only in my opinion)
So,Is the particle type only for INERT particles to execute the program?
To "p->type" ,is it assigned to 1?
3.if ((NNULLP(t)) && (THREAD_TYPE(t) == THREAD_F_WALL))
F_CENTROID(x,f,t);
how to understand it?

Maybe my problem will be naive, but for me as a beginner, it is really important.I hope to get help, but whatever the result, I appreciate your browsing and thinking.
Thanks again!


/* reflect boundary condition for inert particles */
#include "udf.h"
DEFINE_DPM_BC(bc_reflect,p,t,f,f_normal,dim)
{
real alpha; /* angle of particle path with face normal */
real vn=0.;
real nor_coeff = 1.;
real tan_coeff = 0.3;
real normal[3];
int i, idim = dim;
real NV_VEC(x);

#if RP_2D
/* dim is always 2 in 2D compilation. Need special treatment for 2d
axisymmetric and swirl flows */
if (rp_axi_swirl)
{
real R = sqrt(P_POS(p)[1]*P_POS(p)[1] +
P_POS(p)[2]*P_POS(p)[2]);
if (R > 1.e-20)
{
idim = 3;
normal[0] = f_normal[0];
normal[1] = (f_normal[1]*P_POS(p)[1])/R;
normal[2] = (f_normal[1]*P_POS(p)[2])/R;
}
else
{
for (i=0; i<idim; i++)
normal[i] = f_normal[i];
}
}
else
#endif
for (i=0; i<idim; i++)
normal[i] = f_normal[i];

if(p->type==DPM_TYPE_INERT)
{
alpha = M_PI/2. - acos(MAX(-1.,MIN(1.,NV_DOT(normal,P_VEL(p))/
MAX(NV_MAG(P_VEL(p)),DPM_SMALL))));
if ((NNULLP(t)) && (THREAD_TYPE(t) == THREAD_F_WALL))
F_CENTROID(x,f,t);

/* calculate the normal component, rescale its magnitude by
the coefficient of restitution and subtract the change */

/* Compute normal velocity. */
for(i=0; i<idim; i++)
vn += P_VEL(p)[i]*normal[i];

/* Subtract off normal velocity. */
for(i=0; i<idim; i++)
P_VEL(p)[i] -= vn*normal[i];

/* Apply tangential coefficient of restitution. */
for(i=0; i<idim; i++)
P_VEL(p)[i] *= tan_coeff;

/* Add reflected normal velocity. */
for(i=0; i<idim; i++)
P_VEL(p)[i] -= nor_coeff*vn*normal[i];

/* Store new velocity in P_VEL0 of particle */
for(i=0; i<idim; i++)
P_VEL0(p)[i] = P_VEL(p)[i];

return PATH_ACTIVE;
}
return PATH_ABORT;
}


CrystalEternity June 23, 2019 21:57

Thanks for your reply. I will have a try


All times are GMT -4. The time now is 18:16.