bool Foam::faceOnlySet::trackToBoundary ( passiveParticle& singleParticle, DynamicList<point>& samplingPts, DynamicList<label>& samplingCells, DynamicList<label>& samplingFaces, DynamicList<scalar>& samplingCurveDist ) const { // distance vector between sampling points const vector offset = end_ - start_; const vector smallVec = tol*offset; const scalar smallDist = mag(smallVec); passiveParticleCloud particleCloud(mesh()); particle::TrackingData<passiveParticleCloud> trackData(particleCloud); // Alias const point& trackPt = singleParticle.position(); while(true) { point oldPoint = trackPt; singleParticle.trackToFace(end_, trackData); if (singleParticle.face() != -1 && mag(oldPoint - trackPt) > smallDist) { // Reached face. Sample. samplingPts.append(trackPt); samplingCells.append(singleParticle.cell()); samplingFaces.append(singleParticle.face()); samplingCurveDist.append(mag(trackPt - start_)); } if (mag(trackPt - end_) < smallDist) { // end reached return false; } else if (singleParticle.onBoundary()) { // Boundary reached. return true; } } }
bool Foam::faceOnlySet::trackToBoundary ( passiveParticleCloud& particleCloud, passiveParticle& singleParticle, const scalar smallDist, DynamicList<point>& samplingPts, DynamicList<label>& samplingCells, DynamicList<label>& samplingFaces, DynamicList<scalar>& samplingCurveDist ) const { particle::TrackingData<passiveParticleCloud> trackData(particleCloud); const point& trackPt = singleParticle.position(); while(true) { point oldPoint = trackPt; singleParticle.trackToFace(end_, trackData); if (singleParticle.face() != -1 && mag(oldPoint - trackPt) > smallDist) { // Reached face. Sample. samplingPts.append(trackPt); samplingCells.append(singleParticle.cell()); samplingFaces.append(singleParticle.face()); samplingCurveDist.append(mag(trackPt - start_)); } if (mag(trackPt - end_) < smallDist) { // End reached return false; } else if (singleParticle.onBoundary()) { // Boundary reached return true; } } }
bool Foam::polyLineSet::trackToBoundary ( passiveParticleCloud& particleCloud, passiveParticle& singleParticle, label& sampleI, DynamicList<point>& samplingPts, DynamicList<label>& samplingCells, DynamicList<label>& samplingFaces, DynamicList<scalar>& samplingCurveDist ) const { particle::TrackingData<passiveParticleCloud> trackData(particleCloud); while (true) { // Local geometry info const vector offset = sampleCoords_[sampleI+1] - sampleCoords_[sampleI]; const scalar smallDist = mag(tol*offset); singleParticle.track(offset, 0); const point trackPt = singleParticle.position(); if (singleParticle.onBoundaryFace()) { //Info<< "trackToBoundary : reached boundary" // << " trackPt:" << trackPt << endl; if ( mag(trackPt - sampleCoords_[sampleI+1]) < smallDist ) { // Reached samplePt on boundary //Info<< "trackToBoundary : boundary. also sampling." // << " trackPt:" << trackPt << " sampleI+1:" << sampleI+1 // << endl; samplingPts.append(trackPt); samplingCells.append(singleParticle.cell()); samplingFaces.append(singleParticle.face()); // trackPt is at sampleI+1 samplingCurveDist.append(1.0*(sampleI+1)); } return true; } // Reached samplePt in cell samplingPts.append(trackPt); samplingCells.append(singleParticle.cell()); samplingFaces.append(-1); // Convert trackPt to fraction inbetween sampleI and sampleI+1 scalar dist = mag(trackPt - sampleCoords_[sampleI]) / mag(sampleCoords_[sampleI+1] - sampleCoords_[sampleI]); samplingCurveDist.append(sampleI + dist); // go to next samplePt sampleI++; if (sampleI == sampleCoords_.size() - 1) { // no more samples. //Info<< "trackToBoundary : Reached end : sampleI now:" << sampleI // << endl; return false; } } }
bool Foam::uniformSet::trackToBoundary ( passiveParticleCloud& particleCloud, passiveParticle& singleParticle, point& samplePt, label& sampleI, DynamicList<point>& samplingPts, DynamicList<label>& samplingCells, DynamicList<label>& samplingFaces, DynamicList<scalar>& samplingCurveDist ) const { // distance vector between sampling points const vector offset = (end_ - start_)/(nPoints_ - 1); const vector smallVec = tol*offset; const scalar smallDist = mag(smallVec); // Alias const point& trackPt = singleParticle.position(); particle::TrackingData<passiveParticleCloud> trackData(particleCloud); while(true) { // Find next samplePt on/after trackPt. Update samplePt, sampleI if (!nextSample(trackPt, offset, smallDist, samplePt, sampleI)) { // no more samples. if (debug) { Pout<< "trackToBoundary : Reached end : samplePt now:" << samplePt << " sampleI now:" << sampleI << endl; } return false; } if (mag(samplePt - trackPt) < smallDist) { // trackPt corresponds with samplePt. Store and use next samplePt if (debug) { Pout<< "trackToBoundary : samplePt corresponds to trackPt : " << " trackPt:" << trackPt << " samplePt:" << samplePt << endl; } samplingPts.append(trackPt); samplingCells.append(singleParticle.cell()); samplingFaces.append(-1); samplingCurveDist.append(mag(trackPt - start_)); // go to next samplePt if (!nextSample(trackPt, offset, smallDist, samplePt, sampleI)) { // no more samples. if (debug) { Pout<< "trackToBoundary : Reached end : " << " samplePt now:" << samplePt << " sampleI now:" << sampleI << endl; } return false; } } if (debug) { Pout<< "Searching along trajectory from " << " trackPt:" << trackPt << " trackCelli:" << singleParticle.cell() << " to:" << samplePt << endl; } point oldPos = trackPt; label facei = -1; do { singleParticle.stepFraction() = 0; singleParticle.track(samplePt, trackData); 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()) { //Pout<< "trackToBoundary : reached boundary" << endl; if (mag(trackPt - samplePt) < smallDist) { //Pout<< "trackToBoundary : boundary is also sampling point" // << endl; // Reached samplePt on boundary samplingPts.append(trackPt); samplingCells.append(singleParticle.cell()); samplingFaces.append(facei); samplingCurveDist.append(mag(trackPt - start_)); } return true; } //Pout<< "trackToBoundary : reached internal sampling point" << endl; // Reached samplePt in cell or on internal face samplingPts.append(trackPt); samplingCells.append(singleParticle.cell()); samplingFaces.append(-1); samplingCurveDist.append(mag(trackPt - start_)); // go to next samplePt } }