いわて駐在研究日誌

OpenCAE、電子工作、R/C等、徒然なるままに

cfMesh + OF5.x

安心して使えないsHMをやめてcfMeshでメッシュ生成にトライしようとしたが、OF5.x/devだとビルドに失敗するので、ちょっと調査。以下、OF5.xでの検証だが、-devでもいけると思う。

 

まず、ググったところ、以下のとおり

Compiling cfMesh with OpenFOAM 4.x -- CFD Online Discussion Forums

で、cfMeshのソースを変更しないといけないようだ。変更点は3つ。

 

① metaDict_ not declared. Added "IOdictionary.H" to meshLibrary/utilities/meshes/polyMeshGen/polyMeshGen.H

#ifndef polyMeshGen_H
#define polyMeshGen_H

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#include "polyMeshGenCells.H"
#include "dictionary.H"
#include "IOdictionary.H"

namespace Foam
{

 ② edgeMesh has been incorporated into meshTools in OF5 and dev. I did an in-place replacement of -ledgeMesh with nothing

cfMeshのフォルダに散らばって存在しているMake/optionsで-ledgeMeshを削除すれば良いということかな?  ということで、findとsed -i で対処。

find . -name "options" | xargs sed -i s/"-ledgeMesh"/""/g

 

③ Pstream::blocking and Pstream::scheduled have been replaced by Pstream::commsTypes::blocking and Pstream::commsTypes::scheduled - I replaced these

これらもいっぱいあるので、findとsed -iで対応。

 

ここまでやって、tetMeshOptimisation.C, triSurface2DCheck.C, quadricFittingI.H のビルドで、なんかよくわからないエラーが...。eigenVector関数の引数が違うとのこと。

Foam::vector Foam::eigenVector(const tensor&, Foam::scalar, const vector&, const vector&)

vector normal1 = eigenVector(nt, ev[1]);

 :

該当するソースを見ると、

nt:  symmTensor

ev:  eigenVectors of "nt" ・・・実際の引数はev[1]などの成分(スカラー)を渡している。

ということのようなので、OFのsrc/OpenFOAM/primitives/Tensor/tensor/tensor.Cで定義されているeigenValue()の実装が4.xまでと変わったせいのようだ。以下のように修正してみる。

const vector ev = eigenValues(nt);
const vector Ux(1, 0, 0), Uy(0, 1, 0), Uz(0, 0, 1);

//- make sure the point stays on the surface
vector disp = simplex.centrePoint() - points[nodeI];

if( mag(ev[2]) > (mag(ev[1]) + mag(ev[0])) )
{
//- ordinary surface vertex
# ifdef OpenCFDSpecific
vector normal = eigenVectors(nt, ev).z();
# else
vector normal = eigenVector(nt, ev[2], Ux, Uy);
# endif

normal /= (mag(normal)+VSMALL);
disp -= (disp & normal) * normal;
}
else if( mag(ev[1]) > 0.5 * (mag(ev[2]) + mag(ev[0])) )
{
//- this vertex is on an edge
# ifdef OpenCFDSpecific
vector normal1 = eigenVectors(nt, ev).y();
# else
vector normal1 = eigenVector(nt, ev[1], Uz, Ux);
# endif

normal1 /= (mag(normal1)+VSMALL);

# ifdef OpenCFDSpecific
vector normal2 = eigenVectors(nt, ev).z();
# else
vector normal2 = eigenVector(nt, ev[2], Ux, Uy);
# endif

bunnyOctreeのチュートリアルとかやってみたけど、ぱっと見だいじょうぶそう。