• 検索結果がありません。

PowerPoint プレゼンテーション

N/A
N/A
Protected

Academic year: 2021

シェア "PowerPoint プレゼンテーション"

Copied!
30
0
0

読み込み中.... (全文を見る)

全文

(1)

snappyHexMesh/cfMeshコマンドを

用いたメッシュ生成

若嶋 振一郎(NIT, Ichinoseki College) [email protected]

初出: 2017/01/05 更新: 2017/05/20

(2)

Outline

1. snappyHexMeshコマンドについて 1. snappyHexMeshコマンドの概要と準備 2. snappyHexMeshコマンドの実行 2. cfMeshについて 1. cfMeshパッケージの導入 2. cfMeshに含まれるコマンド 3. 準備 4. cfMeshコマンドの実行

(3)

snappyHexMeshコマンド

• OpenFOAMに付属する非構造格子生成コマンド • blockMeshは構造格子を生成 • blockMeshと組み合わせて利用する • しばしばsHMと省略形で引用 • 基本的な流れ ① blockMeshDictでベースメッシュ作成 ② constant/triSurface以下に置いた形状ファイル(.stl, .obj, .vtkなど)から特徴 線を抽出 ③ 形状ファイル、特徴線データを用いてsystem/snappyHexMeshDictに記述し た設定に従い、メッシュを生成

(4)

sHMのしくみ

• CADソフトウェア等で、STLなどの形状ファイルを出力する(形状のどちら 側にメッシュを張るかを確認しておく) • blockMesh でベースメッシュを作成する(手動) • snappyHexMeshの機能により、形状近傍のベースメッシュを細分化する (8分木法) • 領域外になる部分のセルを取り除く(ここまでで “castellate”の状態 ) • 領域外に飛び出ているメッシュを形状に合わせる(“snap”) • 必要があれば境界層メッシュを挿入する(“addLayers”)

(5)

Tutorial: $FOAM_TUTORIALS/incompressible/simpleFoam/motorBike ①形状データは三角形の表面メッシュ(STL, OBJ, VTK形式)ファイルを 用意し、constant/triSurface/に置きます

$ cp $FOAM_TUTORIALS/resources/geometry/motorBike.obj.gz constant/triSurface

$ gunzip constant/triSurface/motorBike.obj.gz (gzip形式を解凍) $ paraview constant/triSurface/motorBike.obj

※ STLファイルなどで、形状のある部分をパッチとして境界条件の指定 に使いたい場合は、個別のstlファイルとして出力して個別にしていする か、それらを1つのstlにまとめておく(solid ~endsolidの組を複数作る)

(6)

Tutorial: $FOAM_TUTORIALS/incompressible/simpleFoam/motorBike ② surfaceFeatureExtractコマンドによる特徴線の抽出を実施(設定 ファイルsystem/surfaceFeatureExtractDict) $ surfaceFeatureExtract → constant/extendedFeatureEdgeMesh以下にobj形式の形で特徴線形状データ が生成。さらにextendedFeatureEdgeMeshファイルも生成 →more motorBike.extendedFeatureEdgeMeshを用いて、constant/triSurfaceの下 に.eMesh形式の特徴線データを出力 →この.eMesh形式ファイルをsnappyHexMeshDict内で記述し、特徴線のデータを メッシュ生成に利用

(7)

system/surfaceFeatureExtract

motorBike.obj {

// How to obtain raw features (extractFromFile || extractFromSurface) extractionMethod extractFromSurface;

extractFromSurfaceCoeffs {

// Mark edges whose adjacent surface normals are at an angle less // than includedAngle as features

// - 0 : selects no edges // - 180: selects all edges

includedAngle 150;

}

subsetFeatures {

// Keep nonManifold edges (edges with >2 connected faces) nonManifoldEdges no;

// Keep open edges (edges with 1 connected face) openEdges yes;

}

// Write options

// Write features to obj format for postprocessing

writeObj yes; } // ************************************************************************* // 面と面が作る角度が includedAngle(deg.) 以下であれば、そ の辺を特徴線とする 形状ファイル名を指定(複数の場合は、並べて記述)

(8)

Tutorial: $FOAM_TUTORIALS/incompressible/simpleFoam/motorBike ③ blockMeshコマンドによるベースメッシュ生成

$ blockMesh

(9)

Tutorial: $FOAM_TUTORIALS/incompressible/simpleFoam/motorBike ④ snappyHexMeshコマンドの実行 → system/snappyHexMeshDictで制御 → 内部的なステップ 1. castellatedMesh ベースメッシュの細分化+必要部分の切り出し 2. snap メッシュの形状へのスナップ 3. addLayers 境界層メッシュの生成 ※ snappyHexMeshコマンド実行時に-overwriteオプションをつけない場合は、こ れらの3つのステップでのメッシュの状態が、3つの時間レベルのデータフォル ダに個別にメッシュが保存されます

