找回密码
 注册
查看: 8076|回复: 11

【求助】一个define_source的问题(源项程序已贴出)

[复制链接]
发表于 2010-3-14 13:52:11 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

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

x
添加源项是出现错误,错误信息以及源项程序如下,请大家帮忙!
源项代码编译通过,但一执行迭代就出错,一步迭代都不能进行,错误信息如下:
here is the error signal:

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: ()
编译通过的信息:
the udfs are compiled and loaded successfully as:
xforce.c
yforce.c
zforce.c
uds.c
Generating Code...
# Generating udf_names.c because of makefile xforce.obj yforce.obj zforce.obj uds.obj
udf_names.c
# Linking libudf.dll because of makefile user_nt.udf udf_names.obj xforce.obj yforce.obj zforce.obj uds.obj
Microsoft (R) Incremental Linker Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
Creating library libudf.lib and object libudf.exp
Done.
"E:/hyc/hyc/RE1000"
Opening library "E:\hyc\hyc\RE1000\libudf"...
Library "E:\hyc\hyc\RE1000\libudf\ntx86\3d\libudf.dll" opened
xforce_source
yforce_source
zforce_source
uds_source
Done.

这是我source的udf,定义一个动量方程的附加体积力,这是x方向的,y和z方向的结构一样:
#include"udf.h"
#include"mem.h"
#include"metric.h"
DEFINE_SOURCE(xforce_source,c,t,dS,eqn)
{
real dens;
real u;
real v;
real w;
real ux;
real uy;
real uz;
real cp;
real A;
real con;
real tx;
real tgx;
real source;
real x[ND_ND];
real ur;
real sc;
real sp;
C_CENTROID(x,c,t);
dens=C_R(c,t);
u=C_U(c,t);
v=C_V(c,t);
w=C_W(c,t);
ux=C_DUDX(c,t);
uy=C_DUDY(c,t);
uz=C_DUDZ(c,t);
A=C_UDSI(c,t,0);
tx=C_T_G(c,t)[0];
con=-0.02;
ur=v*uy+u*uz;
sc=dens*ur+con*A*tx;
sp=dens*ux;
source=sp*u+sc;
dS[eqn]=sp;
return source;
}

用了solve/set/expert,还是不行,诸位高手帮帮忙吧!
发表于 2010-3-15 09:55:51 | 显示全部楼层
你何必搞那么繁琐呢。
#include <udf.h>
DEFINE_SOURCE(x_source,c, t,dS,eqn)
{
real source;
real con=-0.02;
source=CON*C_UDSI(c,t,0)*C_T_RG(c,t)[0]+C_R(c,t)*(C_U(c,t)*C_DUDX(c,t)+C_V(c,t)*C_DUDY(c,t)+C_W(c,t)*C_DUDZ(c,t));
dS[eqn]=0.0;
return source;
}
 楼主| 发表于 2010-3-15 14:11:43 | 显示全部楼层
我现在就是那么写的,还是出错。也用了solve/set/expert。
似乎是温度梯度那一项的问题,把那一项删去,可迭代十几次,然后出错divergence detected in AMG solver: temperature
不知是为什么?
 楼主| 发表于 2010-3-15 15:02:22 | 显示全部楼层
似乎是温度超出限定范围了
出错信息为:
Error: divergence detected in AMG solver: temperature
Error Object: ()
reversed flow in 431 faces on outflow 3.
temperature limited to 1.000000e+000 in 169156 cells on zone 2 in domain 1
  temperature limited to 5.000000e+003 in 75008 cells on zone 2 in domain 1
发表于 2010-3-16 10:51:40 | 显示全部楼层
应该先只解能量方程,算几步以后再把flow和uds选上。
因为能量方程里面没有uds,求解不会出错。
刚上来直接求解flow和uds,因为它的源项里面有uds,而其初值都是全场均匀的,所以在计算梯度项就会出错。
 楼主| 发表于 2010-3-16 11:04:31 | 显示全部楼层
我是先添加uds后迭代了十次,然后代入源项,源项除了三个动量方程有之外,uds也有一个源项,共四个。源项是一个虚拟的附加体积力,代入源项的目的是优化流场。
请问swim兄:如何先解除能量方程呢?
发表于 2010-3-16 11:05:55 | 显示全部楼层
在control-solution里面左侧菜单里选择,先选energy,算几步以后把flow,energy和uds都选上
 楼主| 发表于 2010-3-16 11:09:40 | 显示全部楼层
谢谢swim兄,马上实践
 楼主| 发表于 2010-3-16 11:35:14 | 显示全部楼层
我先将源项代入,然后算energy,迭代两百次,然后算添加源项的flow和uds方程,结果无法计算,直接出现:ACCESS_VIOLATION错误
 楼主| 发表于 2010-3-18 10:21:46 | 显示全部楼层
解不出来,高手们帮忙!
发表于 2010-4-30 00:06:55 | 显示全部楼层

回复 1# calmdown911 的帖子

tx=C_T_G(c,t)[0];

这个宏的使用条件看帮助文件!
发表于 2012-3-11 21:23:46 | 显示全部楼层
我的也是,请高人指点下
#include"udf.h"

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_T_G(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_T_G(c,tc)[1];
}
end_f_loop(f,thread)

}

DEFINE_SOURCE(uds_source,c,thread,dS,eqn)
{
  real source,tem,x[ND_ND];
  
  C_CENTROID(x,c,thread);
  if(x[1]==1)
  {tem=C_T(c,thread);                                         
  source=-0.4*tem;
  dS[eqn]=0.0;
}
  else
  source=0.0;
  return  source;
}
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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