fluent_UDF学习笔记
UDF源代码路径
D:\Program Files\ANSYS Inc\v231\fluent\fluent23.1.0\src
关于颗粒反弹速度的计算
/* 通过面法向单位向量计算速度的法向向量、切向向量,再通过法向、切向恢复系数重新计算反弹速度*/
/* Compute normal velocity.将颗粒速度向面法线方向投影,即计算颗粒速度与法线向量的点乘:V(V1,V2)·n(n1,n2)=V1n1+V2n2 */
for(i=0; i<idim; i++)
vn += TP_VEL(tp)[i]*normal[i];
/* Subtract off normal velocity. 新的颗粒速度为切向速度,及原颗粒速度减去法向速度*/
for(i=0; i<idim; i++)
TP_VEL(tp)[i] -= vn*normal[i];
/* Apply tangential coefficient of restitution. 使用切向恢复系数计算反弹后的切向速度*/
for(i=0; i<idim; i++)
TP_VEL(tp)[i] *= tan_coeff;
/* Add reflected normal velocity.使用法向系数计算反弹后的法向速度,再计算合速度,反弹法向速度为法线反方向,即-n(n1,n2) */
for(i=0; i<idim; i++)
TP_VEL(tp)[i] -= nor_coeff*vn*normal[i];
/* Store new velocity in TP_VEL0 of particle */
for(i=0; i<idim; i++)
TP_VEL0(tp)[i] = TP_VEL(tp)[i]
关于颗粒追踪类型 gtpv_t gvtp;
typedef struct global_tracked_particle_vars_struct
{
#if RP_DPM_CACHE
/* avoids having to pass additional arguments to AddSources();
* later should add extra function args to make clean */
dpm_source_cache_t *source_cache;
int source_cache_size;
int source_cache_count;
film_prop_cache_t *film_prop_cache;
int film_prop_cache_size;
int film_prop_cache_count;
dpm_real_cache_t *real_cache;
int real_cache_size;
int real_cache_count;
dpm_workpile_t *workpile;
int workpile_size;
int workpile_count;
int next_particle;
float *random_cache; /* store precomputed random numbers */
int random_cache_size;
int next_random;
float next_gauss_random; /* save second random generated by gauss_random() */
#endif /* RP_DPM_CACHE */
/*
* Current cell type and number of faces in current cell. Don't use
* cxfaces_per_cell[ctype] for number of faces as hanging nodes may
* add additional faces.
*/
int path_ctype, path_n_faces, path_incl_test;
int path_n_nodes; /* number of nodes in current cell */
int path_face_num;
/* all of the following global data pertains to the cell in which the current
* particle is currently located. Should be updated whenever we start a new
* particle or the particle enters a new cell.
*/
real prevVel[3]; /* velocity of particle in prev step. */
double (*faceEq)[5]; /* faceEq[6*MAX_CELL_NODES][5]; MAX is 6*MAX_CELL_NODES -- polyhedral cell with hanging nodes.
* last element holds magnitude of cross product of edges, e.g., for intersections */
double (*faceEqV)[5]; /* face equation velocity - for face equations moving in time */
#if RP_3D
double (*faceEqA)[4]; /* face equation acceleration - for face equations moving in time */
#endif
double (*facePts)[3][3]; /* facePts[6*MAX_CELL_NODES][3][3]; */
double (*facePtV)[3][3]; /* facePtV[6*MAX_CELL_NODES][3][3]; */
int *validEq; /* validEq[6*MAX_CELL_NODES]; */
cxboolean validMovingEquations; /* safeguard missuse of uninitialized variables */
int *numFacePts; /* numFacePts[6*MAX_CELL_NODES]; */
int *faceIndx; /* faceIndx[6*MAX_CELL_NODES]; */
real zoneEq[3];
int zoneEqSet;
int numCellVisited;
/* equations for perpendicular planes at each edge on the wall film face (max of 4 edges of physical face, not cortex face) */
int *edge_valid; /* edge_valid[MAX_FACE_NODES]; */
double (*edgeEq)[4]; /* edgeEq[MAX_FACE_NODES][4]; */
double (*edgeEqV)[5]; /* for edge equations moving in time */
#if RP_3D
double (*edgeEqA)[4]; /* for edge equations moving in time */
#endif
double (*edgePts)[2][3]; /* for edges moving in time */
double (*edgePtV)[2][3]; /* for edges moving in time */
/* interpolation factors for function values at the current location of the particle. updated every step. */
float *intFact; /* intFact[MAX_CELL_NODES]; */
int n_tracked;
int n_escaped;
int n_aborted;
int n_trapped;//被捕捉颗粒数,无论是aborted or stopped
int n_stripped;
int n_separated;
int n_filmrelease;
#if RP_3D && RP_WALL_FILM
int n_absorbed;
#endif
int n_transformed;
int n_inserted;
int n_evaporated;
int n_incomplete;
int n_incomplete_parallel;
int n_coalesced;
int n_collided;
int n_splashed;
int n_shed;
int n_stick;
int n_rebound;
int n_spread;
#if RP_DPM_CACHE
int n_source_cache_deposits;
int n_cell_updates;
int n_workpile_updates;
#endif /* RP_DPM_CACHE */
int n_migrant;
int n_tracked_migrants;
double dpm_time;
float fldmax[3], fldmin[3]; /* also part of c_par */
struct particle_struct *p_spawned; /* list to carry spawned particles */
struct particle_struct *p_impinging; /* list for impinging particles */
/* subtet tracking */
struct subtet_tracking_location_struct *subtet;
int mc_convergence_failure; /* to report when the RK solver does not converge for multicomponent particles */
} gtpv_t; /* type for global tracked particle vars */
关于颗粒PATH类型 ;
typedef enum
{
PATH_END,//escape
PATH_FINAL_STEP,
PATH_ACTIVE,//继续追踪,track
PATH_BREAK,//
PATH_ABORT,//终止,不再追踪
PATH_STOP,//停止,继续追踪
PATH_NON_LOCAL_PERIODIC,
PATH_NON_LOCAL_OVERSET,
PATH_NON_LOCAL_GTI,
PATH_NON_LOCAL,
PATH_REINJECT,
PATH_MAX_STATUS
} Path_Status;
PATH_STOP
**
表示颗粒停止移动,颗粒静止在壁面上,不过颗粒轨迹仍参与计算,应该能用做颗粒的沉积再剥离
PATH_ABORT与n_aborted对应
颗粒中止计算,从后续计算中移除,不再存在于计算域中,减少计算负担,方便后处理
PATH_END:与n_escaped对应
一般用于计算域的出入口,对于一些壁面也能用作颗粒壁面边界条件的简化处理。
PATH__BREAK
颗粒PATH类型之PATH

颗粒在边界面不断破碎,意味着颗粒轨迹计算不会终止,陷入死循环