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

[snappyHexMesh] Creating very fine, high accuracy mesh with snappyHexMesh

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree7Likes
  • 2 Post By me3840
  • 5 Post By me3840

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 23, 2017, 15:21
Default Creating very fine, high accuracy mesh with snappyHexMesh
  #1
New Member
 
JD Welch
Join Date: Jul 2017
Posts: 8
Rep Power: 5
JD_Welch is on a distinguished road
Hey everyone,

I am relatively new to snappyHesMesh and have been trying to get the most accurate mesh possible. My progress has been pretty substantial but I have not reached the level of accuracy I would like. I am not sure if it possible, but I would like to have an exact replica/copy of the obj/stl model file. I have attached pictures of the progress I have made but I would like my mesh to look like the F1 obj file.

I have also added my snappyHexMeshdict for review and suggestion.

Thank you for any advice.

Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  5                                     |
|   \\  /    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
{
    F1
    {
        type triSurfaceMesh;
        file "F1.obj";
    }

    refinementBox
    {
        type searchableBox;
        min  (-5.5 -0.1   -1);
        max ( 0.1  1.5     1);
    }
};



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

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

    // Allow a certain level of imbalance during refining
    // (since balancing is quite expensive)
    // Expressed as fraction of perfect balance (= overall number of cells /
    // nProcs). 0=balance always.
    maxLoadUnbalance 0.10;


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



    // 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 "F1.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
    {
        F1
        {
            // Surface-wise min and max refinement level
            level (6 6);

            // Optional specification of patch type (default is wall). No
            // constraint types (cyclic, symmetry) etc. are allowed.
            patchInfo
            {
                type wall;
                inGroups (F1Group);
            }
        }
    }

    // Resolve sharp angles
    resolveFeatureAngle 180;


    // 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
    {
        refinementBox
        {
            mode inside;
            levels ((1E15 8));
        }
    }


    // 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.
    locationInMesh (2 3 0);


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

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

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

    // Feature snapping

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

        //- 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
    {
        "(lowerWall|F1).*"
        {
            nSurfaceLayers 1;
        }
    }

    // Expansion factor for layer mesh
    expansionRatio 1.0;

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

    // Minimum thickness of cell layer. If for any reason layer
    // cannot be above minThickness do not add layer.
    // Relative to undistorted size of cell outside layer.
    minThickness 0.1;

    // 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.
    // Note: changed(corrected) w.r.t 17x! (didn't do anything in 17x)
    nGrow 0;

    // Advanced settings

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

    // At non-patched sides allow mesh to slip if extrusion direction makes
    // angle larger than slipFeatureAngle.
    slipFeatureAngle 30;

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

    // Number of smoothing iterations of surface normals
    nSmoothSurfaceNormals 2;

    // 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
    // Note: changed(corrected) w.r.t 17x! 90 degrees corresponds to 130 in 17x.
    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;
}



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


    // Advanced

    //- Number of error distribution iterations
    nSmoothScale 5;
    //- 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;


// ************************************************************************* //
Attached Images
File Type: png F1_1.png (165.9 KB, 689 views)
File Type: jpg F1_close mesh.jpg (75.6 KB, 607 views)
File Type: jpg F1_close obj.jpg (70.0 KB, 601 views)
JD_Welch is offline   Reply With Quote

Old   November 10, 2017, 01:48
Default
  #2
Senior Member
 
Join Date: Nov 2010
Location: USA
Posts: 1,230
Rep Power: 20
me3840 is on a distinguished road
What does accurate mesh mean?

That obj file you have is not nearly refined enough to produce good results. You will see a lot of bumps in your pressure distributions no matter what mesh you apply with that input surface.

From the images the clear problem you have is not refining the surface enough. F1 wings have a lot of curvature and require a lot of refinement.
me3840 is offline   Reply With Quote

Old   November 13, 2017, 01:28
Default
  #3
New Member
 
