STYLE: use List clear() instead of setSize(0), resize(0)

- adds some consistency
This commit is contained in:
Mark Olesen
2023-09-27 17:04:22 +02:00
committed by Andrew Heather
parent 9ac0f03963
commit 524c953af3
15 changed files with 47 additions and 54 deletions

View File

@ -200,7 +200,7 @@ int main(int argc, char *argv[])
) )
{ {
patchMasterBlocks[patchi] = -1; patchMasterBlocks[patchi] = -1;
rawPatches[patchi].setSize(0); rawPatches[patchi].clear();
} }
else else
{ {

View File

@ -1211,7 +1211,7 @@ int main(int argc, char *argv[])
{ {
meshMod.addPoint(points[pointi], pointi, -1, true); meshMod.addPoint(points[pointi], pointi, -1, true);
} }
points.setSize(0); points.clear();
// Add all cells // Add all cells
for (label celli = 0; celli < nCells; celli++) for (label celli = 0; celli < nCells; celli++)
@ -1411,9 +1411,9 @@ int main(int argc, char *argv[])
} }
// Reclaim storage // Reclaim storage
faces.setSize(0); faces.clear();
owner.setSize(0); owner.clear();
neighbour.setSize(0); neighbour.clear();
// Modify mesh // Modify mesh

View File

@ -1059,7 +1059,7 @@ int main(int argc, char *argv[])
} }
} }
patchFaces.setSize(0); // Assume that this is no patch at all patchFaces.clear(); // Assume that this is no patch at all
if (cellCorrespondence[faceIndices[0]] >= 0) if (cellCorrespondence[faceIndices[0]] >= 0)
{ {

View File

@ -71,8 +71,8 @@ bool uniform::sizeLocations
scalarField& shapeSizes scalarField& shapeSizes
) const ) const
{ {
shapePts.setSize(0); shapePts.clear();
shapeSizes.setSize(0); shapeSizes.clear();
return true; return true;
} }

View File

@ -245,10 +245,10 @@ void Foam::GAMGAgglomeration::agglomerateLduAddressing
// Clear the temporary storage for the coarse cell data // Clear the temporary storage for the coarse cell data
cCellnFaces.setSize(0); cCellnFaces.clear();
cCellFaces.setSize(0); cCellFaces.clear();
initCoarseNeighb.setSize(0); initCoarseNeighb.clear();
coarseFaceMap.setSize(0); coarseFaceMap.clear();
// Create coarse-level interfaces // Create coarse-level interfaces

View File

@ -208,10 +208,10 @@ void Foam::polyMesh::clearPrimitives()
{ {
resetMotion(); resetMotion();
points_.setSize(0); points_.clear();
faces_.setSize(0); faces_.clear();
owner_.setSize(0); owner_.clear();
neighbour_.setSize(0); neighbour_.clear();
clearedPrimitives_ = true; clearedPrimitives_ = true;
} }

View File

@ -324,10 +324,10 @@ void Foam::coupledPolyPatch::calcTransformTensors
if (Cf.size() == 0) if (Cf.size() == 0)
{ {
// Dummy geometry. Assume non-separated, parallel. // Dummy geometry. Assume non-separated, parallel.
separation_.setSize(0); separation_.clear();
forwardT_.clear(); forwardT_.clear();
reverseT_.clear(); reverseT_.clear();
collocated_.setSize(0); collocated_.clear();
} }
else else
{ {
@ -352,7 +352,7 @@ void Foam::coupledPolyPatch::calcTransformTensors
// Assume per-face differing transformation, correct later // Assume per-face differing transformation, correct later
separation_.setSize(0); separation_.clear();
forwardT_.setSize(Cf.size()); forwardT_.setSize(Cf.size());
reverseT_.setSize(Cf.size()); reverseT_.setSize(Cf.size());
@ -390,8 +390,8 @@ void Foam::coupledPolyPatch::calcTransformTensors
{ {
// Translational or (unknown and normals aligned) // Translational or (unknown and normals aligned)
forwardT_.setSize(0); forwardT_.clear();
reverseT_.setSize(0); reverseT_.clear();
separation_ = Cr - Cf; separation_ = Cr - Cf;
@ -443,7 +443,7 @@ void Foam::coupledPolyPatch::calcTransformTensors
<< ". Assuming zero separation." << endl; << ". Assuming zero separation." << endl;
} }
separation_.setSize(0); separation_.clear();
collocated_ = boolList(1, true); collocated_ = boolList(1, true);
} }
else else

View File

@ -294,7 +294,7 @@ void Foam::cyclicPolyPatch::calcTransforms
const_cast<tensorField&>(forwardT()) = tensorField(1, revT.T()); const_cast<tensorField&>(forwardT()) = tensorField(1, revT.T());
const_cast<tensorField&>(reverseT()) = tensorField(1, revT); const_cast<tensorField&>(reverseT()) = tensorField(1, revT);
const_cast<vectorField&>(separation()).setSize(0); const_cast<vectorField&>(separation()).clear();
const_cast<boolList&>(collocated()) = boolList(1, false); const_cast<boolList&>(collocated()) = boolList(1, false);
} }
else else

View File

