找回密码
 注册
查看: 1901|回复: 1

求助:加载UDF迭代出错

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

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

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

x
#include "udf.h"
#include "dynamesh_tools.h"
#include "math.h"
#define E 0.001      /* steady error of the velocity */
#define DIA 0.125   /* initial diameter of the nozzle */
#define DIA_MIN 0.115
#define DIA_MAX 0.130   
real a[6],b[10];     /* the values of diameter */
real v1=0;    /* record the average velocity inlet in present time */
real v11=0;   /* record the average velocity inlet in previous time */
real v2=0;    /* record the average velocity outlet in present time*/
real v22=0;   /* record the average velocity outlet in previous time */
real thrust=0;
real Tmax=0;
real Tmax1=0;
real y,z;
real theta;
int i=0;

/* Calculate the step of the loop */
void main()
{
real step;

/* Complete the assignment of the nozzle;
the forward assigns to array a and the reverse assigns to array b */
step=(DIA_MAX-DIA_MIN)/15;
for(i=0; i<6; i++)
{
a= DIA + step*i;
}
for(i=0; i<10; i++)
{
b= DIA - step*(i+1);
}
}

/* Calculate the average velocity of before and after section */
DEFINE_PROFILE(x_velocity,thread,i)
{
  Thread *t;
  face_t f;
  int ID1=8;
  int ID2=15;
  Domain *domain = Get_Domain (1);
  Thread *tf1 = Lookup_Thread (domain, ID1);
  Thread *tf2 = Lookup_Thread (domain, ID2);
     
  begin_f_loop(f,t)
  {          
    v1=-F_U(f,t);          
  }      
  end_f_loop(f,t)

  begin_f_loop(f,t)
  {
    v2=F_U(f,t);          
  }
  end_f_loop(f,t)
}

DEFINE_GRID_MOTION(outlet,domain,dt,time,dtime)
{
  Thread *t;   
  face_t f;
  Thread *tf=DT_THREAD((Dynamic_Thread *)dt);
  int n;
  Node *p;
  theta=atan2(y,z);
  y=DIA*cos(theta);
  z=DIA*sin(theta);
/* Activate the deforming flag on adjacent cell zone */
  SET_DEFORMING_THREAD_FLAG(THREAD_T0(tf));
               
/* Check convergence and calculate thrust */
  if (fabs(v1-v11)<E && fabs(v2-v22)<E)
  {
        thrust = F_R(f,t)*M_PI*a*a*v1/4*(v2-v1);
        Tmax1 = thrust;
/* Grid distortion */
        i=i+1;
    Tmax = thrust;
        if ((Tmax-Tmax1)>0)
        {
/* Loop over the deforming boundary zone's faces;
inner loop loops over all nodes of a given face; */
     begin_f_loop(f,tf)
         {
       f_node_loop(f,tf,n)
                {
         p=F_NODE(f,tf,n);
/* Update the current node only if it has not been previously visited to
avoid to visit the same nodes multiple times */
              if(NODE_POS_NEED_UPDATE(p))
                  {
/* Set flag to indicate that the current node's position has been updated,
so that it will not be updated during a future pass through the loop */
                NODE_Y(p)=a*cos(theta);
                    NODE_Z(p)=a*sin(theta);
            NODE_POS_UPDATED(p);
                  }
                }
         }
      end_f_loop(f,tf);
        }
        else
        {
     begin_f_loop(f,tf)
         {
       f_node_loop(f,tf,n)
                {
         p=F_NODE(f,tf,n);
              if(NODE_POS_NEED_UPDATE(p))
                  {
                     NODE_Y(p)=b*cos(theta);
                    NODE_Z(p)=b*sin(theta);
                    NODE_POS_UPDATED(p);
                  }
                }
         }
      end_f_loop(f,tf);
        }
         v11=v1;
         v22=v2;
         Tmax1=Tmax;
     printf("%f",Tmax1);
   }
}
我做的是一个泵喷口改变直径问题,加载UDF到FLUENT迭代出错,
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: ()
不知道是程序问题还是其他问题呢,求指点
 楼主| 发表于 2012-12-4 10:29:42 | 显示全部楼层
急用,有偿劳动啊,求解答
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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