- 积分
- 0
- 注册时间
- 2010-12-11
- 仿真币
-
- 最后登录
- 1970-1-1
|
本帖最后由 m9907622 于 2015-1-27 15:40 编辑
我想做的是在我自己寫的uds加上二階溫度源項(d2T/dx2+d2T/dy2),在能量方程式加上uds的二階源項(d2T/dx2+d2T/dy2)
如图所示
#include "udf.h"
#include "storage.h"
#include "sg.h"
#define Ra 100000
#define Pr 11.573
#define N 1.0
#define Df 0.5
#define Sr 0.5
#define R 0.5
DEFINE_SOURCE(ymom_s1,c,t,dS,eqn)
{
real con, source;
con = Ra/Pr;
source = con*pow((C_T(c,t)-R),2);
dS[eqn] = con;
return source;
}
DEFINE_SOURCE(ymom_s2,c,t,dS,eqn)
{
real con, source;
con = Ra/Pr*N;
source = -con*C_UDSI(c,t,0);
dS[eqn] = -con;
return source;
}
DEFINE_ADJUST(adjust_UDSIs,d)
{
real x[ND_ND],grad_T[ND_ND], grad_C[ND_ND];
Thread *t;
cell_t c;
if (! Data_Valid_P())
return;
Alloc_Storage_Vars(d,SV_UDSI_RG(0),SV_UDSI_G(0),SV_NULL);
Scalar_Reconstruction(d, SV_UDS_I(0), -1, SV_UDSI_RG(0), NULL);
Scalar_Derivatives(d, SV_UDS_I(0), -1, SV_UDSI_G(0), SV_UDSI_RG(0), UDS_Deriv_Accumulate);
thread_loop_c(t,d)
{
if (FLUID_THREAD_P(t))
{
begin_c_loop_int(c,t)
{
C_CENTROID(x,c,t);
NV_V(grad_T, =,C_T_G(c,t));
NV_V(grad_C, =,C_UDSI_G(c,t,0));
C_UDSI(c,t,1)=grad_T[0];
C_UDSI(c,t,2)=grad_T[1];
C_UDSI(c,t,3)=grad_C[0];
C_UDSI(c,t,4)=grad_C[1];
}
end_c_loop_int(c,t)
}
}
Free_Storage_Vars(d,SV_UDSI_RG(0),SV_UDSI_G(0),SV_NULL);
Alloc_Storage_Vars(d,SV_UDSI_RG(1),SV_UDSI_G(1),SV_NULL);
Scalar_Reconstruction(d, SV_UDS_I(1), -1, SV_UDSI_RG(1), NULL);
Scalar_Derivatives(d, SV_UDS_I(1), -1, SV_UDSI_G(1), SV_UDSI_RG(1), UDS_Deriv_Accumulate);
Alloc_Storage_Vars(d,SV_UDSI_RG(2),SV_UDSI_G(2),SV_NULL);
Scalar_Reconstruction(d, SV_UDS_I(2), -1, SV_UDSI_RG(2), NULL);
Scalar_Derivatives(d, SV_UDS_I(2), -1, SV_UDSI_G(2), SV_UDSI_RG(2), UDS_Deriv_Accumulate);
Alloc_Storage_Vars(d,SV_UDSI_RG(3),SV_UDSI_G(3),SV_NULL);
Scalar_Reconstruction(d, SV_UDS_I(3), -1, SV_UDSI_RG(3), NULL);
Scalar_Derivatives(d, SV_UDS_I(3), -1, SV_UDSI_G(3), SV_UDSI_RG(3), UDS_Deriv_Accumulate);
Alloc_Storage_Vars(d,SV_UDSI_RG(4),SV_UDSI_G(4),SV_NULL);
Scalar_Reconstruction(d, SV_UDS_I(4), -1, SV_UDSI_RG(4), NULL);
Scalar_Derivatives(d, SV_UDS_I(4), -1, SV_UDSI_G(4), SV_UDSI_RG(4), UDS_Deriv_Accumulate);
thread_loop_c(t,d)
{
if (FLUID_THREAD_P(t))
{
begin_c_loop_all(c,t)
{
C_UDMI(c,t,0) = C_UDSI_G(c,t,3)[0];
C_UDMI(c,t,1) = C_UDSI_G(c,t,4)[1];
C_UDMI(c,t,2) = C_UDSI_G(c,t,1)[0];
C_UDMI(c,t,3) = C_UDSI_G(c,t,2)[1];
}
end_c_loop_all(c,t)
}
}
Free_Storage_Vars(d,SV_UDSI_RG(1),SV_UDSI_G(1),SV_NULL);
Free_Storage_Vars(d,SV_UDSI_RG(2),SV_UDSI_G(2),SV_NULL);
Free_Storage_Vars(d,SV_UDSI_RG(3),SV_UDSI_G(3),SV_NULL);
Free_Storage_Vars(d,SV_UDSI_RG(4),SV_UDSI_G(4),SV_NULL);
}
DEFINE_SOURCE(energy_Df,c,t,dS,eqn)
{
real x[ND_ND];
real con, source;
C_CENTROID(x,c,t);
con = Df;
source = con*(C_UDMI(c,t,0)+C_UDMI(c,t,1));
dS[eqn] = 0.0;
return source;
}
DEFINE_SOURCE(species_Sr,c,t,dS,eqn)
{
real x[ND_ND];
real con, source;
C_CENTROID(x,c,t);
con= Sr;
source = con*(C_UDMI(c,t,2)+C_UDMI(c,t,3));
dS[eqn] = 0.0;
return source;
}
上面是我的UDF执行就会出错,不知问题在哪?
请求各位高手,拜托
来自群组: fluent |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
×
|