ENH: snappyHexMesh: add buffer layers before snapping

This commit is contained in:
Mattijs Janssens
2024-12-12 16:13:32 +00:00
parent e7cf8a1d59
commit de5d34787c
231 changed files with 46574 additions and 963 deletions

View File

@ -18,14 +18,14 @@ scale 1;
vertices
(
(-1 -1 -1)
( 2 -1 -1)
( 2 0 -1)
(-1 0 -1)
(-1 -1 1)
( 2 -1 1)
( 2 0 1)
(-1 0 1)
(-1 -0.8 -1)
( 2 -0.8 -1)
( 2 -0.2 -1)
(-1 -0.2 -1)
(-1 -0.8 1)
( 2 -0.8 1)
( 2 -0.2 1)
(-1 -0.2 1)
);
blocks
@ -44,14 +44,30 @@ boundary
type patch;
faces
(
(3 7 6 2)
(1 5 4 0) //back
(2 6 5 1) //outlet
(0 4 7 3) //inlet
(0 3 2 1) //lowerWall
(4 5 6 7) //upperWall
);
}
front
{
type symmetryPlane;
faces
(
(3 7 6 2)
);
}
back
{
type symmetryPlane;
faces
(
(1 5 4 0) //back
);
}
);

View File

@ -5,14 +5,14 @@
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object fvSchemes;
version 2;
format ascii;
class dictionary;
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
@ -20,6 +20,7 @@ ddtSchemes
gradSchemes
{
default Gauss linear;
}
divSchemes
@ -28,14 +29,17 @@ divSchemes
laplacianSchemes
{
default Gauss linear corrected;
}
interpolationSchemes
{
default linear;
}
snGradSchemes
{
default corrected;
}
wallDist

View File

@ -16,6 +16,13 @@ FoamFile
solvers
{
"cellDisplacement.*"
{
solver GAMG;
tolerance 1e-08;
relTol 0;
smoother GaussSeidel;
}
}

View File

@ -14,6 +14,11 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Type of mesh generation:
// - castellated (default)
// - castellatedBufferLayer
//type castellatedBufferLayer;
// Which of the steps to run
castellatedMesh true;
snap true;
@ -427,6 +432,31 @@ castellatedMeshControls
//nCellZoneErodeIter 2;
}
// Internal macro for mesh-motion solver to use
_meshMotionSolver
{
solver displacementPointSmoothing;
displacementPointSmoothingCoeffs
{
//// Use geometricElementTransform to maintain relative sizes
//pointSmoother geometricElementTransform;
//transformationParameter 0.667;
//nPointSmootherIter 10;
// Use laplacian to untangle problem areas
pointSmoother laplacian;
nPointSmootherIter 10;
//relaxationFactors (1.0 0.8 0.6 0.4 0.2 0.0);
//meshQuality
//{
// #includeEtc "caseDicts/meshQualityDict"
//}
}
}
// Settings for the snapping.
snapControls
{
@ -501,6 +531,10 @@ snapControls
//- Attract points only to the surface they originate from. Default
// false. This can improve snapping of intersecting surfaces.
strictRegionSnap true;
// Motion solver to use (when in castellatedBufferLayer)
${_meshMotionSolver}
}
// Settings for the layer addition.
@ -601,19 +635,27 @@ addLayersControls
// motion solvers. It needs specification of the solver to use and
// its control dictionary.
//meshShrinker displacementMotionSolver;
//solver displacementLaplacian;
//displacementLaplacianCoeffs
//solver multiDisplacement;
//solvers
//{
// diffusivity quadratic inverseDistance
// (
// sphere.stl_firstSolid
// maxY
// );
// displacementLaplacian
// {
// // Note that e.g. displacementLaplacian needs entries in
// // fvSchemes, fvSolution. Also specify a minIter > 1 when
// // solving
// // cellDisplacement since otherwise solution might not be
// // sufficiently accurate on points.
// solver displacementLaplacian;
// diffusivity quadratic inverseDistance
// (
// aerofoil
// );
// }
// displacementPointSmoothing
// {
// ${_meshMotionSolver}
// }
//}
// Note that e.g. displacementLaplacian needs entries in
// fvSchemes, fvSolution. Also specify a minIter > 1 when solving
// cellDisplacement since otherwise solution might not be sufficiently
// accurate on points.
// Medial axis analysis (for use with default displacementMedialAxis)

