Upgrade to Pro — share decks privately, control downloads, hide ads and more …

バスケットボール メッシュ生成

kamakiri1225
November 25, 2021

バスケットボール メッシュ生成

kamakiri1225

November 25, 2021
Tweet

More Decks by kamakiri1225

Other Decks in Science

Transcript

  1. バスケットボール
    メッシュ生成
    blockMesh snappyHexMesh
    2021年11月25日
    OpenFOAM

    View Slide

  2. バスケットボールのモデル作成 • FreeCAD
    メッシュ作成
    • blockMesh
    • snappyHexMesh
    解析設定 • OpenFOAM
    計算実行 • OpenFOAM
    結果処理 • Paraview
    プリ処理
    ソルバ
    ポスト処理

    View Slide

  3. basketball.stl
    internalWall-sphere.stl
    internalWall-sphere.stlとbasketball.stlの
    境界にz軸まわり回転流れを与える
    モデル作成 解析条件

    View Slide

  4. /opt/OpenFOAM/OpenFOAM-
    v2012/tutorials/incompressible/simpleFoam/motorbike
    から作業ディレクトリにチュートリアルをコピーする。
    mnt/c/work/openfoam/20211010_basketball_flow/002_mesh_create
    |--motorBike
    | |--0.orig
    | | |--U
    | | |--include
    | | | |--fixedInlet
    | | | |--frontBackUpperPatches
    | | | |--initialConditions
    | | |--k
    | | |--nut
    | | |--omega
    | | |--p
    | |--Allclean
    | |--Allrun
    | |--constant
    | | |--transportProperties
    | | |--triSurface
    | | | |--README
    | | |--turbulenceProperties
    | |--system
    | | |--blockMeshDict
    | | |--controlDict
    | | |--cuttingPlane
    | | |--decomposeParDict.6
    | | |--ensightWrite
    | | |--forceCoeffs
    | | |--fvSchemes
    | | |--fvSolution
    | | |--meshQualityDict
    | | |--snappyHexMeshDict
    | | |--streamLines
    | | |--surfaceFeatureExtractDict
    | | |--topoSetDict
    | | |--wallBoundedStreamLines
    ファイル構成

    View Slide

  5. 「mesh1」「mesh2」フォルダを作成
    「0.orig」「 constant」「 system」フォルダを「mesh1」「mesh2」にコピーする

    View Slide

  6. 「mesh1」フォルダに移って「blockMesh」を実行する。
    「a.foam」ファイルを生成してparaviewでメッシュを確認する。

    View Slide

  7. 「 basketball.stl 」「 internalWall-sphere.stl 」が大きすぎるため1/1000倍にする。
    計算領域が大きすぎるので「blockMeshDict」を
    変更して計算領域を変更する

    View Slide

  8. /*--------------------------------*- C++ -*----------------------------------*¥
    ========= |
    ¥¥ / F ield | OpenFOAM: The Open Source CFD Toolbox
    ¥¥ / O peration | Website: https://openfoam.org
    ¥¥ / A nd | Version: 8
    ¥¥/ M anipulation |
    ¥*---------------------------------------------------------------------------*/
    FoamFile
    {
    version 2.0;
    format ascii;
    class dictionary;
    object blockMeshDict;
    }
    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    convertToMeters 1;
    vertices
    (
    ( -0.20 -0.20 -0.20) //0 /400mm
    ( 0.60 -0.20 -0.20) //1
    ( 0.60 0.20 -0.20) //2
    ( -0.20 0.20 -0.20) //3
    ( -0.20 -0.20 0.20) //4
    ( 0.60 -0.20 0.20) //5
    ( 0.60 0.20 0.20) //6
    ( -0.20 0.20 0.20) //7
    );
    blocks
    (
    hex (0 1 2 3 4 5 6 7) (80 80 80) simpleGrading (1 1 1)
    //1mesh_5mm
    );
    edges
    (
    );
    blocks
    (
    hex (0 1 2 3 4 5 6 7) (80 80 80) simpleGrading (1 1 1)
    //1mesh_5mm
    );
    edges
    (
    );
    boundary
    (
    //patch
    x_min_1
    {
    type patch;
    faces ((0 4 7 3));
    }
    x_max_1
    {
    type patch;
    faces ((1 2 6 5));
    }
    Constant/blockMeshDict
    y_min_1
    {
    type symmetryPlane;
    faces ((0 1 5 4));
    }
    y_max_1
    {
    type symmetryPlane;
    faces ((3 7 6 2));
    }
    z_min_1
    {
    type symmetryPlane;
    faces ((0 3 2 1));
    }
    z_max_1
    {
    type symmetryPlane;
    faces ((4 5 6 7));
    }
    );
    //
    ***********************************************
    ************************** //

    View Slide

  9. 再度blockMeshを実行してparaviewでモデルを確認する。
    モデルのひな形としてはOK

    View Slide

  10. 計算領域のサイズ

    View Slide

  11. C:¥work¥openfoam¥20211010_basketball_flow¥002_mesh_create¥motorBike¥mesh1¥constant¥triSurface
    「constant/triSurface」 の中に「 basketball.stl 」「 internalWall-sphere.stl 」を入れておく。

    View Slide

  12. /*--------------------------------*- C++ -*---------------------------------
    -*¥
    |
    ========= |
    |
    | ¥¥ / F ield | OpenFOAM: The Open Source CFD
    Toolbox |
    | ¥¥ / O peration |
    Version: v2012 |
    | ¥¥ / A nd |
    Website: www.openfoam.com |
    | ¥¥/ M
    anipulation | |
    ¥*--------------------------------------------------------------------------
    -*/
    FoamFile
    {
    version 2.0;
    format ascii;
    class dictionary;
    object snappyHexMeshDict;
    }
    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    //
    // Which of the steps to run
    castellatedMesh true;
    snap true;
    addLayers true;
    geometry
    {
    basketball
    {
    type triSurfaceMesh;
    file "basketball_mm.stl";
    }
    refinementBox
    {
    type box;
    min (-0.1 -0.1 -0.1);
    max ( 0.3 0.1 0.1);
    }
    }
    castellatedMeshControls
    {
    maxLocalCells 100000;
    maxGlobalCells 2000000;
    minRefinementCells 10;
    maxLoadUnbalance 0.10;
    nCellsBetweenLevels 3;
    features
    (
    );
    refinementSurfaces
    {
    basketball
    {
    // Surface-wise min and max refinement level
    level (1 1);
    }
    }
    // Resolve sharp angles
    resolveFeatureAngle 60;
    refinementRegions
    {
    // refinementBox
    // {
    // }
    }
    locationInMesh (0.5 0.0 0.0); // Inside point
    allowFreeStandingZoneFaces true;
    }
    constant/snappyHexMeshDict

    View Slide

  13. constant/snappyHexMeshDict
    snapControls
    {
    nSmoothPatch 3;
    tolerance 2.0;
    //- Number of mesh displacement relaxation iterations.
    nSolveIter 300;
    nRelaxIter 5;
    nFeatureSnapIter 10;
    //- Detect (geometric only) features by sampling the surface
    // (default=false).
    implicitFeatureSnap false;
    //- Use castellatedMeshControls::features (default = true)
    explicitFeatureSnap true;
    //- Detect points on multiple surfaces (only for explicitFeatureSnap)
    multiRegionFeatureSnap false;
    }
    // Settings for the layer addition.
    addLayersControls
    {
    // Are the thickness parameters below relative to the undistorted
    // size of the refined cell outside layer (true) or absolute sizes (false).
    relativeSizes true;
    // Per final patch (so not geometry!) the layer information
    layers
    {
    "basketball"
    {
    nSurfaceLayers 5;
    }
    }
    // Expansion factor for layer mesh
    expansionRatio 1.0;
    finalLayerThickness 0.3;
    minThickness 0.1;
    nGrow 0;
    featureAngle 150;
    slipFeatureAngle 30;
    nRelaxIter 3;
    // Number of smoothing iterations of surface normals
    nSmoothSurfaceNormals 1;
    // Number of smoothing iterations of interior mesh movement direction
    nSmoothNormals 3;
    // Smooth layer thickness over surface patches
    nSmoothThickness 10;
    // Stop layer growth on highly warped cells
    maxFaceThicknessRatio 0.5;
    maxThicknessToMedialRatio 0.3;
    minMedialAxisAngle 90;
    nBufferCellsNoExtrude 0;
    nLayerIter 50;
    }

    View Slide

  14. constant/snappyHexMeshDict
    // Generic mesh quality settings. At any undoable phase these determine
    // where to undo.
    meshQualityControls
    {
    #include "meshQualityDict"
    // Advanced
    //- Number of error distribution iterations
    nSmoothScale 4;
    //- Amount to scale back displacement at error points
    errorReduction 0.75;
    }
    // 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.
    mergeTolerance 1e-6;

    View Slide

  15. snappyHexMeshを実行
    checkMeshを実行してメッシュ品質に問題がないかを確認する

    View Slide

  16. モデルのひな形としてはOK
    paraviewでモデルを確認する。

    View Slide

  17. 「sHM」にsnappyHexMeshで作成したメッシュファイルを保存しておく。
    「3」の中のファイルだけをconstant/polyMeshの中に保存する。

    View Slide