From 8fd827aeb3ed7fa5510383d5fb0abbb9ba3b423f Mon Sep 17 00:00:00 2001 From: graham Date: Tue, 6 Oct 2009 16:59:46 +0100 Subject: [PATCH] Moving to a cell approach for cells that are concave. WIP - still problems. --- src/lagrangian/basic/Cloud/Cloud.C | 297 ++++++---------- src/lagrangian/basic/Cloud/Cloud.H | 29 +- src/lagrangian/basic/Cloud/CloudIO.C | 5 - src/lagrangian/basic/Particle/Particle.C | 409 ++++++++++------------- src/lagrangian/basic/Particle/Particle.H | 17 + 5 files changed, 307 insertions(+), 450 deletions(-) diff --git a/src/lagrangian/basic/Cloud/Cloud.C b/src/lagrangian/basic/Cloud/Cloud.C index 7c2b383b83..b4a38f7ba0 100644 --- a/src/lagrangian/basic/Cloud/Cloud.C +++ b/src/lagrangian/basic/Cloud/Cloud.C @@ -42,7 +42,7 @@ template const Foam::scalar Foam::Cloud::trackingRescueTolerance = 1e-3; template -const Foam::scalar Foam::Cloud::intersectionTolerance = 1e-6; +const Foam::scalar Foam::Cloud::intersectionTolerance = 1e-9; template const Foam::scalar Foam::Cloud::planarCosAngle = (1 - 1e-6); @@ -52,226 +52,143 @@ const Foam::scalar Foam::Cloud::planarCosAngle = (1 - 1e-6); // Calculate using face properties only template -Foam::label Foam::Cloud::isIntrudingFace -( - const label cellI, - const label f0I, - const label f1I -) const +bool Foam::Cloud::isConcaveCell(const label cellI) const { + const cellList& cells = pMesh().cells(); + + const labelList& fOwner = pMesh().faceOwner(); 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 cell& cFaces = cells[cellI]; - 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) + forAll(cFaces, i) { - fn0 *= -1; - } + label f0I = cFaces[i]; - // 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) + forAll(cFaces, j) { - continue; - } + if (j != i) + { + label f1I = cFaces[j]; - const point& pt = points[ptI]; + // Get f0 centre + const point& fc0 = fCentres[f0I]; - // Normal distance from fc0 to pt - scalar d = ((fc0 - pt) & fn0); + const face& f0 = pMesh().faces()[f0I]; - if (d < 0) - { - // Proper concave: f1 on wrong side of f0 - return 2; + 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]; + + // If the cell is concave, the point on f1 will be + // on the outside of the plane of f0, defined by + // its centre and normal, and the angle between + // (fc0 -pt) and fn0 will be greater than 90 + // degrees, so the dot product will be negative. + + scalar d = ((fc0 - pt) & fn0); + + if (d < 0) + { + return true; + } + } + + // Check for co-planar faces, which are also treated + // as concave, as they are not strictly convex. + + 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 true; + } + } } } - // 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; + return false; } template -void Foam::Cloud::calcIntrudingFaces() const +void Foam::Cloud::calcConcaveCells() 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