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

[snappyHexMesh] Beginner with snappyHexMesh

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By Lookid

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 12, 2017, 11:11
Default Beginner with snappyHexMesh
  #1
Member
 
Lilian Chabannes
Join Date: Apr 2017
Posts: 58
Rep Power: 9
Lookid is on a distinguished road
Hello all,

New to OpenFOAM, I'm trying to import stl files and use snappyHexMesh to mesh inside.
Spent the day on it and I misunderstood many things I think !
I have problems that are probably already solved somewhere in the forum, but can't find it, sorry for that.

1st problem

I'm trying to mesh this propeller that I find online :
https://drive.google.com/open?id=0B3...ll1TzMwdG03RTA

Based on the flange snappyHexMesh provided, I obtain this result for the mesh, which is not very smooth you'll agree with me :
https://drive.google.com/open?id=0B3...l9pSkYzekYzbFU

If I increase precision in BlockMeshDict, then it's better, but still not smooth.

And if you look closely there's like piece of mesh floating unattached to the propeller.

Finally it looks like the inside mesh is not created :
https://drive.google.com/open?id=0B3...0JsblM3LTJfaDA

I'm trying to play with the different parameters in snappyHexMeshDict but nothing change much.

Reading the tutorial on the wiki, I thought the blockMesh grid created wasn't important, but apparently it is ? Or I am simply not using snappy in the right way ? (That's the most probable answer)

2nd problem

I tried to do the same with another .stl file, and here it's even worse, everything is running, but there's simply no mesh in the end !
Here's a picture of blockMesh + the initial .stl file :
https://drive.google.com/open?id=0B3...GozV01zdjlTZ0E

For this one, I chose a point in the .eMesh file and put it to locationInMesh to ensure that I'm in the mesh (is this right ?)

