ENH: uniformSet: enable the relative tolerance (tol) as a user-defined optional entry

This commit is contained in:
Kutalmis Bercin
2021-09-14 12:22:13 +01:00
parent c161d0e069
commit cd938d96f3
2 changed files with 12 additions and 12 deletions

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -40,8 +41,6 @@ namespace Foam
addToRunTimeSelectionTable(sampledSet, uniformSet, word); addToRunTimeSelectionTable(sampledSet, uniformSet, word);
} }
const Foam::scalar Foam::uniformSet::tol = 1e-3;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -93,7 +92,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);
point trackPt = singleParticle.position(); point trackPt = singleParticle.position();
@ -207,7 +206,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);
// Force calculation of cloud addressing on all processors // Force calculation of cloud addressing on all processors
@ -429,6 +428,7 @@ Foam::uniformSet::uniformSet
sampledSet(name, mesh, searchEngine, axis), sampledSet(name, mesh, searchEngine, axis),
start_(start), start_(start),
end_(end), end_(end),
tol_(1e-3),
nPoints_(nPoints) nPoints_(nPoints)
{ {
genSamples(); genSamples();
@ -446,6 +446,7 @@ Foam::uniformSet::uniformSet
sampledSet(name, mesh, searchEngine, dict), sampledSet(name, mesh, searchEngine, dict),
start_(dict.get<point>("start")), start_(dict.get<point>("start")),
end_(dict.get<point>("end")), end_(dict.get<point>("end")),
tol_(dict.getCheckOrDefault<scalar>("tol", 1e-3, scalarMinMax::ge(0))),
nPoints_(dict.get<label>("nPoints")) nPoints_(dict.get<label>("nPoints"))
{ {
genSamples(); genSamples();

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -63,7 +64,7 @@ class uniformSet
: :
public sampledSet public sampledSet
{ {
// Private data // Private Data
//- Starting point //- Starting point
point start_; point start_;
@ -71,9 +72,14 @@ class uniformSet
//- End point //- End point
point end_; point end_;
//- Relative tolerance when comparing points
//- relative to difference between start_ and end_
scalar tol_;
//- Number of points //- Number of points
label nPoints_; label nPoints_;
// Private Member Functions // Private Member Functions
//- Calculates - starting at samplePt - the first sampling point //- Calculates - starting at samplePt - the first sampling point
@ -125,13 +131,6 @@ public:
TypeName("uniform"); TypeName("uniform");
// Static data
//- Tolerance when comparing points relative to difference between
// start_ and end_
static const scalar tol;
// Constructors // Constructors
//- Construct from components //- Construct from components