Updated tolerance handling in sampledSet. Inno Gatin

This commit is contained in:
Hrvoje Jasak 2018-12-04 12:42:59 +00:00
parent 4e4caff5c6
commit 752fce1a02
5 changed files with 34 additions and 12 deletions

View file

@ -65,7 +65,7 @@ bool Foam::curveSet::trackToBoundary
const vector offset = const vector offset =
sampleCoords_[sampleI + 1] - sampleCoords_[sampleI]; sampleCoords_[sampleI + 1] - sampleCoords_[sampleI];
const scalar smallDist = mag(tol*offset); const scalar smallDist = mag(tol_()*offset);
point oldPos = trackPt; point oldPos = trackPt;
label facei = -1; label facei = -1;
@ -174,7 +174,7 @@ void Foam::curveSet::calcSamples
{ {
const vector offset = const vector offset =
sampleCoords_[sampleI+1] - sampleCoords_[sampleI]; sampleCoords_[sampleI+1] - sampleCoords_[sampleI];
const scalar smallDist = mag(tol*offset); const scalar smallDist = mag(tol_()*offset);
// Get all boundary intersections // Get all boundary intersections

View file

@ -68,7 +68,7 @@ bool Foam::faceOnlySet::trackToBoundary
{ {
// distance vector between sampling points // distance vector between sampling points
const vector offset = end_ - start_; const vector offset = end_ - start_;
const vector smallVec = tol*offset; const vector smallVec = tol_()*offset;
const scalar smallDist = mag(smallVec); const scalar smallDist = mag(smallVec);
// Alias // Alias
@ -125,7 +125,7 @@ void Foam::faceOnlySet::calcSamples
const vector offset = (end_ - start_); const vector offset = (end_ - start_);
const vector normOffset = offset/mag(offset); const vector normOffset = offset/mag(offset);
const vector smallVec = tol*offset; const vector smallVec = tol_()*offset;
const scalar smallDist = mag(smallVec); const scalar smallDist = mag(smallVec);
@ -208,7 +208,7 @@ 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(segmentI <= maxNSteps_())
{ {
if (trackFaceI != -1) if (trackFaceI != -1)
{ {

View file

@ -33,13 +33,29 @@ License
namespace Foam namespace Foam
{ {
const scalar sampledSet::tol = 1e-5;
defineTypeNameAndDebug(sampledSet, 0); defineTypeNameAndDebug(sampledSet, 0);
defineRunTimeSelectionTable(sampledSet, word); defineRunTimeSelectionTable(sampledSet, word);
} }
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const Foam::debug::tolerancesSwitch
Foam::sampledSet::tol_
(
"sampleSetTolerance",
1e-5
);
const Foam::debug::tolerancesSwitch
Foam::sampledSet::pushTol_
(
"sampleSetPushTolerance",
0.1
);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::label Foam::sampledSet::getBoundaryCell(const label faceI) const Foam::label Foam::sampledSet::getBoundaryCell(const label faceI) const
@ -189,7 +205,7 @@ Foam::point Foam::sampledSet::pushIn
const point& cellCtr = mesh().cellCentres()[cellI]; const point& cellCtr = mesh().cellCentres()[cellI];
point newSample = point newSample =
facePt + tol*(cellCtr - facePt); facePt + pushTol_()*(cellCtr - facePt);
if (!searchEngine().pointInCell(newSample, cellI)) if (!searchEngine().pointInCell(newSample, cellI))
{ {
@ -221,7 +237,7 @@ bool Foam::sampledSet::getTrackingPoint
label& trackFaceI label& trackFaceI
) const ) const
{ {
const scalar smallDist = mag(tol*offset); const scalar smallDist = mag(tol_()*offset);
bool isGoodSample = false; bool isGoodSample = false;

View file

@ -48,6 +48,8 @@ SourceFiles
#include "runTimeSelectionTables.H" #include "runTimeSelectionTables.H"
#include "autoPtr.H" #include "autoPtr.H"
#include "coordSet.H" #include "coordSet.H"
#include "debug.H"
#include "tolerancesSwitch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -201,7 +203,11 @@ public:
//- Tolerance when comparing points. Usually relative to difference //- Tolerance when comparing points. Usually relative to difference
// between start_ and end_ // between start_ and end_
const static scalar tol; static const debug::tolerancesSwitch tol_;
//- Tolerance used to push points out of the face. It is relative to the
// distance between the cell face centre and cell centre.
static const debug::tolerancesSwitch pushTol_;
// Constructors // Constructors

View file

@ -96,7 +96,7 @@ bool Foam::uniformSet::trackToBoundary
{ {
// distance vector between sampling points // distance vector between sampling points
const vector offset = (end_ - start_)/(nPoints_ - 1); const vector offset = (end_ - start_)/(nPoints_ - 1);
const vector smallVec = tol*offset; const vector smallVec = tol_()*offset;
const scalar smallDist = mag(smallVec); const scalar smallDist = mag(smallVec);
// Alias // Alias
@ -233,7 +233,7 @@ void Foam::uniformSet::calcSamples
const vector offset = (end_ - start_)/(nPoints_ - 1); const vector offset = (end_ - start_)/(nPoints_ - 1);
const vector normOffset = offset/mag(offset); const vector normOffset = offset/mag(offset);
const vector smallVec = tol*offset; const vector smallVec = tol_()*offset;
const scalar smallDist = mag(smallVec); const scalar smallDist = mag(smallVec);
// Get all boundary intersections // Get all boundary intersections