mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: polyMeshGeometry: make skewness checking consistent
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -239,6 +239,7 @@ bool Foam::motionSmoother::checkMesh
|
|||||||
maxIntSkew,
|
maxIntSkew,
|
||||||
maxBounSkew,
|
maxBounSkew,
|
||||||
mesh,
|
mesh,
|
||||||
|
mesh.points(),
|
||||||
mesh.cellCentres(),
|
mesh.cellCentres(),
|
||||||
mesh.faceCentres(),
|
mesh.faceCentres(),
|
||||||
mesh.faceAreas(),
|
mesh.faceAreas(),
|
||||||
@ -481,14 +482,14 @@ bool Foam::motionSmoother::checkMesh
|
|||||||
(
|
(
|
||||||
readScalar(dict.lookup("minArea", true))
|
readScalar(dict.lookup("minArea", true))
|
||||||
);
|
);
|
||||||
const scalar maxIntSkew
|
//const scalar maxIntSkew
|
||||||
(
|
//(
|
||||||
readScalar(dict.lookup("maxInternalSkewness", true))
|
// readScalar(dict.lookup("maxInternalSkewness", true))
|
||||||
);
|
//);
|
||||||
const scalar maxBounSkew
|
//const scalar maxBounSkew
|
||||||
(
|
//(
|
||||||
readScalar(dict.lookup("maxBoundarySkewness", true))
|
// readScalar(dict.lookup("maxBoundarySkewness", true))
|
||||||
);
|
//);
|
||||||
const scalar minWeight
|
const scalar minWeight
|
||||||
(
|
(
|
||||||
readScalar(dict.lookup("minFaceWeight", true))
|
readScalar(dict.lookup("minFaceWeight", true))
|
||||||
@ -615,27 +616,30 @@ bool Foam::motionSmoother::checkMesh
|
|||||||
nWrongFaces = nNewWrongFaces;
|
nWrongFaces = nNewWrongFaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (maxIntSkew > 0 || maxBounSkew > 0)
|
|
||||||
{
|
|
||||||
meshGeom.checkFaceSkewness
|
|
||||||
(
|
|
||||||
report,
|
|
||||||
maxIntSkew,
|
|
||||||
maxBounSkew,
|
|
||||||
checkFaces,
|
|
||||||
baffles,
|
|
||||||
&wrongFaces
|
|
||||||
);
|
|
||||||
|
|
||||||
label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
|
//- Note: cannot check the skewness without the points and don't want
|
||||||
|
// to store them on polyMeshGeometry.
|
||||||
Info<< " faces with skewness > "
|
//if (maxIntSkew > 0 || maxBounSkew > 0)
|
||||||
<< setw(3) << maxIntSkew
|
//{
|
||||||
<< " (internal) or " << setw(3) << maxBounSkew
|
// meshGeom.checkFaceSkewness
|
||||||
<< " (boundary) : " << nNewWrongFaces-nWrongFaces << endl;
|
// (
|
||||||
|
// report,
|
||||||
nWrongFaces = nNewWrongFaces;
|
// maxIntSkew,
|
||||||
}
|
// maxBounSkew,
|
||||||
|
// checkFaces,
|
||||||
|
// baffles,
|
||||||
|
// &wrongFaces
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// label nNewWrongFaces = returnReduce(wrongFaces.size(),sumOp<label>());
|
||||||
|
//
|
||||||
|
// Info<< " faces with skewness > "
|
||||||
|
// << setw(3) << maxIntSkew
|
||||||
|
// << " (internal) or " << setw(3) << maxBounSkew
|
||||||
|
// << " (boundary) : " << nNewWrongFaces-nWrongFaces << endl;
|
||||||
|
//
|
||||||
|
// nWrongFaces = nNewWrongFaces;
|
||||||
|
//}
|
||||||
|
|
||||||
if (minWeight >= 0 && minWeight < 1)
|
if (minWeight >= 0 && minWeight < 1)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -29,6 +29,7 @@ License
|
|||||||
#include "tetrahedron.H"
|
#include "tetrahedron.H"
|
||||||
#include "syncTools.H"
|
#include "syncTools.H"
|
||||||
#include "unitConversion.H"
|
#include "unitConversion.H"
|
||||||
|
#include "primitiveMeshTools.H"
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
@ -286,29 +287,6 @@ Foam::scalar Foam::polyMeshGeometry::checkNonOrtho
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::scalar Foam::polyMeshGeometry::calcSkewness
|
|
||||||
(
|
|
||||||
const point& ownCc,
|
|
||||||
const point& neiCc,
|
|
||||||
const point& fc
|
|
||||||
)
|
|
||||||
{
|
|
||||||
scalar dOwn = mag(fc - ownCc);
|
|
||||||
scalar dNei = mag(fc - neiCc);
|
|
||||||
|
|
||||||
point faceIntersection =
|
|
||||||
ownCc*dNei/(dOwn+dNei+VSMALL)
|
|
||||||
+ neiCc*dOwn/(dOwn+dNei+VSMALL);
|
|
||||||
|
|
||||||
return
|
|
||||||
mag(fc - faceIntersection)
|
|
||||||
/ (
|
|
||||||
mag(neiCc-ownCc)
|
|
||||||
+ VSMALL
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Create the neighbour pyramid - it will have positive volume
|
// Create the neighbour pyramid - it will have positive volume
|
||||||
bool Foam::polyMeshGeometry::checkFaceTet
|
bool Foam::polyMeshGeometry::checkFaceTet
|
||||||
(
|
(
|
||||||
@ -1008,6 +986,7 @@ bool Foam::polyMeshGeometry::checkFaceSkewness
|
|||||||
const scalar internalSkew,
|
const scalar internalSkew,
|
||||||
const scalar boundarySkew,
|
const scalar boundarySkew,
|
||||||
const polyMesh& mesh,
|
const polyMesh& mesh,
|
||||||
|
const pointField& points,
|
||||||
const vectorField& cellCentres,
|
const vectorField& cellCentres,
|
||||||
const vectorField& faceCentres,
|
const vectorField& faceCentres,
|
||||||
const vectorField& faceAreas,
|
const vectorField& faceAreas,
|
||||||
@ -1024,14 +1003,8 @@ bool Foam::polyMeshGeometry::checkFaceSkewness
|
|||||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||||
|
|
||||||
// Calculate coupled cell centre
|
// Calculate coupled cell centre
|
||||||
pointField neiCc(mesh.nFaces()-mesh.nInternalFaces());
|
pointField neiCc;
|
||||||
|
syncTools::swapBoundaryCellPositions(mesh, cellCentres, neiCc);
|
||||||
for (label faceI = mesh.nInternalFaces(); faceI < mesh.nFaces(); faceI++)
|
|
||||||
{
|
|
||||||
neiCc[faceI-mesh.nInternalFaces()] = cellCentres[own[faceI]];
|
|
||||||
}
|
|
||||||
syncTools::swapBoundaryFacePositions(mesh, neiCc);
|
|
||||||
|
|
||||||
|
|
||||||
scalar maxSkew = 0;
|
scalar maxSkew = 0;
|
||||||
|
|
||||||
@ -1043,11 +1016,16 @@ bool Foam::polyMeshGeometry::checkFaceSkewness
|
|||||||
|
|
||||||
if (mesh.isInternalFace(faceI))
|
if (mesh.isInternalFace(faceI))
|
||||||
{
|
{
|
||||||
scalar skewness = calcSkewness
|
scalar skewness = primitiveMeshTools::faceSkewness
|
||||||
(
|
(
|
||||||
|
mesh,
|
||||||
|
points,
|
||||||
|
faceCentres,
|
||||||
|
faceAreas,
|
||||||
|
|
||||||
|
faceI,
|
||||||
cellCentres[own[faceI]],
|
cellCentres[own[faceI]],
|
||||||
cellCentres[nei[faceI]],
|
cellCentres[nei[faceI]]
|
||||||
faceCentres[faceI]
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check if the skewness vector is greater than the PN vector.
|
// Check if the skewness vector is greater than the PN vector.
|
||||||
@ -1073,11 +1051,16 @@ bool Foam::polyMeshGeometry::checkFaceSkewness
|
|||||||
}
|
}
|
||||||
else if (patches[patches.whichPatch(faceI)].coupled())
|
else if (patches[patches.whichPatch(faceI)].coupled())
|
||||||
{
|
{
|
||||||
scalar skewness = calcSkewness
|
scalar skewness = primitiveMeshTools::faceSkewness
|
||||||
(
|
(
|
||||||
|
mesh,
|
||||||
|
points,
|
||||||
|
faceCentres,
|
||||||
|
faceAreas,
|
||||||
|
|
||||||
|
faceI,
|
||||||
cellCentres[own[faceI]],
|
cellCentres[own[faceI]],
|
||||||
neiCc[faceI-mesh.nInternalFaces()],
|
neiCc[faceI-mesh.nInternalFaces()]
|
||||||
faceCentres[faceI]
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check if the skewness vector is greater than the PN vector.
|
// Check if the skewness vector is greater than the PN vector.
|
||||||
@ -1103,21 +1086,17 @@ bool Foam::polyMeshGeometry::checkFaceSkewness
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Boundary faces: consider them to have only skewness error.
|
scalar skewness = primitiveMeshTools::boundaryFaceSkewness
|
||||||
// (i.e. treat as if mirror cell on other side)
|
(
|
||||||
|
mesh,
|
||||||
|
points,
|
||||||
|
faceCentres,
|
||||||
|
faceAreas,
|
||||||
|
|
||||||
vector faceNormal = faceAreas[faceI];
|
faceI,
|
||||||
faceNormal /= mag(faceNormal) + ROOTVSMALL;
|
cellCentres[own[faceI]]
|
||||||
|
);
|
||||||
|
|
||||||
vector dOwn = faceCentres[faceI] - cellCentres[own[faceI]];
|
|
||||||
|
|
||||||
vector dWall = faceNormal*(faceNormal & dOwn);
|
|
||||||
|
|
||||||
point faceIntersection = cellCentres[own[faceI]] + dWall;
|
|
||||||
|
|
||||||
scalar skewness =
|
|
||||||
mag(faceCentres[faceI] - faceIntersection)
|
|
||||||
/(2*mag(dWall) + ROOTVSMALL);
|
|
||||||
|
|
||||||
// Check if the skewness vector is greater than the PN vector.
|
// Check if the skewness vector is greater than the PN vector.
|
||||||
// This does not cause trouble but is a good indication of a poor
|
// This does not cause trouble but is a good indication of a poor
|
||||||
@ -1148,12 +1127,18 @@ bool Foam::polyMeshGeometry::checkFaceSkewness
|
|||||||
label face1 = baffles[i].second();
|
label face1 = baffles[i].second();
|
||||||
|
|
||||||
const point& ownCc = cellCentres[own[face0]];
|
const point& ownCc = cellCentres[own[face0]];
|
||||||
|
const point& neiCc = cellCentres[own[face1]];
|
||||||
|
|
||||||
scalar skewness = calcSkewness
|
scalar skewness = primitiveMeshTools::faceSkewness
|
||||||
(
|
(
|
||||||
|
mesh,
|
||||||
|
points,
|
||||||
|
faceCentres,
|
||||||
|
faceAreas,
|
||||||
|
|
||||||
|
face0,
|
||||||
ownCc,
|
ownCc,
|
||||||
cellCentres[own[face1]],
|
neiCc
|
||||||
faceCentres[face0]
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check if the skewness vector is greater than the PN vector.
|
// Check if the skewness vector is greater than the PN vector.
|
||||||
@ -2361,30 +2346,30 @@ bool Foam::polyMeshGeometry::checkFaceTets
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::polyMeshGeometry::checkFaceSkewness
|
//bool Foam::polyMeshGeometry::checkFaceSkewness
|
||||||
(
|
//(
|
||||||
const bool report,
|
// const bool report,
|
||||||
const scalar internalSkew,
|
// const scalar internalSkew,
|
||||||
const scalar boundarySkew,
|
// const scalar boundarySkew,
|
||||||
const labelList& checkFaces,
|
// const labelList& checkFaces,
|
||||||
const List<labelPair>& baffles,
|
// const List<labelPair>& baffles,
|
||||||
labelHashSet* setPtr
|
// labelHashSet* setPtr
|
||||||
) const
|
//) const
|
||||||
{
|
//{
|
||||||
return checkFaceSkewness
|
// return checkFaceSkewness
|
||||||
(
|
// (
|
||||||
report,
|
// report,
|
||||||
internalSkew,
|
// internalSkew,
|
||||||
boundarySkew,
|
// boundarySkew,
|
||||||
mesh_,
|
// mesh_,
|
||||||
cellCentres_,
|
// cellCentres_,
|
||||||
faceCentres_,
|
// faceCentres_,
|
||||||
faceAreas_,
|
// faceAreas_,
|
||||||
checkFaces,
|
// checkFaces,
|
||||||
baffles,
|
// baffles,
|
||||||
setPtr
|
// setPtr
|
||||||
);
|
// );
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::polyMeshGeometry::checkFaceWeights
|
bool Foam::polyMeshGeometry::checkFaceWeights
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -229,6 +229,7 @@ public:
|
|||||||
const scalar internalSkew,
|
const scalar internalSkew,
|
||||||
const scalar boundarySkew,
|
const scalar boundarySkew,
|
||||||
const polyMesh& mesh,
|
const polyMesh& mesh,
|
||||||
|
const pointField& points,
|
||||||
const vectorField& cellCentres,
|
const vectorField& cellCentres,
|
||||||
const vectorField& faceCentres,
|
const vectorField& faceCentres,
|
||||||
const vectorField& faceAreas,
|
const vectorField& faceAreas,
|
||||||
@ -372,16 +373,6 @@ public:
|
|||||||
labelHashSet* setPtr
|
labelHashSet* setPtr
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
bool checkFaceSkewness
|
|
||||||
(
|
|
||||||
const bool report,
|
|
||||||
const scalar internalSkew,
|
|
||||||
const scalar boundarySkew,
|
|
||||||
const labelList& checkFaces,
|
|
||||||
const List<labelPair>& baffles,
|
|
||||||
labelHashSet* setPtr
|
|
||||||
) const;
|
|
||||||
|
|
||||||
bool checkFaceWeights
|
bool checkFaceWeights
|
||||||
(
|
(
|
||||||
const bool report,
|
const bool report,
|
||||||
|
|||||||
Reference in New Issue
Block a user