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:
Mark Olesen
2018-03-13 08:32:40 +01:00
parent 23b6ea4b85
commit 5d1fb23555
91 changed files with 622 additions and 1999 deletions

View File

@ -271,11 +271,7 @@ void Foam::snappySnapDriver::calcNearestFace
<< exit(FatalError);
}
const faceZone& fZone = mesh.faceZones()[zonei];
PackedBoolList isZonedFace(mesh.nFaces());
forAll(fZone, i)
{
isZonedFace[fZone[i]] = 1;
}
PackedBoolList isZonedFace(mesh.nFaces(), fZone);
DynamicList<label> ppFaces(fZone.size());
DynamicList<label> meshFaces(fZone.size());
@ -575,14 +571,14 @@ void Foam::snappySnapDriver::calcNearestFacePointProperties
if (eFaces.size() == 1)
{
// 'real' boundary edge
isBoundaryPoint[e[0]] = true;
isBoundaryPoint[e[1]] = true;
isBoundaryPoint.set(e[0]);
isBoundaryPoint.set(e[1]);
}
else if (eFaces.size() == 2 && bafflePair[eFaces[0]] == eFaces[1])
{
// 'baffle' boundary edge
isBoundaryPoint[e[0]] = true;
isBoundaryPoint[e[1]] = true;
isBoundaryPoint.set(e[0]);
isBoundaryPoint.set(e[1]);
}
}
@ -2873,7 +2869,7 @@ void Foam::snappySnapDriver::determineBaffleFeatures
if (efn.size() == 2 && (efn[0]&efn[1]) < baffleFeatureCos)
{
isBaffleEdge[edgei] = true;
isBaffleEdge.set(edgei);
nBaffleEdges++;
const edge& e = pp.edges()[edgei];
pointStatus[e[0]] = 0;