mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Lagrangian: Rewrite of the particle tracking algorithm to function in
terms of the local barycentric coordinates of the current tetrahedron, rather than the global coordinate system. Barycentric tracking works on any mesh, irrespective of mesh quality. Particles do not get "lost", and tracking does not require ad-hoc "corrections" or "rescues" to function robustly, because the calculation of particle-face intersections is unambiguous and reproducible, even at small angles of incidence. Each particle position is defined by topology (i.e. the decomposed tet cell it is in) and geometry (i.e. where it is in the cell). No search operations are needed on restart or reconstruct, unlike when particle positions are stored in the global coordinate system. The particle positions file now contains particles' local coordinates and topology, rather than the global coordinates and cell. This change to the output format is not backwards compatible. Existing cases with Lagrangian data will not restart, but they will still run from time zero without any modification. This change was necessary in order to guarantee that the loaded particle is valid, and therefore fundamentally prevent "loss" and "search-failure" type bugs (e.g., 2517, 2442, 2286, 1836, 1461, 1341, 1097). The tracking functions have also been converted to function in terms of displacement, rather than end position. This helps remove floating point error issues, particularly towards the end of a tracking step. Wall bounded streamlines have been removed. The implementation proved incompatible with the new tracking algorithm. ParaView has a surface LIC plugin which provides equivalent, or better, functionality. Additionally, bug report <https://bugs.openfoam.org/view.php?id=2517> is resolved by this change.
This commit is contained in:
committed by
Andrew Heather
parent
dd3be135de
commit
743dea87d2
@ -56,13 +56,15 @@ bool Foam::faceOnlySet::trackToBoundary
|
||||
{
|
||||
particle::TrackingData<passiveParticleCloud> trackData(particleCloud);
|
||||
|
||||
const point& trackPt = singleParticle.position();
|
||||
point trackPt = singleParticle.position();
|
||||
|
||||
while(true)
|
||||
{
|
||||
point oldPoint = trackPt;
|
||||
|
||||
singleParticle.trackToFace(end_, trackData);
|
||||
singleParticle.trackToFace(end_ - start_, 0, trackData);
|
||||
|
||||
trackPt = singleParticle.position();
|
||||
|
||||
if (singleParticle.face() != -1 && mag(oldPoint - trackPt) > smallDist)
|
||||
{
|
||||
@ -78,7 +80,7 @@ bool Foam::faceOnlySet::trackToBoundary
|
||||
// End reached
|
||||
return false;
|
||||
}
|
||||
else if (singleParticle.onBoundary())
|
||||
else if (singleParticle.onBoundaryFace())
|
||||
{
|
||||
// Boundary reached
|
||||
return true;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -56,29 +56,16 @@ bool Foam::polyLineSet::trackToBoundary
|
||||
{
|
||||
particle::TrackingData<passiveParticleCloud> trackData(particleCloud);
|
||||
|
||||
// Alias
|
||||
const point& trackPt = singleParticle.position();
|
||||
|
||||
while (true)
|
||||
{
|
||||
// Local geometry info
|
||||
const vector offset = sampleCoords_[sampleI+1] - sampleCoords_[sampleI];
|
||||
const scalar smallDist = mag(tol*offset);
|
||||
|
||||
point oldPos = trackPt;
|
||||
label facei = -1;
|
||||
do
|
||||
{
|
||||
singleParticle.stepFraction() = 0;
|
||||
singleParticle.track(sampleCoords_[sampleI+1], trackData);
|
||||
}
|
||||
while
|
||||
(
|
||||
!singleParticle.onBoundary()
|
||||
&& (mag(trackPt - oldPos) < smallDist)
|
||||
);
|
||||
singleParticle.track(offset, 0);
|
||||
const point trackPt = singleParticle.position();
|
||||
|
||||
if (singleParticle.onBoundary())
|
||||
if (singleParticle.onBoundaryFace())
|
||||
{
|
||||
//Info<< "trackToBoundary : reached boundary"
|
||||
// << " trackPt:" << trackPt << endl;
|
||||
@ -94,7 +81,7 @@ bool Foam::polyLineSet::trackToBoundary
|
||||
// << endl;
|
||||
samplingPts.append(trackPt);
|
||||
samplingCells.append(singleParticle.cell());
|
||||
samplingFaces.append(facei);
|
||||
samplingFaces.append(singleParticle.face());
|
||||
|
||||
// trackPt is at sampleI+1
|
||||
samplingCurveDist.append(1.0*(sampleI+1));
|
||||
|
||||
@ -209,17 +209,25 @@ Foam::point Foam::sampledSet::pushIn
|
||||
label tetPtI;
|
||||
mesh().findTetFacePt(celli, facePt, tetFacei, tetPtI);
|
||||
|
||||
// This is the tolerance that was defined as a static constant of the
|
||||
// particle class. It is no longer used by particle, following the switch to
|
||||
// barycentric tracking. The only place in which the tolerance is now used
|
||||
// is here. I'm not sure what the purpose of this code is, but it probably
|
||||
// wants removing. It is doing tet-searches for a particle position. This
|
||||
// should almost certainly be left to the particle class.
|
||||
const scalar trackingCorrectionTol = 1e-5;
|
||||
|
||||
if (tetFacei == -1 || tetPtI == -1)
|
||||
{
|
||||
newPosition = facePt;
|
||||
|
||||
label trap(1.0/particle::trackingCorrectionTol + 1);
|
||||
label trap(1.0/trackingCorrectionTol + 1);
|
||||
|
||||
label iterNo = 0;
|
||||
|
||||
do
|
||||
{
|
||||
newPosition += particle::trackingCorrectionTol*(cC - facePt);
|
||||
newPosition += trackingCorrectionTol*(cC - facePt);
|
||||
|
||||
mesh().findTetFacePt
|
||||
(
|
||||
|
||||
@ -94,8 +94,7 @@ bool Foam::uniformSet::trackToBoundary
|
||||
const vector smallVec = tol*offset;
|
||||
const scalar smallDist = mag(smallVec);
|
||||
|
||||
// Alias
|
||||
const point& trackPt = singleParticle.position();
|
||||
point trackPt = singleParticle.position();
|
||||
|
||||
particle::TrackingData<passiveParticleCloud> trackData(particleCloud);
|
||||
|
||||
@ -153,32 +152,10 @@ bool Foam::uniformSet::trackToBoundary
|
||||
<< " to:" << samplePt << endl;
|
||||
}
|
||||
|
||||
point oldPos = trackPt;
|
||||
label facei = -1;
|
||||
do
|
||||
{
|
||||
singleParticle.stepFraction() = 0;
|
||||
singleParticle.track(samplePt, trackData);
|
||||
singleParticle.track(samplePt - trackPt, 0);
|
||||
trackPt = singleParticle.position();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "Result of tracking "
|
||||
<< " trackPt:" << trackPt
|
||||
<< " trackCelli:" << singleParticle.cell()
|
||||
<< " trackFacei:" << singleParticle.face()
|
||||
<< " onBoundary:" << singleParticle.onBoundary()
|
||||
<< " samplePt:" << samplePt
|
||||
<< " smallDist:" << smallDist
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
while
|
||||
(
|
||||
!singleParticle.onBoundary()
|
||||
&& (mag(trackPt - oldPos) < smallDist)
|
||||
);
|
||||
|
||||
if (singleParticle.onBoundary())
|
||||
if (singleParticle.onBoundaryFace())
|
||||
{
|
||||
//Pout<< "trackToBoundary : reached boundary" << endl;
|
||||
if (mag(trackPt - samplePt) < smallDist)
|
||||
@ -188,7 +165,7 @@ bool Foam::uniformSet::trackToBoundary
|
||||
// Reached samplePt on boundary
|
||||
samplingPts.append(trackPt);
|
||||
samplingCells.append(singleParticle.cell());
|
||||
samplingFaces.append(facei);
|
||||
samplingFaces.append(singleParticle.face());
|
||||
samplingCurveDist.append(mag(trackPt - start_));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user