CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Meshing & Mesh Conversion (https://www.cfd-online.com/Forums/openfoam-meshing/)
-   -   [snappyHexMesh] Mesh does not snap to geometry (https://www.cfd-online.com/Forums/openfoam-meshing/220641-mesh-does-not-snap-geometry.html)

OskarT September 16, 2019 04:27

Mesh does not snap to geometry
 
I am trying to setup do aerodynamics simulation of a car using symmetry. I've exported the car as STL file from freecad.


I've used blockMesh together with snappyHexMesh but got no snapping at all as seen below.

You can see the images here: https://drive.google.com/drive/folde...Z4?usp=sharing


blockMesh
Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  v1906                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.com                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    object      blockMeshDict;
}

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

scale  1;

vertices
(
    (-4 -0.5 -2) // 0
    (11 -0.5 -2) // 1
    (11  3 -2) // 2
    (-4  3 -2) // 3
    (-4 -0.5 0) // 4
    (11 -0.5 0) // 5
    (11  3 0) // 6
    (-4  3 0) // 7

);

blocks
(
    hex (0 1 2 3 4 5 6 7) (120 30 20) simpleGrading (1 1 1)
);

edges
(
);

boundary
(
    Sym
    {
        type symmetryPlane;
        faces
        (
            (4 5 6 7)
        );
    }
    backPanel
    {
        type symmetryPlane;
        faces
        (
            (3 2 1 0)
        );
    }
    Inlet
    {
        type patch;
        faces
        (
            (4 7 3 0)
        );
    }
    Outlet
    {
        type patch;
        faces
        (
            (1 2 6 5)
        );
    }
    Ground
    {
        type wall;
        faces
        (
            (0 1 5 4)
        );
    }
    Top
    {
        type symmetryPlane;
        faces
        (
            (3 7 6 2)
        );
    }
);


// ************************************************************************* //

snappyHexMesh

Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  v1906                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.com                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    object      snappyHexMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#includeEtc "caseDicts/mesh/generation/snappyHexMeshDict.cfg"
// Which of the steps to run
castellatedMesh true;
snap            true;
addLayers      false;


// 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
{
    Car
    {
        type triSurfaceMesh;
        file "Car.stl";
    }
};


// Settings for the castellatedMesh generation.
castellatedMeshControls
{
        // Specifies a level for any cell intersected by its edges.
    // This is a featureEdgeMesh, read from constant/triSurface for now.
    features
    (
//      { file "CAD.eMesh"; level 1; }
    );



    // 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
    {
        Car
        {
            // Surface-wise min and max refinement level
            level (3 3);
        }
    }
        resolveFeatureAngle 10;
            refinementRegions
    {
                refinementBoxA
        {
            mode inside;
            levels ((1 1)); //Le 1 n'a aucune influence pour une box //------1
        }
    }
    locationInMesh (0 0.1 -0.1); // Offset from (0 0 0) to avoid coinciding with face or edge
                                                                       
        maxLocalCells 1500000;
    maxGlobalCells 2000000;
        minRefinementCells 10;
    nCellsBetweenLevels 6;

}



// Settings for the snapping.
snapControls
{
    nSmoothPatch 3;
    tolerance 4;
    nSolveIter 100;
    nRelaxIter 5;
}




// Settings for the layer addition.
addLayersControls
{
    layers
    {
        "Car.*"
        {
            nSurfaceLayers 6;
        }
        bottom
        {
            nSurfaceLayers 6;
        }
    }

    relativeSizes      false; // false, usually with firstLayerThickness
    expansionRatio      1.2;
//    finalLayerThickness 0.5;
    minThickness        1e-3;
    firstLayerThickness 0.01;

//  maxThicknessToMedialRatio 0.6;
}




// Generic mesh quality settings. At any undoable phase these determine
// where to undo.
meshQualityControls
{
    minTetQuality -1e+30;
}

/*writeFlags
(
//    scalarLevels
    layerSets
    layerFields
); */

mergeTolerance 1e-6;

// ************************************************************************* //

Any ideas on how to fix this?

simrego September 16, 2019 04:55

Hi!

What was the command for snappyHexMesh?
You may missed the -overwrite switch, so you will find your snapped mesh at the second time step.
Also that tolerance is a bit high, you can use the "default" 2.

And as i see you have no feature snapping.
Try to put this into the snapControls:
implicitFeatureSnap true;
explicitFeatureSnap false;

Or:
implicitFeatureSnap false;
explicitFeatureSnap true;

But you will need the edge mesh for this what you are commented in the castellatedMeshControls. This is the default setup, so you can simply uncomment the features without adding these lines.


Maybe this won't solve your problem but you will need it to capture the features.

OskarT September 16, 2019 05:14

Boy do I feel stupid, haha!

It was hiding in the second time step. "snappyHexMesh -overwrite" solved my problem!

I also changed the tolerance down to 2 and opt for the implicit snapping feature but these was not the solution to my problem, my command was.

Thank you! :)


All times are GMT -4. The time now is 11:56.