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

@ -0,0 +1,78 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2309 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
arch "LSB;label=32;scalar=64";
class pointVectorField;
location "0";
object pointDisplacement;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 0 0 0 0 0];
internalField uniform (0 0 0);
// Some macros
__surfaceSlipDisplacement
{
type surfaceSlipDisplacement;
value uniform (0 0 0);
geometry
{
box
{
type triSurfaceMesh;
file blockMesh.obj;
}
}
projectMode nearest;
}
__edgeSlipDisplacement
{
type edgeSlipDisplacement;
file "blockMesh.eMesh";
// Underrelax the displacement on edges since conflicts with
// smoothing. TBD.
velocity (1 1 1);
}
boundaryField
{
// Attract to feature lines
wallsEdges
{
${__edgeSlipDisplacement};
}
// Attract to feature lines
boundaryEdges
{
${__edgeSlipDisplacement};
}
// Attract to feature lines
sideEdges
{
${__edgeSlipDisplacement};
}
// Default is to attract to surface
".*"
{
${__surfaceSlipDisplacement};
}
}
// ************************************************************************* //

View File

@ -6,5 +6,11 @@ cd "${0%/*}" || exit # Run from this directory
cleanCase0
rm -rf constant/geometry
rm -rf constant/extendedFeatureEdgeMesh
rm -rf constant/geometry
#- From pointMesh generation
rm -rf constant/pointMesh
rm -rf constant/triSurface
#------------------------------------------------------------------------------

View File

@ -11,8 +11,29 @@ cp -f \
runApplication blockMesh
# See if we can improve the mesh with a bit of smoothing (whilst freezing
# the features)
# - feature-edge attraction conflicts with mesh smoothing so faces with
# three vertices on feature edge get distorted.
#- Analyse mesh and
# - generate pointMesh with additional feature patches
# (in constant/pointMesh/boundary).
# - write .obj file with outside of mesh
mkdir -p constant/triSurface
runApplication surfaceMeshExtract -featureAngle 50 \
constant/triSurface/blockMesh.obj
#- Extract features from surface (original of blockMesh). Writes .eMesh.
runApplication surfaceFeatureExtract
#- Set the initial field
restore0Dir
runApplication $(getApplication)
#- Run mesh smoother
runApplication moveDynamicMesh
#- Check mesh, generate postprocessing fields
runApplication checkMesh -writeFields '(nonOrthoAngle)'
#------------------------------------------------------------------------------

View File

@ -0,0 +1,12 @@
Demos:
- blockMesh:
- snapping to surface
- surface defined by extrusion of line
- surfaceMeshExtract
- generation of additional pointPatches to handle features
- moveDynamicMesh
- point-based smoothers
- feature-attraction through boundary conditions

View File

