昨天失眠,今天nba还有俩绝杀。。
所以下午才开始干活,比较难受,先看下昨晚仿真的效果,然后解决一下压力曲线的问题
今天解决了一个fluent中udf打印数据的问题
本想参考这个
https://www.cnblogs.com/liusuanyatong/p/11259603.html
结果这哥们文章留坑没写完。。。
直接上自己的代码
没啥技术含量,也是师兄那继承下的
就是12个核跑就打印12遍比较恶心,后来发现有个环境变量表示着程序所在的计算节点号码
#include "udf.h"
#define CDA_NUM 25
int msgCount = 0; // 打印消息额次数
/* 计算流量 */
DEFINE_EXECUTE_AT_END(cal_discharge)
{
Domain *domain;
Thread *thread;
face_t f;
int ID = 11;
domain = Get_Domain(1);
thread = Lookup_Thread(domain, ID);
# if !RP_NODE
{
Message("flow____cal\n");
}
#endif
begin_f_loop(f, thread)
{
F_UDMI(f, thread, 0) = F_FLUX(f, thread);
}
end_f_loop(f, thread)
}
/* 根据流量计算压力 */
DEFINE_PROFILE(p_outlet, t, i)
{
face_t f;
real density = 889.0;
real p;
real CdA = CDA_NUM * pow(10, -6);
real flow = 0.0;
real total_flow = 0.0;
begin_f_loop(f, t)
{
flow += F_UDMI(f, t,0);
}
end_f_loop(f, t)
total_flow = PRF_GRSUM1(flow);
p = (((4*total_flow/density)/CdA)*((4*total_flow/density)/CdA))*density/2;
if (p<0)
{
p = 0;
}
if (p>3500000)
{
p = 3500000;
}
// 做消息过滤
if(myid==0) // myid为环境变量,表示自己所在node号码
{
// 过滤后还是重复3次,没找到原因,这里做一个去重
if(msgCount++ == 0){
Message("flux: %f kg/s\n", total_flow);
Message("p: %f Pa\n", p);
}
if(msgCount>2){
msgCount=0;
}
}
begin_f_loop(f, t)
{
F_PROFILE(f, t, i) = p;
}
end_f_loop(f, t)
}