I found online the propeller.stl file and the second (that doesn't mesh at all) is imported from SolidWorks in .stl ascii format.

Do you have any clue for why it's not even meshing here ?


In case you want to see and try, here are the two files :
https://drive.google.com/open?id=0B3...HN2a2lIcVhEQlU

Sorry again for this probably newbie questions, but OF is really not that easy in the beginning

Thank you !
Lookid is offline   Reply With Quote

Old   April 25, 2017, 06:39
Default
  #2
Senior Member
 
KaLium's Avatar
 
Kal-El
Join Date: Apr 2017
Location: Finland
Posts: 150
Rep Power: 9
KaLium is on a distinguished road
Your boundary mesh is too coarse.

Read this please: https://cfd.direct/openfoam/user-guide/snappyhexmesh/

What is the refimentLevel on the wall? (refimentSurfaces..)
KaLium is offline   Reply With Quote

Old   April 25, 2017, 06:40
Default
  #3
Senior Member
 
KaLium's Avatar
 
Kal-El
Join Date: Apr 2017
Location: Finland
Posts: 150
Rep Power: 9
KaLium is on a distinguished road
Do you want mesh inside the propeller? Why? Are you planning to solve it as solid?
KaLium is offline   Reply With Quote

Old   April 25, 2017, 12:09
Default
  #4
Member
 
Lilian Chabannes
Join Date: Apr 2017
Posts: 58
Rep Power: 9
Lookid is on a distinguished road
Hi,

Since I did some improvements but still not really good.

For the propeller, it was just an example to try snappy, i'm not gonna do anything on it.

For the second case which wasn't working, I was just stupid and my point wasn't inside. But I don't have a good mesh :

• initial geometry :
https://drive.google.com/file/d/0B3B...ew?usp=sharing

• base stl file :
https://drive.google.com/file/d/0B3B...ew?usp=sharing

• zoom in the mesh :
https://drive.google.com/file/d/0B3B...ew?usp=sharing
https://drive.google.com/file/d/0B3B...ew?usp=sharing

Actually saw the videos of Tobias Holzmann explaining everything to have a good mesh from a .stp file (making waterproof with Salome, good triangulation and export as .stl). Those videos are great really expecially for beginners like me but I have some issues.

I work with solidworks, export as .stp but can't open the geometry in SALOME for some reason so what I did is export as .stl, repair the .stl in Blender and then mesh with snappy. This is the result I show and it's not good so actually I'm stuck with this. It's because of the "bad" .stl solidworks is generating probably.

And to explain my goals :

The geometry you can see is a molded piece. (injection silicone molding)

My first goal was to just put a temperature on the boundaries and see the evolution of the cure degree inside the piece with a modified laplacianFoam, which is done.

Now I want to see the flow inside during the injection using interFoam. But I need a proper mesh for this.
Lookid is offline   Reply With Quote

Old   April 26, 2017, 02:27
Default
  #5
Senior Member
 
KaLium's Avatar
 
Kal-El
Join Date: Apr 2017
Location: Finland
Posts: 150
Rep Power: 9
KaLium is on a distinguished road
I think you still need much finer mesh
KaLium is offline   Reply With Quote

Old   May 2, 2017, 09:27
Default
  #6
Member
 
Lilian Chabannes
Join Date: Apr 2017
Posts: 58
Rep Power: 9
Lookid is on a distinguished road
You're right, I've better results, still not as I would like but way better for sure.

https://drive.google.com/open?id=0B3...Vo1OUFuU2lCU2s
https://drive.google.com/open?id=0B3...HZzVGVoT0d3cjA
https://drive.google.com/open?id=0B3...3BsQVpjR1NmN3c

I put 3 layers and sometimes it works well, sometimes not at all (see 3rd screenshot)

Do you have any clue of why ? Is it from the base .stl file ?

Here is the snappyHexMeshDict file

Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  4.x                                   |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     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. 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
{
    coupelleascgro.stl
    {
        type triSurfaceMesh;
        name coupelleascgro;
    }

};



// Settings for the castellatedMesh generation.
castellatedMeshControls
{

    // Refinement parameters
    // ~~~~~~~~~~~~~~~~~~~~~

    // If local number of cells is >= maxLocalCells on any processor
    // switches from from refinement followed by balancing
    // (current method) to (weighted) balancing before refinement.
    maxLocalCells 100000;

    // Overall cell limit (approximately). Refinement will stop immediately
    // upon reaching this number so a refinement level might not complete.
    // Note that this is the number of cells before removing the part which
    // is not 'visible' from the keepPoint. The final number of cells might
    // actually be a lot less.
    maxGlobalCells 2000000;

    // The surface refinement loop might spend lots of iterations refining just a
    // few cells. This setting will cause refinement to stop if <= minimumRefine
    // are selected for refinement. Note: it will at least do one iteration
    // (unless the number of cells to refine is 0)
    minRefinementCells 0;

    // Number of buffer layers between different levels.
    // 1 means normal 2:1 refinement restriction, larger means slower
    // refinement.
    nCellsBetweenLevels 2;



    // Explicit feature edge refinement
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    // Specifies a level for any cell intersected by its edges.
    // This is a featureEdgeMesh, read from constant/triSurface for now.
    features
    (
        /*{
            file "coupelleascgro.eMesh";
            level 0;
        }*/
    );



    // Surface based refinement
    // ~~~~~~~~~~~~~~~~~~~~~~~~

    // Specifies two levels for every surface. The first is the minimum level,
    // every cell intersecting a surface gets refined up to the minimum level.
    // The second level is the maximum level. Cells that 'see' multiple
    // intersections where the intersections make an
    // angle > resolveFeatureAngle get refined up to the maximum level.

    refinementSurfaces
    {
        coupelleascgro
        {
            // Surface-wise min and max refinement level
            level (1 2);
        }
    }

    resolveFeatureAngle 80;


    // Region-wise refinement
    // ~~~~~~~~~~~~~~~~~~~~~~

    // Specifies refinement level for cells in relation to a surface. One of
    // three modes
    // - distance. 'levels' specifies per distance to the surface the
    //   wanted refinement level. The distances need to be specified in
    //   descending order.
    // - inside. 'levels' is only one entry and only the level is used. All
    //   cells inside the surface get refined up to the level. The surface
    //   needs to be closed for this to be possible.
    // - outside. Same but cells outside.

    refinementRegions
    {
    }


    // Mesh selection
    // ~~~~~~~~~~~~~~

    // After refinement patches get added for all refinementSurfaces and
    // all cells intersecting the surfaces get put into these patches. The
    // section reachable from the locationInMesh is kept.
    // NOTE: This point should never be on a face, always inside a cell, even
    // after refinement.
    // This is an outside point locationInMesh;
    locationInMesh (0 0 0); // Inside point

    // Whether any faceZones (as specified in the refinementSurfaces)
    // are only on the boundary of corresponding cellZones or also allow
    // free-standing zone faces. Not used if there are no faceZones.
    allowFreeStandingZoneFaces true;
}



// Settings for the snapping.
snapControls
{
    //- Number of patch smoothing iterations before finding correspondence
    //  to surface
    nSmoothPatch 3;

    //- Relative distance for points to be attracted by surface feature point
    //  or edge. True distance is this factor times local
    //  maximum edge length.
    tolerance 1.0;

    //- Number of mesh displacement relaxation iterations.
    nSolveIter 30;

    //- Maximum number of snapping relaxation iterations. Should stop
    //  before upon reaching a correct mesh.
    nRelaxIter 5;

    // Feature snapping

        //- Number of feature edge snapping iterations.
        //  Leave out altogether to disable.
        nFeatureSnapIter 10;

        //- Detect (geometric) features by sampling the surface
        implicitFeatureSnap false;

        //- Use castellatedMeshControls::features
        explicitFeatureSnap true;

        //- Detect features between multiple surfaces
        //  (only for explicitFeatureSnap, default = false)
        multiRegionFeatureSnap true;
}



// 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 false;

    // Per final patch (so not geometry!) the layer information
    layers
    {
        coupelleascgro
        {
            nSurfaceLayers 3;
        }
    }

    // Expansion factor for layer mesh
    expansionRatio 1.3;


    // Wanted thickness of final added cell layer. If multiple layers
    // is the thickness of the layer furthest away from the wall.
    // Relative to undistorted size of cell outside layer.
    // See relativeSizes parameter.
    finalLayerThickness 0.0003;

    // Minimum thickness of cell layer. If for any reason layer
    // cannot be above minThickness do not add layer.
    // See relativeSizes parameter.
    minThickness 0.0001;

    // If points get not extruded do nGrow layers of connected faces that are
    // also not grown. This helps convergence of the layer addition process
    // close to features.
    nGrow 0;


    // Advanced settings

    // When not to extrude surface. 0 is flat surface, 90 is when two faces
    // are perpendicular
    featureAngle 30;

    // Maximum number of snapping relaxation iterations. Should stop
    // before upon reaching a correct mesh.
    nRelaxIter 5;

    // 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;

    // Reduce layer growth where ratio thickness to medial
    // distance is large
    maxThicknessToMedialRatio 0.3;

    // Angle used to pick up medial axis points
    minMedianAxisAngle 90;

    // Create buffer region for new layer terminations
    nBufferCellsNoExtrude 0;


    // Overall max number of layer addition iterations. The mesher will exit
    // if it reaches this number of iterations; possibly with an illegal
    // mesh.
    nLayerIter 50;

    // Max number of iterations after which relaxed meshQuality controls
    // get used. Up to nRelaxIter it uses the settings in meshQualityControls,
    // after nRelaxIter it uses the values in meshQualityControls::relaxed.
    nRelaxedIter 20;
}



