mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-12-28 03:37:59 +00:00
ENH: code reduction in PackedList, PackedBoolList (issue #751)
- eliminate iterators from PackedList since they were unused, had
lower performance than direct access and added unneeded complexity.
- eliminate auto-vivify for the PackedList '[] operator.
The set() method provides any required auto-vivification and
removing this ability from the '[]' operator allows for a lower
when accessing the values. Replaced the previous cascade of iterators
with simpler reference class.
PackedBoolList:
- (temporarily) eliminate logic and addition operators since
these contained partially unclear semantics.
- the new test() method tests the value of a single bit position and
returns a bool without any ambiguity caused by the return type
(like the get() method), nor the const/non-const access (like
operator[] has). The name corresponds to what std::bitset uses.
- more consistent use of PackedBoolList test(), set(), unset() methods
for fewer operation and clearer code. Eg,
if (list.test(index)) ... | if (list[index]) ...
if (!list.test(index)) ... | if (list[index] == 0u) ...
list.set(index); | list[index] = 1u;
list.unset(index); | list[index] = 0u;
- deleted the operator=(const labelUList&) and replaced with a setMany()
method for more clarity about the intended operation and to avoid any
potential inadvertent behaviour.
This commit is contained in:
@ -152,7 +152,7 @@ tmp<vectorField> calcPointNormals
|
||||
const edge& e = s.edges()[edgeI];
|
||||
forAll(e, i)
|
||||
{
|
||||
if (!isFeaturePoint[e[i]])
|
||||
if (!isFeaturePoint.test(e[i]))
|
||||
{
|
||||
pointNormals[e[i]] = Zero;
|
||||
}
|
||||
@ -179,7 +179,7 @@ tmp<vectorField> calcPointNormals
|
||||
const edge& e = s.edges()[edgeI];
|
||||
forAll(e, i)
|
||||
{
|
||||
if (!isFeaturePoint[e[i]])
|
||||
if (!isFeaturePoint.test(e[i]))
|
||||
{
|
||||
pointNormals[e[i]] += n;
|
||||
nNormals[e[i]]++;
|
||||
@ -242,7 +242,7 @@ void detectSelfIntersections
|
||||
|
||||
if (hitInfo.hit())
|
||||
{
|
||||
isEdgeIntersecting[edgeI] = true;
|
||||
isEdgeIntersecting.set(edgeI);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -297,7 +297,7 @@ label detectIntersectionPoints
|
||||
{
|
||||
scale[pointI] = max(0.0, scale[pointI]-0.2);
|
||||
|
||||
isPointOnHitEdge[pointI] = true;
|
||||
isPointOnHitEdge.set(pointI);
|
||||
nHits++;
|
||||
}
|
||||
}
|
||||
@ -425,7 +425,7 @@ void minSmooth
|
||||
|
||||
forAll(fld, pointI)
|
||||
{
|
||||
if (isAffectedPoint.get(pointI) == 1)
|
||||
if (isAffectedPoint.test(pointI))
|
||||
{
|
||||
newFld[pointI] = min
|
||||
(
|
||||
@ -458,13 +458,13 @@ void lloydsSmoothing
|
||||
forAll(edges, edgeI)
|
||||
{
|
||||
const edge& e = edges[edgeI];
|
||||
if (isSmoothPoint[e[0]])
|
||||
if (isSmoothPoint.test(e[0]))
|
||||
{
|
||||
newIsSmoothPoint[e[1]] = true;
|
||||
newIsSmoothPoint.set(e[1]);
|
||||
}
|
||||
if (isSmoothPoint[e[1]])
|
||||
if (isSmoothPoint.test(e[1]))
|
||||
{
|
||||
newIsSmoothPoint[e[0]] = true;
|
||||
newIsSmoothPoint.set(e[0]);
|
||||
}
|
||||
}
|
||||
Info<< "From points-to-smooth " << isSmoothPoint.count()
|
||||
@ -545,11 +545,11 @@ void lloydsSmoothing
|
||||
const edge& e = edges[edgeI];
|
||||
if (isSmoothPoint[e[0]])
|
||||
{
|
||||
newIsSmoothPoint[e[1]] = true;
|
||||
newIsSmoothPoint.set(e[1]);
|
||||
}
|
||||
if (isSmoothPoint[e[1]])
|
||||
{
|
||||
newIsSmoothPoint[e[0]] = true;
|
||||
newIsSmoothPoint.set(e[0]);
|
||||
}
|
||||
}
|
||||
Info<< "From points-to-smooth " << isSmoothPoint.count()
|
||||
@ -662,17 +662,11 @@ int main(int argc, char *argv[])
|
||||
<< " out of " << s.nEdges() << nl
|
||||
<< endl;
|
||||
|
||||
PackedBoolList isFeaturePoint(s.nPoints());
|
||||
forAll(features.featurePoints(), i)
|
||||
{
|
||||
label pointI = features.featurePoints()[i];
|
||||
isFeaturePoint[pointI] = true;
|
||||
}
|
||||
PackedBoolList isFeaturePoint(s.nPoints(), features.featurePoints());
|
||||
|
||||
const List<surfaceFeatures::edgeStatus> edgeStat(features.toStatus());
|
||||
|
||||
|
||||
|
||||
|
||||
const pointField initialPoints(s.points());
|
||||
|
||||
|
||||
@ -809,9 +803,9 @@ int main(int argc, char *argv[])
|
||||
// Accumulate all affected points
|
||||
forAll(isAffectedPoint, pointI)
|
||||
{
|
||||
if (isAffectedPoint[pointI])
|
||||
if (isAffectedPoint.test(pointI))
|
||||
{
|
||||
isScaledPoint[pointI] = true;
|
||||
isScaledPoint.set(pointI);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user