surfaceFeatureExtract 障害物の特徴線の抽出
特徴線の設定は「system/surfaceFeatureExtractDict」ファイルで行います。
※system/surfaceFeatureExtractDictが無い場合は新規で作成してください。適当なチュートリアル($FOAM_TUTORIALS/incompressible/simpleFoam/motorBike/system/surfaceFeatureExtractDict)からファイルを持ってきても良いです。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
FoamFile { version 2.0; format ascii; class dictionary; object surfaceFeatureExtractDict; } walls_mm_tr.stl { extractionMethod extractFromSurface; extractFromSurfaceCoeffs { includedAngle 150; } subsetFeatures { nonManifoldEdges no; openEdges yes; } writeObj yes; } |
ターミナルで以下のコマンドを実行します。
1 |
surfaceFeatureExtract |
実行すると「constant/triSurface/walls_mm_tr.eMesh」ファイルが作成されます。
1 2 3 4 5 6 7 |
constant/triSurface/ ├── walls.stl ├── walls_mm.stl ├── walls_mm_tr.eMesh └── walls_mm_tr.stl 0 directories, 5 files |
特徴性がどの様にできたかを見たい場合はobjファイルに変換することでParaviewで見ることができます。
以下のコマンドで変換ができます。
1 |
surfaceFeatureConvert constant/triSurface/walls_mm_tr.eMesh constant/triSurface/walls_mm_tr.obj |
walls_mm_tr.objファイルをParaviewで読み込んで確認しましょう。
この特徴線を使って先ほど作成したベースメッシュから「walls_mm_tr.stl」形状を抜き出します。
「system/snappyHexMeshDict」ファイルで設定を行います。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
FoamFile { version 2.0; format ascii; class dictionary; location "system"; object snappyHexMeshDict; } castellatedMesh true; snap true; addLayers true; geometry { walls_mm_tr.stl { type triSurfaceMesh; name walls; regions { walls { name walls; } } } } castellatedMeshControls { features ( { file "walls_mm_tr.eMesh"; level 0; } ); refinementSurfaces { walls { level (0 0); regions { walls { level (0 0); patchInfo { type wall; } } } } } refinementRegions { } locationInMesh (2.0 0.5 0.5); maxLocalCells 100000000; maxGlobalCells 100000000; minRefinementCells 1; nCellsBetweenLevels 9; resolveFeatureAngle 30; allowFreeStandingZoneFaces false; } snapControls { nSolveIter 30; nSmoothPatch 3; tolerance 4.0; nRelaxIter 5; nFeatureSnapIter 10; } addLayersControls { layers { //walls //{ // nSurfaceLayers 3; // } } relativeSizes true; expansionRatio 1.0; finalLayerThickness 0.3; minThickness 0.03; nGrow 1; featureAngle 60; nRelaxIter 5; nSmoothSurfaceNormals 1; nSmoothNormals 3; nSmoothThickness 10; maxFaceThicknessRatio 0.5; maxThicknessToMedialRatio 0.3; minMedianAxisAngle 130; nBufferCellsNoExtrude 0; nLayerIter 50; nRelaxedIter 20; } meshQualityControls { maxNonOrtho 65; maxBoundarySkewness 20; maxInternalSkewness 4; maxConcave 80; minFlatness 0.5; minVol 1.00E-13; minTetQuality -1e30; minArea -1; minTwist 0.05; minDeterminant 0.001; minFaceWeight 0.05; minVolRatio 0.01; minTriangleTwist -1; nSmoothScale 4; errorReduction 0.75; relaxed { maxNonOrtho 180; } } debug 0; mergeTolerance 1e-5; |
設定項目が多くすべて覚えることができないですが以下主要な部分の解説を行います。
ジオメトリの定義
こちらで「walls_mm_tr.stl」から面の名前や領域名などを指定しています。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
geometry { walls_mm_tr.stl { type triSurfaceMesh; name walls; regions { walls { name walls; } } } } |
面の名前を全て「walls」としてしまったのでわかりにくいですが、対応関係がわかるように以下のように色で区別してみました。色が同じところは同じ名前にしておかないとエラーもしくは正常にメッシュ作成が行えません。
ここでは、
- features:特徴線の設定
- refinementSurfaces:再分割領域←今回は再分割は行っていません。
の設定を行っています。
locationInMesh (2.0 0.5 0.5)はメッシュ作成領域の座標を指定するため、障害物内の座標を指定してしまうと障害物内部にメッシュが作成されてしまいます。必ず障害物より外の座標の指定を行う必要があります。
※冒頭の「castellatedMesh true」がtrueであることを確認してください。
Falseだと使わないことになります。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
castellatedMeshControls { features ( { file "walls_mm_tr.eMesh"; level 0; } ); refinementSurfaces { walls0000 { level (0 0); regions { walls { level (0 0); patchInfo { type wall; } } } } } refinementRegions { } locationInMesh (2.0 0.5 0.5); maxLocalCells 100000000; maxGlobalCells 100000000; minRefinementCells 1; nCellsBetweenLevels 9; resolveFeatureAngle 30; allowFreeStandingZoneFaces false; } |
境界層の設定
以下で境界層の設定を行うことができますが、今回は使用していません。
※冒頭の「addLayers true」がtrueであることを確認してください。
Falseだと使わないことになります。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
addLayersControls { layers { //walls //{ // nSurfaceLayers 3; // } } relativeSizes true; expansionRatio 1.0; finalLayerThickness 0.3; minThickness 0.03; nGrow 1; featureAngle 60; nRelaxIter 5; nSmoothSurfaceNormals 1; nSmoothNormals 3; nSmoothThickness 10; maxFaceThicknessRatio 0.5; maxThicknessToMedialRatio 0.3; minMedianAxisAngle 130; nBufferCellsNoExtrude 0; nLayerIter 50; nRelaxedIter 20; } |
ファイルの設定が終わったら以下のコマンドを実行します。
1 |
snappyHexMesh -overwrite |
snappyHexMeshは段階に分けてメッシュ作成を行うため、必要な最新メッシュだけを取り出す場合は、オプションで「-overwrite」を付けます。
では、Paraviewで結果を確認しましょう。
checkMesh メッシュ品質の確認
ターミナルで以下のコマンドでメッシュ品質を確認しましょう。
テキストに書き出すと見やすいので「checkMesh.log」に実行結果を書き出します。
1 |
checkMesh > checkMesh.log |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
/*---------------------------------------------------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: v2006 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ Build : _b45f8f6f58-20200629 OPENFOAM=2006 Arch : "LSB;label=32;scalar=64" Exec : checkMesh Date : Jun 03 2022 Time : 19:11:28 Host : kamakiri-VirtualBox PID : 9377 I/O : uncollated Case : /home/kamakiri/Desktop/OpenFOAM/damBreak_snappyHexMesh_less_less_blog nProcs : 1 trapFpe: Floating point exception trapping enabled (FOAM_SIGFPE). fileModificationChecking : Monitoring run-time modified files using timeStampMaster (fileModificationSkew 5, maxFileModificationPolls 20) allowSystemOperations : Allowing user-supplied system call operations // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Create time Create mesh for time = 0.001 Time = 0.001 Mesh stats points: 18411 faces: 50724 internal faces: 46476 cells: 16200 faces per cell: 6 boundary patches: 6 point zones: 0 face zones: 0 cell zones: 0 Overall number of cells of each type: hexahedra: 16200 prisms: 0 wedges: 0 pyramids: 0 tet wedges: 0 tetrahedra: 0 polyhedra: 0 Checking topology... Boundary definition OK. Cell to face addressing OK. Point usage OK. Upper triangular ordering OK. Face vertices OK. Number of regions: 1 (OK). Checking patch topology for multiply connected surfaces... Patch Faces Points Surface topology minX 324 361 ok (non-closed singly connected) maxX 324 361 ok (non-closed singly connected) minY 900 969 ok (non-closed singly connected) maxY 900 969 ok (non-closed singly connected) minZ 900 969 ok (non-closed singly connected) maxZ 900 969 ok (non-closed singly connected) Checking faceZone topology for multiply connected surfaces... No faceZones found. Checking basic cellZone addressing... No cellZones found. Checking geometry... Overall domain bounding box (0 -0.5 0) (3.22 0.5 1) Mesh has 3 geometric (non-empty/wedge) directions (1 1 1) Mesh has 3 solution (non-empty) directions (1 1 1) Boundary openness (9.29733e-18 -5.46764e-17 5.84362e-17) OK. Max cell openness = 1.40189e-16 OK. Max aspect ratio = 1.15921 OK. Minimum face area = 0.00308636. Maximum face area = 0.00357781. Face area magnitudes OK. Min volume = 0.000198761. Max volume = 0.000198769. Total volume = 3.22. Cell volumes OK. Mesh non-orthogonality Max: 0 average: 0 Non-orthogonality check OK. Face pyramids OK. Max skewness = 4.82706e-14 OK. Coupled point location match (average 0) OK. Mesh OK. Time = 0.002 Mesh stats points: 18411 faces: 50724 internal faces: 46476 cells: 16200 faces per cell: 6 boundary patches: 6 point zones: 0 face zones: 0 cell zones: 0 Overall number of cells of each type: hexahedra: 16200 prisms: 0 wedges: 0 pyramids: 0 tet wedges: 0 tetrahedra: 0 polyhedra: 0 Checking topology... Boundary definition OK. Cell to face addressing OK. Point usage OK. Upper triangular ordering OK. Face vertices OK. Number of regions: 1 (OK). Checking patch topology for multiply connected surfaces... Patch Faces Points Surface topology minX 324 361 ok (non-closed singly connected) maxX 324 361 ok (non-closed singly connected) minY 900 969 ok (non-closed singly connected) maxY 900 969 ok (non-closed singly connected) minZ 900 969 ok (non-closed singly connected) maxZ 900 969 ok (non-closed singly connected) Checking faceZone topology for multiply connected surfaces... No faceZones found. Checking basic cellZone addressing... No cellZones found. Checking geometry... Overall domain bounding box (0 -0.5 0) (3.22 0.5 1) Mesh has 3 geometric (non-empty/wedge) directions (1 1 1) Mesh has 3 solution (non-empty) directions (1 1 1) Boundary openness (9.29733e-18 -5.46764e-17 5.84362e-17) OK. Max cell openness = 1.40189e-16 OK. Max aspect ratio = 1.15921 OK. Minimum face area = 0.00308636. Maximum face area = 0.00357781. Face area magnitudes OK. Min volume = 0.000198761. Max volume = 0.000198769. Total volume = 3.22. Cell volumes OK. Mesh non-orthogonality Max: 0 average: 0 Non-orthogonality check OK. Face pyramids OK. Max skewness = 4.82706e-14 OK. Coupled point location match (average 0) OK. Mesh OK. Time = 0.003 Mesh stats points: 18411 faces: 50724 internal faces: 46476 cells: 16200 faces per cell: 6 boundary patches: 6 point zones: 0 face zones: 0 cell zones: 0 Overall number of cells of each type: hexahedra: 16200 prisms: 0 wedges: 0 pyramids: 0 tet wedges: 0 tetrahedra: 0 polyhedra: 0 Checking topology... Boundary definition OK. Cell to face addressing OK. Point usage OK. Upper triangular ordering OK. Face vertices OK. Number of regions: 1 (OK). Checking patch topology for multiply connected surfaces... Patch Faces Points Surface topology minX 324 361 ok (non-closed singly connected) maxX 324 361 ok (non-closed singly connected) minY 900 969 ok (non-closed singly connected) maxY 900 969 ok (non-closed singly connected) minZ 900 969 ok (non-closed singly connected) maxZ 900 969 ok (non-closed singly connected) Checking faceZone topology for multiply connected surfaces... No faceZones found. Checking basic cellZone addressing... No cellZones found. Checking geometry... Overall domain bounding box (0 -0.5 0) (3.22 0.5 1) Mesh has 3 geometric (non-empty/wedge) directions (1 1 1) Mesh has 3 solution (non-empty) directions (1 1 1) Boundary openness (9.29733e-18 -5.46764e-17 5.84362e-17) OK. Max cell openness = 1.40189e-16 OK. Max aspect ratio = 1.15921 OK. Minimum face area = 0.00308636. Maximum face area = 0.00357781. Face area magnitudes OK. Min volume = 0.000198761. Max volume = 0.000198769. Total volume = 3.22. Cell volumes OK. Mesh non-orthogonality Max: 0 average: 0 Non-orthogonality check OK. Face pyramids OK. Max skewness = 4.82706e-14 OK. Coupled point location match (average 0) OK. Mesh OK. End |
パッチ名の変更
system/createPatchDict
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
/*--------------------------------*- C++ -*----------------------------------*\ ========= | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 6.x | | \\ / A nd | Website: https://openfoam.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class dictionary; object createPatchDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // pointSync false; // Patches to create. patches ( { name other_region; patchInfo { type wall; } constructFrom patches; patches (minX minY minZ maxX maxY); } { name region_maxZ; patchInfo { type wall; } constructFrom patches; patches (maxZ); } { name walls; patchInfo { type wall; } constructFrom patches; patches (wall); } ); // ************************************************************************* // |
1 |
createPatch -overwrite |
メッシュの面要素のリストである境界名は「constant/polyMesh/boundar」に保存されています。変更前と変更後でファイルを確認してみましょう。
変更前
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: v2006 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class polyBoundaryMesh; location "constant/polyMesh"; object boundary; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 7 ( minX { type patch; nFaces 324; startFace 46227; } maxX { type patch; nFaces 324; startFace 46551; } minY { type patch; nFaces 900; startFace 46875; } maxY { type patch; nFaces 900; startFace 47775; } minZ { type patch; nFaces 876; startFace 48675; } maxZ { type patch; nFaces 900; startFace 49551; } walls { type wall; inGroups 1(wall); nFaces 90; startFace 50451; } ) // ************************************************************************* // |
変更後
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: v2006 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class polyBoundaryMesh; location "constant/polyMesh"; object boundary; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 3 ( walls { type wall; inGroups 1(wall); nFaces 90; startFace 46227; } other_region { type wall; inGroups 1(wall); nFaces 3324; startFace 46317; } region_maxZ { type wall; inGroups 1(wall); nFaces 900; startFace 49641; } ) // ************************************************************************* // |
Paraviewでパッチ名を確認してみましょう。
パッチ名が変更されていますね。
はじめからblockMeshで変更後のような面の名前にしておけばよいのですが、今回はcreatePatchを使った面の名前の変更を行う練習のためあえてこのような工程を踏みました。
大変貴重な記事ありがとうございます。