@ -0,0 +1,29 @@
/*--------------------------------*- 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 dynamicMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dynamicFvMesh dynamicMotionSolverFvMesh;
motionSolverLibs (fvMotionSolvers);
motionSolver displacementPointSmoothing;
displacementPointSmoothingCoeffs
{
pointSmoother geometricElementTransform;
transformationParameter 0.667;
nPointSmootherIter 1;
}
// ************************************************************************* //

View File

@ -14,17 +14,7 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
libs (blockMesh);
DebugSwitches
{
//project 1;
//searchableExtrudedCircle 1;
//projectCurve 1;
solution 1;
}
application simpleFoam;
application moveDynamicMesh;
startFrom startTime;
@ -32,7 +22,7 @@ startTime 0;
stopAt endTime;
endTime 100;
endTime 10;
deltaT 1;

View File

@ -0,0 +1,33 @@
/*--------------------------------*- 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;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
blockMesh.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 130;
// Write features to obj format for postprocessing
writeObj yes;
}
// ************************************************************************* //

View File

@ -0,0 +1,58 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2312 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
arch "LSB;label=32;scalar=64";
class volVectorField;
location "1";
object cellDisplacement;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 0 0 0 0 0];
internalField uniform (0 0 0);
boundaryField
{
minX
{
type cellMotion;
value uniform (0 0 0);
}
maxX
{
type cellMotion;
value uniform (0 0 0);
}
minY
{
type cellMotion;
value uniform (0 0 0);
}
maxY
{
type cellMotion;
value uniform (0 0 0);
}
minZ
{
type cellMotion;
value uniform (0 0 0);
}
maxZ
{
type cellMotion;
value uniform (0 0 0);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,81 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2309 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
arch "LSB;label=32;scalar=64";
class pointVectorField;
location "0";
object pointDisplacement;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 0 0 0 0 0];
internalField uniform (0 0 0);
boundaryField
{
minX
{
type surfaceSlipDisplacement;
value uniform (0 0 0);
velocity (0.1 0.1 0.1);
//velocity (100 100 100);
geometry
{
box
{
type triSurfaceMesh;
file box222.obj;
}
}
projectMode nearest;
}
maxX
{
$minX
}
minY
{
$minX
}
maxY
{
$minX
}
minZ
{
$minX
}
maxZ
{
$minX
}
boundaryEdges
{
type edgeSlipDisplacement;
file "box222.eMesh";
//file "box222.extendedFeatureEdgeMesh";
//- Underrelax motion by limiting displacement velocity
velocity (0.1 0.1 0.1);
//velocity (100 100 100);
}
boundaryPoints
{
type pointAttraction;
file "box222.eMesh";
//- Underrelax motion by limiting displacement velocity
velocity (0.1 0.1 0.1);
//velocity (100 100 100);
}
}
// ************************************************************************* //

View File

@ -5,6 +5,14 @@ cd "${0%/*}" || exit # Run from this directory
cleanCase0
rm -rf constant
rm -rf constant/extendedFeatureEdgeMesh
#- From pointMesh generation
rm -rf constant/pointMesh
rm -f constant/triSurface/blockMesh.obj
rm -f constant/triSurface/outside.obj
#- From surfaceFeatureExtract
rm -f constant/triSurface/box222.eMesh
#------------------------------------------------------------------------------

View File

@ -3,6 +3,44 @@ cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
#------------------------------------------------------------------------------
#- Run blockMesh with projection
runApplication blockMesh
# Optional
##- Extrude very thin cells to make it harder. Note: requires a
##- pointSmoother first before doing the displacementLaplacian
#runApplication extrudeMesh
#- Refine some cells
runApplication topoSet
runApplication refineHexMesh c0 -overwrite
#- Generate pointMesh with additional feature patches
# (in constant/pointMesh/boundary). Extracted outside of mesh is not used.
runApplication surfaceMeshExtract -featureAngle 45 \
constant/triSurface/blockMesh.obj
#- Set the initial field
restore0Dir
#- TBD. move triSurfaces to resources
#mkdir -p constant/triSurface
#cp -f \
# "$FOAM_TUTORIALS"/resources/geometry/box222.obj \
# constant/triSurface/
#- Extract features from surface. Writes .eMesh
runApplication surfaceFeatureExtract
##- Morph mesh to the surface (.obj file) and feature-edges (.eMesh file)
#runApplication moveDynamicMesh
runApplication decomposePar
runParallel moveDynamicMesh
runApplication reconstructPar
#------------------------------------------------------------------------------

View File

@ -0,0 +1,53 @@
/*--------------------------------*- 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 dynamicMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dynamicFvMesh dynamicMotionSolverFvMesh;
motionSolverLibs (fvMotionSolvers);
//motionSolver displacementPointSmoothing;
//displacementPointSmoothingCoeffs
//{
// //pointSmoother geometricElementTransform;
// //transformationParameter 0.667;
// pointSmoother laplacian;
//
// nPointSmootherIter 10;
//
// //relaxationFactors (1);
// //meshQuality {}
// //moveInternalFaces true;
//}
motionSolver multiDisplacement;
solvers
{
displacementLaplacian
{
motionSolver displacementLaplacian;
diffusivity uniform;
}
displacementPointSmoothing
{
motionSolver displacementPointSmoothing;
pointSmoother laplacian;
nPointSmootherIter 10;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,79 @@
# Generated by Visualization Toolkit
v -1 -1 -1
v -1 -1 1
v -1 1 -1
v -1 1 1
v 1 -1 -1
v 1 -1 1
v 1 1 -1
v 1 1 1
v -1 -1 -1
v -1 -1 1
v 1 -1 -1
v 1 -1 1
v -1 1 -1
v -1 1 1
v 1 1 -1
v 1 1 1
v -1 -1 -1
v 1 -1 -1
v -1 1 -1
v 1 1 -1
v -1 -1 1
v 1 -1 1
v -1 1 1
v 1 1 1
vn -1 0 0
vn -1 0 0
vn -1 0 0
vn -1 0 0
vn 1 0 0
vn 1 0 0
vn 1 0 0
vn 1 0 0
vn 0 -1 0
vn 0 -1 0
vn 0 -1 0
vn 0 -1 0
vn 0 1 0
vn 0 1 0
vn 0 1 0
vn 0 1 0
vn 0 0 -1
vn 0 0 -1
vn 0 0 -1
vn 0 0 -1
vn 0 0 1
vn 0 0 1
vn 0 0 1
vn 0 0 1
vt -0.5 -0.5
vt 1.5 -0.5
vt -0.5 1.5
vt 1.5 1.5
vt 0.5 -0.5
vt -1.5 -0.5
vt 0.5 1.5
vt -1.5 1.5
vt 0.5 0.5
vt 0.5 -1.5
vt -1.5 0.5
vt -1.5 -1.5
vt -0.5 0.5
vt -0.5 -1.5
vt 1.5 0.5
vt 1.5 -1.5
vt 0.5 -0.5
vt -1.5 -0.5
vt 0.5 1.5
vt -1.5 1.5
vt -0.5 -0.5
vt 1.5 -0.5
vt -0.5 1.5
vt 1.5 1.5
f 1/1/1 2/2/2 4/4/4 3/3/3
f 5/5/5 7/7/7 8/8/8 6/6/6
f 9/9/9 11/11/11 12/12/12 10/10/10
f 13/13/13 14/14/14 16/16/16 15/15/15
f 17/17/17 19/19/19 20/20/20 18/18/18
f 21/21/21 22/22/22 24/24/24 23/23/23

View File

@ -0,0 +1,79 @@
# Generated by Visualization Toolkit
v -2 -1 -1
v -2 -1 1
v -2 1 -1
v -2 1 1
v 2 -1 -1
v 2 -1 1
v 2 1 -1
v 2 1 1
v -2 -1 -1
v -2 -1 1
v 2 -1 -1
v 2 -1 1
v -2 1 -1
v -2 1 1
v 2 1 -1
v 2 1 1
v -2 -1 -1
v 2 -1 -1
v -2 1 -1
v 2 1 -1
v -2 -1 1
v 2 -1 1
v -2 1 1
v 2 1 1
vn -1 0 0
vn -1 0 0
vn -1 0 0
vn -1 0 0
vn 1 0 0
vn 1 0 0
vn 1 0 0
vn 1 0 0
vn 0 -1 0
vn 0 -1 0
vn 0 -1 0
vn 0 -1 0
vn 0 1 0
vn 0 1 0
vn 0 1 0
vn 0 1 0
vn 0 0 -1
vn 0 0 -1
vn 0 0 -1
vn 0 0 -1
vn 0 0 1
vn 0 0 1
vn 0 0 1
vn 0 0 1
vt -0.5 -0.5
vt 1.5 -0.5
vt -0.5 1.5
vt 1.5 1.5
vt 0.5 -0.5
vt -1.5 -0.5
vt 0.5 1.5
vt -1.5 1.5
vt 1.5 0.5
vt 1.5 -1.5
vt -2.5 0.5
vt -2.5 -1.5
vt -1.5 0.5
vt -1.5 -1.5
vt 2.5 0.5
vt 2.5 -1.5
vt 1.5 -0.5
vt -2.5 -0.5
vt 1.5 1.5
vt -2.5 1.5
vt -1.5 -0.5
vt 2.5 -0.5
vt -1.5 1.5
vt 2.5 1.5
f 1/1/1 2/2/2 4/4/4 3/3/3
f 5/5/5 7/7/7 8/8/8 6/6/6
f 9/9/9 11/11/11 12/12/12 10/10/10
f 13/13/13 14/14/14 16/16/16 15/15/15
f 17/17/17 19/19/19 20/20/20 18/18/18
f 21/21/21 22/22/22 24/24/24 23/23/23

View File

@ -127,16 +127,56 @@ faces
boundary
(
walls
minX
{
type wall;
type patch;
faces
(
(1 0) // block 1: x-min
);
}
maxX
{
type patch;
faces
(
(2 1) // block 2: x-max
);
}
minY
{
type patch;
faces
(
(3 2) // block 3: y-min
);
}
maxY
{
type patch;
faces
(
(4 3) // block 4: y-max
);
}
minZ
{
type patch;
faces
(
(5 4) // block 5: z-min
);
}
maxZ
{
type patch;
faces
(
(6 5) // block 6: z-max
);
}

View File

@ -14,6 +14,11 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
DebugSwitches
{
pointBoundaryMesh 1;
}
application blockMesh;
startFrom startTime;
@ -22,9 +27,9 @@ startTime 0;
stopAt endTime;
endTime 0;
endTime 20;
deltaT 0;
deltaT 1;
writeControl timeStep;

View File

@ -0,0 +1,24 @@
/*--------------------------------*- 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;
note "mesh decomposition control dictionary";
object decomposeParDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- The total number of domains (mandatory)
numberOfSubdomains 2;
//- The decomposition method (mandatory)
method scotch;
// ************************************************************************* //

View File

@ -0,0 +1,55 @@
/*--------------------------------*- 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 extrudeMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// What to extrude:
// patch : from patch of another case ('sourceCase')
// mesh : as above but with original case included
// surface : from externally read surface
constructFrom mesh;
// If construct from patch/mesh:
sourceCase "<case>";
// and one of sourcePatches or sourceFaceZones (but not both):
//sourceFaceZones (someFacesZone);
sourcePatches (".*");
// Flip surface normals before usage. Valid only for extrude from surface or
// patch.
flipNormals false;
//- Linear extrusion in point-normal direction
extrudeModel linearNormal;
nLayers 1;
expansionRatio 1.0;
linearNormalCoeffs
{
thickness 1e-6;
}
// Do front and back need to be merged? Usually only makes sense for 360
// degree wedges.
mergeFaces false;
// Merge small edges. Fraction of bounding box.
mergeTol 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -18,19 +18,27 @@ ddtSchemes
{}
gradSchemes
{}
{
default Gauss linear;
}
divSchemes
{}
laplacianSchemes
{}
{
default Gauss linear corrected;
}
interpolationSchemes
{}
{
default linear;
}
snGradSchemes
{}
{
default corrected;
}
// ************************************************************************* //

View File

@ -14,5 +14,20 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
solvers
{
"cellDisplacement.*"
{
solver GAMG;
tolerance 1e-08;
relTol 0;
smoother GaussSeidel;
}
}
PIMPLE
{}
// ************************************************************************* //

View File

@ -0,0 +1,33 @@
/*--------------------------------*- 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;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
box222.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 135;
// Write features to obj format for postprocessing
writeObj yes;
}
// ************************************************************************* //

View File

@ -0,0 +1,47 @@
/*--------------------------------*- 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 topoSetDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
actions
(
{
name c0;
type cellSet;
action new;
source boundaryToCell;
}
{
name c0;
type cellSet;
action subset;
source boxToCell;
sourceInfo
{
box (-100 -100 -100) (0 100 100);
}
}
{
name c0;
type cellSet;
action add;
source boxToCell;
sourceInfo
{
box (-0.3 -0.3 -0.3) (0 0 0);
}
}
);
// ************************************************************************* //