ENH: leak-detection. Fixes #1572.

The final leak can only be decided once all cells have been
deleted. So only exit on final invocation and give warning-only
beforehand. This avoids a lot of false positives.
The tutorial itself didn't actually produce a mesh with leakage
with the old settings. Upped the refinement level to force it
to go through the hole in the geometry.
This commit is contained in:
mattijs
2020-05-18 12:40:08 +01:00
parent 2fa0a2ea9a
commit 3d746e8ac9
5 changed files with 29 additions and 8 deletions

View File

@ -2514,6 +2514,7 @@ Foam::label Foam::meshRefinement::findRegions
const vector& perturbVec, const vector& perturbVec,
const pointField& locationsInMesh, const pointField& locationsInMesh,
const pointField& locationsOutsideMesh, const pointField& locationsOutsideMesh,
const bool exitIfLeakPath,
const writer<scalar>& leakPathFormatter, const writer<scalar>& leakPathFormatter,
const label nRegions, const label nRegions,
labelList& cellRegion, labelList& cellRegion,
@ -2725,6 +2726,8 @@ Foam::label Foam::meshRefinement::findRegions
Pstream::scatter(fName); Pstream::scatter(fName);
if (exitIfLeakPath)
{
FatalErrorInFunction FatalErrorInFunction
<< "Location in mesh " << locationsInMesh[index] << "Location in mesh " << locationsInMesh[index]
<< " is inside same mesh region " << regioni << " is inside same mesh region " << regioni
@ -2733,6 +2736,16 @@ Foam::label Foam::meshRefinement::findRegions
<< nl << " Dumped leak path to " << fName << nl << " Dumped leak path to " << fName
<< exit(FatalError); << exit(FatalError);
} }
else
{
WarningInFunction
<< "Location in mesh " << locationsInMesh[index]
<< " is inside same mesh region " << regioni
<< " as one of the locations outside mesh "
<< locationsOutsideMesh
<< nl << "Dumped leak path to " << fName << endl;
}
}
} }
} }
@ -2763,6 +2776,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitMeshRegions
const labelList& globalToSlavePatch, const labelList& globalToSlavePatch,
const pointField& locationsInMesh, const pointField& locationsInMesh,
const pointField& locationsOutsideMesh, const pointField& locationsOutsideMesh,
const bool exitIfLeakPath,
const writer<scalar>& leakPathFormatter const writer<scalar>& leakPathFormatter
) )
{ {
@ -2783,6 +2797,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitMeshRegions
mergeDistance_ * vector::one, // perturbVec mergeDistance_ * vector::one, // perturbVec
locationsInMesh, locationsInMesh,
locationsOutsideMesh, locationsOutsideMesh,
exitIfLeakPath,
leakPathFormatter, leakPathFormatter,
cellRegion.nRegions(), cellRegion.nRegions(),
cellRegion, cellRegion,

View File

@ -1439,6 +1439,7 @@ public:
const vector& perturbVec, const vector& perturbVec,
const pointField& locationsInMesh, const pointField& locationsInMesh,
const pointField& locationsOutsideMesh, const pointField& locationsOutsideMesh,
const bool exitIfLeakPath,
const writer<scalar>& leakPathFormatter, const writer<scalar>& leakPathFormatter,
const label nRegions, const label nRegions,
labelList& cellRegion, labelList& cellRegion,
@ -1453,6 +1454,7 @@ public:
const labelList& globalToSlavePatch, const labelList& globalToSlavePatch,
const pointField& locationsInMesh, const pointField& locationsInMesh,
const pointField& locationsOutsideMesh, const pointField& locationsOutsideMesh,
const bool exitIfLeakPath,
const writer<scalar>& leakPathFormatter const writer<scalar>& leakPathFormatter
); );

View File

@ -4258,6 +4258,7 @@ void Foam::meshRefinement::baffleAndSplitMesh
globalToSlavePatch, globalToSlavePatch,
locationsInMesh, locationsInMesh,
locationsOutsideMesh, locationsOutsideMesh,
true, // Exit if any connection between inside and outside
leakPathFormatter leakPathFormatter
); );
@ -4368,6 +4369,7 @@ void Foam::meshRefinement::mergeFreeStandingBaffles
globalToSlavePatch, globalToSlavePatch,
locationsInMesh, locationsInMesh,
locationsOutsideMesh, locationsOutsideMesh,
true, // Exit if any connection between inside and outside
leakPathFormatter leakPathFormatter
); );
@ -4443,6 +4445,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitMesh
mergeDistance_ * vector::one, // perturbVec mergeDistance_ * vector::one, // perturbVec
locationsInMesh, locationsInMesh,
locationsOutsideMesh, locationsOutsideMesh,
false, // do not exit if outside location found
leakPathFormatter, leakPathFormatter,
cellRegion.nRegions(), cellRegion.nRegions(),
cellRegion, cellRegion,

View File

@ -2700,6 +2700,7 @@ void Foam::snappyRefineDriver::splitAndMergeBaffles
globalToSlavePatch_, globalToSlavePatch_,
refineParams.locationsInMesh(), refineParams.locationsInMesh(),
refineParams.locationsOutsideMesh(), refineParams.locationsOutsideMesh(),
true, // exit if any path to outside points
setFormatter_ setFormatter_
); );

View File

@ -119,7 +119,7 @@ castellatedMeshControls
"motorBike.*" "motorBike.*"
{ {
// Surface-wise min and max refinement level // Surface-wise min and max refinement level
level (5 6); level (6 6);
// Optional specification of patch type (default is wall). No // Optional specification of patch type (default is wall). No
// constraint types (cyclic, symmetry) etc. are allowed. // constraint types (cyclic, symmetry) etc. are allowed.