Commit 41fc7145 authored by Mark Olesen's avatar Mark Olesen
Browse files

Use the PackedList unset() method in a few places

- also PackedBoolList.get(x) == 1 can be written without the ==
  comparison since the unsigned -> bool conversion is fast
parent d2d39c32
......@@ -330,7 +330,7 @@ Foam::PackedBoolList Foam::syncTools::getMasterFaces(const polyMesh& mesh)
{
forAll(pp, i)
{
isMasterFace.set(pp.start()+i, 0);
isMasterFace.unset(pp.start()+i);
}
}
}
......@@ -341,7 +341,7 @@ Foam::PackedBoolList Foam::syncTools::getMasterFaces(const polyMesh& mesh)
for (label i = pp.size()/2; i < pp.size(); i++)
{
isMasterFace.set(pp.start()+i, 0);
isMasterFace.unset(pp.start()+i);
}
}
else
......
......@@ -97,9 +97,9 @@ void Foam::dynamicRefineFvMesh::calculateProtectedCells
forAll(faceNeighbour(), faceI)
{
label own = faceOwner()[faceI];
bool ownProtected = (unrefineableCell.get(own) == 1);
bool ownProtected = unrefineableCell.get(own);
label nei = faceNeighbour()[faceI];
bool neiProtected = (unrefineableCell.get(nei) == 1);
bool neiProtected = unrefineableCell.get(nei);
if (ownProtected && (cellLevel[nei] > cellLevel[own]))
{
......@@ -113,7 +113,7 @@ void Foam::dynamicRefineFvMesh::calculateProtectedCells
for (label faceI = nInternalFaces(); faceI < nFaces(); faceI++)
{
label own = faceOwner()[faceI];
bool ownProtected = (unrefineableCell.get(own) == 1);
bool ownProtected = unrefineableCell.get(own);
if
(
ownProtected
......@@ -710,10 +710,10 @@ Foam::labelList Foam::dynamicRefineFvMesh::selectRefineCells
if
(
cellLevel[cellI] < maxRefinement
&& candidateCell.get(cellI) == 1
&& candidateCell.get(cellI)
&& (
unrefineableCell.empty()
|| unrefineableCell.get(cellI) == 0
|| !unrefineableCell.get(cellI)
)
)
{
......@@ -731,10 +731,10 @@ Foam::labelList Foam::dynamicRefineFvMesh::selectRefineCells
if
(
cellLevel[cellI] == level
&& candidateCell.get(cellI) == 1
&& candidateCell.get(cellI)
&& (
unrefineableCell.empty()
|| unrefineableCell.get(cellI) == 0
|| !unrefineableCell.get(cellI)
)
)
{
......@@ -792,7 +792,7 @@ Foam::labelList Foam::dynamicRefineFvMesh::selectUnrefinePoints
forAll(pCells, pCellI)
{
if (markedCell.get(pCells[pCellI]) == 1)
if (markedCell.get(pCells[pCellI]))
{
hasMarked = true;
break;
......@@ -837,7 +837,7 @@ void Foam::dynamicRefineFvMesh::extendMarkedCells
forAll(markedCell, cellI)
{
if (markedCell.get(cellI) == 1)
if (markedCell.get(cellI))
{
const cell& cFaces = cells()[cellI];
......@@ -902,7 +902,7 @@ Foam::dynamicRefineFvMesh::dynamicRefineFvMesh(const IOobject& io)
{
label cellI = pCells[i];
if (protectedCell_.get(cellI) == 0)
if (!protectedCell_.get(cellI))
{
if (pointLevel[pointI] <= cellLevel[cellI])
{
......
......@@ -1118,7 +1118,7 @@ void Foam::motionSmoother::updateMesh()
forAll(meshPoints, i)
{
isInternalPoint_.set(meshPoints[i], 0);
isInternalPoint_.unset(meshPoints[i]);
}
// Calculate master edge addressing
......
......@@ -1584,11 +1584,11 @@ Foam::label Foam::hexRef8::faceConsistentRefinement
{
if (maxSet)
{
refineCell.set(nei, 1);
refineCell.set(nei);
}
else
{
refineCell.set(own, 0);
refineCell.unset(own);
}
nChanged++;
}
......@@ -1596,11 +1596,11 @@ Foam::label Foam::hexRef8::faceConsistentRefinement
{
if (maxSet)
{
refineCell.set(own, 1);
refineCell.set(own);
}
else
{
refineCell.set(nei, 0);
refineCell.unset(nei);
}
nChanged++;
}
......@@ -1631,7 +1631,7 @@ Foam::label Foam::hexRef8::faceConsistentRefinement
{
if (!maxSet)
{
refineCell.set(own, 0);
refineCell.unset(own);
nChanged++;
}
}
......@@ -1639,7 +1639,7 @@ Foam::label Foam::hexRef8::faceConsistentRefinement
{
if (maxSet)
{
refineCell.set(own, 1);
refineCell.set(own);
nChanged++;
}
}
......@@ -1658,7 +1658,7 @@ void Foam::hexRef8::checkWantedRefinementLevels
PackedBoolList refineCell(mesh_.nCells());
forAll(cellsToRefine, i)
{
refineCell.set(cellsToRefine[i], 1);
refineCell.set(cellsToRefine[i]);
}
for (label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++)
......@@ -2043,7 +2043,7 @@ Foam::labelList Foam::hexRef8::consistentRefinement
PackedBoolList refineCell(mesh_.nCells());
forAll(cellsToRefine, i)
{
refineCell.set(cellsToRefine[i], 1);
refineCell.set(cellsToRefine[i]);
}
while (true)
......@@ -2071,7 +2071,7 @@ Foam::labelList Foam::hexRef8::consistentRefinement
forAll(refineCell, cellI)
{
if (refineCell.get(cellI) == 1)
if (refineCell.get(cellI))
{
nRefined++;
}
......@@ -2082,7 +2082,7 @@ Foam::labelList Foam::hexRef8::consistentRefinement
forAll(refineCell, cellI)
{
if (refineCell.get(cellI) == 1)
if (refineCell.get(cellI))
{
newCellsToRefine[nRefined++] = cellI;
}
......@@ -2895,7 +2895,7 @@ Foam::labelList Foam::hexRef8::consistentSlowRefinement2
if (wanted > cellLevel_[cellI]+1)
{
refineCell.set(cellI, 1);
refineCell.set(cellI);
}
}
faceConsistentRefinement(true, refineCell);
......@@ -2924,7 +2924,7 @@ Foam::labelList Foam::hexRef8::consistentSlowRefinement2
forAll(refineCell, cellI)
{
if (refineCell.get(cellI) == 1)
if (refineCell.get(cellI))
{
nRefined++;
}
......@@ -2935,7 +2935,7 @@ Foam::labelList Foam::hexRef8::consistentSlowRefinement2
forAll(refineCell, cellI)
{
if (refineCell.get(cellI) == 1)
if (refineCell.get(cellI))
{
newCellsToRefine[nRefined++] = cellI;
}
......@@ -2968,7 +2968,7 @@ Foam::labelList Foam::hexRef8::consistentSlowRefinement2
PackedBoolList refineCell(mesh_.nCells());
forAll(newCellsToRefine, i)
{
refineCell.set(newCellsToRefine[i], 1);
refineCell.set(newCellsToRefine[i]);
}
const PackedBoolList savedRefineCell(refineCell);
......@@ -2981,7 +2981,7 @@ Foam::labelList Foam::hexRef8::consistentSlowRefinement2
);
forAll(refineCell, cellI)
{
if (refineCell.get(cellI) == 1)
if (refineCell.get(cellI))
{
cellsOut2.insert(cellI);
}
......@@ -2996,11 +2996,7 @@ Foam::labelList Foam::hexRef8::consistentSlowRefinement2
{
forAll(refineCell, cellI)
{
if
(
refineCell.get(cellI) == 1
&& savedRefineCell.get(cellI) == 0
)
if (refineCell.get(cellI) && !savedRefineCell.get(cellI))
{
dumpCell(cellI);
FatalErrorIn
......@@ -3606,7 +3602,7 @@ Foam::labelListList Foam::hexRef8::setRefinement
forAll(cFaces, i)
{
affectedFace.set(cFaces[i], 1);
affectedFace.set(cFaces[i]);
}
}
}
......@@ -3615,7 +3611,7 @@ Foam::labelListList Foam::hexRef8::setRefinement
{
if (faceMidPoint[faceI] >= 0)
{
affectedFace.set(faceI, 1);
affectedFace.set(faceI);
}
}
......@@ -3627,7 +3623,7 @@ Foam::labelListList Foam::hexRef8::setRefinement
forAll(eFaces, i)
{
affectedFace.set(eFaces[i], 1);
affectedFace.set(eFaces[i]);
}
}
}
......@@ -3644,7 +3640,7 @@ Foam::labelListList Foam::hexRef8::setRefinement
forAll(faceMidPoint, faceI)
{
if (faceMidPoint[faceI] >= 0 && affectedFace.get(faceI) == 1)
if (faceMidPoint[faceI] >= 0 && affectedFace.get(faceI))
{
// Face needs to be split and hasn't yet been done in some way
// (affectedFace - is impossible since this is first change but
......@@ -3765,7 +3761,7 @@ Foam::labelListList Foam::hexRef8::setRefinement
}
// Mark face as having been handled
affectedFace.set(faceI, 0);
affectedFace.unset(faceI);
}
}
......@@ -3795,7 +3791,7 @@ Foam::labelListList Foam::hexRef8::setRefinement
{
label faceI = eFaces[i];
if (faceMidPoint[faceI] < 0 && affectedFace.get(faceI) == 1)
if (faceMidPoint[faceI] < 0 && affectedFace.get(faceI))
{
// Unsplit face. Add edge splits to face.
......@@ -3876,7 +3872,7 @@ Foam::labelListList Foam::hexRef8::setRefinement
modFace(meshMod, faceI, newFace, own, nei);
// Mark face as having been handled
affectedFace.set(faceI, 0);
affectedFace.unset(faceI);
}
}
}
......@@ -3895,7 +3891,7 @@ Foam::labelListList Foam::hexRef8::setRefinement
forAll(affectedFace, faceI)
{
if (affectedFace.get(faceI) == 1)
if (affectedFace.get(faceI))
{
const face& f = mesh_.faces()[faceI];
......@@ -3918,7 +3914,7 @@ Foam::labelListList Foam::hexRef8::setRefinement
modFace(meshMod, faceI, f, own, nei);
// Mark face as having been handled
affectedFace.set(faceI, 0);
affectedFace.unset(faceI);
}
}
......@@ -5102,7 +5098,7 @@ Foam::labelList Foam::hexRef8::consistentUnrefinement
{
label pointI = pointsToUnrefine[i];
unrefinePoint.set(pointI, 1);
unrefinePoint.set(pointI);
}
......@@ -5115,13 +5111,13 @@ Foam::labelList Foam::hexRef8::consistentUnrefinement
forAll(unrefinePoint, pointI)
{
if (unrefinePoint.get(pointI) == 1)
if (unrefinePoint.get(pointI))
{
const labelList& pCells = mesh_.pointCells(pointI);
forAll(pCells, j)
{
unrefineCell.set(pCells[j], 1);
unrefineCell.set(pCells[j]);
}
}
}
......@@ -5149,17 +5145,24 @@ Foam::labelList Foam::hexRef8::consistentUnrefinement
if (maxSet)
{
unrefineCell.set(nei, 1);
unrefineCell.set(nei);
}
else
{
// could also combine with unset:
// if (!unrefineCell.unset(own))
// {
// FatalErrorIn("hexRef8::consistentUnrefinement(..)")
// << "problem cell already unset"
// << abort(FatalError);
// }
if (unrefineCell.get(own) == 0)
{
FatalErrorIn("hexRef8::consistentUnrefinement(..)")
<< "problem" << abort(FatalError);
}
unrefineCell.set(own, 0);
unrefineCell.unset(own);
}
nChanged++;
}
......@@ -5167,7 +5170,7 @@ Foam::labelList Foam::hexRef8::consistentUnrefinement
{
if (maxSet)
{
unrefineCell.set(own, 1);
unrefineCell.set(own);
}
else
{
......@@ -5177,7 +5180,7 @@ Foam::labelList Foam::hexRef8::consistentUnrefinement
<< "problem" << abort(FatalError);
}
unrefineCell.set(nei, 0);
unrefineCell.unset(nei);
}
nChanged++;
}
......@@ -5213,7 +5216,7 @@ Foam::labelList Foam::hexRef8::consistentUnrefinement
<< "problem" << abort(FatalError);
}
unrefineCell.set(own, 0);
unrefineCell.unset(own);
nChanged++;
}
}
......@@ -5227,7 +5230,7 @@ Foam::labelList Foam::hexRef8::consistentUnrefinement
<< "problem" << abort(FatalError);
}
unrefineCell.set(own, 1);
unrefineCell.set(own);
nChanged++;
}
}
......@@ -5255,15 +5258,15 @@ Foam::labelList Foam::hexRef8::consistentUnrefinement
// Knock out any point whose cell neighbour cannot be unrefined.
forAll(unrefinePoint, pointI)
{
if (unrefinePoint.get(pointI) == 1)
if (unrefinePoint.get(pointI))
{
const labelList& pCells = mesh_.pointCells(pointI);
forAll(pCells, j)
{
if (unrefineCell.get(pCells[j]) == 0)
if (!unrefineCell.get(pCells[j]))
{
unrefinePoint.set(pointI, 0);
unrefinePoint.unset(pointI);
break;
}
}
......@@ -5277,7 +5280,7 @@ Foam::labelList Foam::hexRef8::consistentUnrefinement
forAll(unrefinePoint, pointI)
{
if (unrefinePoint.get(pointI) == 1)
if (unrefinePoint.get(pointI))
{
nSet++;
}
......@@ -5288,7 +5291,7 @@ Foam::labelList Foam::hexRef8::consistentUnrefinement
forAll(unrefinePoint, pointI)
{
if (unrefinePoint.get(pointI) == 1)
if (unrefinePoint.get(pointI))
{
newPointsToUnrefine[nSet++] = pointI;
}
......
......@@ -228,14 +228,14 @@ Foam::pointField Foam::autoSnapDriver::smoothPatchDisplacement
label f0 = baffles[i].first();
label f1 = baffles[i].second();
if (isMasterFace.get(f0) == 1)
if (isMasterFace.get(f0))
{
// Make f1 a slave
isMasterFace.set(f1, 0);
isMasterFace.unset(f1);
}
else if (isMasterFace.get(f1) == 1)
else if (isMasterFace.get(f1))
{
isMasterFace.set(f0, 0);
isMasterFace.unset(f0);
}
else
{
......@@ -262,7 +262,7 @@ Foam::pointField Foam::autoSnapDriver::smoothPatchDisplacement
{
label faceI = pFaces[pfI];
if (isMasterFace.get(pp.addressing()[faceI]) == 1)
if (isMasterFace.get(pp.addressing()[faceI]))
{
avgBoundary[patchPointI] += pp[faceI].centre(points);
nBoundary[patchPointI]++;
......@@ -451,7 +451,7 @@ Foam::pointField Foam::autoSnapDriver::smoothPatchDisplacement
point newPos;
if (nonManifoldPoint.get(i) == 0u)
if (!nonManifoldPoint.get(i))
{
// Points that are manifold. Weight the internal and boundary
// by their number of faces and blend with
......@@ -1373,7 +1373,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::autoSnapDriver::repatchToSurface
{
label faceI = pp.addressing()[i];
if (hitSurface[i] != -1 && (isZonedFace.get(faceI) == 0))
if (hitSurface[i] != -1 && !isZonedFace.get(faceI))
{
closestPatch[i] = globalToPatch_
[
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment