ENH: edgeCollapser: Make mesh checking optional and set default values for dictionary

Update biconic25-55Run35 tutorial with simplified collapseDict
This commit is contained in:
laurence
2013-01-21 14:39:16 +00:00
parent 52c637f806
commit 4256e0a770
6 changed files with 136 additions and 231 deletions

View File

@ -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 collapseEdgesCoeffs
{ {
// Edges shorter than this absolute value will be merged // Edges shorter than this absolute value will be merged
@ -22,10 +27,6 @@ collapseEdgesCoeffs
// The maximum angle between two edges that share a point attached to // The maximum angle between two edges that share a point attached to
// no other edges // no other edges
maximumMergeAngle 30; 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;
} }
@ -34,10 +35,6 @@ collapseFacesCoeffs
// The initial face length factor // The initial face length factor
initialFaceLengthFactor 0.5; 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 // 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 // the target face length multiplied by this coefficient, collapse it
// to a point. // to a point.
@ -63,12 +60,20 @@ collapseFacesCoeffs
} }
meshQualityCoeffs controlMeshQualityCoeffs
{ {
// Name of the dictionary that has the mesh quality coefficients used // Name of the dictionary that has the mesh quality coefficients used
// by motionSmoother::checkMesh // by motionSmoother::checkMesh
#include "meshQualityDict"; #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 // Maximum number of smoothing iterations for the reductionFactors
maximumSmoothingIterations 2; maximumSmoothingIterations 2;

View File

@ -427,9 +427,13 @@ Foam::polyMeshFilter::polyMeshFilter(const fvMesh& mesh)
IOobject::NO_WRITE IOobject::NO_WRITE
) )
), ),
controlMeshQuality_
(
dict_.lookupOrDefault<Switch>("controlMeshQuality", false)
),
collapseEdgesCoeffDict_(dict_.subDict("collapseEdgesCoeffs")), collapseEdgesCoeffDict_(dict_.subDict("collapseEdgesCoeffs")),
collapseFacesCoeffDict_(dict_.subDict("collapseFacesCoeffs")), collapseFacesCoeffDict_(dict_.subOrEmptyDict("collapseFacesCoeffs")),
meshQualityCoeffDict_(dict_.subDict("meshQualityCoeffs")), meshQualityCoeffDict_(dict_.subOrEmptyDict("controlMeshQualityCoeffs")),
minLen_(readScalar(collapseEdgesCoeffDict_.lookup("minimumEdgeLength"))), minLen_(readScalar(collapseEdgesCoeffDict_.lookup("minimumEdgeLength"))),
maxCos_ maxCos_
( (
@ -443,27 +447,39 @@ Foam::polyMeshFilter::polyMeshFilter(const fvMesh& mesh)
), ),
edgeReductionFactor_ edgeReductionFactor_
( (
readScalar(collapseEdgesCoeffDict_.lookup("reductionFactor")) meshQualityCoeffDict_.lookupOrDefault<scalar>("edgeReductionFactor", -1)
), ),
maxIterations_ maxIterations_
( (
readLabel(meshQualityCoeffDict_.lookup("maximumIterations")) meshQualityCoeffDict_.lookupOrAddDefault<label>("maximumIterations", 1)
), ),
maxSmoothIters_ maxSmoothIters_
( (
readLabel(meshQualityCoeffDict_.lookup("maximumSmoothingIterations")) meshQualityCoeffDict_.lookupOrAddDefault<label>
(
"maximumSmoothingIterations",
0
)
), ),
initialFaceLengthFactor_ initialFaceLengthFactor_
( (
readScalar(collapseFacesCoeffDict_.lookup("initialFaceLengthFactor")) collapseFacesCoeffDict_.lookupOrAddDefault<scalar>
(
"initialFaceLengthFactor",
-1
)
), ),
faceReductionFactor_ faceReductionFactor_
( (
readScalar(collapseFacesCoeffDict_.lookup("reductionFactor")) meshQualityCoeffDict_.lookupOrAddDefault<scalar>
(
"faceReductionFactor",
-1
)
), ),
maxPointErrorCount_ maxPointErrorCount_
( (
readLabel(meshQualityCoeffDict_.lookup("maxPointErrorCount")) meshQualityCoeffDict_.lookupOrAddDefault<label>("maxPointErrorCount", 0)
), ),
minEdgeLen_(), minEdgeLen_(),
faceFilterFactor_() faceFilterFactor_()
@ -547,23 +563,10 @@ Foam::label Foam::polyMeshFilter::filter(const label nOriginalBadFaces)
Map<point> collapsePointToLocation(newMesh.nPoints()); Map<point> collapsePointToLocation(newMesh.nPoints());
// Mark points on boundary // Mark points on boundary
const labelList boundaryPoint = findBoundaryPoints const labelList boundaryPoint = findBoundaryPoints(newMesh);
(
newMesh//,
// boundaryIOPts
);
edgeCollapser collapser(newMesh, collapseFacesCoeffDict_); 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 // Collapse faces
labelPair nCollapsedPtEdge = collapser.markSmallSliverFaces labelPair nCollapsedPtEdge = collapser.markSmallSliverFaces
@ -832,6 +835,8 @@ Foam::label Foam::polyMeshFilter::filter(const label nOriginalBadFaces)
// Do not allow collapses in regions of error. // Do not allow collapses in regions of error.
// Updates minEdgeLen, nRelaxedEdges // Updates minEdgeLen, nRelaxedEdges
if (controlMeshQuality_)
{
PackedBoolList isErrorPoint(newMesh.nPoints()); PackedBoolList isErrorPoint(newMesh.nPoints());
nBadFaces = edgeCollapser::checkMeshQuality nBadFaces = edgeCollapser::checkMeshQuality
( (
@ -868,6 +873,11 @@ Foam::label Foam::polyMeshFilter::filter(const label nOriginalBadFaces)
pointErrorCount pointErrorCount
); );
} }
else
{
return -1;
}
}
return nBadFaces; return nBadFaces;
} }
@ -931,11 +941,7 @@ Foam::label Foam::polyMeshFilter::filterEdges
Map<point> collapsePointToLocation(newMesh.nPoints()); Map<point> collapsePointToLocation(newMesh.nPoints());
// Mark points on boundary // Mark points on boundary
const labelList boundaryPoint = findBoundaryPoints const labelList boundaryPoint = findBoundaryPoints(newMesh);
(
newMesh//,
// boundaryIOPts
);
edgeCollapser collapser(newMesh, collapseFacesCoeffDict_); edgeCollapser collapser(newMesh, collapseFacesCoeffDict_);
@ -1059,6 +1065,8 @@ Foam::label Foam::polyMeshFilter::filterEdges
// Do not allow collapses in regions of error. // Do not allow collapses in regions of error.
// Updates minEdgeLen, nRelaxedEdges // Updates minEdgeLen, nRelaxedEdges
if (controlMeshQuality_)
{
PackedBoolList isErrorPoint(newMesh.nPoints()); PackedBoolList isErrorPoint(newMesh.nPoints());
nBadFaces = edgeCollapser::checkMeshQuality nBadFaces = edgeCollapser::checkMeshQuality
( (
@ -1087,6 +1095,11 @@ Foam::label Foam::polyMeshFilter::filterEdges
pointErrorCount pointErrorCount
); );
} }
else
{
return -1;
}
}
return nBadFaces; return nBadFaces;
} }
@ -1174,6 +1187,8 @@ Foam::label Foam::polyMeshFilter::filterIndirectPatchFaces()
// Do not allow collapses in regions of error. // Do not allow collapses in regions of error.
// Updates minEdgeLen, nRelaxedEdges // Updates minEdgeLen, nRelaxedEdges
if (controlMeshQuality_)
{
PackedBoolList isErrorPoint(newMesh.nPoints()); PackedBoolList isErrorPoint(newMesh.nPoints());
nBadFaces = edgeCollapser::checkMeshQuality nBadFaces = edgeCollapser::checkMeshQuality
( (
@ -1187,6 +1202,7 @@ Foam::label Foam::polyMeshFilter::filterIndirectPatchFaces()
<< returnReduce(isErrorPoint.count(), sumOp<unsigned int>()) << returnReduce(isErrorPoint.count(), sumOp<unsigned int>())
<< endl; << endl;
} }
}
return nBadFaces; return nBadFaces;
} }

