diff --git a/src/lagrangian/basic/Cloud/Cloud.C b/src/lagrangian/basic/Cloud/Cloud.C index b4a38f7ba0..5d6cc5705a 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-9; +const Foam::scalar Foam::Cloud::intersectionTolerance = SMALL; template const Foam::scalar Foam::Cloud::planarCosAngle = (1 - 1e-6); @@ -59,37 +59,52 @@ bool Foam::Cloud::isConcaveCell(const label cellI) const const labelList& fOwner = pMesh().faceOwner(); const vectorField& fAreas = pMesh().faceAreas(); const pointField& fCentres = pMesh().faceCentres(); + const pointField& cCentres = pMesh().cellCentres(); const pointField& points = pMesh().points(); + PackedBoolList& intrudesIntoOwner = intrudesIntoOwnerPtr_(); + PackedBoolList& intrudesIntoNeighbour = intrudesIntoNeighbourPtr_(); + const cell& cFaces = cells[cellI]; + bool concave = false; + forAll(cFaces, i) { label f0I = cFaces[i]; + // Get f0 centre + const point& fc0 = fCentres[f0I]; + + const face& f0 = pMesh().faces()[f0I]; + + 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; + } + + // Check if the cell centre is visible from the plane of the face + + if (((fc0 - cCentres[cellI]) & fn0) < 0) + { + Pout<< "Face " << f0I + << " is not visible from the centre of cell " << cellI + << endl; + } + forAll(cFaces, j) { if (j != i) { label f1I = cFaces[j]; - // 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) @@ -114,7 +129,17 @@ bool Foam::Cloud::isConcaveCell(const label cellI) const if (d < 0) { - return true; + // Concave face + if (fOwner[f0I] == cellI) + { + intrudesIntoOwner[f0I] = 1; + } + else + { + intrudesIntoNeighbour[f0I] = 1; + } + + concave = true; } } @@ -134,13 +159,22 @@ bool Foam::Cloud::isConcaveCell(const label cellI) const if ((fn0 & fn1) > planarCosAngle) { // Planar face - return true; + if (fOwner[f0I] == cellI) + { + intrudesIntoOwner[f0I] = 1; + } + else + { + intrudesIntoNeighbour[f0I] = 1; + } + + concave = true; } } } } - return false; + return concave; } @@ -152,15 +186,16 @@ void Foam::Cloud::calcConcaveCells() const concaveCellPtr_.reset(new PackedBoolList(pMesh().nCells())); PackedBoolList& concaveCell = concaveCellPtr_(); + intrudesIntoOwnerPtr_.reset(new PackedBoolList(pMesh().nFaces())); + intrudesIntoNeighbourPtr_.reset(new PackedBoolList(pMesh().nFaces())); + + forAll(cells, cellI) { if (isConcaveCell(cellI)) { concaveCell[cellI] = 1; } - - // Force all cells to be decomposed - concaveCell[cellI] = 1; } { @@ -236,6 +271,8 @@ template void Foam::Cloud::clearOut() { concaveCellPtr_.clear(); + intrudesIntoOwnerPtr_.clear(); + intrudesIntoNeighbourPtr_.clear(); labels_.clearStorage(); } @@ -255,6 +292,30 @@ const } +template +const Foam::PackedBoolList& Foam::Cloud::intrudesIntoOwner() +const +{ + if (!intrudesIntoOwnerPtr_.valid()) + { + calcConcaveCells(); + } + return intrudesIntoOwnerPtr_(); +} + + +template +const Foam::PackedBoolList& Foam::Cloud::intrudesIntoNeighbour() +const +{ + if (!intrudesIntoNeighbourPtr_.valid()) + { + calcConcaveCells(); + } + return intrudesIntoNeighbourPtr_(); +} + + template Foam::label Foam::Cloud::getNewParticleID() const { diff --git a/src/lagrangian/basic/Cloud/Cloud.H b/src/lagrangian/basic/Cloud/Cloud.H index e30204abd6..b151827d0a 100644 --- a/src/lagrangian/basic/Cloud/Cloud.H +++ b/src/lagrangian/basic/Cloud/Cloud.H @@ -81,6 +81,12 @@ class Cloud //- Is the cell concave mutable autoPtr concaveCellPtr_; + //- Does face intrude into owner cell + mutable autoPtr intrudesIntoOwnerPtr_; + + //- Does face intrude into neighbour cell + mutable autoPtr intrudesIntoNeighbourPtr_; + //- Overall count of particles ever created. Never decreases. mutable label particleCount_; @@ -221,6 +227,13 @@ public: //- Whether each cell is concave (demand driven data) const PackedBoolList& concaveCell() const; + //- Per face whether it intrudes into the owner cell.(demand driven) + const PackedBoolList& intrudesIntoOwner() const; + + //- Per face whether it intrudes into the neighbour cell. (demand + // driven. + const PackedBoolList& intrudesIntoNeighbour() const; + // Iterators diff --git a/src/lagrangian/basic/Particle/Particle.C b/src/lagrangian/basic/Particle/Particle.C index 81b0532c97..b2dc2d3299 100644 --- a/src/lagrangian/basic/Particle/Particle.C +++ b/src/lagrangian/basic/Particle/Particle.C @@ -38,7 +38,7 @@ License template void Foam::Particle::findFaces ( - const vector& position, + const vector& endPosition, DynamicList