Fluent 串行UDF改并行UDF? 100
串行可以计算,但是按照网上和帮助上改成并行的,结果并行计算和串行结果不一样(可以肯定并行计算错了),实在没搞明白host和node该怎么设,有没有大神指导一下改怎么改啊?UDF是求取特定体积的,涉及了循环,初步猜测是不同node的值没有汇总,导致结果中时间列是对的,变量列是错的....
#include "udf.h"
DEFINE_EXECUTE_AT_END(execute_at_end)
{
FILE *fp;
fp = fopen("vf.txt", "a");
real volume = 0.0;
real mass_fraction = 0.0;
real v = 0.0;
real vf = 0.0;
real flow_time = RP_Get_Real("flow-time");
int cold_index = 0;
#if !RP_HOST
Domain * d;
Thread * tc;
cell_t c;
d = Get_Domain(1);
#endif
#if !RP_HOST
thread_loop_c(tc, d)
{
begin_c_loop_int(c, tc)
{
mass_fraction = C_YI(c, tc, cold_index);
if (mass_fraction>0.13253545)
{
volume = C_VOLUME(c, tc);
v += volume;
}
}
vf = v * 100 / 0.01720534;
end_c_loop_int(c, tc)
}
#endif
#if !RP_HOST
fprintf(fp, "%f, %f \n", flow_time, vf);
fclose(fp);
#endif
}