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
}




















