ENH: use move construct for cellZone/faceZone

This commit is contained in:
Mark Olesen
2018-03-07 11:28:05 +01:00
parent 4fe8ed8245
commit b4a2876c56
9 changed files with 40 additions and 102 deletions

View File

@ -29,17 +29,10 @@
const polyPatch& masterPatch = const polyPatch& masterPatch =
mesh.boundaryMesh()[masterPatchName]; mesh.boundaryMesh()[masterPatchName];
labelList isf(masterPatch.size());
forAll(isf, i)
{
isf[i] = masterPatch.start() + i;
}
fz[3*pairI] = new faceZone fz[3*pairI] = new faceZone
( (
mergeName + "MasterZone", mergeName + "MasterZone",
isf, identity(masterPatch.size(), masterPatch.start()),
false, // none are flipped false, // none are flipped
0, 0,
mesh.faceZones() mesh.faceZones()
@ -50,17 +43,10 @@
const polyPatch& slavePatch = const polyPatch& slavePatch =
mesh.boundaryMesh()[slavePatchName]; mesh.boundaryMesh()[slavePatchName];
labelList osf(slavePatch.size());
forAll(osf, i)
{
osf[i] = slavePatch.start() + i;
}
fz[3*pairI + 1] = new faceZone fz[3*pairI + 1] = new faceZone
( (
mergeName + "SlaveZone", mergeName + "SlaveZone",
osf, identity(slavePatch.size(), slavePatch.start()),
false, // none are flipped false, // none are flipped
1, 1,
mesh.faceZones() mesh.faceZones()

View File

@ -591,7 +591,7 @@ int main(int argc, char *argv[])
{ {
addr[n] = facei; addr[n] = facei;
flip[n] = faceToFlip[facei]; flip[n] = faceToFlip[facei];
n++; ++n;
} }
} }

View File

@ -233,8 +233,8 @@ int main(int argc, char *argv[])
new faceZone new faceZone
( (
"membraneFaces", "membraneFaces",
faces, std::move(faces),
zoneFlip, std::move(zoneFlip),
0, 0,
mesh.faceZones() mesh.faceZones()
); );

View File

@ -1925,7 +1925,7 @@ int main(int argc, char *argv[])
new cellZone new cellZone
( (
zoneName, //name zoneName, //name
regionCells, //addressing std::move(regionCells), //addressing
zoneI, //index zoneI, //index
cellZones //cellZoneMesh cellZones //cellZoneMesh
) )

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -79,17 +79,10 @@ void Foam::linearValveFvMesh::addZonesAndModifiers()
const word innerSliderName(motionDict_.subDict("slider").lookup("inside")); const word innerSliderName(motionDict_.subDict("slider").lookup("inside"));
const polyPatch& innerSlider = boundaryMesh()[innerSliderName]; const polyPatch& innerSlider = boundaryMesh()[innerSliderName];
labelList isf(innerSlider.size());
forAll(isf, i)
{
isf[i] = innerSlider.start() + i;
}
fz[0] = new faceZone fz[0] = new faceZone
( (
"insideSliderZone", "insideSliderZone",
isf, identity(innerSlider.size(), innerSlider.start()),
false, // none are flipped false, // none are flipped
0, 0,
faceZones() faceZones()
@ -99,17 +92,10 @@ void Foam::linearValveFvMesh::addZonesAndModifiers()
const word outerSliderName(motionDict_.subDict("slider").lookup("outside")); const word outerSliderName(motionDict_.subDict("slider").lookup("outside"));
const polyPatch& outerSlider = boundaryMesh()[outerSliderName]; const polyPatch& outerSlider = boundaryMesh()[outerSliderName];
labelList osf(outerSlider.size());
forAll(osf, i)
{
osf[i] = outerSlider.start() + i;
}
fz[1] = new faceZone fz[1] = new faceZone
( (
"outsideSliderZone", "outsideSliderZone",
osf, identity(outerSlider.size(), outerSlider.start()),
false, // none are flipped false, // none are flipped
1, 1,
faceZones() faceZones()

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -86,17 +86,10 @@ void Foam::linearValveLayersFvMesh::addZonesAndModifiers()
const word innerSliderName(motionDict_.subDict("slider").lookup("inside")); const word innerSliderName(motionDict_.subDict("slider").lookup("inside"));
const polyPatch& innerSlider = boundaryMesh()[innerSliderName]; const polyPatch& innerSlider = boundaryMesh()[innerSliderName];
labelList isf(innerSlider.size());
forAll(isf, i)
{
isf[i] = innerSlider.start() + i;
}
fz[0] = new faceZone fz[0] = new faceZone
( (
"insideSliderZone", "insideSliderZone",
isf, identity(innerSlider.size(), innerSlider.start()),
false, // none are flipped false, // none are flipped
0, 0,
faceZones() faceZones()
@ -106,17 +99,10 @@ void Foam::linearValveLayersFvMesh::addZonesAndModifiers()
const word outerSliderName(motionDict_.subDict("slider").lookup("outside")); const word outerSliderName(motionDict_.subDict("slider").lookup("outside"));
const polyPatch& outerSlider = boundaryMesh()[outerSliderName]; const polyPatch& outerSlider = boundaryMesh()[outerSliderName];
labelList osf(outerSlider.size());
forAll(osf, i)
{
osf[i] = outerSlider.start() + i;
}
fz[1] = new faceZone fz[1] = new faceZone
( (
"outsideSliderZone", "outsideSliderZone",
osf, identity(outsideSlider.size(), outsideSlider.start()),
false, // none are flipped false, // none are flipped
1, 1,
faceZones() faceZones()
@ -133,16 +119,10 @@ void Foam::linearValveLayersFvMesh::addZonesAndModifiers()
const polyPatch& layerPatch = boundaryMesh()[layerPatchName]; const polyPatch& layerPatch = boundaryMesh()[layerPatchName];
labelList lpf(layerPatch.size());
forAll(lpf, i)
{
lpf[i] = layerPatch.start() + i;
}
fz[3] = new faceZone fz[3] = new faceZone
( (
"valveLayerZone", "valveLayerZone",
identity(layerPatch.size(), layerPatch.start()),
lpf, lpf,
true, // all are flipped true, // all are flipped
0, 0,

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -79,17 +79,10 @@ void Foam::mixerFvMesh::addZonesAndModifiers()
const word innerSliderName(motionDict_.subDict("slider").lookup("inside")); const word innerSliderName(motionDict_.subDict("slider").lookup("inside"));
const polyPatch& innerSlider = boundaryMesh()[innerSliderName]; const polyPatch& innerSlider = boundaryMesh()[innerSliderName];
labelList isf(innerSlider.size());
forAll(isf, i)
{
isf[i] = innerSlider.start() + i;
}
fz[0] = new faceZone fz[0] = new faceZone
( (
"insideSliderZone", "insideSliderZone",
isf, identity(innerSlider.size(), innerSlider.start()),
false, // none are flipped false, // none are flipped
0, 0,
faceZones() faceZones()
@ -99,17 +92,10 @@ void Foam::mixerFvMesh::addZonesAndModifiers()
const word outerSliderName(motionDict_.subDict("slider").lookup("outside")); const word outerSliderName(motionDict_.subDict("slider").lookup("outside"));
const polyPatch& outerSlider = boundaryMesh()[outerSliderName]; const polyPatch& outerSlider = boundaryMesh()[outerSliderName];
labelList osf(outerSlider.size());
forAll(osf, i)
{
osf[i] = outerSlider.start() + i;
}
fz[1] = new faceZone fz[1] = new faceZone
( (
"outsideSliderZone", "outsideSliderZone",
osf, identity(outerSlider.size(), outerSlider.start()),
false, // none are flipped false, // none are flipped
1, 1,
faceZones() faceZones()
@ -124,7 +110,7 @@ void Foam::mixerFvMesh::addZonesAndModifiers()
regionSplit rs(*this); regionSplit rs(*this);
// Get the region of the cell containing the origin. // 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()); labelList movingCells(nCells());
label nMovingCells = 0; label nMovingCells = 0;
@ -134,17 +120,17 @@ void Foam::mixerFvMesh::addZonesAndModifiers()
if (rs[celli] == originRegion) if (rs[celli] == originRegion)
{ {
movingCells[nMovingCells] = celli; movingCells[nMovingCells] = celli;
nMovingCells++; ++nMovingCells;
} }
} }
movingCells.setSize(nMovingCells); movingCells.resize(nMovingCells);
Info<< "Number of cells in the moving region: " << nMovingCells << endl; Info<< "Number of cells in the moving region: " << nMovingCells << endl;
cz[0] = new cellZone cz[0] = new cellZone
( (
"movingCells", "movingCells",
movingCells, std::move(movingCells),
0, 0,
cellZones() cellZones()
); );
@ -203,14 +189,14 @@ void Foam::mixerFvMesh::calcMovingMasks() const
const labelList& cellAddr = cellZones()["movingCells"]; 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 // Mark all the points as moving
const face& curFace = f[curCell[facei]]; const face& curFace = f[facei];
forAll(curFace, pointi) forAll(curFace, pointi)
{ {
@ -227,9 +213,9 @@ void Foam::mixerFvMesh::calcMovingMasks() const
const labelList& innerSliderAddr = faceZones()[innerSliderZoneName]; 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) forAll(curFace, pointi)
{ {
@ -245,9 +231,9 @@ void Foam::mixerFvMesh::calcMovingMasks() const
const labelList& outerSliderAddr = faceZones()[outerSliderZoneName]; 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) forAll(curFace, pointi)
{ {

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -133,7 +133,7 @@ void Foam::movingConeTopoFvMesh::addZonesAndModifiers()
zone1[nZoneFaces1] = facei; zone1[nZoneFaces1] = facei;
Info<< "face " << facei << " for zone 1. Flip: " Info<< "face " << facei << " for zone 1. Flip: "
<< flipZone1[nZoneFaces1] << endl; << flipZone1[nZoneFaces1] << endl;
nZoneFaces1++; ++nZoneFaces1;
} }
else if else if
( (
@ -150,7 +150,7 @@ void Foam::movingConeTopoFvMesh::addZonesAndModifiers()
Info<< "face " << facei << " for zone 2. Flip: " Info<< "face " << facei << " for zone 2. Flip: "
<< flipZone2[nZoneFaces2] << endl; << flipZone2[nZoneFaces2] << endl;
nZoneFaces2++; ++nZoneFaces2;
} }
} }
@ -173,23 +173,23 @@ void Foam::movingConeTopoFvMesh::addZonesAndModifiers()
new faceZone new faceZone
( (
"rightExtrusionFaces", "rightExtrusionFaces",
zone1, std::move(zone1),
flipZone1, std::move(flipZone1),
nFz, nFz,
faceZones() faceZones()
); );
nFz++; ++nFz;
fz[nFz] = fz[nFz] =
new faceZone new faceZone
( (
"leftExtrusionFaces", "leftExtrusionFaces",
zone2, std::move(zone2),
flipZone2, std::move(flipZone2),
nFz, nFz,
faceZones() faceZones()
); );
nFz++; ++nFz;
fz.setSize(nFz); fz.setSize(nFz);
@ -218,7 +218,7 @@ void Foam::movingConeTopoFvMesh::addZonesAndModifiers()
motionDict_.subDict("right").lookup("maxThickness") motionDict_.subDict("right").lookup("maxThickness")
) )
); );
nMods++; ++nMods;
tm[nMods] = new layerAdditionRemoval tm[nMods] = new layerAdditionRemoval
( (
@ -235,7 +235,7 @@ void Foam::movingConeTopoFvMesh::addZonesAndModifiers()
motionDict_.subDict("left").lookup("maxThickness") motionDict_.subDict("left").lookup("maxThickness")
) )
); );
nMods++; ++nMods;
tm.setSize(nMods); tm.setSize(nMods);
Info<< "Adding " << nMods << " mesh modifiers" << endl; Info<< "Adding " << nMods << " mesh modifiers" << endl;