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] Cylindrical blockmesh to Improve snappyHexMesh Results (https://www.cfd-online.com/Forums/openfoam-meshing/160812-cylindrical-blockmesh-improve-snappyhexmesh-results.html)

nicholas.jones October 13, 2015 18:51

Cylindrical blockmesh to Improve snappyHexMesh Results
 
2 Attachment(s)
All,

I have been trying to use a cylindrical blockMesh to improve my snappyHexMesh results. An example blockMesh is attached. I find that coarse simple blockMeshes results in holes when two surfaces of my .stl files become close together (also attached). I can use a finer blockMesh, but I get very large meshes as a result. I am hoping there is a more elegant solution!

Although the initial blockMesh looks good, I receive an error from snappyHexMesh, citing the following:
Quote:

Shell refinement iteration 0
----------------------------

Marked for refinement due to distance to explicit features : 0 cells.
Marked for refinement due to refinement shells : 0 cells.


--> FOAM FATAL ERROR:
Illegal maxFaceDiff 0
Value should be >= 1

From function hexRef8::consistentSlowRefinement(const label, const labelList&, const labelList&, const label, const labelList&)
in file polyTopoChange/polyTopoChange/hexRef8.C at line 2370.

FOAM exiting
Google has very few illegal maxFaceDif 0 errors, so im hoping someone here might have an idea.

Should I persue this strategy to improve my snappyHexMeshes, or am I better off sticking with a simple blockMesh?

The code I use to generate cylindrical meshes is below (thanks to the folks at CFD-Online back in 2006, this code is excellent!):

Quote:

/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.3.0 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
changecom(//)changequote([,])
define(calc, [esyscmd(perl -e 'printf ($1)')])
define(VCOUNT, 0)
define(vlabel, [[// ]Vertex $1 = VCOUNT define($1, VCOUNT)define([VCOUNT], incr(VCOUNT))])


convertToMeters 0.00001;

define(D, 6693) //6.693 mm column diameter
define(L, 30000) //30 cm length
define(PI, 3.14159265)

define(R, calc(D/2))
define(CW, calc(D/4)) //Width of middle square section

define(CX, calc(R*cos((PI/180)*45)))
define(CZ, calc(R*sin((PI/180)*45)))

define(NPS, 10) //how many cells in the square section
define(NPD, 15) //how many cells from square section to perimeter
define(NPY, 15) // how many cells from top to bottom

vertices
(
( CW 0.0 CW) vlabel(fiveoclocksqb)
(-CW 0.0 CW) vlabel(sevenoclocksqb)
(-CW 0.0 -CW) vlabel(elevenoclocksqb)
( CW 0.0 -CW) vlabel(oneoclocksqb)

( CX 0.0 CZ) vlabel(fiveoclockcb)
(-CX 0.0 CZ) vlabel(sevenoclockcb)
(-CX 0.0 -CZ) vlabel(elevenoclockcb)
( CX 0.0 -CZ) vlabel(oneoclockcb)

( CW L CW) vlabel(fiveoclocksqt)
(-CW L CW) vlabel(sevenoclocksqt)
(-CW L -CW) vlabel(elevenoclocksqt)
( CW L -CW) vlabel(oneoclocksqt)

( CX L CZ) vlabel(fiveoclockct)
(-CX L CZ) vlabel(sevenoclockct)
(-CX L -CZ) vlabel(elevenoclockct)
( CX L -CZ) vlabel(oneoclockct)
);

blocks
(
//square block
hex (
sevenoclocksqb fiveoclocksqb oneoclocksqb elevenoclocksqb
sevenoclocksqt fiveoclocksqt oneoclocksqt elevenoclocksqt
)
(NPS NPS NPY)
simpleGrading (1 1 1)

//slice1
hex (
sevenoclockcb fiveoclockcb fiveoclocksqb sevenoclocksqb
sevenoclockct fiveoclockct fiveoclocksqt sevenoclocksqt
)
(NPS NPD NPY)
simpleGrading (1 1 1)

//slice2
hex (
sevenoclocksqb elevenoclocksqb elevenoclockcb sevenoclockcb
sevenoclocksqt elevenoclocksqt elevenoclockct sevenoclockct
)
(NPS NPD NPY)
simpleGrading (1 1 1)

//slice3
hex (
elevenoclocksqb oneoclocksqb oneoclockcb elevenoclockcb
elevenoclocksqt oneoclocksqt oneoclockct elevenoclockct
)
(NPS NPD NPY)
simpleGrading (1 1 1)

//slice4
hex (
oneoclocksqb fiveoclocksqb fiveoclockcb oneoclockcb
oneoclocksqt fiveoclocksqt fiveoclockct oneoclockct
)
(NPS NPD NPY)
simpleGrading (1 1 1)

);


//create the quarter circles
edges
(
arc fiveoclockcb sevenoclockcb (0.0 0.0 R)
arc sevenoclockcb elevenoclockcb (-R 0.0 0.0)
arc elevenoclockcb oneoclockcb (0.0 0.0 -R)
arc oneoclockcb fiveoclockcb (R 0.0 0.0)

arc fiveoclockct sevenoclockct (0.0 L R)
arc sevenoclockct elevenoclockct (-R L 0.0)
arc elevenoclockct oneoclockct (0.0 L -R)
arc oneoclockct fiveoclockct (R L 0.0)

);

boundary
(
Inlet
{
type patch;
faces
(
(fiveoclocksqb oneoclocksqb elevenoclocksqb sevenoclocksqb)
(fiveoclocksqb fiveoclockcb oneoclockcb oneoclocksqb)
(fiveoclockcb fiveoclocksqb sevenoclocksqb sevenoclockcb)
(sevenoclocksqb elevenoclocksqb elevenoclockcb sevenoclockcb)
(oneoclocksqb oneoclockcb elevenoclockcb elevenoclocksqb)
);
}

Outlet
{
type patch;
faces
(
(fiveoclocksqt oneoclocksqt elevenoclocksqt sevenoclocksqt)
(fiveoclocksqt fiveoclockct oneoclockct oneoclocksqt)
(fiveoclockct fiveoclocksqt sevenoclocksqt sevenoclockct)
(sevenoclocksqt elevenoclocksqt elevenoclockct sevenoclockct)
(oneoclocksqt oneoclockct elevenoclockct elevenoclocksqt)
);
}

Walls
{
type wall;
faces
(
(sevenoclockcb fiveoclockcb fiveoclockct sevenoclockct)
(sevenoclockcb sevenoclockct elevenoclockct elevenoclockcb)
(elevenoclockcb elevenoclockct oneoclockct oneoclockcb)
(oneoclockcb oneoclockct fiveoclockct fiveoclockcb)
);
}

);

mergePatchPairs
(
);
snappyHexMeshDict is attached:

Quote:

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

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

castellatedMesh true;
snap true;
addLayers false;

geometry
{
Balls.stl {type triSurfaceMesh; name Balls;}
};

castellatedMeshControls
{

maxLocalCells 10000000;
maxGlobalCells 70000000;
minRefinementCells 10;
nCellsBetweenLevels 0;



features
(
// {file "Inlet.eMesh"; level 2;}
// {file "Outlet.eMesh"; level 2;}
// {file "Balls.eMesh"; level 2;}
// {file "Walls.eMesh"; level 2;}
);

refinementSurfaces
{
Balls {level (1 2);}
}

resolveFeatureAngle 30;

refinementRegions
{
//refinementBox
//{
// mode inside;
// levels ((1E15 4));
//}
}


locationInMesh (0.01519 0.00008 0.18982);

allowFreeStandingZoneFaces true;
}



snapControls
{

nSmoothPatch 3;
tolerance 1;
nSolveIter 30;
nRelaxIter 5;

//- Highly experimental and wip: number of feature edge snapping
// iterations. Leave out altogether to disable.
// Of limited use in this case since faceZone faces not handled.
//nFeatureSnapIter 10;

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

//- Use castellatedMeshControls::features
explicitFeatureSnap false;

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

}


addLayersControls
{
relativeSizes true;

// Per final patch (so not geometry!) the layer information
layers
{
"Balls"
{
nSurfaceLayers 40;
}
}

// Expansion factor for layer mesh
expansionRatio 1.05;

// 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.
finalLayerThickness 0.1;

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

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

// Advanced settings

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

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

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

// Stop layer growth on highly warped cells
maxFaceThicknessRatio 1;

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

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

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



meshQualityControls
{
#include "meshQualityDict"

relaxed
{
maxNonOrtho 75;
}

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

mergeTolerance 1E-6;


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

nicholas.jones October 14, 2015 14:10

All,

The error was originating from the snappyHexMeshDict. The cylindrical blockMeshDict m4 is helpful in improving my mesh, any may be a more effective solution for this kind of problem.

Tscar January 2, 2018 13:14

May I ask how exactly did you solve this issue?

kandelabr May 16, 2019 09:52

nCellsBetweenLevels 0;

that's how, don't ask me how i know that :rolleyes:


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