主题:[原创]求助连续读写数据
DEFINE_ADJUST(Gradient_Adjust,domain)
{
real qh;
cell_t c;
Thread *t;
real time;
FILE *fp;
time=RP_Get_Real("flow-time");
if (!Data_Valid_P())
return;
thread_loop_c (t, domain)
{
if (FLUID_THREAD_P(t))
{
begin_c_loop(c, t)
{
real x[ND_ND];
C_CENTROID(x,c,t);
if (0.315<=x[0]&&x[0]<=0.32&&1<=x[1]&&x[1]<=1.005) qh=-lambda_1*C_UDSI_G(c,t,Temp)[0];
else;
}
end_c_loop(c, t)
fp=fopen("E:\\fluentwork\\data.txt","w+");
fprintf(fp,"%.0f\t %.2f\n",time,qh);
fclose(fp);
}
}
}
求助我想把数据都写在文本中,为什么数据都被覆盖了,我想每隔3600s写一个数据
格式应该是
time1 qh1
time2 qh2
time3 qh3
time4 qh4
. .
. .
. .
但是上面的程序都覆盖了 只保留了第一行,怎么办呢?
请高手帮忙啊!
{
real qh;
cell_t c;
Thread *t;
real time;
FILE *fp;
time=RP_Get_Real("flow-time");
if (!Data_Valid_P())
return;
thread_loop_c (t, domain)
{
if (FLUID_THREAD_P(t))
{
begin_c_loop(c, t)
{
real x[ND_ND];
C_CENTROID(x,c,t);
if (0.315<=x[0]&&x[0]<=0.32&&1<=x[1]&&x[1]<=1.005) qh=-lambda_1*C_UDSI_G(c,t,Temp)[0];
else;
}
end_c_loop(c, t)
fp=fopen("E:\\fluentwork\\data.txt","w+");
fprintf(fp,"%.0f\t %.2f\n",time,qh);
fclose(fp);
}
}
}
求助我想把数据都写在文本中,为什么数据都被覆盖了,我想每隔3600s写一个数据
格式应该是
time1 qh1
time2 qh2
time3 qh3
time4 qh4
. .
. .
. .
但是上面的程序都覆盖了 只保留了第一行,怎么办呢?
请高手帮忙啊!