加载中…
个人资料
小寒
小寒
  • 博客等级:
  • 博客积分:0
  • 博客访问:403
  • 关注人气:6
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

Fluent UDF函数(转载)

(2014-09-09 16:31:19)
标签:

教育

分类: fluent

1. Data_Valid_P


You can check that the cell values of the variables that appear in your function are accessible before you compute the function by using the Data_Valid_P macro.


boolean Data_Valid_P()

Data_Valid_P is defined in the id.h header file, and is included in udf.h. The function returns 1 (true) if the data is valid, and 0 (false) if it is not.

Example


if(!Data_Valid_P())                  return;

For example, suppose you read a case file and, in the process, load a UDF. If that function performs a calculation using variables that have not yet been initialized, such as the velocity at interior cells, an error will occur. To avoid this kind of error, an if else condition can be added to your code. If ( if) the data are available, the function can be computed in the normal way. If not ( else), no (or some trivial) calculation can be performed instead. Once the flow field has been initialized, the function can be reinvoked so that the correct calculation can be performed.

2. FLUID_THREAD_P


You can use the FLUID_THREAD_P function to check whether a thread is a fluid thread. The function returns 1 (true) if the thread you specify is valid, and 0 (false) if it is not.


boolean FLUID_THREAD_P()

Example


FLUID_THREAD_P(t0)

3. NV_MAG


The utility NV_MAG computes the magnitude of a vector. This is taken as the square root of the sum of the squares of the vector components.


NV_MAG(x)

    2D:  sqrt(x[0]*x[0] + x[1]*x[1]); 
    3D:  sqrt(x[0]*x[0] + x[1]*x[1] + x[2]*x[2]);

4. NV_MAG2


The utility NV_MAG2 computes the sum of squares of vector components.


NV_MAG2(x)

    2D:  (x[0]*x[0] + x[1]*x[1]); 
    3D:  (x[0]*x[0] + x[1]*x[1] + x[2]*x[2]);

5. F_PROFILE

F_PROFILE can be used to store a boundary condition in memory for a given face and thread, and is typically nested within a face loop. See mem.h for the complete macro definition for F_PROFILE.

F_PROFILE is typically used along with DEFINE_PROFILE; the index i that is an argument to DEFINE_PROFILE is the same variable in F_PROFILE.

 

 

    
Macro: F_PROFILE( f, t, i) 
    
Argument types: face_t f 
  Thread *t 
  int i 
    
Function returns: void

 

The arguments of F_PROFILE are f, the index of the face face_t; t, a pointer to the face's thread t; and an integer i. These variables are passed by the FLUENT solver to your UDF.

i is an identifier for the variable that is being set at a particular boundary. For example, an inlet boundary may have a total pressure and a total temperature associated with it (both of which can be described by user-defined functions). One of the inlet boundary variables will be identified in FLUENT by the integer 0, and the other by the integer 1. The values of these integers are set by the solver when you define your boundary conditions using the Boundary Conditions panel in a FLUENT session.

Sample

begin_f_loop(f, t)
    {
      F_CENTROID(x,f,t);
      y = x[1];
      F_PROFILE(f, t, i) = 1.1e5 - y*y/(.0745*.0745)*0.1e5;
    }
  end_f_loop(f, t)

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有