STYLE: adjust some internal variables names in hierarchGeomDecomp

This commit is contained in:
Mark Olesen
2019-03-20 12:02:42 +01:00
parent 88630d6367
commit efd84d01b2
2 changed files with 73 additions and 76 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2004-2010, 2015-2018 OpenCFD Ltd. \\ / A nd | Copyright (C) 2004-2010, 2015-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -54,16 +54,18 @@ namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::hierarchGeomDecomp::setDecompOrder() void Foam::hierarchGeomDecomp::setOrder()
{ {
word order; const word order(coeffsDict_.lookupOrDefault<word>("order", ""));
if (coeffsDict_.readIfPresent("order", order)) if (order.empty())
{ {
if (order.size() != 3) return;
}
else if (order.size() != 3)
{ {
FatalIOErrorInFunction(decompDict_) FatalIOErrorInFunction(decompDict_)
<< "number of characters in order (" << order << ") != 3" << "Number of characters in order (" << order << ") != 3"
<< exit(FatalIOError); << exit(FatalIOError);
} }
@ -73,9 +75,9 @@ void Foam::hierarchGeomDecomp::setDecompOrder()
switch (order[i]) switch (order[i])
{ {
case 'x': decompOrder_[i] = 0; break; case 'x': order_[i] = 0; break;
case 'y': decompOrder_[i] = 1; break; case 'y': order_[i] = 1; break;
case 'z': decompOrder_[i] = 2; break; case 'z': order_[i] = 2; break;
default: default:
FatalIOErrorInFunction(decompDict_) FatalIOErrorInFunction(decompDict_)
@ -86,30 +88,29 @@ void Foam::hierarchGeomDecomp::setDecompOrder()
} }
} }
} }
}
Foam::label Foam::hierarchGeomDecomp::findLower Foam::label Foam::hierarchGeomDecomp::findLower
( (
const List<scalar>& l, const UList<scalar>& list,
const scalar t, const scalar val,
const label initLow, const label first,
const label initHigh const label last
) )
{ {
if (initHigh <= initLow) label low = first;
{ label high = last;
return initLow;
}
label low = initLow; if (high <= low)
label high = initHigh; {
return low;
}
while ((high - low) > 1) while ((high - low) > 1)
{ {
label mid = (low + high)/2; const label mid = (low + high)/2;
if (l[mid] < t) if (list[mid] < val)
{ {
low = mid; low = mid;
} }
@ -121,18 +122,14 @@ Foam::label Foam::hierarchGeomDecomp::findLower
// high and low can still differ by one. Choose best. // high and low can still differ by one. Choose best.
label tIndex = -1; if (list[high-1] < val)
if (l[high-1] < t)
{ {
tIndex = high; return high;
} }
else else
{ {
tIndex = low; return low;
} }
return tIndex;
} }
@ -184,12 +181,11 @@ bool Foam::hierarchGeomDecomp::findBinary
scalar& midValue // value at mid scalar& midValue // value at mid
) )
{ {
label low = minIndex;
scalar lowValue = minValue; scalar lowValue = minValue;
scalar highValue = maxValue; scalar highValue = maxValue;
// (one beyond) index of highValue
label high = values.size(); label low = minIndex;
label high = values.size(); // (one beyond) index of highValue
// Safeguards to avoid infinite loop. // Safeguards to avoid infinite loop.
scalar midValuePrev = VGREAT; scalar midValuePrev = VGREAT;
@ -340,13 +336,13 @@ Foam::label Foam::hierarchGeomDecomp::sortComponent
const label sizeTol, const label sizeTol,
const pointField& points, const pointField& points,
const labelList& current, // slice of points to decompose const labelList& current, // slice of points to decompose
const direction componentIndex, // index in decompOrder_ const direction componentIndex, // index in order_
const label mult, // multiplication factor for finalDecomp const label mult, // multiplication factor for finalDecomp
labelList& finalDecomp labelList& finalDecomp
) const ) const
{ {
// Current component // Current component
const label compI = decompOrder_[componentIndex]; const label compI = order_[componentIndex];
// Track the number of times that findBinary() did not converge // Track the number of times that findBinary() did not converge
label nWarnings = 0; label nWarnings = 0;
@ -532,13 +528,13 @@ Foam::label Foam::hierarchGeomDecomp::sortComponent
const scalarField& weights, const scalarField& weights,
const pointField& points, const pointField& points,
const labelList& current, // slice of points to decompose const labelList& current, // slice of points to decompose
const direction componentIndex, // index in decompOrder_ const direction componentIndex, // index in order_
const label mult, // multiplication factor for finalDecomp const label mult, // multiplication factor for finalDecomp
labelList& finalDecomp labelList& finalDecomp
) const ) const
{ {
// Current component // Current component
const label compI = decompOrder_[componentIndex]; const label compI = order_[componentIndex];
// Track the number of times that findBinary() did not converge // Track the number of times that findBinary() did not converge
label nWarnings = 0; label nWarnings = 0;
@ -727,9 +723,9 @@ Foam::hierarchGeomDecomp::hierarchGeomDecomp
) )
: :
geomDecomp(typeName, decompDict), geomDecomp(typeName, decompDict),
decompOrder_({0,1,2}) order_({0,1,2})
{ {
setDecompOrder(); setOrder();
} }
@ -740,9 +736,9 @@ Foam::hierarchGeomDecomp::hierarchGeomDecomp
) )
: :
geomDecomp(typeName, decompDict, regionName), geomDecomp(typeName, decompDict, regionName),
decompOrder_({0,1,2}) order_({0,1,2})
{ {
setDecompOrder(); setOrder();
} }
@ -773,7 +769,7 @@ Foam::labelList Foam::hierarchGeomDecomp::decompose
sizeTol, sizeTol,
rotatedPoints, rotatedPoints,
slice, slice,
0, // Sort first component in decompOrder. 0, // Sort first component in order_
1, // Offset for different x bins. 1, // Offset for different x bins.
finalDecomp finalDecomp
); );
@ -816,7 +812,7 @@ Foam::labelList Foam::hierarchGeomDecomp::decompose
weights, weights,
rotatedPoints, rotatedPoints,
slice, slice,
0, // Sort first component in decompOrder. 0, // Sort first component in order_
1, // Offset for different x bins. 1, // Offset for different x bins.
finalDecomp finalDecomp
); );

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2004-2010, 2017-2018 OpenCFD Ltd. \\ / A nd | Copyright (C) 2004-2010, 2017-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2015 OpenFOAM Foundation | Copyright (C) 2011-2015 OpenFOAM Foundation
@ -50,7 +50,7 @@ Description
Method coefficients: Method coefficients:
\table \table
Property | Description | Required | Default Property | Description | Required | Default
n | (nx ny nz) | yes n | (nx ny nz) | yes |
delta | delta for rotation matrix | no | 0.001 delta | delta for rotation matrix | no | 0.001
order | order of operation | no | xyz order | order of operation | no | xyz
\endtable \endtable
@ -78,17 +78,27 @@ class hierarchGeomDecomp
: :
public geomDecomp public geomDecomp
{ {
// Private data // Private Data
//- Decomposition order in terms of components. //- Decomposition order in terms of components.
FixedList<direction, 3> decompOrder_; FixedList<direction, 3> order_;
// Private Member Functions // Private Member Functions
//- Convert ordering string ("xyz") into list of components. //- Convert ordering string ("xyz") into list of components.
// Checks for bad entries, but no check for duplicate entries. // Checks for bad entries, but no check for duplicate entries.
void setDecompOrder(); void setOrder();
//- Find index of value in list between
//- first (inclusive) and last (exclusive)
static label findLower
(
const UList<scalar>& list,
const scalar val,
const label first,
const label last
);
//- Evaluates the weighted sizes for each sorted point. //- Evaluates the weighted sizes for each sorted point.
static void calculateSortedWeightedSizes static void calculateSortedWeightedSizes
@ -101,15 +111,6 @@ class hierarchGeomDecomp
scalarField& sortedWeightedSizes scalarField& sortedWeightedSizes
); );
//- Find index of t in list inbetween indices left and right
static label findLower
(
const List<scalar>&,
const scalar t,
const label left,
const label right
);
//- Find midValue (at local index mid) such that the number of //- Find midValue (at local index mid) such that the number of
// elements between mid and leftIndex are (globally summed) the // elements between mid and leftIndex are (globally summed) the
// wantedSize. Binary search. // wantedSize. Binary search.