JD Welch
Join Date: Jul 2017
Posts: 8
Rep Power: 5
JD_Welch is on a distinguished road
Thank you for the feedback. I have been trying to determine how to increase the refinement.

Accurate mesh = almost a direct representation/reproduction of the obj file.

You mentioned that I need to increase the refinement of the obj file. My issue is that I am not quite sure how to increase the refinement anymore. My only idea is to increase the refinement is to increase the resolution/number of cells of my initial blockMesh.

Is this a way to increase the refinement of my obj file? Maybe doubling the number of cells in each direction?

Again, thank you for the feedback and assistance.
JD_Welch is offline   Reply With Quote

Old   November 13, 2017, 02:40
Default
  #4
Senior Member
 
Join Date: Nov 2010
Location: USA
Posts: 1,230
Rep Power: 20
me3840 is on a distinguished road
An obj file is a discrete format; in other words it's a list of triangles. You cannot refine it in any easy manner. Blockmesh will not affect this in any way.

You need to go back to the analytic CAD format and export a new obj with a finer resolution to get a finer surface.
me3840 is offline   Reply With Quote

Old   November 16, 2017, 01:19
Default
  #5
New Member
 
JD Welch
Join Date: Jul 2017
Posts: 8
Rep Power: 5
JD_Welch is on a distinguished road
Increasing the resolution of my OBJ file to increase the resolution of my SHM does make sense.

I am still confused about why I cannot create an SHM STL that is a replica of the OBJ. The original OBJ is 53 MB and to increase the resolution seems like creating an unreasonably large file. Should I use an STL file format instead of OBJ to decrease the file size, since there are no textures?

What would you recommend as export settings to use with OpenFoam?

Again, thank you for your time and guidance.
JD_Welch is offline   Reply With Quote

Old   November 16, 2017, 03:37
Default
  #6
Senior Member
 
Join Date: Nov 2010
Location: USA
Posts: 1,230
Rep Power: 20
me3840 is on a distinguished road
You're using a lot of terms here that don't make a lot of sense to me.

I'm not sure what you mean by "SHM STL". snappyHexMesh makes volume meshes, not STL meshes. If you mean "can snappyHexMesh produce a surface during volume meshing that is close to the input surface mesh" then of course the answer is yes, this just requires a lot of refinement on the surface using snappy's surface refinement features. But snappy cannot refine the geometry of an input mesh. If I input an octagon into snappy no amount of refinement will yield me a circle.

53MB is pretty small, especially for a geometry as complex as this that has a lot of curvature. I would fully expect a finely-resolved surface mesh of an F1 car to be measured in gigabytes or more. Now remember you only need enough resolution to be slightly finer than the volume mesh resolution you want (or can afford). So that's the export level you should choose.

If you're worried about a 53MB file then you're really going to need more storage, large aerodynamics cases can easily be 50-100GB just for steady runs.
konangsh and JD_Welch like this.
me3840 is offline   Reply With Quote

Old   November 16, 2017, 17:47
Default
  #7
New Member
 
JD Welch
Join Date: Jul 2017
Posts: 8
Rep Power: 5
JD_Welch is on a distinguished road
I am sorry about using terms that do not make sense to you. I am still learning the appropriate language to use in this context (CFD).

Your explanation of how snappyHexMesh creates a volume mesh makes more sense to me now. It is making a void that is a representation of the initial geometry. Your example of an octagon not being able to become a circle is understood. The resolution of the volume mesh is limited by the input file.

You mention that you snappyHexMesh can produce a surface mesh that is close to the input file, depending on the surface refinement settings. I had provided pictures of my input file, and the volume mesh and they are similar but not high enough resolution. When switching between the 2nd and 3rd picture, you can see the difference between the input OBj file and the volume mesh. Does it look like this because the triangles are so large in my initial file? Or is it from my surface refinement settings?

