|
发表于 2013-3-5 15:32:06
|
显示全部楼层
整个程序逻辑结构都不正确。随便改了一下,编译通过,但没计算过。整个程序流程应该是:先判断颗粒所在的网格,然后判断该网格是不是壁面的邻接网格,如果是就加你要的力,不是的话就设置为零。
#include "udf.h"
#define KVISO 1.48e-06 /*kinematic viscosity*/
#define DP 10.e-06 /*particle diameter*/
#define BB 2.e-19 /*B*/
#define ZZ .4e-9 /*Z*/
#define CC .833e-01 /*constant*/
const int zone_ID=8;
DEFINE_DPM_BODY_FORCE(lift_van,p,i)
{
int n;
real dens,lift_force, wall_shear_force, van_force,TAU, USTAR,lift, adhension,area,result;
real A[ND_ND];
face_t wall_f;
cell_t c;
Thread *tc,*tf,*wall_tf;
Domain*d;
cxboolean IsCellNeighborToWall=FALSE;
d=Get_Domain(1);
//get which cell the particle located in
c=RP_CELL(&p->cCell);
tc= RP_THREAD(&p->cCell);
//judge whether cell is neighbor to wall
c_face_loop(c,tc,n)
{
tf=C_FACE_THREAD(c,tc,n);
if(zone_ID==THREAD_ID(tf))
{
wall_f=C_FACE(c,tc,n);
wall_tf=tf;
IsCellNeighborToWall=TRUE;
}
}
if(IsCellNeighborToWall) //if cell is neighbor to wall, then add force
{
F_AREA(A,wall_f,wall_tf);
area=NV_MAG(A);
wall_shear_force=NV_MAG(F_STORAGE_R_N3V(wall_f,wall_tf,SV_WALL_SHEAR));
TAU=wall_shear_force/area;
dens=F_R(wall_f,wall_tf);
USTAR=sqrt(TAU/dens);
lift=dens*pow(KVISO,2)*20.90*pow(0.5*USTAR/KVISO,2.31);
adhension=BB*DP*CC*pow(ZZ,2);
if(lift>adhension)
{
lift_force=lift;
van_force=adhension;
result=(lift_force-van_force)/P_MASS(p);
}
else
result=0; // if lift<=adhension, no force added
}
else
result=0; // for cell not neighbor to wall, set to zero
return result;
} |
|