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

View File

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