OpenFOAM 4.1 を CentOS 6.5 にインストールメモ

2020年4月26日

はじめに

OpenFOAM 4.1 をソースコードからコンパイルする。

インストール対象マシン

CentOS 6.5 (x86_64)

パッケージの準備

パッケージを こちら からダウンロードする。

$ tar xvzf OpenFOAM-4.x-version-4.1.tar.gz -C ~/OpenFOAM
$ tar xvzf ThirdParty-4.x-version-4.1.tar.gz -C ~/OpenFOAM
$ cd ~/OpenFOAM
$ mv OpenFOAM-4.x-version-4.1 OpenFOAM/OpenFOAM-4.1
$ mv ThirdParty-4.x-version-4.1 OpenFOAM/ThirdParty-4.1

~/.bashrc に以下を追加。

. ~/OpenFOAM/OpenFOAM-4.1/etc/bashrc

端末を再起動する。"foam" と打って $WM_PROJECT_DIR (OpenFOAM のディレクトリ) に移動できれば OK。

コンパイル

必要なパッケージを入れる。

# yum install flex
# yum install boost-devel
# yum install zlib-devel

設定ファイルを編集して、foamHexMesh がコンパイルされないようにする。

~/OpenFOAM/OpenFOAM-4.1/etc/bashrc

# Build foamyHexMesh
#export FOAMY_HEX_MESH=yes

端末を再起動する。

コンパイル。

$ foam
$ ./Allwmake

エラーが出るので、1 つずつ対処する。

エラー

/home/cfd/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/Identity.H:80: error: only declarations of constructors can be eexplicitf
/home/cfd/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/Identity.H:86: error: only declarations of constructors can be eexplicitf
make: *** [/home/cfd/OpenFOAM/OpenFOAM-4.1/platforms/linux64GccDPInt32Opt/src/OSspecific/POSIX/signals/sigStopAtWriteNow.o] エラー 1

修正: src/OpenFOAM/lnInclude/Identity.H

    //inline explicit operator label() const
    inline operator label() const
    {
        return 1;
    }

    //- Return 1 for scalar
    //inline explicit operator scalar() const
    inline operator scalar() const
    {
        return 1;
    }

エラー

fvMesh/fvMesh.H:381: error: using etypenamef outside of template
make: *** [/home/cfd/OpenFOAM/OpenFOAM-4.1/platforms/linux64GccDPInt32Opt/src/finiteVolume/fvMesh/fvMeshGeometry.o] エラー 1

修正: src/finiteVolume/lnInclude/fvMesh.H

template<>
//typename pTraits<sphericalTensor>::labelType
pTraits<sphericalTensor>::labelType
fvMesh::validComponents() const;

エラー

fvMesh/fvMesh.C:883: error: using ‘typename’ outside of template
make: *** [/home/cfd/OpenFOAM/OpenFOAM-4.1/platforms/linux64GccDPInt32Opt/src/finiteVolume/fvMesh/fvMesh.o] エラー 1

修正: src/finiteVolume/lnInclude/fvMesh.C

template<>
//typename Foam::pTraits<Foam::sphericalTensor>::labelType
Foam::pTraits<Foam::sphericalTensor>::labelType
Foam::fvMesh::validComponents<Foam::sphericalTensor>() const
{
    return Foam::pTraits<Foam::sphericalTensor>::labelType(1);
}

エラー

/home/cfd/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/geometricOneFieldI.H:68: error: using ‘typename’ outside of template
/home/cfd/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/geometricOneFieldI.H: In member function ‘Foam::oneField::FieldType Foam::geometricOneField::primitiveField() const’:
/home/cfd/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude/geometricOneFieldI.H:71: error: using ‘typename’ outside of template
make: *** [/home/cfd/OpenFOAM/OpenFOAM-4.1/platforms/linux64GccDPInt32Opt/src/finiteVolume/fvMesh/wallDist/patchDistMethods/Poisson/PoissonPatchDistMethod.o] エラー 1

修正: src/OpenFOAM/lnInclude/geometricOneFieldI.H

