sampledSet/face: Improved robustness of face selection

This commit is contained in:
Henry Weller
2016-03-19 21:21:23 +00:00
parent 1b93e52c79
commit 649128313b
2 changed files with 32 additions and 41 deletions

View File

@ -47,17 +47,13 @@ bool Foam::faceOnlySet::trackToBoundary
( (
passiveParticleCloud& particleCloud, passiveParticleCloud& particleCloud,
passiveParticle& singleParticle, passiveParticle& singleParticle,
const scalar smallDist,
DynamicList<point>& samplingPts, DynamicList<point>& samplingPts,
DynamicList<label>& samplingCells, DynamicList<label>& samplingCells,
DynamicList<label>& samplingFaces, DynamicList<label>& samplingFaces,
DynamicList<scalar>& samplingCurveDist DynamicList<scalar>& samplingCurveDist
) const ) const
{ {
// distance vector between sampling points
const vector offset = end_ - start_;
const vector smallVec = tol*offset;
const scalar smallDist = mag(smallVec);
particle::TrackingData<passiveParticleCloud> trackData(particleCloud); particle::TrackingData<passiveParticleCloud> trackData(particleCloud);
// Alias // Alias
@ -101,7 +97,7 @@ void Foam::faceOnlySet::calcSamples
DynamicList<scalar>& samplingCurveDist DynamicList<scalar>& samplingCurveDist
) const ) const
{ {
// distance vector between sampling points // Distance vector between sampling points
if (mag(end_ - start_) < SMALL) if (mag(end_ - start_) < SMALL)
{ {
FatalErrorInFunction FatalErrorInFunction
@ -138,13 +134,12 @@ void Foam::faceOnlySet::calcSamples
} }
// Get first tracking point. Use bPoint, bFaceI if provided. // Get first tracking point. Use bPoint, bFaceI if provided.
point trackPt; point trackPt;
label trackCellI = -1; label trackCellI = -1;
label trackFaceI = -1; label trackFaceI = -1;
//Info<< "before getTrackingPoint : bPoint:" << bPoint // Pout<< "before getTrackingPoint : bPoint:" << bPoint
// << " bFaceI:" << bFaceI << endl; // << " bFaceI:" << bFaceI << endl;
getTrackingPoint getTrackingPoint
( (
@ -152,25 +147,25 @@ void Foam::faceOnlySet::calcSamples
bPoint, bPoint,
bFaceI, bFaceI,
smallDist, smallDist,
trackPt, trackPt,
trackCellI, trackCellI,
trackFaceI trackFaceI
); );
//Info<< "after getTrackingPoint : " // Pout<< "after getTrackingPoint : "
// << " trackPt:" << trackPt // << " trackPt:" << trackPt
// << " trackCellI:" << trackCellI // << " trackCellI:" << trackCellI
// << " trackFaceI:" << trackFaceI // << " trackFaceI:" << trackFaceI
// << endl; // << endl;
if (trackCellI == -1) if (trackCellI == -1)
{ {
// Line start_ - end_ does not intersect domain at all. // Line start_ - end_ does not intersect domain at all.
// (or is along edge) // (or is along edge)
// Set points and cell/face labels to empty lists // Set points and cell/face labels to empty lists
//Info<< "calcSamples : Both start_ and end_ outside domain"
// << endl; // Pout<< "calcSamples : Both start_ and end_ outside domain"
// << endl;
return; return;
} }
@ -181,11 +176,11 @@ void Foam::faceOnlySet::calcSamples
trackFaceI = findNearFace(trackCellI, trackPt, smallDist); trackFaceI = findNearFace(trackCellI, trackPt, smallDist);
} }
//Info<< "calcSamples : got first point to track from :" // Pout<< "calcSamples : got first point to track from :"
// << " trackPt:" << trackPt // << " trackPt:" << trackPt
// << " trackCell:" << trackCellI // << " trackCell:" << trackCellI
// << " trackFace:" << trackFaceI // << " trackFace:" << trackFaceI
// << endl; // << endl;
// //
// Track until hit end of all boundary intersections // Track until hit end of all boundary intersections
@ -200,11 +195,11 @@ void Foam::faceOnlySet::calcSamples
// index in bHits; current boundary intersection // index in bHits; current boundary intersection
label bHitI = 1; label bHitI = 1;
while(true) while (true)
{ {
if (trackFaceI != -1) if (trackFaceI != -1)
{ {
//Info<< "trackPt:" << trackPt << " on face so use." << endl; // Pout<< "trackPt:" << trackPt << " on face so use." << endl;
samplingPts.append(trackPt); samplingPts.append(trackPt);
samplingCells.append(trackCellI); samplingCells.append(trackCellI);
samplingFaces.append(trackFaceI); samplingFaces.append(trackFaceI);
@ -223,32 +218,27 @@ void Foam::faceOnlySet::calcSamples
( (
particleCloud, particleCloud,
singleParticle, singleParticle,
smallDist,
samplingPts, samplingPts,
samplingCells, samplingCells,
samplingFaces, samplingFaces,
samplingCurveDist samplingCurveDist
); );
// fill sampleSegments // Fill sampleSegments
for (label i = samplingPts.size() - 1; i >= startSegmentI; --i) for (label i = samplingPts.size() - 1; i >= startSegmentI; --i)
{ {
samplingSegments.append(segmentI); samplingSegments.append(segmentI);
} }
if (!reachedBoundary) if (!reachedBoundary)
{ {
//Info<< "calcSamples : Reached end of samples: " // Pout<< "calcSamples : Reached end of samples: "
// << " samplePt now:" << singleParticle.position() // << " samplePt now:" << singleParticle.position()
// << endl; // << endl;
break; break;
} }
// Go past boundary intersection where tracking stopped
// Use coordinate comparison instead of face comparison for
// accuracy reasons
bool foundValidB = false; bool foundValidB = false;
while (bHitI < bHits.size()) while (bHitI < bHits.size())
@ -257,15 +247,15 @@ void Foam::faceOnlySet::calcSamples
(bHits[bHitI].hitPoint() - singleParticle.position()) (bHits[bHitI].hitPoint() - singleParticle.position())
& normOffset; & normOffset;
//Info<< "Finding next boundary : " // Pout<< "Finding next boundary : "
// << "bPoint:" << bHits[bHitI].hitPoint() // << "bPoint:" << bHits[bHitI].hitPoint()
// << " tracking:" << singleParticle.position() // << " tracking:" << singleParticle.position()
// << " dist:" << dist // << " dist:" << dist
// << endl; // << endl;
if (dist > smallDist) if (dist > smallDist)
{ {
// hitpoint is past tracking position // Hit-point is past tracking position
foundValidB = true; foundValidB = true;
break; break;
} }
@ -275,7 +265,7 @@ void Foam::faceOnlySet::calcSamples
} }
} }
if (!foundValidB) if (!foundValidB || bHitI == bHits.size() - 1)
{ {
// No valid boundary intersection found beyond tracking position // No valid boundary intersection found beyond tracking position
break; break;

View File

@ -70,6 +70,7 @@ class faceOnlySet
( (
passiveParticleCloud& particleCloud, passiveParticleCloud& particleCloud,
passiveParticle& singleParticle, passiveParticle& singleParticle,
const scalar smallDist,
DynamicList<point>& samplingPts, DynamicList<point>& samplingPts,
DynamicList<label>& samplingCells, DynamicList<label>& samplingCells,
DynamicList<label>& samplingFaces, DynamicList<label>& samplingFaces,