mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: edgeCollapser: Make mesh checking optional and set default values for dictionary
Update biconic25-55Run35 tutorial with simplified collapseDict
This commit is contained in:
@ -14,6 +14,11 @@ FoamFile
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// If on, after collapsing check the quality of the mesh. If bad faces are
|
||||
// generated then redo the collapsing with stricter filtering.
|
||||
controlMeshQuality on;
|
||||
|
||||
|
||||
collapseEdgesCoeffs
|
||||
{
|
||||
// Edges shorter than this absolute value will be merged
|
||||
@ -22,21 +27,13 @@ collapseEdgesCoeffs
|
||||
// The maximum angle between two edges that share a point attached to
|
||||
// no other edges
|
||||
maximumMergeAngle 30;
|
||||
|
||||
// The amount that minimumEdgeLength will be reduced by for each
|
||||
// edge if that edge's collapse generates a poor quality face
|
||||
reductionFactor 0.5;
|
||||
}
|
||||
|
||||
|
||||
collapseFacesCoeffs
|
||||
{
|
||||
// The initial face length factor
|
||||
initialFaceLengthFactor 0.5;
|
||||
|
||||
// The amount that initialFaceLengthFactor will be reduced by for each
|
||||
// face if its collapse generates a poor quality face
|
||||
reductionFactor $initialFaceLengthFactor;
|
||||
initialFaceLengthFactor 0.5;
|
||||
|
||||
// If the face can't be collapsed to an edge, and it has a span less than
|
||||
// the target face length multiplied by this coefficient, collapse it
|
||||
@ -63,12 +60,20 @@ collapseFacesCoeffs
|
||||
}
|
||||
|
||||
|
||||
meshQualityCoeffs
|
||||
controlMeshQualityCoeffs
|
||||
{
|
||||
// Name of the dictionary that has the mesh quality coefficients used
|
||||
// by motionSmoother::checkMesh
|
||||
#include "meshQualityDict";
|
||||
|
||||
// The amount that minimumEdgeLength will be reduced by for each
|
||||
// edge if that edge's collapse generates a poor quality face
|
||||
edgeReductionFactor 0.5;
|
||||
|
||||
// The amount that initialFaceLengthFactor will be reduced by for each
|
||||
// face if its collapse generates a poor quality face
|
||||
faceReductionFactor $initialFaceLengthFactor;
|
||||
|
||||
// Maximum number of smoothing iterations for the reductionFactors
|
||||
maximumSmoothingIterations 2;
|
||||
|
||||
|
||||
@ -427,9 +427,13 @@ Foam::polyMeshFilter::polyMeshFilter(const fvMesh& mesh)
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
),
|
||||
controlMeshQuality_
|
||||
(
|
||||
dict_.lookupOrDefault<Switch>("controlMeshQuality", false)
|
||||
),
|
||||
collapseEdgesCoeffDict_(dict_.subDict("collapseEdgesCoeffs")),
|
||||
collapseFacesCoeffDict_(dict_.subDict("collapseFacesCoeffs")),
|
||||
meshQualityCoeffDict_(dict_.subDict("meshQualityCoeffs")),
|
||||
collapseFacesCoeffDict_(dict_.subOrEmptyDict("collapseFacesCoeffs")),
|
||||
meshQualityCoeffDict_(dict_.subOrEmptyDict("controlMeshQualityCoeffs")),
|
||||
minLen_(readScalar(collapseEdgesCoeffDict_.lookup("minimumEdgeLength"))),
|
||||
maxCos_
|
||||
(
|
||||
@ -443,27 +447,39 @@ Foam::polyMeshFilter::polyMeshFilter(const fvMesh& mesh)
|
||||
),
|
||||
edgeReductionFactor_
|
||||
(
|
||||
readScalar(collapseEdgesCoeffDict_.lookup("reductionFactor"))
|
||||
meshQualityCoeffDict_.lookupOrDefault<scalar>("edgeReductionFactor", -1)
|
||||
),
|
||||
maxIterations_
|
||||
(
|
||||
readLabel(meshQualityCoeffDict_.lookup("maximumIterations"))
|
||||
meshQualityCoeffDict_.lookupOrAddDefault<label>("maximumIterations", 1)
|
||||
),
|
||||
maxSmoothIters_
|
||||
(
|
||||
readLabel(meshQualityCoeffDict_.lookup("maximumSmoothingIterations"))
|
||||
meshQualityCoeffDict_.lookupOrAddDefault<label>
|
||||
(
|
||||
"maximumSmoothingIterations",
|
||||
0
|
||||
)
|
||||
),
|
||||
initialFaceLengthFactor_
|
||||
(
|
||||
readScalar(collapseFacesCoeffDict_.lookup("initialFaceLengthFactor"))
|
||||
collapseFacesCoeffDict_.lookupOrAddDefault<scalar>
|
||||
(
|
||||
"initialFaceLengthFactor",
|
||||
-1
|
||||
)
|
||||
),
|
||||
faceReductionFactor_
|
||||
(
|
||||
readScalar(collapseFacesCoeffDict_.lookup("reductionFactor"))
|
||||
meshQualityCoeffDict_.lookupOrAddDefault<scalar>
|
||||
(
|
||||
"faceReductionFactor",
|
||||
-1
|
||||
)
|
||||
),
|
||||
maxPointErrorCount_
|
||||
(
|
||||
readLabel(meshQualityCoeffDict_.lookup("maxPointErrorCount"))
|
||||
meshQualityCoeffDict_.lookupOrAddDefault<label>("maxPointErrorCount", 0)
|
||||
),
|
||||
minEdgeLen_(),
|
||||
faceFilterFactor_()
|
||||
@ -547,23 +563,10 @@ Foam::label Foam::polyMeshFilter::filter(const label nOriginalBadFaces)
|
||||
Map<point> collapsePointToLocation(newMesh.nPoints());
|
||||
|
||||
// Mark points on boundary
|
||||
const labelList boundaryPoint = findBoundaryPoints
|
||||
(
|
||||
newMesh//,
|
||||
// boundaryIOPts
|
||||
);
|
||||
const labelList boundaryPoint = findBoundaryPoints(newMesh);
|
||||
|
||||
edgeCollapser collapser(newMesh, collapseFacesCoeffDict_);
|
||||
|
||||
// Per face collapse status:
|
||||
// -1 : not collapsed
|
||||
// >= 0 : index of point in face to collapse to
|
||||
List<Map<point> > faceCollapseToPoints
|
||||
(
|
||||
newMesh.nFaces(),
|
||||
Map<point>()
|
||||
);
|
||||
|
||||
{
|
||||
// Collapse faces
|
||||
labelPair nCollapsedPtEdge = collapser.markSmallSliverFaces
|
||||
@ -832,41 +835,48 @@ Foam::label Foam::polyMeshFilter::filter(const label nOriginalBadFaces)
|
||||
// Do not allow collapses in regions of error.
|
||||
// Updates minEdgeLen, nRelaxedEdges
|
||||
|
||||
PackedBoolList isErrorPoint(newMesh.nPoints());
|
||||
nBadFaces = edgeCollapser::checkMeshQuality
|
||||
(
|
||||
newMesh,
|
||||
meshQualityCoeffDict_,
|
||||
isErrorPoint
|
||||
);
|
||||
if (controlMeshQuality_)
|
||||
{
|
||||
PackedBoolList isErrorPoint(newMesh.nPoints());
|
||||
nBadFaces = edgeCollapser::checkMeshQuality
|
||||
(
|
||||
newMesh,
|
||||
meshQualityCoeffDict_,
|
||||
isErrorPoint
|
||||
);
|
||||
|
||||
Info<< nl << " Number of bad faces : " << nBadFaces << nl
|
||||
<< " Number of marked points : "
|
||||
<< returnReduce(isErrorPoint.count(), sumOp<unsigned int>())
|
||||
<< endl;
|
||||
Info<< nl << " Number of bad faces : " << nBadFaces << nl
|
||||
<< " Number of marked points : "
|
||||
<< returnReduce(isErrorPoint.count(), sumOp<unsigned int>())
|
||||
<< endl;
|
||||
|
||||
updatePointErrorCount
|
||||
(
|
||||
isErrorPoint,
|
||||
origToCurrentPointMap,
|
||||
pointErrorCount
|
||||
);
|
||||
updatePointErrorCount
|
||||
(
|
||||
isErrorPoint,
|
||||
origToCurrentPointMap,
|
||||
pointErrorCount
|
||||
);
|
||||
|
||||
checkMeshEdgesAndRelaxEdges
|
||||
(
|
||||
newMesh,
|
||||
origToCurrentPointMap,
|
||||
isErrorPoint,
|
||||
pointErrorCount
|
||||
);
|
||||
checkMeshEdgesAndRelaxEdges
|
||||
(
|
||||
newMesh,
|
||||
origToCurrentPointMap,
|
||||
isErrorPoint,
|
||||
pointErrorCount
|
||||
);
|
||||
|
||||
checkMeshFacesAndRelaxEdges
|
||||
(
|
||||
newMesh,
|
||||
origToCurrentPointMap,
|
||||
isErrorPoint,
|
||||
pointErrorCount
|
||||
);
|
||||
checkMeshFacesAndRelaxEdges
|
||||
(
|
||||
newMesh,
|
||||
origToCurrentPointMap,
|
||||
isErrorPoint,
|
||||
pointErrorCount
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return nBadFaces;
|
||||
@ -931,11 +941,7 @@ Foam::label Foam::polyMeshFilter::filterEdges
|
||||
Map<point> collapsePointToLocation(newMesh.nPoints());
|
||||
|
||||
// Mark points on boundary
|
||||
const labelList boundaryPoint = findBoundaryPoints
|
||||
(
|
||||
newMesh//,
|
||||
// boundaryIOPts
|
||||
);
|
||||
const labelList boundaryPoint = findBoundaryPoints(newMesh);
|
||||
|
||||
edgeCollapser collapser(newMesh, collapseFacesCoeffDict_);
|
||||
|
||||
@ -1059,33 +1065,40 @@ Foam::label Foam::polyMeshFilter::filterEdges
|
||||
// Do not allow collapses in regions of error.
|
||||
// Updates minEdgeLen, nRelaxedEdges
|
||||
|
||||
PackedBoolList isErrorPoint(newMesh.nPoints());
|
||||
nBadFaces = edgeCollapser::checkMeshQuality
|
||||
(
|
||||
newMesh,
|
||||
meshQualityCoeffDict_,
|
||||
isErrorPoint
|
||||
);
|
||||
if (controlMeshQuality_)
|
||||
{
|
||||
PackedBoolList isErrorPoint(newMesh.nPoints());
|
||||
nBadFaces = edgeCollapser::checkMeshQuality
|
||||
(
|
||||
newMesh,
|
||||
meshQualityCoeffDict_,
|
||||
isErrorPoint
|
||||
);
|
||||
|
||||
Info<< nl << " Number of bad faces : " << nBadFaces << nl
|
||||
<< " Number of marked points : "
|
||||
<< returnReduce(isErrorPoint.count(), sumOp<unsigned int>())
|
||||
<< endl;
|
||||
Info<< nl << " Number of bad faces : " << nBadFaces << nl
|
||||
<< " Number of marked points : "
|
||||
<< returnReduce(isErrorPoint.count(), sumOp<unsigned int>())
|
||||
<< endl;
|
||||
|
||||
updatePointErrorCount
|
||||
(
|
||||
isErrorPoint,
|
||||
origToCurrentPointMap,
|
||||
pointErrorCount
|
||||
);
|
||||
updatePointErrorCount
|
||||
(
|
||||
isErrorPoint,
|
||||
origToCurrentPointMap,
|
||||
pointErrorCount
|
||||
);
|
||||
|
||||
checkMeshEdgesAndRelaxEdges
|
||||
(
|
||||
newMesh,
|
||||
origToCurrentPointMap,
|
||||
isErrorPoint,
|
||||
pointErrorCount
|
||||
);
|
||||
checkMeshEdgesAndRelaxEdges
|
||||
(
|
||||
newMesh,
|
||||
origToCurrentPointMap,
|
||||
isErrorPoint,
|
||||
pointErrorCount
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return nBadFaces;
|
||||
@ -1174,18 +1187,21 @@ Foam::label Foam::polyMeshFilter::filterIndirectPatchFaces()
|
||||
// Do not allow collapses in regions of error.
|
||||
// Updates minEdgeLen, nRelaxedEdges
|
||||
|
||||
PackedBoolList isErrorPoint(newMesh.nPoints());
|
||||
nBadFaces = edgeCollapser::checkMeshQuality
|
||||
(
|
||||
newMesh,
|
||||
meshQualityCoeffDict_,
|
||||
isErrorPoint
|
||||
);
|
||||
if (controlMeshQuality_)
|
||||
{
|
||||
PackedBoolList isErrorPoint(newMesh.nPoints());
|
||||
nBadFaces = edgeCollapser::checkMeshQuality
|
||||
(
|
||||
newMesh,
|
||||
meshQualityCoeffDict_,
|
||||
isErrorPoint
|
||||
);
|
||||
|
||||
Info<< nl << " Number of bad faces : " << nBadFaces << nl
|
||||
<< " Number of marked points : "
|
||||
<< returnReduce(isErrorPoint.count(), sumOp<unsigned int>())
|
||||
<< endl;
|
||||
Info<< nl << " Number of bad faces : " << nBadFaces << nl
|
||||
<< " Number of marked points : "
|
||||
<< returnReduce(isErrorPoint.count(), sumOp<unsigned int>())
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
return nBadFaces;
|
||||
|
||||
@ -70,14 +70,18 @@ class polyMeshFilter
|
||||
//- Dictionary containing the coefficient sub-dictionaries
|
||||
const IOdictionary dict_;
|
||||
|
||||
//- After collapsing, check the mesh quality and redo the collapsing
|
||||
// iteration if there are too many bad faces in the mesh
|
||||
Switch controlMeshQuality_;
|
||||
|
||||
//- Coefficients for collapsing edges
|
||||
const dictionary& collapseEdgesCoeffDict_;
|
||||
|
||||
//- Coefficients for collapsing faces
|
||||
const dictionary& collapseFacesCoeffDict_;
|
||||
dictionary collapseFacesCoeffDict_;
|
||||
|
||||
//- Coefficients for controlling the mesh quality
|
||||
const dictionary& meshQualityCoeffDict_;
|
||||
dictionary meshQualityCoeffDict_;
|
||||
|
||||
//- Remove edges shorter than this length
|
||||
const scalar minLen_;
|
||||
|
||||
@ -1226,10 +1226,13 @@ Foam::edgeCollapser::edgeCollapser
|
||||
)
|
||||
:
|
||||
mesh_(mesh),
|
||||
guardFraction_(readScalar(dict.lookup("guardFraction"))),
|
||||
guardFraction_
|
||||
(
|
||||
dict.lookupOrDefault<scalar>("guardFraction", 0)
|
||||
),
|
||||
maxCollapseFaceToPointSideLengthCoeff_
|
||||
(
|
||||
readScalar(dict.lookup("maxCollapseFaceToPointSideLengthCoeff"))
|
||||
dict.lookupOrDefault<scalar>("maxCollapseFaceToPointSideLengthCoeff", 0)
|
||||
),
|
||||
allowEarlyCollapseToPoint_
|
||||
(
|
||||
@ -1237,7 +1240,7 @@ Foam::edgeCollapser::edgeCollapser
|
||||
),
|
||||
allowEarlyCollapseCoeff_
|
||||
(
|
||||
readScalar(dict.lookup("allowEarlyCollapseCoeff"))
|
||||
dict.lookupOrDefault<scalar>("allowEarlyCollapseCoeff", 0)
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
@ -22,62 +22,6 @@ collapseEdgesCoeffs
|
||||
// The maximum angle between two edges that share a point attached to
|
||||
// no other edges
|
||||
maximumMergeAngle 5;
|
||||
|
||||
// The amount that minimumEdgeLength will be reduced by for each
|
||||
// edge if that edge's collapse generates a poor quality face
|
||||
reductionFactor 0.5;
|
||||
}
|
||||
|
||||
|
||||
collapseFacesCoeffs
|
||||
{
|
||||
// The initial face length factor
|
||||
initialFaceLengthFactor 0.5;
|
||||
|
||||
// The amount that initialFaceLengthFactor will be reduced by for each
|
||||
// face if its collapse generates a poor quality face
|
||||
reductionFactor $initialFaceLengthFactor;
|
||||
|
||||
// If the face can't be collapsed to an edge, and it has a span less than
|
||||
// the target face length multiplied by this coefficient, collapse it
|
||||
// to a point.
|
||||
maxCollapseFaceToPointSideLengthCoeff 0.3;
|
||||
|
||||
// Allow early collapse of edges to a point
|
||||
allowEarlyCollapseToPoint on;
|
||||
|
||||
// Fraction to premultiply maxCollapseFaceToPointSideLengthCoeff by if
|
||||
// allowEarlyCollapseToPoint is enabled
|
||||
allowEarlyCollapseCoeff 0.2;
|
||||
|
||||
// Defining how close to the midpoint (M) of the projected
|
||||
// vertices line a projected vertex (X) can be before making this
|
||||
// an invalid edge collapse
|
||||
//
|
||||
// X---X-g----------------M----X-----------g----X--X
|
||||
//
|
||||
// Only allow a collapse if all projected vertices are outwith
|
||||
// guardFraction (g) of the distance form the face centre to the
|
||||
// furthest vertex in the considered direction
|
||||
guardFraction 0.1;
|
||||
}
|
||||
|
||||
|
||||
meshQualityCoeffs
|
||||
{
|
||||
// Name of the dictionary that has the mesh quality coefficients used
|
||||
// by motionSmoother::checkMesh
|
||||
#include "meshQualityDict";
|
||||
|
||||
// Maximum number of smoothing iterations for the reductionFactors
|
||||
maximumSmoothingIterations 2;
|
||||
|
||||
// Maximum number of outer iterations is mesh quality checking is enabled
|
||||
maximumIterations 10;
|
||||
|
||||
// Maximum number of iterations deletion of a point can cause a bad face
|
||||
// to be constructed before it is forced to not be deleted
|
||||
maxPointErrorCount 5;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,67 +0,0 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: dev |
|
||||
| \\ / A nd | Web: www.OpenFOAM.org |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class dictionary;
|
||||
object meshQualityDict;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Maximum non-orthogonality allowed. Set to 180 to disable.
|
||||
maxNonOrtho 180;
|
||||
|
||||
//- Max skewness allowed. Set to <0 to disable.
|
||||
maxBoundarySkewness 50;
|
||||
|
||||
//- Max skewness allowed. Set to <0 to disable.
|
||||
maxInternalSkewness 10;
|
||||
|
||||
//- Max concaveness allowed. Is angle (in degrees) below which concavity
|
||||
// is allowed. 0 is straight face, <0 would be convex face.
|
||||
// Set to 180 to disable.
|
||||
maxConcave 80;
|
||||
|
||||
//- Minimum pyramid volume. Is absolute volume of cell pyramid.
|
||||
// Set to a sensible fraction of the smallest cell volume expected.
|
||||
// Set to very negative number (e.g. -1E30) to disable.
|
||||
minVol 1e-20;
|
||||
|
||||
//- Minimum quality of the tet formed by the face-centre
|
||||
// and variable base point minimum decomposition triangles and
|
||||
// the cell centre. This has to be a positive number for tracking
|
||||
// to work. Set to very negative number (e.g. -1E30) to
|
||||
// disable.
|
||||
// <0 = inside out tet,
|
||||
// 0 = flat tet
|
||||
// 1 = regular tet
|
||||
minTetQuality 1e-30;
|
||||
|
||||
//- Minimum face area. Set to <0 to disable.
|
||||
minArea -1;
|
||||
|
||||
//- Minimum face twist. Set to <-1 to disable. dot product of face normal
|
||||
//- and face centre triangles normal
|
||||
minTwist 0.0;
|
||||
|
||||
//- minimum normalised cell determinant
|
||||
//- 1 = hex, <= 0 = folded or flattened illegal cell
|
||||
minDeterminant 0.001;
|
||||
|
||||
//- minFaceWeight (0 -> 0.5)
|
||||
minFaceWeight 0.02;
|
||||
|
||||
//- minVolRatio (0 -> 1)
|
||||
minVolRatio 0.01;
|
||||
|
||||
//must be >0 for Fluent compatibility
|
||||
minTriangleTwist -1;
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user