找回密码
 注册
查看: 1551|回复: 5

udf能否在耦合求解中使用?

[复制链接]
发表于 2006-4-13 12:27:22 | 显示全部楼层 |阅读模式

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

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

x
我的udf很简单,就是记录一个动点每一步的压力变化,原来我选择分离求解器时没有任何问题,但选用耦合求解器后,计算完一步后出错,并且没有把我的结果记录下来,希望高手指点。
/* This program is to output the pressure of face. */
#include "udf.h"
#define v1 69.44
#define p1  9  /*Zone ID  that can be found in define boundary condition in Fluent*/


real FC[3];/*存放face的质心坐标*/
FILE *fp;

DEFINE_EXECUTE_AT_END(output_pre)
{  
int num_steps;
real curr_time;
real tolerance;
real dis;
real flow_t;
real FP[5];/*存放face质心的压力*/
real point1[3]={-55.95,-1.6,2.15}; /*输出结果点的初始坐标*/


face_t f;
cell_t c;
Thread *t,tf;
Domain *d;
d=Get_Domain(1);
fp=fopen("suidao52-500-1-1m.txt","a");

   num_steps=N_TIME;
   if (num_steps==1)
     {
       fprintf(fp,"%15s%15s%15s%15s%15s%15s\n","num_steps","flow_time","pre_p1");
      
     }
   
   curr_time=CURRENT_TIME;
   flow_t=RP_Get_Real("flow-time");
   fprintf(fp,"%15d",num_steps);
   fprintf(fp,"%15.4f",flow_t);
   point1[0]=point1[0]+v1*curr_time;
  

  
  /*判断第一点*/
   t=Lookup_Thread(d, p1); /*找到指定区域的thread,根据点所在的位置指定尽量小的区域*/
   tolerance=1;
   begin_f_loop(f,t)
     {F_CENTROID(FC,f,t);
          dis=sqrt((FC[0]-point1[0])*(FC[0]-point1[0])+(FC[1]-point1[1])*(FC[1]-point1[1])+(FC[2]-point1[2])*(FC[2]-point1[2]));
          if(dis<tolerance)
           {
            tolerance=dis;
            FP[1]=F_P(f,t);
/*         fprintf(fp,"x1=%-12.4f y1=%-12.4f z1=%-12.4f\n",FC[0],FC[1],FC[2]); */
           }
      }
   end_f_loop(f,t)
   

fprintf(fp,"%15.4f\n",FP[1]);

fclose(fp);
}
发表于 2006-4-13 20:31:42 | 显示全部楼层

udf能否在耦合求解中使用?

point1[0]=point1[0]+v1*curr_time;

考虑考虑,是不是有错!!!
另外:
  curr_time=CURRENT_TIME;
  flow_t=RP_Get_Real("flow-time");
此两句一个意思!!
 楼主| 发表于 2006-4-13 22:35:09 | 显示全部楼层

udf能否在耦合求解中使用?

这句话应该没错啊,因为这个点是随物体沿x轴方向以V1的速度运动,下一步的坐标point1[0]就等于原来的坐标加上运动的距离(速度乘以时间),其它语句应该是没问题,因为我一个一个的试过了,就是  FP[1]=F_P(f,t); 有问题,因为只要把这个语句去掉就可以,我查了fluent的帮助,说到了F_P(f,t)不能在耦合求解中使用;
5.4 Face Variables
The macros listed in Table  5.4.1- 5.4.2 can be used to return real face variables in SI units. Note that these variables are available only in the segregated solver.
但5.3中讲到
5.3 Cell Variables
Dependent cell data that are stored in a FLUENT solver can be accessed using macros listed in this section. The macros can be used to return real variables in SI units. The cell variables are available in both the segregated and the coupled solvers.
也就是说关于cell的命令在耦合求解中是可以使用的,因此我根据上述命令改成如下:
begin_c_loop(c,t)
     {C_CENTROID(FC,c,t);
          dis=sqrt((FC[0]-point1[0])*(FC[0]-point1[0])+(FC[1]-point1[1])*(FC[1]-point1[1])+(FC[2]-point1[2])*(FC[2]-point1[2]));
          if(dis<tolerance)
           {
            tolerance=dis;
            FP[1]=C_P(c,t);
            }
      }
   end_c_loop(c,t)
但还是不行,希望高手指点。
 楼主| 发表于 2006-4-16 09:57:01 | 显示全部楼层

udf能否在耦合求解中使用?

其他的兄弟们有没有遇到过啊
发表于 2006-4-16 13:48:06 | 显示全部楼层

udf能否在耦合求解中使用?

CURRENT_TIME 是 流动时间吧,不是时间步长阿!
第一步:
point1[0]=point1[0]+v1*curr_time;
第二步:
point1[0]=point1[0]+v1*curr_time;
         =(point1[0]+v1*curr_time)+v1*curr_time
         =point1[0]+ v1*curr_time*2.
莫非我理解有误!?我再看看!
你每步显示一下point1[0].察看一下结果

 楼主| 发表于 2006-4-17 15:05:44 | 显示全部楼层

udf能否在耦合求解中使用?

每一步都有这个语句real point1[3]={-55.95,-1.6,2.15}; /*输出结果点的初始坐标*/,是不是fluent每执行一步都要对坐标初始化呢,因为我发现输出坐标都是对的,每一步都是point1[0]=point1[0]+v1*curr_time。关键是FP[1]=C_P(c,t);只要这个语句去掉就可以。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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