BUG: lambda numerator and denominator too small for tiny domains.

They go < SMALL for micro/nano domains and trigger corrections.  An absolute
value of SMALL is not justifiable, using cell volume scaled comparison.
This commit is contained in:
graham
2011-04-06 11:12:33 +01:00
parent 86a87a59eb
commit bddb31eaf8
2 changed files with 22 additions and 11 deletions

View File

@ -97,12 +97,19 @@ inline Foam::scalar Foam::particle::tetLambda
scalar lambdaNumerator = (base - from) & n; scalar lambdaNumerator = (base - from) & n;
scalar lambdaDenominator = (to - from) & n; scalar lambdaDenominator = (to - from) & n;
if (mag(lambdaDenominator) < SMALL) // n carries the area of the tet faces, so the dot product with a
// delta-length has the units of volume. Comparing the component of each
// delta-length in the direction of n times the face area to a fraction of
// the cell volume.
scalar tol = 1e3*SMALL*mesh_.cellVolumes()[cellI];
if (mag(lambdaDenominator) < tol)
{ {
if (mag(lambdaNumerator) < SMALL) if (mag(lambdaNumerator) < tol)
{ {
// Track starts on the face, and is potentially // Track starts on the face, and is potentially
// parallel to it. +-SMALL/+-SMALL is not a good // parallel to it. +-tol/+-tol is not a good
// comparison, return 0.0, in anticipation of tet // comparison, return 0.0, in anticipation of tet
// centre correction. // centre correction.
@ -110,10 +117,11 @@ inline Foam::scalar Foam::particle::tetLambda
} }
else else
{ {
if (mag((to - from)) < SMALL) if (mag((to - from)) < tol/mag(n))
{ {
// Zero length track, not along the face, face // 'Zero' length track (compared to the tolerance, which is
// cannot be crossed. // based on the cell volume, divided by the tet face area), not
// along the face, face cannot be crossed.
return GREAT; return GREAT;
} }
@ -291,12 +299,14 @@ inline Foam::scalar Foam::particle::movingTetLambda
} }
if (mag(lambdaDenominator) < SMALL) scalar tol = 1e3*SMALL*mesh_.cellVolumes()[cellI];
if (mag(lambdaDenominator) < tol)
{ {
if (mag(lambdaNumerator) < SMALL) if (mag(lambdaNumerator) < tol)
{ {
// Track starts on the face, and is potentially // Track starts on the face, and is potentially
// parallel to it. +-SMALL)/+-SMALL is not a good // parallel to it. +-tol)/+-tol is not a good
// comparison, return 0.0, in anticipation of tet // comparison, return 0.0, in anticipation of tet
// centre correction. // centre correction.
@ -304,7 +314,7 @@ inline Foam::scalar Foam::particle::movingTetLambda
} }
else else
{ {
if (mag((to - from)) < SMALL) if (mag((to - from)) < tol/mag(n))
{ {
// Zero length track, not along the face, face // Zero length track, not along the face, face
// cannot be crossed. // cannot be crossed.

View File

@ -30,6 +30,7 @@ License
#include "symmetryPolyPatch.H" #include "symmetryPolyPatch.H"
#include "wallPolyPatch.H" #include "wallPolyPatch.H"
#include "wedgePolyPatch.H" #include "wedgePolyPatch.H"
#include "meshTools.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -463,7 +464,7 @@ Foam::scalar Foam::particle::trackToFace
// << origId_ << " " << origProc_<< nl // << origId_ << " " << origProc_<< nl
// << "# face: " << tetFaceI_ << nl // << "# face: " << tetFaceI_ << nl
// << "# tetPtI: " << tetPtI_ << nl // << "# tetPtI: " << tetPtI_ << nl
// << "# tetBasePtI: " << mesh.tetBasePtIs()[tetFaceI_] << nl // << "# tetBasePtI: " << mesh_.tetBasePtIs()[tetFaceI_] << nl
// << "# tet.mag(): " << tet.mag() << nl // << "# tet.mag(): " << tet.mag() << nl
// << "# tet.quality(): " << tet.quality() // << "# tet.quality(): " << tet.quality()
// << endl; // << endl;