找回密码
 注册
Simdroid-非首页
查看: 28|回复: 0

[求助]關於在方程是後面加二階導數源項問題

[复制链接]
发表于 2015-1-27 15:29:29 | 显示全部楼层 |阅读模式 来自 台湾
本帖最后由 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

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Simapps系列直播

Archiver|小黑屋|联系我们|仿真互动网 ( 京ICP备15048925号-7 )

GMT+8, 2024-10-1 15:17 , Processed in 0.027071 second(s), 11 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表