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] Add layer function in snappyHexMesh (https://www.cfd-online.com/Forums/openfoam-meshing/158571-add-layer-function-snappyhexmesh.html)

Gerrit August 28, 2015 14:57

Add layer function in snappyHexMesh
 
1 Attachment(s)
Hi,

I am trying to prepare for a bigger project about a CFD simulation of an heat exchanger. Therefore I practice all the functions and stuff I would like to do with a simple pipe.
The meshing for the pipe without the layer works without problems.
As far as I understood snappy needs another .stl file where the layer starts..
So I inserted one (Picture).
Now it does not work and the error message is quite strange:
Code:

/*---------------------------------------------------------------------------*\| =========                |                                                || \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          ||  \\    /  O peration    | Version:  2.4.0                                ||  \\  /    A nd          | Web:      www.OpenFOAM.org                      ||    \\/    M anipulation  |                                                |\*---------------------------------------------------------------------------*/Build  : 2.4.0-f0842aea0e77Exec  : snappyHexMesh -overwriteDate  : Aug 28 2015Time  : 20:51:38Host  : "gerrit-HP-Pavilion-dv7-Notebook-PC"PID    : 4636Case  : /home/gerrit/OpenFOAM/gerrit-2.4.0/Own/incompressible/pipe_simple_foamnProcs : 1sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).fileModificationChecking : Monitoring run-time modified files using timeStampMasterallowSystemOperations : Allowing user-supplied system call operations// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //Create timeCreate mesh for time = 0Read mesh in = 0.02 s--> FOAM FATAL IO ERROR: "ill defined primitiveEntry starting at keyword 'nSurfaceLayers' on line 97 and ending at line 158"file: /home/gerrit/OpenFOAM/gerrit-2.4.0/Own/incompressible/pipe_simple_foam/system/snappyHexMeshDict at line 158.    From function primitiveEntry::readEntry(const dictionary&, Istream&)    in file lnInclude/IOerror.C at line 132.FOAM exiting

In a tutorial I saw once, that in the snappyHexMeshDict the layer.stl has as well an eMesh file. In my case it does not, although it is defined in the surfaceFeatureExtractDict file.

Is the eMesh necessary? And if so, how should it get that?

Thanks a lot!



Gerrit

me3840 September 27, 2015 23:09

This error message looks like you have a syntax error in your snappyHexMeshDict. Can you post it?

SHM does not require another STL outlining the location of the layer; the layer itself is automatically generated. You only need the geometry of your actual simulation object or domain, and a blockMesh grid.

the surfaceFeatureExtractDict is used with the surfaceFeatureExtract utility to try and recover more edges and align the snaps to them well. You can use this prior to SHM if you would like.

Gerrit September 28, 2015 05:18

Hi,

thank you for your reply. I could solve my problem manly on my own. Instead of using the addLayersControls, I used refinementRegions which was what I searched for from the beginning. My aim was only to have a more fine mesh at the walls. As far as I understood the refinementRegions is the easier way to go for this, isn't it?

What pros does the addLayersControl offer, compared to the refinementRegions?

Thanks!

me3840 September 28, 2015 12:02

Well addLayersControl and refinementRegions don't really do the same thing. refinementRegions is useful for bulk refinement of the core mesh away or near the wall. addLayersControl is useful for resolving near-wall gradients. These are apples-to-oranges and often can complement each other, but never replace each other.

Gerrit September 28, 2015 12:30

Ok, that sound interesting :-)

I just attach a short version of my snappyHexMeshDict.
As you can easily see, I do not really use the addLayersControl until now, but I am always open for new.

The patch "lights" referees to something like a pipe in the flow, where it would be nice to have a fine mesh around it.

Would that be simply the following?
Code:

layers
  {
    lights
      {
          nSurfaceLayers 1;
      }
  }

Code:


/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  2.2.0                                |
|  \\  /    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;    // make basic mesh ?
snap            true;    // decide to snap back to surface ?
addLayers      false;  // decide to add viscous layers ?


geometry // Load in STL files here
{
    inlet_inlet_scaled.stl {type triSurfaceMesh; name inlet_scale;}
    outlet_outlet_scaled.stl {type triSurfaceMesh; name outlet_scale;}   
    wall_pipe_scaled.stl    {type triSurfaceMesh; name pipe;}
    wall_lights_scale.stl    {type triSurfaceMesh; name lights;}
   
};