// Generic mesh quality settings. At any undoable phase these determine
// where to undo.
meshQualityControls
{
    #include "meshQualityDict"

    // Optional : some meshing phases allow usage of relaxed rules.
    // See e.g. addLayersControls::nRelaxedIter.
    relaxed
    {
        //- Maximum non-orthogonality allowed. Set to 180 to disable.
        maxNonOrtho         80;
        maxBoundarySkewness 20;
        maxInternalSkewness 5;
        maxConcave          80;
    }

    // Advanced

    //- Number of error distribution iterations
    nSmoothScale 4;
    //- Amount to scale back displacement at error points
    errorReduction 0.75;
}


// Advanced

// Write flags
writeFlags
(
    scalarLevels    // write volScalarField with cellLevel for postprocessing
    layerSets       // write cellSets, faceSets of faces in layer
    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;


// ************************************************************************* //
Lookid is offline   Reply With Quote

Old   May 3, 2017, 10:40
Default
  #7
Member
 
Lilian Chabannes
Join Date: Apr 2017
Posts: 58
Rep Power: 9
Lookid is on a distinguished road
Problems solved,

I finally managed to have .step file for the model I wanted instead of .stl. Then I followed the youtube tutorial made by Tobias Holzmann (they are awesome, big thanks to this guy) and I have now a good mesh.

Thank you KaLium
Tobi likes this.
Lookid 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
[CAD formats] Creating waterproof STL using snappyHexMesh or salome Tobi OpenFOAM Meshing & Mesh Conversion 58 May 13, 2020 06:01
[snappyHexMesh] Running snappyHexMesh in parallel - optimizing peterhess OpenFOAM Meshing & Mesh Conversion 2 January 3, 2018 02:54
[snappyHexMesh] snappyHexMesh beginner CRI_CFD OpenFOAM Meshing & Mesh Conversion 5 June 20, 2014 06:57
[snappyHexMesh] stitchMesh and snappyHexMesh gdbaldw OpenFOAM Meshing & Mesh Conversion 0 December 23, 2009 02:09
[snappyHexMesh] snappyHexMesh beginner problems sErik OpenFOAM Meshing & Mesh Conversion 1 November 16, 2009 08:47


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