(10)

Tutorial: $FOAM_TUTORIALS/incompressible/simpleFoam/motorBike $ snappyHexMesh ・・・・ かなり時間がかかる

$ ls

0.orig 1 2 3 Allclean Allrun constant system

$ paraFoam & 各時間のメッシュを確認してみる(バイクカウル部の垂 直断面図)

(11)

snappyHexMeshDict

• https://cfd.direct/openfoam/user-guide/snappyhexmesh/に詳述 • snappyHexMeshDict(300行!)の構造を順に確認してみる

// Which of the steps to run castellatedMesh true;

snap true;

addLayers true;

(12)

② 形状の記述

// Geometry. Definition of all surfaces. All surfaces are of class // searchableSurface.

// Surfaces are used

// - to specify refinement for any mesh cell intersecting it

// - to specify refinement for any mesh cell inside/outside/near // - to 'snap' the mesh boundary to the surface

geometry { motorBike.obj { type triSurfaceMesh; name motorBike; } refinementBox { type searchableBox; min (-1.0 -0.7 0.0); max ( 8.0 0.7 2.5); objやstlファイルを記述し、ここではそのsurfaceに motorBikeというパッチ名をつける 特定の領域(BOXやCYRINDERなど)でメッシュをリ ファインする領域も指定できる

(13)

③ castellatedMesh/snap/addLyersの設定

// Settings for the castellatedMesh generation. castellatedMeshControls

{

(別紙で説明)

}

// Settings for the snapping. snapControls

{

(別紙で説明)

}

// Settings for the layer addition. addLayersControls

{

(別紙で説明)

(14)

④ MeshQualityControlの設定

meshQualityControls {

#include "meshQualityDict"

// Advanced

//- Number of error distribution iterations nSmoothScale 4;

//- Amount to scale back displacement at error points errorReduction 0.75;

}

// Include defaults parameters from master dictionary

#includeEtc "caseDicts/meshQualityDict“

//- minFaceWeight (0 -> 0.5)

(15)

⑤ Advanced部分の設定(経験的にあまり弄ることはない) // Advanced // Write flags writeFlags ( scalarLevels layerSets

layerFields // write volScalarField for layer coverage

);

// Merge tolerance. Is fraction of overall bounding box of initial mesh. // Note: the write tolerance needs to be higher than this.

(16)

sHMの実行のまとめ

$ blockMesh $ surfaceFeatureExtract $ snappyHexMesh ⇒ 3つの実行ステップごとに、ステップで生成したメッシュが時刻ディレクトリ に保存される。問題が無ければ0以外のディレクトリを削除して $ snappyHexMesh –overwrite として、上書きでメッシュ生成を行う # すべてまっさらな状態から行うには、 $ foamCleanPolyMesh メッシュのチェック $ checkMesh

(17)

sHM関連のトピックス(後日追記予定)

• 2Dメッシュの生成方法 • stl,obj形式について

(18)

cfMesh(A library for polyhedral mesh generation )

• Creative Fields(http://cfMesh.com)で開発中

• 商用版のcfMeshPro([email protected])と無償版cfMesh(1.1.2)の2つが ある(機能的には当然Pro版が最新実装)

• 無償版cfMeshはsourceforgeでソースが公開(GPL)

• https://sourceforge.net/p/cfmesh/code/ci/v1.1.2/tree/

(19)

cfMeshの機能

• 八分木法によるメッシュ生成(sHMと似ている) • stlや基本的形状から細分化領域を指定できる • 自動境界適合メッシュ生成、テトラ、ヘキサ、ポリヘドラルメッシュ • 境界層メッシュ生成 • 並列計算によるメッシュ生成

(20)

download & install

$ cd of-4.x (ユーザーフォルダ)

$ git clone https://git.code.sf.net/p/cfmesh/code cfmesh-devel $ cd cfmesh-devel $ ./Allwmake (OF4.xの導入済みであること) インストール後の更新 $ cd cfmesh-devel $ git pull $ ./Allwmake

(21)

cfMeshにより導入されるコマンド(24個)

• FLMAToSurface • FMSToSurface • FMSToVTK • cartesian2DMesh • cartesianMesh • checkSurfaceMesh • copySurfaceParts • generateBoundaryLayers • importSurfaceAsSubset • improveMeshQuality • improveSymmetryPlanes • mergeSurfacePatches • meshToFPMA • pMesh • patchesToSubsets • preparePar • removeSurfaceFacets • scaleMesh • scaleSurfaceMesh • subsetToPatch • surfaceFeatureEdges • surfaceGenerateBoundingBox • surfaceToFMS • tetMesh

(22)

cfMeshに含まれるtutorial

$ tree -L 2 . . ├── cartesian2DMesh │ └── hatOctree ├── cartesianMesh │ ├── asmoOctree├── bunnyOctree├── elbow_90degree├── intakePortOctree├── multipleOrifices├── sBendOctree├── sawOctree├── ship5415Octree└── singleOrifice ├── pMesh │ ├── bunnyPoly└── multipleOrifices └── tetMesh ├── cutCubeOctree └── socketOctree ※ 配布のものそのままでは、エラーになるものもあるようです

(23)

cfMeshによるメッシュ生成の流れ(cartesianMesh)

① stlファイルの準備 • cfMeshは単独のstlファイルが必要 • ただし、stlファイルの中に、パッチ毎のsolidが含まれている状態 → 面毎に名前がついており、パッチ名に対応する 例 tutorials/cartesianMesh/sawOctree/sav1.stl

(24)

stlファイルの構造

solid patch000 facet normal 0.811072 -0.468654 0.350037 outer loop vertex 4.76676 10.8144 51.1671 vertex 4.64955 10.8767 51.5221 vertex 4.59512 10.6202 51.3048 endloop endfacet ・・・ endsolid patch000 solid patch001 facet ... endsolid patch001 : 三角形(facet)のデータ solid パッチ名

(25)

cfMeshによるメッシュ生成の流れ(cartesianMesh)

② 特徴線の抽出(.fmsファイルの作成) • sHMと同様に特徴線を抽出し、メッシュ生成に利用する(無くてもよい) • もとの形状データ+特徴線データを1つのファイルに出力する • 特徴線を含んだ形に変更するためには,下記のコマンドを実行する。(引数 は入力ファイル名と出力ファイル名)

$ surfaceFeatureEdges sav1.stl sav1withFeature.stl

• 出力ファイルの拡張子をfmsにすることで,cfMeshのファイル形式で出力さ れる(fms形式のほうが精度が良い) angleオプションをつけるべし

(26)

• surfaceFeatureEdges all.stl all.fms

(27)

cfMeshによるメッシュ生成の流れ(cartesianMesh)

③ cartesianMeshの実行

• system/meshDictを設定

• 特徴線を含んだ形に変更するためには,下記のコマンドを実行する。(引数 は入力ファイル名と出力ファイル名)

$ surfaceFeatureEdges sav1.stl sav1Feature.stl

• 出力ファイルの拡張子をfmsにすることで,cfMeshのファイル形式で出力さ れる(fms形式のほうが精度が良い) angleオプションをつけるべし

(28)

system/meshDict

surfaceFile “mesh.fms”; 形状ファイル(stl, fms形式) maxCellSize 10.0; 最大セルサイズ(絶対値指定) boundaryCellSize 1.0; 境界層セルサイズ(option) boundaryCellSizeRefinementThickness 1.0; 境界層厚さ(option) minCellSize 1.0; 最小セルサイズ(option) boundaryLayers { } 境界層の設定ブロック localRefinement { } パッチ名によるリファイン設定 surfaceMeshRefinement { } サーフェスのリファイン設定 edgeMeshRefinement { } エッジベースのリファイン設定 objectRefinements { } オブジェクトによるリファイン設定 anisotropicSources { } 異方性メッシュの設定 renameBoundary { } パッチ名の変更 workflowControls { } コントロール keepCellsIntersectingBoundary 1;

(29)

cfMesh利用時の注意点

cfMeshの「ベースメッシュ」は、セルサイズを指定することでx-y-z方 向に直交格子が作られる このため、対称性を考えた周期境界などを考えたい場合は、問題 よっては、完全に対称性を加味できない場合がある→この場合は、 ベースメッシュをblockMeshで作成するsHMのほうが有利な時がある

(30)

以上で、snappyHexMesh/cfMeshに関する

参照

関連したドキュメント

It is natural to conjecture that, as δ → 0, the scaling limit of the discrete λ 0 -exploration path converges in distribution to a continuous path, and further that this continuum λ

Hence, in the Dirichlet-type and Neumann-type cases respectively, the sets P k used here are analogous to the sets (0, ∞) × T k+1 and (0, ∞) × S k , and we see that using the sets P

To define the category of sets of which this type of sets is the type of objects requires choosing a second universe of types U 0 and an element u of U 0 such that U = El(u) where El

Taking care of all above mentioned dates we want to create a discrete model of the evolution in time of the forest.. We denote by x 0 1 , x 0 2 and x 0 3 the initial number of

③  「ぽちゃん」の表記を、 「ぽっちゃん」と読んだ者が2 0名(「ぼちゃん」について何か記入 した者 7 4 名の内、 2 7

○事 業 名 海と日本プロジェクト Sea級グルメスタジアム in 石川 ○実施日程・場所 令和元年 7月26日(金) 能登高校(石川県能登町) ○主 催

(0 10 - 0 25) Mazolin™ applications should begin prior to disease development and continue throughout the season on a 7- to 14-day schedule, following the resistance

(0 .10 - 0 .25) TETRABAN applications should begin prior to disease development and continue throughout the season on 7- to 21-day intervals following the resistance