我想将我的边界层剪切力修改为t=d2u/dx2,u为边界层上一点的速度,x为切向方向。就是将剪切力设定为速度在切向方向的二阶导但是在直接使用C_UDSI_G这个宏的时候会出现segmentation fault。下面是我的代码:
# include "udf.h"
# define domain_ID 2
DEFINE_ADJUST(adjust_gradient, domain)
{
Thread *t;
cell_t c;
face_t f;
domain = Get_Domain(domain_ID);
/* Fill UDS with the variable. */
thread_loop_c(t,domain)
begin_c_loop (c,t)
{
C_UDSI(c,t,0) = C_DUDX(c,t);
}
end_c_loop (c,t)
}
DEFINE_ON_DEMAND(store_gradient)
{
Domain *domain;
face_t f;
cell_t c;
Thread *t;
domain=Get_Domain(1);
/* Fill the UDM with magnitude of gradient. */
thread_loop_c(t,domain)
begin_c_loop (c,t)
{
C_UDMI(c,t,0) = C_UDSI_G(c,t,0)[0];
}
end_c_loop (c,t)
}
DEFINE_PROFILE(shear_stressx, t,position)
{
face_t f;
cell_t c0;
real xw[ND_ND],xc[ND_ND],taux;
real a = 0.00012;
Thread *t0= t->t0;
begin_f_loop(f,t)
{
c0= F_C0(f,t);
F_CENTROID(xw,f,t);
C_CENTROID(xc,c0,t0);
taux=-a*C_UDMI(c0,t0,0);
F_PROFILE(f,t,position) = taux;
}
end_f_loop(f,t)
}
在execute on demand 的时候就会出现SEGMENTATION 错误,但是如果将C_UDMI(c,t,0) = C_UDSI_G(c,t,0)[0];改成C_UDMI(c,t,0) =NV_MAG(C_UDSI_G(c,t,0))算的话,又会使剪切力直接为零,球球各位大佬帮帮忙,感激不尽。 |