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

[snappyHexMesh] Bad stl surface fitting

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By asltpo

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 24, 2023, 15:05
Default Bad stl surface fitting
  #1
DGT
New Member
 
Damien
Join Date: Jul 2012
Posts: 4
Rep Power: 14
DGT is on a distinguished road
Good evening,


I am new with snappyHexMesh and currently trying to mesh a square beam.
I am facing problem as can be seen on the picture : there are some steps in the mesh
(the red square is the stl geometry).

Previously, I already tried to mesh the same square but with no angle of attack and it was fine.


I tried to increase the resolution which led me to huge mesh, played with the angle, but nothing seems to work.

If someone knows how to solve my problem, it would be great.


Thank you for your help,


Damien





Code:
/*--------------------------------*- 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       false;


geometry
{
    Beam_5deg_mesh.stl     {type triSurfaceMesh; name Beam1;
                   regions  {solid  {name Beam1;}}
                  }
}


castellatedMeshControls
{
 
    maxLocalCells 1000000;
    maxGlobalCells 20000000;
    minRefinementCells 20;
    maxLoadUnbalance 0.10;
    nCellsBetweenLevels 1;
    features (
               {file "Beam_5deg_mesh.eMesh"; level 9;}
    );
    resolveFeatureAngle 4;
    featureAngle 4;
    locationInMesh (1.0001 1.0001 6.43);
    allowFreeStandingZoneFaces true;

    refinementSurfaces
    {
        Beam1
        {
            // Surface-wise min and max refinement level
            level (6 10);

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


snapControls
{   
    nSmoothPatch 10;
    tolerance 0.10;
    nSolveIter 300;
    nRelaxIter 5;
    nFeatureSnapIter 30;
    implicitFeatureSnap false;
    explicitFeatureSnap true;
    multiRegionFeatureSnap false;
}
addLayersControls
{
    relativeSizes false;
    expansionRatio 1.2;
    firstLayerThickness 0.001;
    minThickness 0.0005;
    nGrow 0;
    featureAngle 30;
    slipFeatureAngle 30;
    nRelaxIter 5;
    nSmoothSurfaceNormals 1;
    nSmoothNormals 3;
    nSmoothThickness 10;
    maxFaceThicknessRatio 0.5;
    maxThicknessToMedialRatio 0.3;
    minMedialAxisAngle 90;
    nBufferCellsNoExtrude 0;
    nLayerIter 15;
    layers
    {
        "Beam1"
        {
            nSurfaceLayers 3;
        }
    }
}  

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;


// ************************************************************************* //
beam.jpg
DGT is offline   Reply With Quote

Old   February 28, 2023, 18:54
Default
  #2
New Member
 
Tom
Join Date: Jan 2023
Posts: 4
Rep Power: 3
asltpo is on a distinguished road
Hi Damian,

Firstly a caveat: I'm also fairly new to SHM so not speaking from vast experience.

It looks like you have an issue with the "snapping" stage of the process, because your Beam1 boundary appears castellated suggesting it has not snapped accurately (or at all) to the stl.

According to the user guide:

Quote:
The snapping phase attempts to adapt the castellated mesh to conform to the input geometry. These controls are located in the snapControls sub-dictionary.

Snapping involves projecting and morphing the mesh to, e.g. the surfaces and features, in an iterative process. If the adaptations invalidate the mesh quality criteria the step is undone and replayed using modified parameters. The sequence ensures that the resulting mesh achieves a minimum quality, at the expense of full geometry conformation.

The good practice is to start with the default values and adjust them only after inspecting the mesh.

The parameters need to be set for snapping onto the surfaces and features separately.

The algorithm first smooth the mesh on the patches and in the volume. Then, in the morphing stage displace the vertexes towards the surface. Only those vertexes are attracted to the surface which are located in the region defined by the local edge length multiplied by the tolerance entry from the snapControls dictionary (by default set to 2).

If the mesh quality is violated, vertices are moved back in a given fraction of the step (keyword errorReduction in the snappyHexMeshDict.meshQualityControls dictionary). After mesh quality check the next attempt to move the point towards the geometry takes place. This process is repeated until the maximum number of iterations is reached. Each step is reversible.

After the successful snapping or running out of iterations mesh is cleaned from unnecessary non-orthogonal planar faces.
So, assuming that SHM definitely did attempt to snap (and this should be evident from the log file), it's possible that your mesh quality criteria are too strict to allow the boundary nodes in the castellated mesh to move onto the surface. I guess this would be more likely to crop up when your beam has non-zero angle of attack because that will tend to create triangular cells at the surface which are inherently lower in quality.

So you could try relaxing the mesh quality criteria in meshQualityDict to see if this improves snapping.

An alternative approach might be to rotate the background mesh by the angle of attack so it is aligned with your beam, then rotate the final mesh back again afterwards.

Hope this helps.
lourencosm likes this.
asltpo is online now   Reply With Quote

Old   March 1, 2023, 02:35
Default
  #3
DGT
New Member
 
Damien
Join Date: Jul 2012
Posts: 4
Rep Power: 14
DGT is on a distinguished road
Hello Tom,


Thank you for your answer.
I'm sorry but the snappy is not as bad as I showed on the picture : it was just a matter of time step in paraview !
I'm facing some other problems now and trying to solve them.


Thank you for your help.


Damien
DGT 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
[Gmsh] gmshToFoam generates patches with 0 faces and 0 points Simurgh OpenFOAM Meshing & Mesh Conversion 4 August 25, 2023 08:58
SU2 7.0.7 Built on CentOS 7, parallel computation pyscript mpi exit error? EternalSeekerX SU2 3 October 9, 2020 19:28
[mesh manipulation] extrudeMesh from STL Surface TRT OpenFOAM Meshing & Mesh Conversion 1 March 26, 2018 08:15
Immersed mesh - STL surface intersection tool arvind3008 Main CFD Forum 0 October 17, 2012 06:51
Problems of Duns Codes! Martin J Main CFD Forum 8 August 15, 2003 00:19


All times are GMT -4. The time now is 13:52.