castellatedMeshControls
{
    maxLocalCells 1000000;  //max cells per CPU core
    maxGlobalCells 2000000; //max cells to use before mesh deletion step
    minRefinementCells 10;  //was 0 - zero means no bad cells are allowed during refinement stages
    maxLoadUnbalance 0.10;
    nCellsBetweenLevels 1;  // expansion factor between each high & low refinement zone

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

    features // taken from STL from each .eMesh file created by "SurfaceFeatureExtract" command
    (
        {file "inlet_inlet_scaled.eMesh"; level 3;}
    {file "outlet_outlet_scaled.eMesh"; level 3;}
    {file "wall_pipe_scaled.eMesh"; level 3;}
    {file "wall_lights_scale.eMesh"; level 3;}
   
    );

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

    refinementSurfaces // Surface-wise min and max refinement level
    {
    inlet_scale{level (0 0);}
          outlet_scale{level (0 0);}
    pipe{level (2 4);}
    lights{level (2 4);}
   
    } 


    resolveFeatureAngle 95;  // Resolve sharp angles // Default 30
    refinementRegions        // In descending levels of fine-ness
    {
        pipe    {
            mode distance;
            levels ((0.001 5));
            }

       
        lights
            {
            mode distance;
            levels ((0.001 5));
            }

      }
locationInMesh (0 0.08 -0.7);  //to decide which side of mesh to keep **
  allowFreeStandingZoneFaces true;
}


// Settings for the snapping.
snapControls
{
    nSmoothPatch 4;
    tolerance 4.0;
    nSolveIter 30;
    nRelaxIter 5;
    nFeatureSnapIter 15; // default is 10
   
// New settings from openfoam 2.2 onwards for SHMesh

implicitFeatureSnap false; // default is false - detects without doing surfaceFeatureExtract
explicitFeatureSnap true; // default is true
multiRegionFeatureSnap false; // deafault is false - detects features between multiple surfaces

}



// Settings for the layer addition.
addLayersControls //add the PATCH names from inside the STL file so STLpatchName_insideSTLName
{
    relativeSizes false; // was true
    layers
    {
    //visc_main
  //          {nSurfaceLayers 3;} // was 3
    //visc_refine_1
//        {nSurfaceLayers 3;} // was 3
//    visc_refine_2
//        {nSurfaceLayers 3;} // was 3
    }

    expansionRatio 1.3;
    finalLayerThickness 0.00016; //was 0.00016
    minThickness 0.00008; //was 0.00008
    nGrow 0; // was 1


    // Advanced settings

    featureAngle 80; // was 70 //- When not to extrude surface. 0 is flat, 90 is right angle.
    nRelaxIter 3;  //- Max# of snapping relaxation iter. Should stop before upon reaching a correct mesh.
    nSmoothSurfaceNormals 1;  // Number of smoothing iterations of surface normals
    nSmoothNormals 3; // Number of smoothing iterations of interior mesh movement direction
    nSmoothThickness 10;  // Smooth layer thickness over surface patches
    maxFaceThicknessRatio 0.5; // Stop layer growth on highly warped cells
    maxThicknessToMedialRatio 0.3; // Reduce layer growth where ratio thickness to medial distance is large
    minMedianAxisAngle 130;  // Angle used to pick up medial axis points
    nBufferCellsNoExtrude 0;  // Create buffer region for new layer terminations
    nLayerIter 50; // Overall max number of layer addition iterations
}



// Generic mesh quality settings. At any undoable phase these determine
// where to undo.
meshQualityControls
{
    maxNonOrtho 65;
    maxBoundarySkewness 20;
    maxInternalSkewness 4;
    maxConcave 80;
    minFlatness 0.5;
    minVol 1e-13;
    minTetQuality 1e-9;
    minArea -1;
    minTwist 0.02;    //0.05
    minDeterminant 0.001;
    minFaceWeight 0.02;
    minVolRatio 0.01;
    minTriangleTwist -1;

    // Advanced

    nSmoothScale 4;
    errorReduction 0.75;
}

// Advanced

debug 0;


// Merge tolerance. Is fraction of overall bounding box of initial mesh.
// Note: the write tolerance needs to be higher than this.
mergeTolerance 1E-6;


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

By the way, the original file comes from a tutorial - I left the comments so I always knew more or less what I am supposed to do!

Thanks!


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