mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: cyclicAMI: stabilise projection in case of 90 degree angles. Fixes #930.
This commit is contained in:
@ -235,7 +235,14 @@ Foam::scalar Foam::faceAreaIntersect::triangleIntersect
|
||||
// Cut source triangle with all inward pointing faces of target triangle
|
||||
// - triangles in workTris1 are inside target triangle
|
||||
|
||||
const scalar t = sqrt(triArea(src));
|
||||
const scalar srcArea(triArea(src));
|
||||
if (srcArea < ROOTVSMALL)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
// Typical length scale
|
||||
const scalar t = sqrt(srcArea);
|
||||
|
||||
// Edge 0
|
||||
{
|
||||
@ -243,10 +250,29 @@ Foam::scalar Foam::faceAreaIntersect::triangleIntersect
|
||||
// workTris1 list
|
||||
|
||||
scalar s = mag(tgt1 - tgt0);
|
||||
//plane pl0(tgt0, tgt1, tgt1 + s*n);
|
||||
plane pl0(tgt0, (tgt0 - tgt1)^(-s*n), true);
|
||||
if (s < ROOTVSMALL)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
// Note: outer product with n pre-scaled with edge length. This is
|
||||
// purely to avoid numerical errors because of drastically
|
||||
// different vector lengths.
|
||||
const vector n0((tgt0 - tgt1)^(-s*n));
|
||||
const scalar magSqrN0(magSqr(n0));
|
||||
if (magSqrN0 < ROOTVSMALL)
|
||||
{
|
||||
// Triangle either zero edge length (s == 0) or
|
||||
// perpendicular to face normal n. In either case zero
|
||||
// overlap area
|
||||
return 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
plane pl0(tgt0, n0/Foam::sqrt(magSqrN0), false);
|
||||
triSliceWithPlane(src, pl0, workTris1, nWorkTris1, t);
|
||||
}
|
||||
}
|
||||
|
||||
if (nWorkTris1 == 0)
|
||||
{
|
||||
@ -259,8 +285,23 @@ Foam::scalar Foam::faceAreaIntersect::triangleIntersect
|
||||
// workTris2 list (re-use tris storage)
|
||||
|
||||
scalar s = mag(tgt2 - tgt1);
|
||||
//plane pl1(tgt1, tgt2, tgt2 + s*n);
|
||||
plane pl1(tgt1, (tgt1 - tgt2)^(-s*n), true);
|
||||
if (s < ROOTVSMALL)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
const vector n1((tgt1 - tgt2)^(-s*n));
|
||||
const scalar magSqrN1(magSqr(n1));
|
||||
|
||||
if (magSqrN1 < ROOTVSMALL)
|
||||
{
|
||||
// Triangle either zero edge length (s == 0) or
|
||||
// perpendicular to face normal n. In either case zero
|
||||
// overlap area
|
||||
return 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
plane pl1(tgt1, n1/Foam::sqrt(magSqrN1), false);
|
||||
|
||||
nWorkTris2 = 0;
|
||||
|
||||
@ -274,6 +315,7 @@ Foam::scalar Foam::faceAreaIntersect::triangleIntersect
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Edge 2
|
||||
{
|
||||
@ -281,8 +323,23 @@ Foam::scalar Foam::faceAreaIntersect::triangleIntersect
|
||||
// workTris1 list (re-use workTris1 storage)
|
||||
|
||||
scalar s = mag(tgt2 - tgt0);
|
||||
//plane pl2(tgt2, tgt0, tgt0 + s*n);
|
||||
plane pl2(tgt2, (tgt2 - tgt0)^(-s*n), true);
|
||||
if (s < ROOTVSMALL)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
const vector n2((tgt2 - tgt0)^(-s*n));
|
||||
const scalar magSqrN2(magSqr(n2));
|
||||
|
||||
if (magSqrN2 < ROOTVSMALL)
|
||||
{
|
||||
// Triangle either zero edge length (s == 0) or
|
||||
// perpendicular to face normal n. In either case zero
|
||||
// overlap area
|
||||
return 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
plane pl2(tgt2, n2/Foam::sqrt(magSqrN2), false);
|
||||
|
||||
nWorkTris1 = 0;
|
||||
|
||||
@ -313,6 +370,7 @@ Foam::scalar Foam::faceAreaIntersect::triangleIntersect
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
|
||||
|
||||
Reference in New Issue
Block a user