View File

@ -0,0 +1,10 @@
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions # Tutorial clean functions
#------------------------------------------------------------------------------
rm -rf constant/extendedFeatureEdgeMesh
rm -rf constant/triSurface/block.eMesh
cleanCase0
#------------------------------------------------------------------------------

View File

@ -0,0 +1,24 @@
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
#------------------------------------------------------------------------------
#mkdir -p constant/triSurface
#cp -f \
# "$FOAM_TUTORIALS"/resources/geometry/flange.stl.gz \
# constant/triSurface
runApplication blockMesh
runApplication surfaceFeatureExtract
runApplication snappyHexMesh
runApplication checkMesh -writeFields '(nonOrthoAngle)'
# Run parallel a bit as well
runApplication decomposePar
runParallel -s parallel snappyHexMesh
runParallel -s parallel checkMesh -writeFields '(nonOrthoAngle)'
#------------------------------------------------------------------------------

View File

@ -0,0 +1,2 @@
- rotated block inside regular blockMesh
- set up to add buffer layers after smoothing outside

View File

@ -0,0 +1,41 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1812 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object dynamicMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dynamicFvMesh dynamicMotionSolverFvMesh;
solver displacementPointSmoothing;
displacementPointSmoothingCoeffs
{
//// Use geometricElementTransform to maintain relative sizes
//pointSmoother geometricElementTransform;
//transformationParameter 0.667;
//nPointSmootherIter 10;
// Use laplacian to untangle problem areas
pointSmoother laplacian;
nPointSmootherIter 100;
//relaxationFactors (1.0 0.8 0.6 0.4 0.2 0.0);
//meshQuality
//{
// #includeEtc "caseDicts/meshQualityDict"
//}
}
// ************************************************************************* //

View File

@ -0,0 +1,21 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1812 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
nu 0.01;
// ************************************************************************* //

View File

@ -0,0 +1,38 @@
# Wavefront OBJ file written 2024-01-24T16:36:27
o block
# points : 8
# faces : 6
# zones : 6
# 0 maxY (nFaces: 1)
# 1 minX (nFaces: 1)
# 2 minZ (nFaces: 1)
# 3 maxX (nFaces: 1)
# 4 maxZ (nFaces: 1)
# 5 minY (nFaces: 1)
# <points count="8">
v 0 0 0
v -0.5773502691896258 -0.2113248654051871 0.7886751345948129
v -1.154700538379252 0.5773502691896258 0.5773502691896258
v -0.5773502691896258 0.7886751345948129 -0.2113248654051871
v 0.5773502691896258 0.5773502691896258 0.5773502691896258
v 0 1.366025403784439 0.3660254037844388
v -0.5773502691896258 1.154700538379252 1.154700538379252
v 0 0.3660254037844388 1.366025403784439
# </points>
# <faces count="6">
g maxY
f 4 3 7 6
g minX
f 1 2 3 4
g minZ
f 1 4 6 5
g maxX
f 5 6 7 8
g maxZ
f 2 8 7 3
g minY
f 1 5 8 2
# </faces>

View File

@ -0,0 +1,96 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1812 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
scale 1;
vertices
(
(-2 -1 -1)
( 1 -1 -1)
( 1 2 -1)
(-2 2 -1)
(-2 -1 2)
( 1 -1 2)
( 1 2 2)
(-2 2 2)
);
blocks
(
hex (0 1 2 3 4 5 6 7) (20 20 20) simpleGrading (1 1 1)
);
edges
(
);
boundary
(
minX
{
type wall;
faces
(
(0 4 7 3)
);
}
maxX
{
type wall;
faces
(
(2 6 5 1)
);
}
minY
{
type wall;
faces
(
(1 5 4 0)
);
}
maxY
{
type wall;
faces
(
(3 7 6 2)
);
}
minZ
{
type wall;
faces
(
(0 3 2 1)
);
}
maxZ
{
type wall;
faces
(
(4 5 6 7)
);
}
);
// ************************************************************************* //

View File

