Commit 55f06f71 authored by graham's avatar graham
Browse files

ENH: Particle tracking. Resetting tracking back to existing algorithm

from experimental inside/outside cell method.
parent b7f8f37d
......@@ -30,189 +30,6 @@ License
#include "mapPolyMesh.H"
#include "Time.H"
#include "OFstream.H"
#include "triPointRef.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<class ParticleType>
const Foam::scalar Foam::Cloud<ParticleType>::minValidTrackFraction = 1e-6;
template<class ParticleType>
const Foam::scalar Foam::Cloud<ParticleType>::trackingRescueTolerance = 1e-4;
template<class ParticleType>
const Foam::scalar Foam::Cloud<ParticleType>::intersectionTolerance = 0;
template<class ParticleType>
const Foam::scalar Foam::Cloud<ParticleType>::planarCosAngle = (1 - 1e-6);
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
// Calculate using face properties only
template<class ParticleType>
bool Foam::Cloud<ParticleType>::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 pointField& cCentres = pMesh().cellCentres();
const pointField& points = pMesh().points();
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];
const face& f1 = pMesh().faces()[f1I];
// 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)
{
// Concave face
concave = 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
concave = true;
}
}
}
}
return concave;
}
template<class ParticleType>
void Foam::Cloud<ParticleType>::calcConcaveCells() const
{
const cellList& cells = pMesh().cells();
concaveCellPtr_.reset(new PackedBoolList(pMesh().nCells()));
PackedBoolList& concaveCell = concaveCellPtr_();
forAll(cells, cellI)
{
// if (isConcaveCell(cellI))
// {
// concaveCell[cellI] = 1;
// // TODO: extend selection to include any point connected
// // cell if there are conflicts between cells using the two
// // different methods
// }
// Force all cells to be treated exactly
concaveCell[cellI] = 1;
// Force all cells to be treated by planes
// concaveCell[cellI] = 0;
}
// {
// // Write cells that are concave to file
// DynamicList<label> tmpConcaveCells;
// forAll(cells, cellI)
// {
// if (concaveCell[cellI])
// {
// tmpConcaveCells.append(cellI);
// }
// }
// Pout<< "Cloud<ParticleType>::calcConcaveCells() :"
// << " overall cells in mesh : " << pMesh().nCells() << nl
// << " of these concave : " << tmpConcaveCells.size() << endl;
// fileName fName = pMesh().time().path()/"concaveCells";
// Pout<< " Writing " << fName.name() << endl;
// OFstream file(fName);
// file << tmpConcaveCells;
// file.flush();
// }
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
......@@ -220,14 +37,12 @@ template<class ParticleType>
Foam::Cloud<ParticleType>::Cloud
(
const polyMesh& pMesh,
const IDLList<ParticleType>& particles,
const bool concaveCheck
const IDLList<ParticleType>& particles
)
:
cloud(pMesh),
IDLList<ParticleType>(),
polyMesh_(pMesh),
concaveCheck_(concaveCheck),
particleCount_(0)
{
IDLList<ParticleType>::operator=(particles);
......@@ -239,43 +54,20 @@ Foam::Cloud<ParticleType>::Cloud
(
const polyMesh& pMesh,
const word& cloudName,
const IDLList<ParticleType>& particles,
const bool concaveCheck
const IDLList<ParticleType>& particles
)
:
cloud(pMesh, cloudName),
IDLList<ParticleType>(),
polyMesh_(pMesh),
concaveCheck_(concaveCheck),
particleCount_(0)
{
IDLList<ParticleType>::operator=(particles);
}
template<class ParticleType>
void Foam::Cloud<ParticleType>::clearOut()
{
concaveCellPtr_.clear();
labels_.clearStorage();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class ParticleType>
const Foam::PackedBoolList& Foam::Cloud<ParticleType>::concaveCell()
const
{
if (!concaveCellPtr_.valid())
{
calcConcaveCells();
}
return concaveCellPtr_();
}
template<class ParticleType>
Foam::label Foam::Cloud<ParticleType>::getNewParticleID() const
{
......
......@@ -39,7 +39,6 @@ SourceFiles
#include "IDLList.H"
#include "IOField.H"
#include "polyMesh.H"
#include "PackedBoolList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -75,11 +74,6 @@ class Cloud
const polyMesh& polyMesh_;
const bool concaveCheck_;
//- Is the cell concave
mutable autoPtr<PackedBoolList> concaveCellPtr_;
//- Overall count of particles ever created. Never decreases.
mutable label particleCount_;
......@@ -89,12 +83,6 @@ class Cloud
// Private Member Functions
//- Determine if a particular cell is concave
bool isConcaveCell(const label cellI) const;
//- Analyse mesh for faces not being convex.
void calcConcaveCells() const;
//- Initialise cloud on IO constructor
void initCloud(const bool checkClass);
......@@ -123,20 +111,6 @@ public:
// Static data
//- The smallest allowable trackFraction in trackToFace before
// an intervention is required
static const scalar minValidTrackFraction;
//- Fraction of distance to cell centre to move a particle to
// 'rescue' it from a tracking problem
static const scalar trackingRescueTolerance;
//- Overlap tolerance for face intersections.
static const scalar intersectionTolerance;
//- cosine of angle for faces to be planar.
static const scalar planarCosAngle;
//- Name of cloud properties dictionary
static word cloudPropertiesName;
......@@ -147,8 +121,7 @@ public:
Cloud
(
const polyMesh& mesh,
const IDLList<ParticleType>& particles,
const bool concaveCheck = true
const IDLList<ParticleType>& particles
);
//- Construct from mesh, cloud name, and a list of particles
......@@ -156,8 +129,7 @@ public:
(
const polyMesh& mesh,
const word& cloudName,
const IDLList<ParticleType>& particles,
const bool concaveCheck = true
const IDLList<ParticleType>& particles
);
//- Construct from mesh by reading from file
......@@ -165,8 +137,7 @@ public:
Cloud
(
const polyMesh& mesh,
const bool checkClass = true,
const bool concaveCheck = true
const bool checkClass = true
);
......@@ -176,17 +147,10 @@ public:
(
const polyMesh& pMesh,
const word& cloudName,
const bool checkClass = true,
const bool concaveCheck = true
const bool checkClass = true
);
// Destructor
//- Destroy any demand-driven data
void clearOut();
// Member Functions
// Access
......@@ -226,9 +190,6 @@ public:
return IDLList<ParticleType>::size();
};
//- Whether each cell is concave (demand driven data)
const PackedBoolList& concaveCell() const;
// Iterators
......
......@@ -135,13 +135,11 @@ template<class ParticleType>
Foam::Cloud<ParticleType>::Cloud
(
const polyMesh& pMesh,
const bool checkClass,
const bool concaveCheck
const bool checkClass
)
:
cloud(pMesh),
polyMesh_(pMesh),
concaveCheck_(concaveCheck),
particleCount_(0)
{
initCloud(checkClass);
......@@ -153,13 +151,11 @@ Foam::Cloud<ParticleType>::Cloud
(
const polyMesh& pMesh,
const word& cloudName,
const bool checkClass,
const bool concaveCheck
const bool checkClass
)
:
cloud(pMesh, cloudName),
polyMesh_(pMesh),
concaveCheck_(concaveCheck),
particleCount_(0)
{
initCloud(checkClass);
......
This diff is collapsed.
......@@ -163,60 +163,22 @@ protected:
const label facei
) const;
//- Find the faces between endPosition and cell centre
//- Find the faces between position and cell centre
void findFaces
(
const vector& endPosition,
const vector& position,
DynamicList<label>& faceList
) const;
//- Find the faces between endPosition and cell centre
//- Find the faces between position and cell centre
void findFaces
(
const vector& endPosition,
const vector& position,
const label celli,
const scalar stepFraction,
DynamicList<label>& faceList
) const;
//- Determine if the testPt is inside the cell by an exact
// intersection test
bool insideCellExact
(
const vector& testPt,
const label celli,
bool beingOnAFaceMeansOutside
) const;
//- Track to cell face using face decomposition, used for
// concave cells.
template<class TrackData>
void trackToFaceExact
(
scalar& trackFraction,
const vector& endPosition,
TrackData& td
);
//- Track to cell face using the infinite planes of the faces.
// The cell *must* be convex.
template<class TrackData>
void trackToFacePlanes
(
scalar& trackFraction,
const vector& endPosition,
TrackData& td
);
//- Change cell or interact with a patch as required
template<class TrackData>
void faceAction
(
scalar& trackFraction,
const vector& endPosition,
TrackData& td
);
// Patch interactions
......
......@@ -47,7 +47,7 @@ inline Foam::scalar Foam::Particle<ParticleType>::lambda
vector Cf = mesh.faceCentres()[facei];
// patch interaction
if (cloud_.boundaryFace(facei))
if (!cloud_.internalFace(facei))
{
label patchi = patch(facei);
const polyPatch& patch = mesh.boundaryMesh()[patchi];
......@@ -195,7 +195,7 @@ inline Foam::scalar Foam::Particle<ParticleType>::lambda
vector Cf = mesh.faceCentres()[facei];
// patch interaction
if (cloud_.boundaryFace(facei))
if (!cloud_.internalFace(facei))
{
label patchi = patch(facei);
const polyPatch& patch = mesh.boundaryMesh()[patchi];
......@@ -207,11 +207,10 @@ inline Foam::scalar Foam::Particle<ParticleType>::lambda
scalar CCf = mag((C - Cf) & Sf);
// check if distance between cell centre and face centre
// is larger than wallImpactDistance
const ParticleType& p = static_cast<const ParticleType&>(*this);
if (CCf > p.wallImpactDistance(Sf))
{
Cf -= p.wallImpactDistance(Sf)*Sf;
Cf -=p.wallImpactDistance(Sf)*Sf;
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment