LoginSignup
1
2

More than 5 years have passed since last update.

OpenFOAMにおけるファイル・ディレクトリの操作

Last updated at Posted at 2016-11-03

ファイル操作関数の定義場所

OpenFOAMでは、ファイル操作関連の関数はOSspecific.HおよびPOSIX.Cで定義されています。
OpenFOAM C++ Documentation: OSspecific.H
OpenFOAM C++ Documentation: POSIX.C

例えば
- home()
- cwd()
- exists(const fileName&, const bool)
- isDir(const fileName&)
- isFile(const fileName&, const bool)
などが定義されています。

使用例

例えば、あるGeometricFieldの初期化において、そのフィールドに対応するファイルが時間ディレクトリ内に存在する場合にファイルを読み取って初期化するするには

if (isFile(runTime.timePath()/"sigma"))
{
    sigmaPtr_.set
    (
        new volSymmTensorField
        (
            IOobject
            (
                "sigma",
                runTime.timeName(),
                mesh,
                IOobject::MUST_READ,
                IOobject::AUTO_WRITE
            ),
            mesh
        )
    );
}
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2