ENH: polyDualMesh: demonstrate cellDecomposer,polyDualMesh

This commit is contained in:
mattijs 2024-12-16 12:24:20 +00:00
parent 1462a5effa
commit ea4508c079
15 changed files with 39161 additions and 0 deletions

View File

@ -0,0 +1,80 @@
/*--------------------------------*- 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
exposedFacesEdges
{
${__edgeSlipDisplacement};
}
// Attract to feature lines
boundaryEdges
{
${__edgeSlipDisplacement};
}
// Attract to feature lines
boundaryPoints
{
${__edgeSlipDisplacement};
// Override to point-based attraction
type pointAttraction;
}
// Default is to attract to surface
".*"
{
${__surfaceSlipDisplacement};
}
}
// ************************************************************************* //

View File

@ -0,0 +1,11 @@
#!/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
rm -rf *.obj
cleanCase0
#------------------------------------------------------------------------------

View File

@ -0,0 +1,55 @@
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
#------------------------------------------------------------------------------
# Create tet mesh
# ~~~~~~~~~~~~~~~
# (using blockMesh but another tool could work as well)
# Create block
runApplication blockMesh
runApplication topoSet
# Create cut-out to make it more interesting
runApplication subsetMesh c0 -patch exposedFaces -overwrite
# Create tet decomposition as 'tetMesh' region
runApplication postProcess -func tetDecomposition
# Move tet mesh to default location
\rm -r constant/polyMesh
mv constant/tetMesh/polyMesh constant/polyMesh
\rm -rf constant/tetMesh system/tetMesh
# Convert to poly
# ~~~~~~~~~~~~~~~
# Convert to poly
runApplication polyDualMesh 45 -concaveMultiCells -overwrite
# Set up to run smoothing
# ~~~~~~~~~~~~~~~~~~~~~~~
# Detect feature edges on mesh and generate new point patches from these.
mkdir -p constant/triSurface
runApplication surfaceMeshExtract \
-featureAngle 45 constant/triSurface/blockMesh.obj
#- Extract features from surface (original of blockMesh). Writes .eMesh.
runApplication surfaceFeatureExtract
cp -r 0.orig 0
# Smoothing
# ~~~~~~~~~
runApplication moveDynamicMesh
runApplication checkMesh -writeFields '(nonOrthoAngle)'
#------------------------------------------------------------------------------

View File

@ -0,0 +1,4 @@
- example of tetDecomposition and polyDualMesh.
- uses boundary conditions on points to implement constraints
- currently uses simple Laplacian pointSmoother which does not improve
mesh quality. Probably should implement a 'smart' method.

View File

@ -0,0 +1,43 @@
/*--------------------------------*- 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;
motionSolverLibs (fvMotionSolvers);
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"
//}
}
// ************************************************************************* //

File diff suppressed because it is too large Load Diff

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,101 @@
/*--------------------------------*- 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 20) simpleGrading (1 1 1)
);
edges
(
);
boundary
(
minX
{
type patch;
faces
(
(0 4 7 3)
);
}
maxX
{
type patch;
faces
(
(2 6 5 1)
);
}
minY
{
type patch;
faces
(
(1 5 4 0)
);
}
maxY
{
type patch;
faces
(
(3 7 6 2)
);
}
minZ
{
type patch;
faces
(
(0 3 2 1)
);
}
maxZ
{
type patch;
faces
(
(4 5 6 7)
);
}
exposedFaces
{
type patch;
faces ();
}
);
// ************************************************************************* //

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 checkMesh;
startFrom latestTime; //startTime;
startTime 0;
stopAt endTime;
endTime 10;
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,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 135;
// Write features to obj format for postprocessing
writeObj yes;
}
// ************************************************************************* //

View File

@ -0,0 +1,28 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2406 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object sample;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
type cellDecomposer;
libs (fieldFunctionObjects);
fields ();
mapRegion tetMesh;
decomposeType faceCentre;
// Cell set to decompose
selectionMode all;
// ************************************************************************* //

View File

@ -0,0 +1,36 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2406 |
| \\ / 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 boxToCell;
sourceInfo
{
box (-100 -100 -100) (0.5 0.5 0.5); // Edit box bounds as required
}
}
{
name c0;
type cellSet;
action invert;
}
);
// ************************************************************************* //