ENH: remove reliance on the Xfer class (issue #639)

This class is largely a pre-C++11 holdover. It is now possible to
simply use move construct/assignment directly.

In a few rare cases (eg, polyMesh::resetPrimitives) it has been
replaced by an autoPtr.
This commit is contained in:
Mark Olesen
2018-03-05 13:28:53 +01:00
parent 57291e8692
commit 3d608bf06a
241 changed files with 3106 additions and 3971 deletions

View File

@ -340,38 +340,32 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets)
curPointLabels
);
procMeshPtr.reset
procMeshPtr = autoPtr<polyMesh>::New
(
new polyMesh
IOobject
(
IOobject
(
this->polyMesh::name(), // region of undecomposed mesh
facesInstance(),
processorDb
),
xferMove(facesInstancePoints),
xferMove(procFaces),
xferMove(procCells)
)
this->polyMesh::name(), // region of undecomposed mesh
facesInstance(),
processorDb
),
std::move(facesInstancePoints),
std::move(procFaces),
std::move(procCells)
);
}
else
{
procMeshPtr.reset
procMeshPtr = autoPtr<polyMesh>::New
(
new polyMesh
IOobject
(
IOobject
(
this->polyMesh::name(), // region of undecomposed mesh
facesInstance(),
processorDb
),
xferMove(procPoints),
xferMove(procFaces),
xferMove(procCells)
)
this->polyMesh::name(), // region of undecomposed mesh
facesInstance(),
processorDb
),
std::move(procPoints),
std::move(procFaces),
std::move(procCells)
);
}
polyMesh& procMesh = procMeshPtr();
@ -751,7 +745,7 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets)
IOobject::NO_WRITE,
false
),
xferMove(procPoints)
std::move(procPoints)
);
pointsInstancePoints.write();
}

View File

@ -652,9 +652,7 @@ int main(int argc, char *argv[])
runTime,
IOobject::NO_READ
),
xferCopy(pointField()),
xferCopy(faceList()),
xferCopy(cellList())
Zero
)
);

View File

@ -166,15 +166,7 @@ Foam::autoPtr<Foam::fvMesh> Foam::loadOrCreateMesh
// Create dummy mesh. Only used on procs that don't have mesh.
IOobject noReadIO(io);
noReadIO.readOpt() = IOobject::NO_READ;
fvMesh dummyMesh
(
noReadIO,
xferCopy(pointField()),
xferCopy(faceList()),
xferCopy(labelList()),
xferCopy(labelList()),
false
);
fvMesh dummyMesh(noReadIO, Zero, false);
// Add patches
List<polyPatch*> patches(patchEntries.size());
@ -261,8 +253,8 @@ Foam::autoPtr<Foam::fvMesh> Foam::loadOrCreateMesh
// parallel
//Pout<< "Reading mesh from " << io.objectPath() << endl;
autoPtr<fvMesh> meshPtr(new fvMesh(io));
fvMesh& mesh = meshPtr();
auto meshPtr = autoPtr<fvMesh>::New(io);
fvMesh& mesh = *meshPtr;

View File

@ -279,15 +279,11 @@ Foam::parLagrangianRedistributor::redistributeLagrangianPositions
}
// Construct map
return autoPtr<mapDistributeBase>
return autoPtr<mapDistributeBase>::New
(
new mapDistributeBase
(
constructSize,
subMap.xfer(),
constructMap.xfer()
)
constructSize,
std::move(subMap),
std::move(constructMap)
);
}

View File

