From 9ef96ef0a8e6c0959fe8db6199f60432cfdd6c4e Mon Sep 17 00:00:00 2001 From: graham Date: Tue, 6 Oct 2009 10:21:43 +0100 Subject: [PATCH 01/16] Modified version of Mattijs' concave tracking modifications. Changes to Mattijs' work are: + Correct use of normals and cosine (dot product) to identify planar faces. + Correct use for lambda in tracking - it is a fraction, not a distance. + Not doing a reduce on demand driven construction data - not all processors call it at the same time, so crashes. This implementation contains an attempt at making the calculation of lambdaC (from the cell centre) use decomposed triangles for faces, but this is a bad approach, the concept of using lambdaC relies on the definition of a convex polyhedron, i.e. none of the planes of the faces of the polyhedron are inside the volume. Can't use this method and will need to treat a convex cell completely differently, not just some of its faces. --- src/lagrangian/basic/Cloud/Cloud.C | 285 ++++++++++++++++++++++- src/lagrangian/basic/Cloud/Cloud.H | 65 +++++- src/lagrangian/basic/Cloud/CloudIO.C | 13 +- src/lagrangian/basic/Particle/Particle.C | 193 +++++++++++++-- 4 files changed, 533 insertions(+), 23 deletions(-) diff --git a/src/lagrangian/basic/Cloud/Cloud.C b/src/lagrangian/basic/Cloud/Cloud.C index e3e0b4f63f..7c2b383b83 100644 --- a/src/lagrangian/basic/Cloud/Cloud.C +++ b/src/lagrangian/basic/Cloud/Cloud.C @@ -31,6 +31,250 @@ License #include "mapPolyMesh.H" #include "Time.H" #include "OFstream.H" +#include "triPointRef.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +template +const Foam::scalar Foam::Cloud::minValidTrackFraction = 1e-10; + +template +const Foam::scalar Foam::Cloud::trackingRescueTolerance = 1e-3; + +template +const Foam::scalar Foam::Cloud::intersectionTolerance = 1e-6; + +template +const Foam::scalar Foam::Cloud::planarCosAngle = (1 - 1e-6); + + +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // + +// Calculate using face properties only +template +Foam::label Foam::Cloud::isIntrudingFace +( + const label cellI, + const label f0I, + const label f1I +) const +{ + const vectorField& fAreas = pMesh().faceAreas(); + const pointField& fCentres = pMesh().faceCentres(); + const labelList& fOwner = pMesh().faceOwner(); + const pointField& points = pMesh().points(); + + // Get f0 centre + const point& fc0 = fCentres[f0I]; + + const face& f0 = pMesh().faces()[f0I]; + + const face& f1 = pMesh().faces()[f1I]; + + vector fn0 = fAreas[f0I]; + fn0 /= (mag(fn0) + VSMALL); + + // Flip normal if required so that it is always pointing out of + // the cell + if (fOwner[f0I] != cellI) + { + fn0 *= -1; + } + + // Is any vertex of f1 on wrong side of the plane of f0? + + forAll(f1, f1pI) + { + label ptI = f1[f1pI]; + + // Skip points that are shared between f1 and f0 + if (findIndex(f0, ptI) > -1) + { + continue; + } + + const point& pt = points[ptI]; + + // Normal distance from fc0 to pt + scalar d = ((fc0 - pt) & fn0); + + if (d < 0) + { + // Proper concave: f1 on wrong side of f0 + return 2; + } + } + + // Could be a convex cell, but check angle for planar faces. + + vector fn1 = fAreas[f1I]; + fn1 /= (mag(fn1) + VSMALL); + + // Flip normal if required so that it is always pointing out of + // the cell + if (fOwner[f1I] != cellI) + { + fn1 *= -1; + } + + if ((fn0 & fn1) > planarCosAngle) + { + // Planar face + return 1; + } + + return 0; +} + + +template +void Foam::Cloud::calcIntrudingFaces() const +{ + const labelList& fOwner = pMesh().faceOwner(); + const cellList& cells = pMesh().cells(); + + intrudesIntoOwnerPtr_.reset(new PackedBoolList(pMesh().nFaces())); + PackedBoolList& intrudesIntoOwner = intrudesIntoOwnerPtr_(); + intrudesIntoNeighbourPtr_.reset(new PackedBoolList(pMesh().nFaces())); + PackedBoolList& intrudesIntoNeighbour = intrudesIntoNeighbourPtr_(); + + PackedBoolList cellsWithProblemFaces(cells.size()); + DynamicList