CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Meshing & Mesh Conversion

[snappyHexMesh] gmsh import add layers with shm

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By Hr_kules
  • 1 Post By CaptCrash

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 26, 2022, 09:52
Default gmsh import add layers with shm
  #1
Senior Member
 
Nico
Join Date: Jan 2022
Location: Germany
Posts: 122
Rep Power: 6
Hr_kules is on a distinguished road
Hey,

i an older post i found a quote stating that it is possible to create a mesh in gmsh and import it to further create the boundary layer with snappy hex mesh.


Is this actually possible? If so, has anybody done that before and can tell how to do that? Or just share some experiences?
Hr_kules is offline   Reply With Quote

Old   October 26, 2022, 11:11
Default
  #2
Senior Member
 
Nico
Join Date: Jan 2022
Location: Germany
Posts: 122
Rep Power: 6
Hr_kules is on a distinguished road
I have just tried doing that with a simple pipe and it actually works.
Hr_kules is offline   Reply With Quote

Old   November 20, 2022, 17:50
Default
  #3
New Member
 
Join Date: Nov 2022
Posts: 7
Rep Power: 3
CaptCrash is on a distinguished road
Would you be able to describe the process you used?
CaptCrash is offline   Reply With Quote

Old   November 21, 2022, 06:05
Default
  #4
Senior Member
 
Nico
Join Date: Jan 2022
Location: Germany
Posts: 122
Rep Power: 6
Hr_kules is on a distinguished road
Hey, yes of course!

I have created the mesh in GMSH with a script alone. The resulting mesh is located in the case in the constant folder -> constant/mesh.msh
I import the mesh with gmshToFoam constant/mesh.msh
Prvious command creates the polymesh folder with faces, cellzones and so on..
In the snappyHexMeshDict i start with following settings:
Code:
/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  9
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    format      ascii;
    class       dictionary;
    object      snappyHexMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#includeEtc "caseDicts/mesh/generation/snappyHexMeshDict.cfg"

castellatedMesh off;
snap            off;
addLayers       on;
Note that the castellated mesh and snap procedures are turned off. However all the settings must still exist in the dict, although they are not needed:
Code:
geometry
{
    dummy
    {
        type            triSurfaceMesh;
        file            "dummy.stl";
        regions
        {
            dummy1.stl        {name dummy1;}
            dummy2.stl        {name dummy2;}
            dummy3.stl        {name dummy3;}
            dummy4.stl    {name dummy4;}            
        }
    }
};

castellatedMeshControls
{
    features
    (
    );

    refinementSurfaces
    {
        dummy
        {
            level          (0 0);
            regions
            {
                dummy1            { level  (1 1); patchInfo { type wall;  } } 
                dummy2            { level  (1 1); patchInfo { type wall;  } } 
                dummy3            { level  (1 1); patchInfo { type wall;  } } 
                dummy4            { level  (1 1); patchInfo { type wall;  } } 

            }
         }



    }

    locationInMesh (0.0 0.0 0.005);

    nCellsBetweenLevels 2;

    resolveFeatureAngle 15;
}

snapControls
{
    implicitFeatureSnap    true;
}
What you actually write doesn't matter expect that a dummy stl with whatever names you apply needs to exist, however nothing is done. Just make sure the settings and a consistent named stl exist.
In the last portion of the script:
Code:
addLayersControls
{
    layers
    {
        top
        {
            nSurfaceLayers  5;
            mergeFaces      true;
        }
        bottom
        {
            nSurfaceLayers  5;
            mergeFaces      true;
        }
        left
        {
            nSurfaceLayers  5;
            mergeFaces      true;
        }
        right
        {
            nSurfaceLayers  5;
            mergeFaces      true;
        }                        
    }
    relativeSizes   true;
    expansionRatio  1.2;
    finalLayerThickness 0.4;
    minThickness    0.001;
}
You can make references to the imported patches, given they were named in GMSH, if not, you should name them in GMSH before you import the mesh to OpenFoam.

For simple geometries you can simply run:

gmshToFoam constant/mesh.msh
createPatch -overwrite
snappyHexMesh -overwrite

Side note: Since i want some of the patches to be walls i use the createPatch dict to change the boundary type to wall and use the createFromPatch option of the createPatch dict.

The resulting mesh in my case was mesh with various elements mixed, the checkMesh command doesn't complain about the mesh and test runs were all quite successfull, so i hope this helps you! If you have any further questions i will try ma best to answer them!
jherb likes this.
Hr_kules is offline   Reply With Quote

Old   November 21, 2022, 16:57
Default
  #5
New Member
 
Join Date: Nov 2022
Posts: 7
Rep Power: 3
CaptCrash is on a distinguished road
Thanks! That is very useful.
Hr_kules likes this.
CaptCrash is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[snappyHexMesh] Snappy add layers failed mqsim OpenFOAM Meshing & Mesh Conversion 1 January 24, 2021 15:02
[snappyHexMesh] Add Layers in snappyHexMesh shchepan OpenFOAM Meshing & Mesh Conversion 24 May 14, 2020 12:29
[snappyHexMesh] Fail to create boundary layers during sHM farahiam OpenFOAM Meshing & Mesh Conversion 13 October 15, 2014 19:46
[Gmsh] 2D Mesh Generation Tutorial for GMSH aeroslacker OpenFOAM Meshing & Mesh Conversion 12 January 19, 2012 03:52
[snappyHexMesh] SHM add layers problem doubtsincfd OpenFOAM Meshing & Mesh Conversion 0 June 6, 2011 12:01


All times are GMT -4. The time now is 14:18.