@ -125,7 +125,7 @@ void Foam::parLagrangianRedistributor::redistributeLagrangianFields
IOobject::NO_WRITE,
false
),
xferMove<Field<Type>>(field)
std::move(field)
).write();
}
}
@ -212,7 +212,7 @@ void Foam::parLagrangianRedistributor::redistributeLagrangianFieldFields
IOobject::NO_WRITE,
false
),
xferMove<Field<Field<Type>>>(field)
std::move(field)
).write();
}
}
@ -309,7 +309,7 @@ void Foam::parLagrangianRedistributor::redistributeStoredLagrangianFields
IOobject::NO_WRITE,
false
),
xferMove<Field<typename Container::value_type>>(field)
std::move(field)
).write();
}
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -1353,10 +1353,7 @@ autoPtr<mapDistributePolyMesh> redistributeAndWrite
//}
return autoPtr<mapDistributePolyMesh>
(
new mapDistributePolyMesh(map.xfer())
);
return autoPtr<mapDistributePolyMesh>::New(std::move(map));
}
@ -1407,7 +1404,7 @@ autoPtr<mapDistributePolyMesh> createReconstructMap
autoPtr<mapDistributePolyMesh> mapPtr;
if (baseMeshPtr.valid() && baseMeshPtr().nCells()) //baseMeshPtr.valid())
if (baseMeshPtr.valid() && baseMeshPtr().nCells())
{
const fvMesh& baseMesh = baseMeshPtr();
@ -1417,8 +1414,8 @@ autoPtr<mapDistributePolyMesh> createReconstructMap
mapDistribute cellMap
(
baseMesh.nCells(),
cellSubMap.xfer(),
cellAddressing.xfer()
std::move(cellSubMap),
std::move(cellAddressing)
);
labelListList faceSubMap(Pstream::nProcs());
@ -1427,8 +1424,8 @@ autoPtr<mapDistributePolyMesh> createReconstructMap
mapDistribute faceMap
(
baseMesh.nFaces(),
faceSubMap.xfer(),
faceAddressing.xfer(),
std::move(faceSubMap),
std::move(faceAddressing),
false, //subHasFlip
true //constructHasFlip
);
@ -1439,8 +1436,8 @@ autoPtr<mapDistributePolyMesh> createReconstructMap
mapDistribute pointMap
(
baseMesh.nPoints(),
pointSubMap.xfer(),
pointAddressing.xfer()
std::move(pointSubMap),
std::move(pointAddressing)
);
labelListList patchSubMap(Pstream::nProcs());
@ -1451,8 +1448,8 @@ autoPtr<mapDistributePolyMesh> createReconstructMap
mapDistribute patchMap
(
baseMesh.boundaryMesh().size(),
patchSubMap.xfer(),
boundaryAddressing.xfer()
std::move(patchSubMap),
std::move(boundaryAddressing)
);
const label nOldPoints = mesh.nPoints();
@ -1475,12 +1472,12 @@ autoPtr<mapDistributePolyMesh> createReconstructMap
nOldPoints,
nOldFaces,
nOldCells,
oldPatchStarts.xfer(),
oldPatchNMeshPoints.xfer(),
pointMap.xfer(),
faceMap.xfer(),
cellMap.xfer(),
patchMap.xfer()
std::move(oldPatchStarts),
std::move(oldPatchNMeshPoints),
std::move(pointMap),
std::move(faceMap),
std::move(cellMap),
std::move(patchMap)
)
);
}
@ -1493,8 +1490,8 @@ autoPtr<mapDistributePolyMesh> createReconstructMap
mapDistribute cellMap
(
0,
cellSubMap.xfer(),
cellConstructMap.xfer()
std::move(cellSubMap),
std::move(cellConstructMap)
);
labelListList faceSubMap(Pstream::nProcs());
@ -1504,8 +1501,8 @@ autoPtr<mapDistributePolyMesh> createReconstructMap
mapDistribute faceMap
(
0,
faceSubMap.xfer(),
faceConstructMap.xfer(),
std::move(faceSubMap),
std::move(faceConstructMap),
false, //subHasFlip
true //constructHasFlip
);
@ -1517,8 +1514,8 @@ autoPtr<mapDistributePolyMesh> createReconstructMap
mapDistribute pointMap
(
0,
pointSubMap.xfer(),
pointConstructMap.xfer()
std::move(pointSubMap),
std::move(pointConstructMap)
);
labelListList patchSubMap(Pstream::nProcs());
@ -1530,8 +1527,8 @@ autoPtr<mapDistributePolyMesh> createReconstructMap
mapDistribute patchMap
(
0,
patchSubMap.xfer(),
patchConstructMap.xfer()
std::move(patchSubMap),
std::move(patchConstructMap)
);
const label nOldPoints = mesh.nPoints();
@ -1554,12 +1551,12 @@ autoPtr<mapDistributePolyMesh> createReconstructMap
nOldPoints,
nOldFaces,
nOldCells,
oldPatchStarts.xfer(),
oldPatchNMeshPoints.xfer(),
pointMap.xfer(),
faceMap.xfer(),
cellMap.xfer(),
patchMap.xfer()
std::move(oldPatchStarts),
std::move(oldPatchNMeshPoints),
std::move(pointMap),
std::move(faceMap),
std::move(cellMap),
std::move(patchMap)
)
);
}
@ -1587,7 +1584,6 @@ void readProcAddressing
//{
// Pout<< "Reading addressing from " << io.name() << " at "
// << mesh.facesInstance() << nl << endl;
// distMap.clear();
// distMap.reset(new IOmapDistributePolyMesh(io));
//}
//else
@ -1604,7 +1600,7 @@ void readProcAddressing
mesh,
IOobject::READ_IF_PRESENT
),
labelList(0)
labelList()
);
labelIOList faceProcAddressing
(
@ -1616,7 +1612,7 @@ void readProcAddressing
mesh,
IOobject::READ_IF_PRESENT
),
labelList(0)
labelList()
);
labelIOList pointProcAddressing
(
@ -1628,7 +1624,7 @@ void readProcAddressing
mesh,
IOobject::READ_IF_PRESENT
),
labelList(0)
labelList()
);
labelIOList boundaryProcAddressing
(
@ -1640,7 +1636,7 @@ void readProcAddressing
mesh,
IOobject::READ_IF_PRESENT
),
labelList(0)
labelList()
);
@ -2580,7 +2576,7 @@ int main(int argc, char *argv[])
runTime,
IOobject::READ_IF_PRESENT
),
labelList(0)
labelList()
);
if
(