From b4a2876c56c287ee18332337809a754b3c5c00f7 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 7 Mar 2018 11:28:05 +0100 Subject: [PATCH] ENH: use move construct for cellZone/faceZone --- .../fluent3DMeshToFoam/fluent3DMeshToFoam.L | 2 +- .../generation/blockMesh/mergePatchPairs.H | 18 +------- .../createBaffles/createBaffles.C | 2 +- .../mesh/manipulation/splitMesh/splitMesh.C | 4 +- .../splitMeshRegions/splitMeshRegions.C | 2 +- .../linearValveFvMesh/linearValveFvMesh.C | 20 ++------- .../linearValveLayersFvMesh.C | 28 ++---------- .../mixerFvMesh/mixerFvMesh.C | 44 +++++++------------ .../movingConeTopoFvMesh.C | 22 +++++----- 9 files changed, 40 insertions(+), 102 deletions(-) diff --git a/applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L b/applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L index c123305d47..f4ab86e9a7 100644 --- a/applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L +++ b/applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L @@ -1168,7 +1168,7 @@ int main(int argc, char *argv[]) forAll(faceZoneIDs, faceZonei) { - label zoneID = faceGroupZoneID[faceZoneIDs[faceZonei] ]; + label zoneID = faceGroupZoneID[faceZoneIDs[faceZonei]]; word name = groupName[zoneID]; const word& type = groupType[zoneID]; diff --git a/applications/utilities/mesh/generation/blockMesh/mergePatchPairs.H b/applications/utilities/mesh/generation/blockMesh/mergePatchPairs.H index c4e472363c..d62120d878 100644 --- a/applications/utilities/mesh/generation/blockMesh/mergePatchPairs.H +++ b/applications/utilities/mesh/generation/blockMesh/mergePatchPairs.H @@ -29,17 +29,10 @@ const polyPatch& masterPatch = mesh.boundaryMesh()[masterPatchName]; - labelList isf(masterPatch.size()); - - forAll(isf, i) - { - isf[i] = masterPatch.start() + i; - } - fz[3*pairI] = new faceZone ( mergeName + "MasterZone", - isf, + identity(masterPatch.size(), masterPatch.start()), false, // none are flipped 0, mesh.faceZones() @@ -50,17 +43,10 @@ const polyPatch& slavePatch = mesh.boundaryMesh()[slavePatchName]; - labelList osf(slavePatch.size()); - - forAll(osf, i) - { - osf[i] = slavePatch.start() + i; - } - fz[3*pairI + 1] = new faceZone ( mergeName + "SlaveZone", - osf, + identity(slavePatch.size(), slavePatch.start()), false, // none are flipped 1, mesh.faceZones() diff --git a/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C b/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C index 784ee755a5..5d97589024 100644 --- a/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C +++ b/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C @@ -591,7 +591,7 @@ int main(int argc, char *argv[]) { addr[n] = facei; flip[n] = faceToFlip[facei]; - n++; + ++n; } } diff --git a/applications/utilities/mesh/manipulation/splitMesh/splitMesh.C b/applications/utilities/mesh/manipulation/splitMesh/splitMesh.C index f55cba9814..bd55fcf267 100644 --- a/applications/utilities/mesh/manipulation/splitMesh/splitMesh.C +++ b/applications/utilities/mesh/manipulation/splitMesh/splitMesh.C @@ -233,8 +233,8 @@ int main(int argc, char *argv[]) new faceZone ( "membraneFaces", - faces, - zoneFlip, + std::move(faces), + std::move(zoneFlip), 0, mesh.faceZones() ); diff --git a/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C b/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C index defed945be..fb987cc1a0 100644 --- a/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C +++ b/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C @@ -1925,7 +1925,7 @@ int main(int argc, char *argv[]) new cellZone ( zoneName, //name - regionCells, //addressing + std::move(regionCells), //addressing zoneI, //index cellZones //cellZoneMesh ) diff --git a/src/topoChangerFvMesh/linearValveFvMesh/linearValveFvMesh.C b/src/topoChangerFvMesh/linearValveFvMesh/linearValveFvMesh.C index fa59d955a2..432fff4c34 100644 --- a/src/topoChangerFvMesh/linearValveFvMesh/linearValveFvMesh.C +++ b/src/topoChangerFvMesh/linearValveFvMesh/linearValveFvMesh.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -79,17 +79,10 @@ void Foam::linearValveFvMesh::addZonesAndModifiers() const word innerSliderName(motionDict_.subDict("slider").lookup("inside")); const polyPatch& innerSlider = boundaryMesh()[innerSliderName]; - labelList isf(innerSlider.size()); - - forAll(isf, i) - { - isf[i] = innerSlider.start() + i; - } - fz[0] = new faceZone ( "insideSliderZone", - isf, + identity(innerSlider.size(), innerSlider.start()), false, // none are flipped 0, faceZones() @@ -99,17 +92,10 @@ void Foam::linearValveFvMesh::addZonesAndModifiers() const word outerSliderName(motionDict_.subDict("slider").lookup("outside")); const polyPatch& outerSlider = boundaryMesh()[outerSliderName]; - labelList osf(outerSlider.size()); - - forAll(osf, i) - { - osf[i] = outerSlider.start() + i; - } - fz[1] = new faceZone ( "outsideSliderZone", - osf, + identity(outerSlider.size(), outerSlider.start()), false, // none are flipped 1, faceZones() diff --git a/src/topoChangerFvMesh/linearValveLayersFvMesh/linearValveLayersFvMesh.C b/src/topoChangerFvMesh/linearValveLayersFvMesh/linearValveLayersFvMesh.C index 7728b146fc..607485d9c3 100644 --- a/src/topoChangerFvMesh/linearValveLayersFvMesh/linearValveLayersFvMesh.C +++ b/src/topoChangerFvMesh/linearValveLayersFvMesh/linearValveLayersFvMesh.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -86,17 +86,10 @@ void Foam::linearValveLayersFvMesh::addZonesAndModifiers() const word innerSliderName(motionDict_.subDict("slider").lookup("inside")); const polyPatch& innerSlider = boundaryMesh()[innerSliderName]; - labelList isf(innerSlider.size()); - - forAll(isf, i) - { - isf[i] = innerSlider.start() + i; - } - fz[0] = new faceZone ( "insideSliderZone", - isf, + identity(innerSlider.size(), innerSlider.start()), false, // none are flipped 0, faceZones() @@ -106,17 +99,10 @@ void Foam::linearValveLayersFvMesh::addZonesAndModifiers() const word outerSliderName(motionDict_.subDict("slider").lookup("outside")); const polyPatch& outerSlider = boundaryMesh()[outerSliderName]; - labelList osf(outerSlider.size()); - - forAll(osf, i) - { - osf[i] = outerSlider.start() + i; - } - fz[1] = new faceZone ( "outsideSliderZone", - osf, + identity(outsideSlider.size(), outsideSlider.start()), false, // none are flipped 1, faceZones() @@ -133,16 +119,10 @@ void Foam::linearValveLayersFvMesh::addZonesAndModifiers() const polyPatch& layerPatch = boundaryMesh()[layerPatchName]; - labelList lpf(layerPatch.size()); - - forAll(lpf, i) - { - lpf[i] = layerPatch.start() + i; - } - fz[3] = new faceZone ( "valveLayerZone", + identity(layerPatch.size(), layerPatch.start()), lpf, true, // all are flipped 0, diff --git a/src/topoChangerFvMesh/mixerFvMesh/mixerFvMesh.C b/src/topoChangerFvMesh/mixerFvMesh/mixerFvMesh.C index 3d09c7d967..d613e33906 100644 --- a/src/topoChangerFvMesh/mixerFvMesh/mixerFvMesh.C +++ b/src/topoChangerFvMesh/mixerFvMesh/mixerFvMesh.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -79,17 +79,10 @@ void Foam::mixerFvMesh::addZonesAndModifiers() const word innerSliderName(motionDict_.subDict("slider").lookup("inside")); const polyPatch& innerSlider = boundaryMesh()[innerSliderName]; - labelList isf(innerSlider.size()); - - forAll(isf, i) - { - isf[i] = innerSlider.start() + i; - } - fz[0] = new faceZone ( "insideSliderZone", - isf, + identity(innerSlider.size(), innerSlider.start()), false, // none are flipped 0, faceZones() @@ -99,17 +92,10 @@ void Foam::mixerFvMesh::addZonesAndModifiers() const word outerSliderName(motionDict_.subDict("slider").lookup("outside")); const polyPatch& outerSlider = boundaryMesh()[outerSliderName]; - labelList osf(outerSlider.size()); - - forAll(osf, i) - { - osf[i] = outerSlider.start() + i; - } - fz[1] = new faceZone ( "outsideSliderZone", - osf, + identity(outerSlider.size(), outerSlider.start()), false, // none are flipped 1, faceZones() @@ -124,7 +110,7 @@ void Foam::mixerFvMesh::addZonesAndModifiers() regionSplit rs(*this); // Get the region of the cell containing the origin. - label originRegion = rs[findNearestCell(cs().origin())]; + const label originRegion = rs[findNearestCell(cs().origin())]; labelList movingCells(nCells()); label nMovingCells = 0; @@ -134,17 +120,17 @@ void Foam::mixerFvMesh::addZonesAndModifiers() if (rs[celli] == originRegion) { movingCells[nMovingCells] = celli; - nMovingCells++; + ++nMovingCells; } } - movingCells.setSize(nMovingCells); + movingCells.resize(nMovingCells); Info<< "Number of cells in the moving region: " << nMovingCells << endl; cz[0] = new cellZone ( "movingCells", - movingCells, + std::move(movingCells), 0, cellZones() ); @@ -203,14 +189,14 @@ void Foam::mixerFvMesh::calcMovingMasks() const const labelList& cellAddr = cellZones()["movingCells"]; - forAll(cellAddr, celli) + for (const label celli : cellAddr) { - const cell& curCell = c[cellAddr[celli]]; + const cell& curCell = c[celli]; - forAll(curCell, facei) + for (const label facei : curCell) { // Mark all the points as moving - const face& curFace = f[curCell[facei]]; + const face& curFace = f[facei]; forAll(curFace, pointi) { @@ -227,9 +213,9 @@ void Foam::mixerFvMesh::calcMovingMasks() const const labelList& innerSliderAddr = faceZones()[innerSliderZoneName]; - forAll(innerSliderAddr, facei) + for (const label facei : innerSliderAddr) { - const face& curFace = f[innerSliderAddr[facei]]; + const face& curFace = f[facei]; forAll(curFace, pointi) { @@ -245,9 +231,9 @@ void Foam::mixerFvMesh::calcMovingMasks() const const labelList& outerSliderAddr = faceZones()[outerSliderZoneName]; - forAll(outerSliderAddr, facei) + for (const label facei : outerSliderAddr) { - const face& curFace = f[outerSliderAddr[facei]]; + const face& curFace = f[facei]; forAll(curFace, pointi) { diff --git a/src/topoChangerFvMesh/movingConeTopoFvMesh/movingConeTopoFvMesh.C b/src/topoChangerFvMesh/movingConeTopoFvMesh/movingConeTopoFvMesh.C index 1142d6d8c7..e19c60194b 100644 --- a/src/topoChangerFvMesh/movingConeTopoFvMesh/movingConeTopoFvMesh.C +++ b/src/topoChangerFvMesh/movingConeTopoFvMesh/movingConeTopoFvMesh.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -133,7 +133,7 @@ void Foam::movingConeTopoFvMesh::addZonesAndModifiers() zone1[nZoneFaces1] = facei; Info<< "face " << facei << " for zone 1. Flip: " << flipZone1[nZoneFaces1] << endl; - nZoneFaces1++; + ++nZoneFaces1; } else if ( @@ -150,7 +150,7 @@ void Foam::movingConeTopoFvMesh::addZonesAndModifiers() Info<< "face " << facei << " for zone 2. Flip: " << flipZone2[nZoneFaces2] << endl; - nZoneFaces2++; + ++nZoneFaces2; } } @@ -173,23 +173,23 @@ void Foam::movingConeTopoFvMesh::addZonesAndModifiers() new faceZone ( "rightExtrusionFaces", - zone1, - flipZone1, + std::move(zone1), + std::move(flipZone1), nFz, faceZones() ); - nFz++; + ++nFz; fz[nFz] = new faceZone ( "leftExtrusionFaces", - zone2, - flipZone2, + std::move(zone2), + std::move(flipZone2), nFz, faceZones() ); - nFz++; + ++nFz; fz.setSize(nFz); @@ -218,7 +218,7 @@ void Foam::movingConeTopoFvMesh::addZonesAndModifiers() motionDict_.subDict("right").lookup("maxThickness") ) ); - nMods++; + ++nMods; tm[nMods] = new layerAdditionRemoval ( @@ -235,7 +235,7 @@ void Foam::movingConeTopoFvMesh::addZonesAndModifiers() motionDict_.subDict("left").lookup("maxThickness") ) ); - nMods++; + ++nMods; tm.setSize(nMods); Info<< "Adding " << nMods << " mesh modifiers" << endl;