fluentudf.docx
- 文档编号:23985830
- 上传时间:2023-05-23
- 格式:DOCX
- 页数:14
- 大小:16.80KB
fluentudf.docx
《fluentudf.docx》由会员分享,可在线阅读,更多相关《fluentudf.docx(14页珍藏版)》请在冰豆网上搜索。
fluentudf
/***********************************************************************/
/*vprofile.c*/
/*UDFforspecifyingsteady-statevelocityprofileboundarycondition*/
/***********************************************************************/
#include"udf.h"
DEFINE_PROFILE(inlet_x_velocity,thread,position)
{
realx[ND_ND];/*thiswillholdthepositionvector*/
realy;
face_tf;
begin_f_loop(f,thread)
{
F_CENTROID(x,f,thread);
y=x[1];
F_PROFILE(f,thread,position)=20.-y*y/(.0745*.0745)*20.;
}
end_f_loop(f,thread)
}
/**********************************************************************/
/*unsteady.c*/
/*UDFforspecifyingatransientvelocityprofileboundarycondition*/
/**********************************************************************/
#include"udf.h"
DEFINE_PROFILE(unsteady_velocity,thread,position)
{
face_tf;
begin_f_loop(f,thread)
{
realt=RP_Get_Real("flow-time");
F_PROFILE(f,thread,position)=20.+5.0*sin(10.*t);
}
end_f_loop(f,thread)
}
/******************************************************************/
/*UDFthataddsmomentumsourcetermandderivativetoductflow*/
/******************************************************************/
#include"udf.h"
#defineCON20.0
DEFINE_SOURCE(cell_x_source,cell,thread,dS,eqn)
{
realsource;
if(C_T(cell,thread)<=288.)
{
/*sourceterm*/
source=-CON*C_U(cell,thread);
/*derivativeofsourcetermw.r.t.x-velocity.*/
dS[eqn]=-CON;
}
else
source=dS[eqn]=0.;
returnsource;
}
/*********************************************************************/
/*UDFforspecifyingatemperature-dependentviscosityproperty*/
/*********************************************************************/
#include"udf.h"
DEFINE_PROPERTY(cell_viscosity,cell,thread)
{
realmu_lam;
realtemp=C_T(cell,thread);
if(temp>288.)
mu_lam=5.5e-3;
elseif(temp>286.)
mu_lam=143.2135-0.49725*temp;
else
mu_lam=1.;
returnmu_lam;
}
/**************************************************************/
/*rate.c*/
/*UDFforspecifyingareactionrateinaporousmedium*/
/**************************************************************/
#include"udf.h"
#defineK12.0e-2
#defineK25.
DEFINE_VR_RATE(user_rate,c,t,r,mole_weight,species_mf,rate,rr_t)
{
reals1=species_mf[0];
realmw1=mole_weight[0];
if(FLUID_THREAD_P(t)&&THREAD_VAR(t).fluid.porous)
*rate=K1*s1/pow((1.+K2*s1),2.0)/mw1;
else
*rate=0.;
}
/***********************************************************************/
/*UDFforcomputingthemagnitudeofthegradientofT^4*/
/***********************************************************************/
#include"udf.h"
/*Definewhichuser-definedscalarstouse.*/
enum
{
T4,
MAG_GRAD_T4,
N_REQUIRED_UDS
};
DEFINE_ADJUST(adjust_fcn,domain)
{
Thread*t;
cell_tc;
face_tf;
/*Makesurethereareenoughuser-definedscalars.*/
if(n_uds Internal_Error("notenoughuser-definedscalarsallocated"); /*FillfirstUDSwithtemperatureraisedtofourthpower.*/ thread_loop_c(t,domain) { if(NULL! =THREAD_STORAGE(t,SV_UDS_I(T4))) { begin_c_loop(c,t) { realT=C_T(c,t); C_UDSI(c,t,T4)=pow(T,4.); } end_c_loop(c,t) } } thread_loop_f(t,domain) { if(NULL! =THREAD_STORAGE(t,SV_UDS_I(T4))) { begin_f_loop(f,t) { realT=0.; if(NULL! =THREAD_STORAGE(t,SV_T)) T=F_T(f,t); elseif(NULL! =THREAD_STORAGE(t->t0,SV_T)) T=C_T(F_C0(f,t),t->t0); F_UDSI(f,t,T4)=pow(T,4.); } end_f_loop(f,t) } } /*FillsecondUDSwithmagnitudeofgradient.*/ thread_loop_c(t,domain) { if(NULL! =THREAD_STORAGE(t,SV_UDS_I(T4))&& NULL! =T_STORAGE_R_NV(t,SV_UDSI_G(T4))) { begin_c_loop(c,t) { C_UDSI(c,t,MAG_GRAD_T4)=NV_MAG(C_UDSI_G(c,t,T4)); } end_c_loop(c,t) } } thread_loop_f(t,domain) { if(NULL! =THREAD_STORAGE(t,SV_UDS_I(T4))&& NULL! =T_STORAGE_R_NV(t->t0,SV_UDSI_G(T4))) { begin_f_loop(f,t) { F_UDSI(f,t,MAG_GRAD_T4)=C_UDSI(F_C0(f,t),t->t0,MAG_GRAD_T4); } end_f_loop(f,t) } } } /**************************************************************/ /*ImplementationoftheP1modelusinguser-definedscalars*/ /**************************************************************/ #include"udf.h" /*Definewhichuser-definedscalarstouse.*/ enum { P1, N_REQUIRED_UDS }; staticrealabs_coeff=1.0;/*absorptioncoefficient*/ staticrealscat_coeff=0.0;/*scatteringcoefficient*/ staticreallas_coeff=0.0;/*linear-anisotropic*/ /*scatteringcoefficient*/ staticrealepsilon_w=1.0;/*wallemissivity*/ DEFINE_ADJUST(p1_adjust,domain) { /*Makesurethereareenoughuserdefined-scalars.*/ if(n_uds Internal_Error("notenoughuser-definedscalarsallocated"); } DEFINE_SOURCE(energy_source,c,t,dS,eqn) { dS[eqn]=-16.*abs_coeff*SIGMA_SBC*pow(C_T(c,t),3.); return-abs_coeff*(4.*SIGMA_SBC*pow(C_T(c,t),4.)-C_UDSI(c,t,P1)); } DEFINE_SOURCE(p1_source,c,t,dS,eqn) { dS[eqn]=-abs_coeff; returnabs_coeff*(4.*SIGMA_SBC*pow(C_T(c,t),4.)-C_UDSI(c,t,P1)); } DEFINE_DIFFUSIVITY(p1_diffusivity,c,t,i) { return1./(3.*abs_coeff+(3.-las_coeff)*scat_coeff); } DEFINE_PROFILE(p1_bc,thread,position) { face_tf; realA[ND_ND],At; realdG[ND_ND],dr0[ND_ND],es[ND_ND],ds,A_by_es; realaterm,alpha0,beta0,gamma0,Gsource,Ibw; realEw=epsilon_w/(2.*(2.-epsilon_w)); Thread*t0=thread->t0; /*Donothingifareasaren'tcomputedyetornotnexttofluid.*/ if(! Data_Valid_P()||! FLUID_THREAD_P(t0))return; begin_f_loop(f,thread) { cell_tc0=F_C0(f,thread); BOUNDARY_FACE_GEOMETRY(f,thread,A,ds,es,A_by_es,dr0); At=NV_MAG(A); if(NULLP(T_STORAGE_R_NV(t0,SV_UDSI_G(P1)))) Gsource=0.;/*ifgradientnotstoredyet*/ else BOUNDARY_SECONDARY_GRADIENT_SOURCE(Gsource,SV_UDSI_G(P1), dG,es,A_by_es,1.); gamma0=C_UDSI_DIFF(c0,t0,P1); alpha0=A_by_es/ds; beta0=Gsource/alpha0; aterm=alpha0*gamma0/At; Ibw=SIGMA_SBC*pow(WALL_TEMP_OUTER(f,thread),4.)/M_PI; /*Specifytheradiativeheatflux.*/ F_PROFILE(f,thread,position)= aterm*Ew/(Ew+aterm)*(4.*M_PI*Ibw-C_UDSI(c0,t0,P1)+beta0); } end_f_loop(f,thread) } DEFINE_HEAT_FLUX(heat_flux,f,t,c0,t0,cid,cir) { realEw=epsilon_w/(2.*(2.-epsilon_w)); cid[0]=Ew*F_UDSI(f,t,P1); cid[3]=4.0*Ew*SIGMA_SBC; } #defineDEFINE_ADJUST(name,domain)\ voidname(Domain*domain) #defineDEFINE_INIT(name,domain)\ voidname(Domain*domain) #defineDEFINE_ON_DEMAND(name)\ voidname(void) #defineDEFINE_RW_FILE(name,fp)\ voidname(FILE*fp) #defineDEFINE_CG_MOTION(name,dt,vel,omega,time,dtime)\ voidname(void*dt,realvel[],realomega[],realtime,realdtime) #defineDEFINE_DIFFUSIVITY(name,c,t,i) realname(cell_tc,Thread*t,inti) #defineDEFINE_GEOM(name,d,dt,position)\ voidname(Domain*d,void*dt,real*position) #defineDEFINE_GRID_MOTION(name,d,dt,time,dtime)\ voidname(Domain*d,void*dt,realtime,realdtime) #defineDEFINE_HEAT_FLUX(name,f,t,c0,t0,cid,cir)\ voidname(face_tf,Thread*t,cell_tc0,\ Thread*t0,realcid[],realcir[]) #defineDEFINE_NOX_RATE(name,c,t,NOx)\ voidname(cell_tc,Thread*t,NOx_Parameter*NOx) #defineDEFINE_PROFILE(name,t,i)\ voidname(Thread*t,inti) #defineDEFINE_PROPERTY(name,c,t)\ realname(cell_tc,Thread*t) #defineDEFINE_SCAT_PHASE_FUNC(name,c,f)\ realname(realc,real*f) #defineDEFINE_SOURCE(name,c,t,dS,i)\ realname(cell_tc,Thread*t,realdS[],inti) #defineDEFINE_SR_RATE(name,f,t,r,mw,yi,rr)\ voidname(face_tc,Thread*t,\ Reaction*r,real*mw,real*yi,real*rr) #defineDEFINE_TURB_PREMIX_SOURCE(name,c,t,turbulent_flame_speed,source)\ voidname(cell_tc,Thread*t,real*turbulent_flame_speed,real*source) #defineDEFINE_TURBULENT_VISCOSITY(name,c,t)realname(cell_tc,Thread*t) #defineDEFINE_UDS_FLUX(name,f,t,i)\ realname(face_tf,Thread*t,inti) #defineDEFINE_UDS_UNSTEADY(name,c,t,i,apu,su)\ voidname(cell_tc,Thread*t,inti,real*apu,real*su) #defineDEFINE_VR_RATE(name,c,t,r,mw,yi,rr,rr_t)\ voidname(cell_tc,Thread*t,\ Reaction*r,real*mw,real*yi,\ real*rr,real*rr_t) #defineDEFINE_CAVITATION_RATE(name,c,t,p,rhoV,rhoL,vofV,p_v,n_b,m_dot)\ voidname(cell_tc,Thread*t,real*p,real*rhoV,real*rhoL,real*vofV,\ real*p_v,real*n_b,real*m_dot) #defineDEFINE_DRIFT_DIAM(name,c,t)\ realname(cell_tc,Thread*t) #defineDEFINE_EXCHANGE_PROPERTY(name,c,mixture_thread,\ second_column_phase_index,first_column_phase_index)\ realname(cell_tc,Thread*mixture_thread,intsecond_column_phase_index,\ intfirst_column_phase_index) #defineDEFINE_VECTOR_EXCHANGE_PROPERTY(name,c,mixture_thread,\ second_column_phase_index,first_column_phase_index,vector_result)\ voidname(cell_tc,Thread*mixture_thread,intsecond_column_phase_index,\ intfirst_column_phase_index,real*vector_result) #defineDEFINE_DPM_BODY_FORCE(name,p,i)\ realname(Tracked_Particle*p,inti) #defineDEFINE_DPM_DRAG(name,Re)\ realname(realRe) #defineDEFINE_DPM_SOURCE(name,c,t,S,strength,p)\ voidname(cell_tc,Thread*t,dpms_t*S,\ realstrength,Tracked_Particle*p) #defineDEFINE_DPM_PROPERTY(name,c,t,p)\ realname(cell_tc,Thread*t,Tracked_Particle*p) #defineDEFINE_DPM_OUTPUT(name,header,fp,p,t,plane)\ voidname(intheader,FILE*fp,\ Tracked_Particle*p,Thread*t,Plane*plane) #defineDEFINE_DPM_EROSION(name,p,t,f,normal,alpha,Vmag,mdot)\ voidname(Tracked_Particle*p,Thread*t,\
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- fluentudf
![提示](https://static.bdocx.com/images/bang_tan.gif)