CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

UDF about boundary condition

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 23, 2019, 02:27
Post UDF about boundary condition
  #1
New Member
 
Jim
Join Date: Jun 2019
Posts: 6
Rep Power: 6
CrystalEternity is on a distinguished road
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 is offline   Reply With Quote

Old   June 23, 2019, 21:47
Default
  #2
Senior Member
 
Join Date: Feb 2010
Posts: 164
Rep Power: 17
gearboy is on a distinguished road
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 View Post
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 is offline   Reply With Quote

Old   June 23, 2019, 21:57
Default
  #3
New Member
 
Jim
Join Date: Jun 2019
Posts: 6
Rep Power: 6
CrystalEternity is on a distinguished road
Thanks for your reply. I will have a try
CrystalEternity is offline   Reply With Quote

Reply

Tags
threead_f_wall, udf,boundary condition,p


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cyclic boundary condition in foam-extend 4.0 rellumeister OpenFOAM Pre-Processing 2 March 3, 2020 08:03
Fluent Boundary Condition with UDF amitjoshi FLUENT 0 November 16, 2018 02:21
How do you use heat flux as a boundary condition in a non-wall area in UDF? JuBong Fluent UDF and Scheme Programming 2 July 2, 2018 21:15
Out File does not show Imbalance in % Mmaragann CFX 5 January 20, 2017 10:20
An error has occurred in cfx5solve: volo87 CFX 5 June 14, 2013 17:44


All times are GMT -4. The time now is 03:54.