【发布时间】:2018-05-14 10:38:35
【问题描述】:
我开发了一个 CFD 仿真模型,该模型主要在一个循环中运行。
有一些数据需要在每个时间步输出,例如线性代数求解器中的收敛和迭代。
执行此操作的最佳做法是什么?目前我有:
for(int tstep=0;tstep<maxTstep;++tstep)
{
<code>
outFile<<"data"<<endl;
{
在每个循环结束时将一行写入多个文件。这样做是否更好:
for(int tstep=0;tstep<maxTstep;++tstep)
{
<code>
outputVector.push_back("data");
}
for(int i=0;i<outputVector.size();++i) outFile<<outputVector[i]<<endl;
将输出数据添加到向量中,然后一次性写入文件?
【问题讨论】: