|
楼主 |
发表于 2011-5-31 00:10:52
|
显示全部楼层
我做螺旋桨模拟, 非定常, 不过一次write moment 只能出一个文件,我想一次性输出所有气动数据, 刚刚看了udf 的几个例题 觉得不是太难, 所以就上传问题问了一下。 呵呵,前面的问题已经解决了, 现在把自己写的udf 奉上, 可是新的问题出现了,希望前辈们不吝赐教:
/********************************************************************
UDF for integrating pressure forces and displaying it in the
console
*********************************************************************/
#include "udf.h"
#include "metric.h"
#include "mem.h"
#define airfoil_tid 15 /* Zone ID of airfoil */
#define domain_zone 1
float P_i;
float A_i;
float U_i;
float V_i;
float W_i;
float Fpx;
float Fpy;
float Fp[ND_ND];/* for pressure force storing*/
float A[ND_ND]; /*for airfoil element area storing*/
float C[ND_ND]; /*for cell center data storing*/
int i;
float a; /*a = d2u/dx2,*/
/*float b; /*b = d3v/dxdy*/
/*float c; /* c = d2u/dy2*/
float mu_t;
float tx;/*shear stress in x dirction*/
Domain *domain;
face_t f; /* airfoil surface*/
cell_t c;
Thread *t;/* wing thread*/
domain = Get_Domain(domain_zone);
t = Lookup_Thread(domain, airfoil_tid); /×这个thread指向是翼型表面×/
DEFINE_ADJUST(forces,domain)
{
Fpx=0;
Fpy=0;
begin_f_loop(f,t)
{
F_AREA(A,f,t);
P_i = F_P(f,t);
Fpx += P_i*A[0]; /× pressure in x direction*/
Fpy += P_i*A[1]; /×pressure force in y direction*/
}
end_f_loop(f,t)
thread_loop_c(t,domain)
{
/*t = Thread */
/* mu_t = C_MU_T(c,t);*/
begin_c_loop(c,t)
{
/* C_CENTROID(C,c,t);*/
C_UDSI(c,t,0) = C_DUDX(c,t);/*d2u/dx2*/ 这是问题所在了, 怎么试 就是在这个环节出的问题, 这是想求二阶导数,问题就出现在这, 希望前辈看看, 指点指点
/* a = C_UDSI_G(c,t,0)[0]*mu_t; */
/* b = C_UDSI(c,t,0) = C_DVDY(c,t);/*d2v/dxdy*/
/* C_UDSI(c,t,0) = C_DWDZ(c,t);/*d2w/dz2*/
/* c = C_UDSI(c,t,1) = C_DUDY(c,t);/*d2u/dy2*/
/* C_UDSI(c,t,2) = C_DUDZ(c,t);/*d2u/dz2*/
/*tx = a*mu_t;/*((1./3.)*mu_t*(4*a+b))+mu_t(c);*/
}
end_c_loop(c,t)
}
Message("Fpx = %f, Fpy = %f,%d,%f\n", Fpx,Fpy,ND_ND,a);/*use Message for compile method */
/* printf("forces2 are: %f,%f\n", Fp[0],Fp[1]); /* use printf for interpreted method */
}
我把case 文件也附上, 是个弯板问题
[ 本帖最后由 chenzhaolin 于 2011-5-30 16:29 编辑 ] |
|