@ -0,0 +1,97 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1812 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
scale 1;
vertices
(
(0 0 0)
(1 0 0)
(1 1 0)
(0 1 0)
(0 0 1)
(1 0 1)
(1 1 1)
(0 1 1)
);
blocks
(
//hex (0 1 2 3 4 5 6 7) (20 20 10) simpleGrading (100 100 1)
hex (0 1 2 3 4 5 6 7) (1 1 1) simpleGrading (1 1 1)
);
edges
(
);
boundary
(
minX
{
type wall;
faces
(
(0 4 7 3)
);
}
maxX
{
type wall;
faces
(
(2 6 5 1)
);
}
minY
{
type wall;
faces
(
(1 5 4 0)
);
}
maxY
{
type wall;
faces
(
(3 7 6 2)
);
}
minZ
{
type wall;
faces
(
(0 3 2 1)
);
}
maxZ
{
type wall;
faces
(
(4 5 6 7)
);
}
);
// ************************************************************************* //

View File

@ -0,0 +1,49 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1812 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application snappyHexMesh;
startFrom startTime;
startTime 0;
stopAt writeNow;
endTime 30;
deltaT 1;
writeControl timeStep;
writeInterval 1;
purgeWrite 0;
writeFormat ascii;
writePrecision 16;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //

View File

@ -0,0 +1,24 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1806 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
note "mesh decomposition control dictionary";
object decomposeParDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- The total number of domains (mandatory)
numberOfSubdomains 5;
//- The decomposition method (mandatory)
method scotch; //random;
// ************************************************************************* //

View File

@ -0,0 +1,59 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1812 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//geometry
//{
// type highAspectRatio;
// minAspect 0;
// maxAspect 0;
//}
ddtSchemes
{
default Euler;
}
gradSchemes
{
default Gauss linear;
grad(p) Gauss linear;
}
divSchemes
{
default none;
div(phi,U) Gauss linear;
}
laplacianSchemes
{
default Gauss linear orthogonal;
}
interpolationSchemes
{
default linear;
}
snGradSchemes
{
default orthogonal;
}
// ************************************************************************* //

View File

@ -0,0 +1,52 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1812 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
solvers
{
p
{
solver PCG;
preconditioner DIC;
tolerance 1e-06;
relTol 0.05;
}
pFinal
{
$p;
relTol 0;
}
U
{
solver smoothSolver;
smoother symGaussSeidel;
tolerance 1e-05;
relTol 0;
}
}
PISO
{
nCorrectors 2;
nNonOrthogonalCorrectors 0;
pRefCell 0;
pRefValue 0;
}
// ************************************************************************* //

View File

@ -0,0 +1,32 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1812 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object meshQualityDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Include defaults parameters from master dictionary
#includeEtc "caseDicts/meshQualityDict"
//maxNonOrtho 180;
//maxConcave 180;
//minVol -1e30;
maxBoundarySkewness -1;
maxInternalSkewness -1;
//minTetQuality -1e30;
//minDeterminant -1e30;
//minTwist -1;
//minFaceWeight -1;
//minVolRatio -1;
//minDeterminant -1;
// ************************************************************************* //

View File

