动量方程有浮力和表面张力流。浮力流作为源项,表面张力用边界条件udf编入。还有个求解浓度方程uds~~和一个浓度边界条件~编了以下udf,求高手帮我看看下面一个UDF错了没?编译什么的没问题。但是在导入fluent后计算时无法初始化~~CODE: #include "udf.h"
DEFINE_UDS_UNSTEADY(MyUnsteady,c,thread,i,apu,su)
{
real physical_dt, vol, phi_old;
physical_dt = RP_Get_Real("physical-time-step");
vol = C_VOLUME(c,thread);
*apu = -vol / physical_dt; /*implicit part*/
phi_old = C_STORAGE_R(c,thread,SV_UDSI_M1(i));
*su = vol*phi_old/physical_dt; /*explicit part*/
}
DEFINE_UDS_FLUX(MyFlux,f,thread,i)
{
real NV_VEC(unit_vec), NV_VEC(A); //声明矢量变量
F_AREA(A, f, thread);
NV_DS(unit_vec, =, 1, 1, 1, *, 1); //单位矢量赋值
return NV_DOT(unit_vec, A); //矢量点积
}
DEFINE_DIFFUSIVITY(MyDiff,c,thread,i)
{
return 1.6667e-3;
}
DEFINE_SOURCE(uds_source,c,thread,dS,eqn)
{
dS[eqn]=0.0;
return 0.0;
}
DEFINE_PROFILE(density,thread,position)
{
real x[ND_ND];
real y,t,d;
cell_t c;
begin_c_loop(c,thread)
{
C_CENTROID(x,c,thread);
y=2*x[1];
t=RP_Get_Real("physical-time-step");
d=C_YI(c,thread,1);
C_PROFILE(c,thread,position)=(d*9.0*10E-8)/(y-10E-7*t);
}
end_c_loop(c,thread)
}
DEFINE_PROFILE(xshear_stress,thread,position)
{
face_t f;
cell_t c;
Thread *tc;
begin_f_loop(f,thread)
{
c=F_C0(f,thread);
tc=THREAD_T0(thread);
F_PROFILE(f,thread,position)=-10.0*C_UDMI(c,tc,0);
}
end_f_loop(f,thread)
}
DEFINE_PROFILE(yshear_stress,thread,position)
{
face_t f;
cell_t c;
Thread *tc;
begin_f_loop(f,thread)
{
c=F_C0(f,thread);
tc=THREAD_T0(thread);
F_PROFILE(f,thread,position)=-10.0*C_UDMI(c,tc,1);
}
end_f_loop(f,thread)
}
DEFINE_SOURCE(ymomentum_source,c,thread,dS,eqn)
{
real source,tem;
C_UDMI(c,thread,0)=C_T_G(c,thread)[0];
C_UDMI(c,thread,1)=C_T_G(c,thread)[1];
tem=C_T(c,thread);
source=-0.4*tem;
dS[eqn]=0.0;
return source;
}
初始化时产生这样的错误~~~
Error:
FLUENT received fatal signal (ACCESS_VIOLATION)
1. Note exact events leading to error.
2. Save case/data under new name.
3. Exit program and restart to continue.
4. Report error to your distributor.
Error Object: ()
[ Last edited by xiegangmai on 2012-3-16 at 20:28 ]