OF文件读写
-
#include "fvCFD.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // class proxyWriter : public regIOobject { private: scalar value_; proxyWriter(const proxyWriter&) = delete; void operator=(const proxyWriter&) = delete; public: proxyWriter(const IOobject& io, const scalar& value) : regIOobject(io), value_(value) { } virtual bool writeData(Ostream& os) const { os<<value_; return os.good(); } proxyWriter& operator++() { ++value_; return *this; } }; int main(int argc, char *argv[]) { #include "setRootCaseLists.H" #include "createTime.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // proxyWriter writer ( IOobject ( "value", runTime.timeName(), runTime, IOobject::NO_READ, IOobject::AUTO_WRITE ), 0. ); Info<< "\nStarting time loop\n" << endl; while (runTime.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; ++writer; runTime.write(); runTime.printExecutionTime(Info); } Info<< "End\n" << endl; return 0; } :chigua:
-
您好,我目前对 源程序 添加了读写IOobject代码,但编译存在一定问题,您可以指点一下吗?谢谢,帖子如下:
http://www.cfd-china.com/topic/3329/湍流模型里面如何输出动态系数/2 -
#include "fvCFD.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // class proxyWriter : public regIOobject { private: scalar value_; proxyWriter(const proxyWriter&) = delete; void operator=(const proxyWriter&) = delete; public: proxyWriter(const IOobject& io, const scalar& value) : regIOobject(io), value_(value) { } virtual bool writeData(Ostream& os) const { os<<value_; return os.good(); } proxyWriter& operator++() { ++value_; return *this; } }; int main(int argc, char *argv[]) { #include "setRootCaseLists.H" #include "createTime.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // proxyWriter writer ( IOobject ( "value", runTime.timeName(), runTime, IOobject::NO_READ, IOobject::AUTO_WRITE ), 0. ); Info<< "\nStarting time loop\n" << endl; while (runTime.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; ++writer; runTime.write(); runTime.printExecutionTime(Info); } Info<< "End\n" << endl; return 0; } :chigua:
@马乔 @Samuel-Tu 请问这个怎么用?这是重新编译一个lib然后link到controlDict吗?那怎么知道是在这一步的什么时候输出?是计算前还是计算后?