@ -1229,20 +1229,20 @@ void Foam::polyDualMesh::calcDual
// Create cells. // Create cells.
cellList dualCells(mesh.nPoints()); cellList dualCells(mesh.nPoints());
forAll(dualCells, celli) // unnecessary...
{ // forAll(dualCells, celli)
dualCells[celli].setSize(0); // {
} // dualCells[celli].clear();
// }
forAll(dualOwner, facei) forAll(dualOwner, facei)
{ {
label celli = dualOwner[facei]; label celli = dualOwner[facei];
labelList& cFaces = dualCells[celli]; if (celli != -1)
{
label sz = cFaces.size(); dualCells[celli].push_back(facei);
cFaces.setSize(sz+1); }
cFaces[sz] = facei;
} }
forAll(dualNeighbour, facei) forAll(dualNeighbour, facei)
{ {
@ -1250,11 +1250,7 @@ void Foam::polyDualMesh::calcDual
if (celli != -1) if (celli != -1)
{ {
labelList& cFaces = dualCells[celli]; dualCells[celli].push_back(facei);
label sz = cFaces.size();
cFaces.setSize(sz+1);
cFaces[sz] = facei;
} }
} }

View File

@ -1006,7 +1006,7 @@ Foam::label Foam::polyMeshFilter::filterEdges
label nOuterIterations = 0; label nOuterIterations = 0;
minEdgeLen_.resize(mesh_.nEdges(), minLen()); minEdgeLen_.resize(mesh_.nEdges(), minLen());
faceFilterFactor_.resize(0); faceFilterFactor_.clear();
labelList pointErrorCount(mesh_.nPoints(), Zero); labelList pointErrorCount(mesh_.nPoints(), Zero);

View File

@ -445,7 +445,7 @@ void Foam::InteractionLists<ParticleType>::buildInteractionLists()
// At this point, wallFaceBbsToExchange does not need to be // At this point, wallFaceBbsToExchange does not need to be
// maintained or distributed as it is not longer needed. // maintained or distributed as it is not longer needed.
wallFaceBbsToExchange.setSize(0); wallFaceBbsToExchange.clear();
wallFaceMap().reverseDistribute wallFaceMap().reverseDistribute
( (
@ -615,9 +615,9 @@ void Foam::InteractionLists<ParticleType>::findExtendedProcBbsInRange
List<label>& extendedProcBbsOrigProc List<label>& extendedProcBbsOrigProc
) )
{ {
extendedProcBbsInRange.setSize(0); extendedProcBbsInRange.clear();
extendedProcBbsTransformIndex.setSize(0); extendedProcBbsTransformIndex.clear();
extendedProcBbsOrigProc.setSize(0); extendedProcBbsOrigProc.clear();
DynamicList<treeBoundBox> tmpExtendedProcBbsInRange; DynamicList<treeBoundBox> tmpExtendedProcBbsInRange;
DynamicList<label> tmpExtendedProcBbsTransformIndex; DynamicList<label> tmpExtendedProcBbsTransformIndex;

View File

@ -234,7 +234,7 @@ void Foam::cyclicAMIPolyPatch::calcTransforms
const_cast<tensorField&>(forwardT()) = tensorField(1, revT.T()); const_cast<tensorField&>(forwardT()) = tensorField(1, revT.T());
const_cast<tensorField&>(reverseT()) = tensorField(1, revT); const_cast<tensorField&>(reverseT()) = tensorField(1, revT);
const_cast<vectorField&>(separation()).setSize(0); const_cast<vectorField&>(separation()).clear();
const_cast<boolList&>(collocated()) = boolList(1, false); const_cast<boolList&>(collocated()) = boolList(1, false);
break; break;
@ -269,7 +269,7 @@ void Foam::cyclicAMIPolyPatch::calcTransforms
const_cast<tensorField&>(forwardT()).clear(); const_cast<tensorField&>(forwardT()).clear();
const_cast<tensorField&>(reverseT()).clear(); const_cast<tensorField&>(reverseT()).clear();
const_cast<vectorField&>(separation()).setSize(0); const_cast<vectorField&>(separation()).clear();
const_cast<boolList&>(collocated()) = boolList(1, true); const_cast<boolList&>(collocated()) = boolList(1, true);
break; break;

View File

@ -2890,7 +2890,7 @@ void Foam::polyTopoChange::removeFace
<< abort(FatalError); << abort(FatalError);
} }
faces_[facei].setSize(0); faces_[facei].clear();
region_[facei] = -1; region_[facei] = -1;
faceOwner_[facei] = -1; faceOwner_[facei] = -1;
faceNeighbour_[facei] = -1; faceNeighbour_[facei] = -1;

View File

@ -618,7 +618,7 @@ Foam::faceTriangulation::faceTriangulation
if (!valid) if (!valid)
{ {
setSize(0); clear();
} }
} }
@ -639,7 +639,7 @@ Foam::faceTriangulation::faceTriangulation
if (!valid) if (!valid)
{ {
setSize(0); clear();
} }
} }

View File

@ -252,11 +252,9 @@ void Foam::radiation::viewFactor::initialise()
DebugInFunction<< "Number of procBound : " << nbri << endl; DebugInFunction<< "Number of procBound : " << nbri << endl;
PtrList<const lduPrimitiveProcessorInterface> primitiveInterfaces; PtrList<const lduPrimitiveProcessorInterface> primitiveInterfaces(nbri);
internalCoeffs_.clear();
primitiveInterfaces.setSize(nbri); boundaryCoeffs_.resize_null(nbri);
internalCoeffs_.setSize(0);
boundaryCoeffs_.setSize(nbri);
nbri = 0; nbri = 0;
@ -368,8 +366,7 @@ void Foam::radiation::viewFactor::initialise()
); );
} }
lduInterfacePtrsList allInterfaces; lduInterfacePtrsList allInterfaces(primitiveInterfaces.size());
allInterfaces.setSize(primitiveInterfaces.size());
forAll(primitiveInterfaces, i) forAll(primitiveInterfaces, i)
{ {