What would I have to change in my surface refinement settings (snappyHexMesh code listed above) to have the input file and volume mesh be identical? Or will that never happen because my initial file is not high enough resolution?

Knowing that 53 MB is small is good to know. Most of the files I have ever worked with have been smaller than this; even the tutorial files are smaller than 50 MB. Is there any other file format that to use other than an OBJ or STL as my initial file? Like a STEP/STP, IGS, or BREP.

Again, thank you for all the feedback. I was only able to learn so much on my own, and that level of understanding got me so far in understanding the learning material, obviously.
JD_Welch is offline   Reply With Quote

Old   November 16, 2017, 20:03
Default
  #8
Senior Member
 
Join Date: Nov 2010
Location: USA
Posts: 1,230
Rep Power: 20
me3840 is on a distinguished road
Your mesh does not look like the OBJ because the mesh in snappy is not fine enough yes. If you refine it more, you will get something similar to the OBJ surface.

I'm just saying that's not really going to be a useful exercise because the OBJ itself is too coarse. You'll get a mesh out of it, yeah, but the result from that mesh will be useless for modeling the physics.

snappy will only take input discrete formats; STL, OBJ, etc. It cannot resolve analytic CAD geometry like STEP/IGS. This is why having the initial surface being high quality is so critical to the final result.

I know stuff like this is hard to get elsewhere, that's why I'm answering you
me3840 is offline   Reply With Quote

Old   November 17, 2017, 01:28
Default
  #9
New Member
 
JD Welch
Join Date: Jul 2017
Posts: 8
Rep Power: 5
JD_Welch is on a distinguished road
Thank you so much for this feedback.

I took a look at the OpenFOAM snappyHexMesh documentation and am not sure how to increase refine the snappy mesh. The picture I originally included was my best attempt at increasing the refinement.

Is there any chance you can give me some suggestions on how to increase the refinement of my snappy mesh?

If I can get a more refined stl file, I will see how the new snappy mesh comes out.

I am using this F1 model and will try and export it at a higher refinement and hopefully will get a more refined snappy mesh.
JD_Welch is offline   Reply With Quote

Old   November 17, 2017, 01:46
Default
  #10
Senior Member
 
Join Date: Nov 2010
Location: USA
Posts: 1,230
Rep Power: 20
me3840 is on a distinguished road
Ah, luckily you have the solidworks model there, so you should be able to export the STL with any resolution you wish if you have solidworks.

There are several mechanisms to refine anything in snappy:
1. Refining the background mesh (blockMesh). Generally very expensive because it refines everything. Use this as a last resort.

2. Refining the mesh in a volume using refinementRegions. Useful for resolving wakes and getting control into a volume. Looks like you have one of these, but this is not the first place to go for refining a surface.

3. Refining the mesh using a feature curve. Great for resolving things that are very small features, i.e. gurney flaps and trailing edges.

4. Refining the surface using refinementSurfaces. You are already using this above, you have it set to 6 levels. I would recommend you split the STL up into many surfaces and apply different resolutions to them. You will need a lot more refinement on, say, the front wing than you would the floor or body. This is your primary weapon for refinement.
keitaro7_14, altinel, YUGU and 2 others like this.
me3840 is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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] snappyHexMesh can't create a fine Mesh from stl from Rhinoceros Taghi OpenFOAM Meshing & Mesh Conversion 13 May 4, 2017 16:48
[snappyHexMesh] SnappyHexMesh .stl Jochem OpenFOAM Meshing & Mesh Conversion 10 September 23, 2016 05:26
[snappyHexMesh] No layers in a small gap bobburnquist OpenFOAM Meshing & Mesh Conversion 6 August 26, 2015 10:38
[ANSYS Meshing] Creating a region of fine mesh within 3D fluid domain raven ANSYS Meshing & Geometry 1 August 13, 2014 12:11
How to control Minximum mesh space? hung FLUENT 7 April 18, 2005 10:38


All times are GMT -4. The time now is 17:20.