View File

@ -70,14 +70,18 @@ class polyMeshFilter
//- Dictionary containing the coefficient sub-dictionaries //- Dictionary containing the coefficient sub-dictionaries
const IOdictionary dict_; 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 //- Coefficients for collapsing edges
const dictionary& collapseEdgesCoeffDict_; const dictionary& collapseEdgesCoeffDict_;
//- Coefficients for collapsing faces //- Coefficients for collapsing faces
const dictionary& collapseFacesCoeffDict_; dictionary collapseFacesCoeffDict_;
//- Coefficients for controlling the mesh quality //- Coefficients for controlling the mesh quality
const dictionary& meshQualityCoeffDict_; dictionary meshQualityCoeffDict_;
//- Remove edges shorter than this length //- Remove edges shorter than this length
const scalar minLen_; const scalar minLen_;

View File

@ -1226,10 +1226,13 @@ Foam::edgeCollapser::edgeCollapser
) )
: :
mesh_(mesh), mesh_(mesh),
guardFraction_(readScalar(dict.lookup("guardFraction"))), guardFraction_
(
dict.lookupOrDefault<scalar>("guardFraction", 0)
),
maxCollapseFaceToPointSideLengthCoeff_ maxCollapseFaceToPointSideLengthCoeff_
( (
readScalar(dict.lookup("maxCollapseFaceToPointSideLengthCoeff")) dict.lookupOrDefault<scalar>("maxCollapseFaceToPointSideLengthCoeff", 0)
), ),
allowEarlyCollapseToPoint_ allowEarlyCollapseToPoint_
( (
@ -1237,7 +1240,7 @@ Foam::edgeCollapser::edgeCollapser
), ),
allowEarlyCollapseCoeff_ allowEarlyCollapseCoeff_
( (
readScalar(dict.lookup("allowEarlyCollapseCoeff")) dict.lookupOrDefault<scalar>("allowEarlyCollapseCoeff", 0)
) )
{} {}

View File

@ -22,62 +22,6 @@ collapseEdgesCoeffs
// The maximum angle between two edges that share a point attached to // The maximum angle between two edges that share a point attached to
// no other edges // no other edges
maximumMergeAngle 5; 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;
} }

View File

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