@ -0,0 +1,364 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2312 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object snappyHexMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Type of mesh generation:
// - castellated (default)
// - castellatedBufferLayer
type castellatedBufferLayer;
// Which of the steps to run
castellatedMesh true;
snap true;
addLayers false; //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
{
block
{
type triSurfaceMesh;
file "block.obj";
}
}
// 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 2000000;
// 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 0;
// Number of buffer layers between different levels.
// 1 means normal 2:1 refinement restriction, larger means slower
// refinement.
nCellsBetweenLevels 1;
// 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 "block.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
{
block
{
// Surface-wise min and max refinement level
level (2 2);
faceZone block;
faceType internal;
//addBufferLayers true;
}
}
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
{
}
// 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.
// This is an outside point locationInMesh (-0.033 -0.033 0.0033);
locationInMesh (0.00013 0.00013 0.00013); // Inside point
// 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 false;
nCellZoneErodeIter -1;
}
// Internal macro for mesh-motion solver to use
_meshMotionSolver
{
solver displacementPointSmoothing;
displacementPointSmoothingCoeffs
{
//// Use geometricElementTransform to maintain relative sizes
//pointSmoother geometricElementTransform;
//transformationParameter 0.667;
//nPointSmootherIter 10;
// Use laplacian to untangle problem areas
pointSmoother laplacian;
nPointSmootherIter 10;
//relaxationFactors (1.0 0.8 0.6 0.4 0.2 0.0);
//meshQuality
//{
// #includeEtc "caseDicts/meshQualityDict"
//}
}
}
// Settings for the snapping.
snapControls
{
//- Number of patch smoothing iterations before finding correspondence
// to surface
nSmoothPatch 3;
//- 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;
//- When to split face with diagonal attraction:
// 0 : only if perfect alignment (angle = 0) with feature itself
// 180 : always
concaveAngle 180;
//- When to split distorted face: not split if areas would differ too
// much (ideal is equal size i.e. area-ratio 1). -1 : disable check
minAreaRatio -1;
//- Number of mesh displacement relaxation iterations.
nSolveIter 300;
//- Maximum number of snapping relaxation iterations. Should stop
// before upon reaching a correct mesh.
nRelaxIter 5;
// Feature snapping
//- Number of feature edge snapping iterations.
// Leave out altogether to disable.
nFeatureSnapIter 10;
//- Detect (geometric) features by sampling the surface
implicitFeatureSnap true;
//- Use castellatedMeshControls::features
explicitFeatureSnap true;
//- Detect features between multiple surfaces
// (only for explicitFeatureSnap, default = false)
multiRegionFeatureSnap true;
// Motion solver to use
${_meshMotionSolver}
}
// 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
{
"block_.*"
{
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.5;
// Minimum thickness of cell layer. If for any reason layer
// cannot be above minThickness do not add layer.
// See relativeSizes parameter.
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.
nGrow 0;
// Advanced settings
// When not to extrude surface. 0 is flat surface, 90 is when two faces
// are perpendicular
featureAngle 30;
// Maximum number of snapping relaxation iterations. Should stop
// before upon reaching a correct mesh.
nRelaxIter 5;
// 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 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
minMedialAxisAngle 90;
// Create buffer region for new layer terminations
nBufferCellsNoExtrude 0;
//- Use displacementMotionSolver to shrink mesh
meshShrinker displacementMotionSolver;
// Motion solver to use
${_meshMotionSolver}
// 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 20;
}
// Generic mesh quality settings. At any undoable phase these determine
// where to undo.
meshQualityControls
{
#include "meshQualityDict"
// Optional : some meshing phases allow usage of relaxed rules.
// See e.g. addLayersControls::nRelaxedIter.
relaxed
{
//- Maximum non-orthogonality allowed. Set to 180 to disable.
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
);
//debugFlags
//(
// mesh
// attraction
//);
// Merge tolerance. Is fraction of overall bounding box of initial mesh.
// Note: the write tolerance needs to be higher than this.
mergeTolerance 1E-6;
// ************************************************************************* //

View File

@ -0,0 +1,35 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2312 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object surfaceFeatureExtractDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
block.obj
{
// How to obtain raw features (extractFromFile || extractFromSurface)
extractionMethod extractFromSurface;
// Mark edges whose adjacent surface normals are at an angle less
// than includedAngle as features
// - 0 : selects no edges
// - 180: selects all edges
includedAngle 150;
// Write options
// Write features to obj format for postprocessing
writeObj yes;
}
// ************************************************************************* //

View File

@ -0,0 +1,9 @@
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions # Tutorial clean functions
#------------------------------------------------------------------------------
cleanCase0
rm -f *.obj
#------------------------------------------------------------------------------

View File

@ -0,0 +1,12 @@
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
#------------------------------------------------------------------------------
runApplication blockMesh
runApplication snappyHexMesh
runApplication checkMesh -writeFields '(nonOrthoAngle)'
#------------------------------------------------------------------------------

View File

@ -0,0 +1,2 @@
- sphere with inside and outside meshed
- demonstrates buffer layers

View File

@ -0,0 +1,41 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1812 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object dynamicMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dynamicFvMesh dynamicMotionSolverFvMesh;
solver displacementPointSmoothing;
displacementPointSmoothingCoeffs
{
//// Use geometricElementTransform to maintain relative sizes
//pointSmoother geometricElementTransform;
//transformationParameter 0.667;
//nPointSmootherIter 10;
// Use laplacian to untangle problem areas
pointSmoother laplacian;
nPointSmootherIter 100;
//relaxationFactors (1.0 0.8 0.6 0.4 0.2 0.0);
//meshQuality
//{
// #includeEtc "caseDicts/meshQualityDict"
//}
}
// ************************************************************************* //

View File

@ -0,0 +1,21 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1812 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
nu 0.01;
// ************************************************************************* //

View File

@ -0,0 +1,96 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2312 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
scale 1;
vertices
(
(-1 -1 -1)
( 1 -1 -1)
( 1 1 -1)
(-1 1 -1)
(-1 -1 1)
( 1 -1 1)
( 1 1 1)
(-1 1 1)
);
blocks
(
hex (0 1 2 3 4 5 6 7) (20 20 20) simpleGrading (1 1 1)
);
edges
(
);
boundary
(
minX
{
type wall;
faces
(
(0 4 7 3)
);
}
maxX
{
type wall;
faces
(
(2 6 5 1)
);
}
minY
{
type wall;
faces
(
(1 5 4 0)
);
}
maxY
{
type wall;
faces
(
(3 7 6 2)
);
}
minZ
{
type wall;
faces
(
(0 3 2 1)
);
}
maxZ
{
type wall;
faces
(
(4 5 6 7)
);
}
);
// ************************************************************************* //

View File

@ -0,0 +1,49 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1812 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application snappyHexMesh;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 30;
deltaT 1;
writeControl timeStep;
writeInterval 1;
purgeWrite 0;
writeFormat ascii;
writePrecision 16;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //

View File

@ -0,0 +1,30 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1806 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
note "mesh decomposition control dictionary";
object decomposeParDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
////- The total number of domains (mandatory)
//numberOfSubdomains 2;
//
////- The decomposition method (mandatory)
//method random;
//- The total number of domains (mandatory)
numberOfSubdomains 11;
//- The decomposition method (mandatory)
method scotch;
// ************************************************************************* //

View File

@ -0,0 +1,59 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1812 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//geometry
//{
// type highAspectRatio;
// minAspect 0;
// maxAspect 0;
//}
ddtSchemes
{
default Euler;
}
gradSchemes
{
default Gauss linear;
grad(p) Gauss linear;
}
divSchemes
{
default none;
div(phi,U) Gauss linear;
}
laplacianSchemes
{
default Gauss linear corrected;
}
interpolationSchemes
{
default linear;
}
snGradSchemes
{
default corrected;
}
// ************************************************************************* //

View File

@ -0,0 +1,57 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1812 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
solvers
{
p
{
solver PCG;
preconditioner DIC;
tolerance 1e-06;
relTol 0.05;
}
pFinal
{
$p;
relTol 0;
}
U
{
solver smoothSolver;
smoother symGaussSeidel;
tolerance 1e-05;
relTol 0;
}
cellDisplacement
{
$pFinal;
}
}
PISO
{
nCorrectors 2;
nNonOrthogonalCorrectors 0;
pRefCell 0;
pRefValue 0;
}
// ************************************************************************* //

View File

@ -0,0 +1,32 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1812 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object meshQualityDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Include defaults parameters from master dictionary
#includeEtc "caseDicts/meshQualityDict"
//maxNonOrtho 180;
//maxConcave 180;
//minVol -1e30;
maxBoundarySkewness -1;
maxInternalSkewness -1;
//minTetQuality -1e30;
//minDeterminant -1e30;
//minTwist -1;
//minFaceWeight -1;
//minVolRatio -1;
//minDeterminant -1;
// ************************************************************************* //

View File

@ -0,0 +1,380 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2312 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object snappyHexMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Type of mesh generation:
// - castellated (default)
// - castellatedBufferLayer (adds single layer of cells before snapping)
type castellatedBufferLayer;
// 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
{
sphere
{
type sphere;
origin (0.0 0 0);
radius 0.5;
}
outside
{
type box;
min (-0.91 -0.91 -0.91);
max ( 0.91 0.91 0.91);
}
}
// 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 2000000;
// 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 0;
// Number of buffer layers between different levels.
// 1 means normal 2:1 refinement restriction, larger means slower
// refinement.
nCellsBetweenLevels 1;
// 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
(
);
// 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
{
sphere
{
// Surface-wise min and max refinement level
level (1 1);
addBufferLayers true;
}
outside
{
// Surface-wise min and max refinement level
level (1 1);
// Disable buffer layers
addBufferLayers false;
}
}
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
{
}
// 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.
// This is an outside point locationInMesh (-0.033 -0.033 0.0033);
locationsInMesh
(
(( 0.001 0.001 0.001) sphere)
(( 0.701 0.701 0.701) outside)
);
// 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 false;
}
// Internal macro for mesh-motion solver to use
_meshMotionSolver
{
solver displacementPointSmoothing;
displacementPointSmoothingCoeffs
{
//// Use geometricElementTransform to maintain relative sizes
//pointSmoother geometricElementTransform;
//transformationParameter 0.667;
//nPointSmootherIter 10;
// Use laplacian to untangle problem areas
pointSmoother laplacian;
nPointSmootherIter 10;
//relaxationFactors (1.0 0.8 0.6 0.4 0.2 0.0);
//meshQuality
//{
// #includeEtc "caseDicts/meshQualityDict"
//}
}
}
// Settings for the snapping.
snapControls
{
//- Number of patch smoothing iterations before finding correspondence
// to surface
nSmoothPatch 3;
//- 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;
//- When to split face with diagonal attraction:
// 0 : only if perfect alignment (angle = 0) with feature itself
// 180 : always
concaveAngle 180;
//- When to split distorted face: not split if areas would differ too
// much (ideal is equal size i.e. area-ratio 1). -1 : disable check
minAreaRatio -1;
//- Number of mesh displacement relaxation iterations.
nSolveIter 10;
//- Maximum number of snapping relaxation iterations. Should stop
// before upon reaching a correct mesh.
nRelaxIter 5;
// Feature snapping
//- Number of feature edge snapping iterations.
// Leave out altogether to disable.
nFeatureSnapIter 10;
//- Detect (geometric) features by sampling the surface
implicitFeatureSnap true;
//- Use castellatedMeshControls::features
explicitFeatureSnap true;
//- Detect features between multiple surfaces
// (only for explicitFeatureSnap, default = false)
multiRegionFeatureSnap true;
// Motion solver to use
${_meshMotionSolver}
}
// 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
{
"(sphere_to_outside|outside_to_sphere)"
{
nSurfaceLayers 3;
}
}
// Expansion factor for layer mesh
expansionRatio 1.4;
// 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.5;
// Minimum thickness of cell layer. If for any reason layer
// cannot be above minThickness do not add layer.
// See relativeSizes parameter.
minThickness 0.01;
// 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.
nGrow 0;
// Advanced settings
// When not to extrude surface. 0 is flat surface, 90 is when two faces
// are perpendicular
featureAngle 30;
// Maximum number of snapping relaxation iterations. Should stop
// before upon reaching a correct mesh.
nRelaxIter 5;
// 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 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
minMedialAxisAngle 90;
// Create buffer region for new layer terminations
nBufferCellsNoExtrude 0;
//- Use displacementMotionSolver to shrink mesh
meshShrinker displacementMotionSolver;
// Motion solver to use
${_meshMotionSolver}
// Do some more iterations since shrinking is over a larger distance.
// Note: laplacian smoothing does destroy the cell sizing - maybe use
// the geometricElementTransform smoother instead.
displacementPointSmoothingCoeffs
{
nPointSmootherIter 100;
}
// 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 20;
}
// Generic mesh quality settings. At any undoable phase these determine
// where to undo.
meshQualityControls
{
#include "meshQualityDict"
// Optional : some meshing phases allow usage of relaxed rules.
// See e.g. addLayersControls::nRelaxedIter.
relaxed
{
//- Maximum non-orthogonality allowed. Set to 180 to disable.
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
);
debugFlags
(
// mesh
// attraction
);
// Merge tolerance. Is fraction of overall bounding box of initial mesh.
// Note: the write tolerance needs to be higher than this.
mergeTolerance 1E-6;
// ************************************************************************* //