ENH: polyMesh: additional mesh checks about interpolation weights and volume ratio

This commit is contained in:
mattijs
2013-04-15 15:24:23 +01:00
parent aa57b759b9
commit 8460d967cc
4 changed files with 373 additions and 1 deletions

View File

@ -500,6 +500,190 @@ bool Foam::polyMesh::checkCellDeterminant
}
bool Foam::polyMesh::checkFaceWeight
(
const vectorField& fCtrs,
const vectorField& fAreas,
const vectorField& cellCtrs,
const bool report,
const scalar minWeight,
labelHashSet* setPtr
) const
{
if (debug)
{
Info<< "bool polyMesh::checkFaceWeight(const bool"
<< ", labelHashSet*) const: "
<< "checking for low face interpolation weights" << endl;
}
tmp<scalarField> tfaceWght = polyMeshTools::faceWeights
(
*this,
fCtrs,
fAreas,
cellCtrs
);
scalarField& faceWght = tfaceWght();
label nErrorFaces = 0;
scalar minDet = GREAT;
scalar sumDet = 0.0;
label nSummed = 0;
// Statistics only for internal and masters of coupled faces
PackedBoolList isMasterFace(syncTools::getInternalOrMasterFaces(*this));
forAll (faceWght, faceI)
{
if (faceWght[faceI] < minWeight)
{
// Note: insert both sides of coupled faces
if (setPtr)
{
setPtr->insert(faceI);
}
nErrorFaces++;
}
// Note: statistics only on master of coupled faces
if (isMasterFace[faceI])
{
minDet = min(minDet, faceWght[faceI]);
sumDet += faceWght[faceI];
nSummed++;
}
}
reduce(nErrorFaces, sumOp<label>());
reduce(minDet, minOp<scalar>());
reduce(sumDet, sumOp<scalar>());
reduce(nSummed, sumOp<label>());
if (debug || report)
{
if (nSummed > 0)
{
Info<< " Face interpolation weight : minimum: " << minDet
<< " average: " << sumDet/nSummed
<< endl;
}
}
if (nErrorFaces > 0)
{
if (debug || report)
{
Info<< " ***Faces with small interpolation found, number of faces: "
<< nErrorFaces << endl;
}
return true;
}
else
{
if (debug || report)
{
Info<< " Face interpolation weight check OK." << endl;
}
return false;
}
return false;
}
bool Foam::polyMesh::checkVolRatio
(
const scalarField& cellVols,
const bool report,
const scalar minRatio,
labelHashSet* setPtr
) const
{
if (debug)
{
Info<< "bool polyMesh::checkVolRatio(const bool"
<< ", labelHashSet*) const: "
<< "checking for low volume ratio" << endl;
}
tmp<scalarField> tvolRatio = polyMeshTools::volRatio(*this, cellVols);
scalarField& volRatio = tvolRatio();
label nErrorFaces = 0;
scalar minDet = GREAT;
scalar sumDet = 0.0;
label nSummed = 0;
// Statistics only for internal and masters of coupled faces
PackedBoolList isMasterFace(syncTools::getInternalOrMasterFaces(*this));
forAll (volRatio, faceI)
{
if (volRatio[faceI] < minRatio)
{
// Note: insert both sides of coupled faces
if (setPtr)
{
setPtr->insert(faceI);
}
nErrorFaces++;
}
// Note: statistics only on master of coupled faces
if (isMasterFace[faceI])
{
minDet = min(minDet, volRatio[faceI]);
sumDet += volRatio[faceI];
nSummed++;
}
}
reduce(nErrorFaces, sumOp<label>());
reduce(minDet, minOp<scalar>());
reduce(sumDet, sumOp<scalar>());
reduce(nSummed, sumOp<label>());
if (debug || report)
{
if (nSummed > 0)
{
Info<< " Face volume ratio : minimum: " << minDet
<< " average: " << sumDet/nSummed
<< endl;
}
}
if (nErrorFaces > 0)
{
if (debug || report)
{
Info<< " ***Faces with small volume ratio found, number of faces: "
<< nErrorFaces << endl;
}
return true;
}
else
{
if (debug || report)
{
Info<< " Face volume ratio check OK." << endl;
}
return false;
}
return false;
}
//- Could override checkClosedBoundary to not look at (collocated!) coupled
// faces
//bool Foam::polyMesh::checkClosedBoundary(const bool report) const
@ -582,6 +766,36 @@ bool Foam::polyMesh::checkCellDeterminant
}
bool Foam::polyMesh::checkFaceWeight
(
const bool report,
const scalar minWeight,
labelHashSet* setPtr
) const
{
return checkFaceWeight
(
faceCentres(),
faceAreas(),
cellCentres(),
report,
minWeight,
setPtr
);
}
bool Foam::polyMesh::checkVolRatio
(
const bool report,
const scalar minRatio,
labelHashSet* setPtr
) const
{
return checkVolRatio(cellVolumes(), report, minRatio, setPtr);
}
bool Foam::polyMesh::checkMeshMotion
(
const pointField& newPoints,