//inline typename Foam::geometricOneField::Internal::FieldType
inline Foam::geometricOneField::Internal::FieldType
Foam::geometricOneField::primitiveField() const
{
    //return typename Internal::FieldType();
    return Internal::FieldType();
}

修正: src/OpenFOAM/lnInclude/geometricOneField.H

        //inline typename Internal::FieldType primitiveField() const;
        inline Internal::FieldType primitiveField() const;

エラー

lnInclude/surfaceInterpolationScheme.H:262: error: using ‘typename’ outside of template
make: *** [/home/cfd/OpenFOAM/OpenFOAM-4.1/platforms/linux64GccDPInt32Opt/src/finiteVolume/fvMesh/wallDist/patchDistMethods/Poisson/PoissonPatchDistMethod.o] エラー 1

修正: src/finiteVolume/lnInclude/surfaceInterpolationScheme.H

template<>
tmp
<
    GeometricField
    <
        //typename innerProduct<vector, scalar>::type,
        innerProduct<vector, scalar>::type,
        fvsPatchField,
        surfaceMesh
    >
>

エラー

interpolation/surfaceInterpolation/surfaceInterpolationScheme/surfaceInterpolationSchemes.C:68: error: using ‘typename’ outside of template
interpolation/surfaceInterpolation/surfaceInterpolationScheme/surfaceInterpolationSchemes.C: In member function ‘Foam::tmp<Foam::GeometricField<typename Foam::innerProduct<Foam::Vector<double>, Type>::type, Foam::fvsPatchField, Foam::surfaceMesh> > Foam::surfaceInterpolationScheme<Type>::dotInterpolate(const Foam::surfaceVectorField&, const Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>&) const [with Type = double]’:
interpolation/surfaceInterpolation/surfaceInterpolationScheme/surfaceInterpolationSchemes.C:86: error: using ‘typename’ outside of template
interpolation/surfaceInterpolation/surfaceInterpolationScheme/surfaceInterpolationSchemes.C:94: error: using ‘typename’ outside of template
make: *** [/home/cfd/OpenFOAM/OpenFOAM-4.1/platforms/linux64GccDPInt32Opt/src/finiteVolume/interpolation/surfaceInterpolation/surfaceInterpolationScheme/surfaceInterpolationSchemes.o] エラー 1

修正: src/finiteVOlume/lnInclude/surfaceInterpolationSchemes.C

template<>
Foam::tmp
<
    Foam::GeometricField
    <
        //typename Foam::innerProduct<Foam::vector, Foam::scalar>::type,
        Foam::innerProduct<Foam::vector, Foam::scalar>::type,
        Foam::fvsPatchField,
        Foam::surfaceMesh
    >
>
Foam::surfaceInterpolationScheme<Foam::scalar>::dotInterpolate
(
    const surfaceVectorField& Sf,
    const GeometricField<scalar, fvPatchField, volMesh>&
) const
{
    NotImplemented;

    return
        tmp
        <
            GeometricField
            <
                //typename innerProduct<vector, scalar>::type,
                innerProduct<vector, scalar>::type,
                fvsPatchField,
                surfaceMesh
            >
        >
        (
            GeometricField
            <
                //typename innerProduct<vector, scalar>::type,
                innerProduct<vector, scalar>::type,
                fvsPatchField,
                surfaceMesh
            >::null()
        );
}

エラー

rigidBodyMotion/rigidBodyMotion.C:53: error: ‘nullptr’ was not declared in this scope
make: *** [/home/cfd/OpenFOAM/OpenFOAM-4.1/platforms/linux64GccDPInt32Opt/src/rigidBodyDynamics/rigidBodyMotion/rigidBodyMotion.o] エラー 1

修正: src/rigidBodyDynamics/lnInclude/rigidBodyMotion.C

Foam::RBD::rigidBodyMotion::rigidBodyMotion()
:
    rigidBodyModel(),
    motionState_(*this),
    motionState0_(*this),
    aRelax_(1.0),
    aDamp_(1.0),
    report_(false),
    //solver_(nullptr)
    solver_(NULL)
{}