CODE:
/********************************************************************
UDF for integrating turbulent dissipation and printing it to
console window at the end of the current iteration or time step
*********************************************************************/
#include "udf.h"
#include "math.h"
#include "mem.h"
#include "global.h"
FILE *fp;
FILE *fp1;
DEFINE_EXECUTE_AT_END(pressure)
{
Domain *d;
d=Get_Domain(1);
fp=fopen("dp_body.txt","a");
real FC[ND_ND];
real x_body1,y_body1,p_body1;
cell_t c;
Thread *ft=Lookup_Thread(d,9);
Thread *ft1=Lookup_Thread(d,10);
thread_loop_c(ft,d)
{
//loop over all cells//
begin_c_loop(c,ft)
{
C_P(c,ft);//get the pressure//
C_CENTROID(FC,c,ft);
// 输出x坐标和压力值
x_body1=FC[0];
y_body1=FC[1];
p_body1=C_P(c,ft);
}
end_c_loop(c,ft)
}
}
fprintf(fp," x= %-8.5f y= %-8.5f dp=%-12.5f\n ",x_body1,y_body1,dp); //输入到文本里。
Message(" x= %-8.5f dp=%-12.5f\n ",x_body1,dp); //直接输出到fluent运行界面
fclose(fp);
}