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

@ -277,7 +277,7 @@ int main(int argc, char *argv[])
runTime.constant(),
runTime
),
xferCopy(blocks.points()), // could we re-use space?
pointField(blocks.points()), // Copy, could we re-use space?
blocks.cells(),
blocks.patches(),
blocks.patchNames(),

View File

@ -63,7 +63,7 @@ class extrudedMesh
//- Construct and return the extruded mesh points
template<class Face, template<class> class FaceList, class PointField>
Xfer<pointField> extrudedPoints
pointField extrudedPoints
(
const PrimitivePatch<Face, FaceList, PointField>& extrudePatch,
const extrudeModel&
@ -71,7 +71,7 @@ class extrudedMesh
//- Construct and return the extruded mesh faces
template<class Face, template<class> class FaceList, class PointField>
Xfer<faceList> extrudedFaces
faceList extrudedFaces
(
const PrimitivePatch<Face, FaceList, PointField>& extrudePatch,
const extrudeModel&
@ -79,7 +79,7 @@ class extrudedMesh
//- Construct and return the extruded mesh cells
template<class Face, template<class> class FaceList, class PointField>
Xfer<cellList> extrudedCells
cellList extrudedCells
(
const PrimitivePatch<Face, FaceList, PointField>& extrudePatch,
const extrudeModel&
@ -87,10 +87,10 @@ class extrudedMesh
//- Disallow default bitwise copy construct
extrudedMesh(const extrudedMesh&);
extrudedMesh(const extrudedMesh&) = delete;
//- Disallow default bitwise assignment
void operator=(const extrudedMesh&);
void operator=(const extrudedMesh&) = delete;
public:

View File

@ -34,7 +34,7 @@ template
template<class> class FaceList,
class PointField
>
Foam::Xfer<Foam::pointField> Foam::extrudedMesh::extrudedPoints
Foam::pointField Foam::extrudedMesh::extrudedPoints
(
const PrimitivePatch<Face, FaceList, PointField>& extrudePatch,
const extrudeModel& model
@ -47,9 +47,9 @@ Foam::Xfer<Foam::pointField> Foam::extrudedMesh::extrudedPoints
pointField ePoints((nLayers + 1)*surfacePoints.size());
for (label layer=0; layer<=nLayers; layer++)
for (label layer=0; layer <= nLayers; ++layer)
{
label offset = layer*surfacePoints.size();
const label offset = layer*surfacePoints.size();
forAll(surfacePoints, i)
{
@ -62,13 +62,12 @@ Foam::Xfer<Foam::pointField> Foam::extrudedMesh::extrudedPoints
}
}
// return points for transferring
return xferMove(ePoints);
return ePoints;
}
template<class Face, template<class> class FaceList, class PointField>
Foam::Xfer<Foam::faceList> Foam::extrudedMesh::extrudedFaces
Foam::faceList Foam::extrudedMesh::extrudedFaces
(
const PrimitivePatch<Face, FaceList, PointField>& extrudePatch,
const extrudeModel& model
@ -188,13 +187,13 @@ Foam::Xfer<Foam::faceList> Foam::extrudedMesh::extrudedFaces
);
}
// return points for transferring
return xferMove(eFaces);
return eFaces;
}
template<class Face, template<class> class FaceList, class PointField>
Foam::Xfer<Foam::cellList> Foam::extrudedMesh::extrudedCells
Foam::cellList Foam::extrudedMesh::extrudedCells
(
const PrimitivePatch<Face, FaceList, PointField>& extrudePatch,
const extrudeModel& model
@ -295,8 +294,7 @@ Foam::Xfer<Foam::cellList> Foam::extrudedMesh::extrudedCells
facei++;
}
// return points for transferring
return xferMove(eCells);
return eCells;
}

View File

@ -1880,7 +1880,7 @@ int main(int argc, char *argv[])
}
}
}
const primitiveFacePatch extrudePatch(zoneFaces.xfer(), mesh.points());
const primitiveFacePatch extrudePatch(std::move(zoneFaces), mesh.points());
Pstream::listCombineGather(isInternal, orEqOp<bool>());
@ -2405,10 +2405,7 @@ int main(int argc, char *argv[])
IOobject::AUTO_WRITE,
false
),
xferCopy(pointField()),
xferCopy(faceList()),
xferCopy(labelList()),
xferCopy(labelList()),
Zero,
false
);

View File

@ -247,7 +247,7 @@ void Foam::patchToPoly2DMesh::addPatchFacesToOwner()
<< nExternalEdges << endl;
}
owner_ = newOwner.xfer();
owner_.transfer(newOwner);
}

View File

@ -184,24 +184,21 @@ int main(int argc, char *argv[])
poly2DMesh.createMesh();
mesh.reset
mesh = autoPtr<polyMesh>::New
(
new polyMesh
IOobject
(
IOobject
(
polyMesh::defaultRegion,
runTimeExtruded.constant(),
runTimeExtruded,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
xferMove(poly2DMesh.points()),
xferMove(poly2DMesh.faces()),
xferMove(poly2DMesh.owner()),
xferMove(poly2DMesh.neighbour())
)
polyMesh::defaultRegion,
runTimeExtruded.constant(),
runTimeExtruded,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
std::move(poly2DMesh.points()),
std::move(poly2DMesh.faces()),
std::move(poly2DMesh.owner()),
std::move(poly2DMesh.neighbour())
);
Info<< "Constructing patches." << endl;
@ -224,17 +221,14 @@ int main(int argc, char *argv[])
}
else if (surfaceFormat == POLYMESH2D)
{
mesh.reset
mesh = autoPtr<polyMesh>::New
(
new polyMesh
Foam::IOobject
(
Foam::IOobject
(
Foam::polyMesh::defaultRegion,
runTimeExtruded.timeName(),
runTimeExtruded,
Foam::IOobject::MUST_READ
)
Foam::polyMesh::defaultRegion,
runTimeExtruded.timeName(),
runTimeExtruded,
Foam::IOobject::MUST_READ
)
);
}

View File

@ -141,14 +141,11 @@ autoPtr<mapDistribute> buildMap
List<Map<label>> compactMap;
return autoPtr<mapDistribute>
return autoPtr<mapDistribute>::New
(
new mapDistribute
(
globalIndexing,
pointPoints,
compactMap
)
globalIndexing,
pointPoints,
compactMap
);
}

View File

@ -593,23 +593,20 @@ Foam::DelaunayMesh<Triangulation>::createMesh
Info<< "Creating mesh" << endl;
autoPtr<polyMesh> meshPtr
auto meshPtr = autoPtr<polyMesh>::New
(
new polyMesh
IOobject
(
IOobject
(
name,
time().timeName(),
time(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
xferMove(points),
xferMove(faces),
xferMove(owner),
xferMove(neighbour)
)
name,
time().timeName(),
time(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
std::move(points),
std::move(faces),
std::move(owner),
std::move(neighbour)
);
Info<< "Adding patches" << endl;

View File

@ -105,14 +105,11 @@ Foam::DistributedDelaunayMesh<Triangulation>::buildMap
}
}
return autoPtr<mapDistribute>
return autoPtr<mapDistribute>::New
(
new mapDistribute
(
constructSize,
sendMap.xfer(),
constructMap.xfer()
)
constructSize,
std::move(sendMap),
std::move(constructMap)
);
}

View File

@ -36,9 +36,7 @@ License
namespace Foam
{
defineTypeNameAndDebug(backgroundMeshDecomposition, 0);
defineTypeNameAndDebug(backgroundMeshDecomposition, 0);
}
@ -114,14 +112,11 @@ Foam::autoPtr<Foam::mapDistribute> Foam::backgroundMeshDecomposition::buildMap
}
}
return autoPtr<mapDistribute>
return autoPtr<mapDistribute>::New
(
new mapDistribute
(
constructSize,
sendMap.xfer(),
constructMap.xfer()
)
constructSize,
std::move(sendMap),
std::move(constructMap)
);
}

View File

@ -727,23 +727,20 @@ Foam::conformalVoronoiMesh::createPolyMeshFromPoints
labelList cellToDelaunayVertex(removeUnusedCells(owner, neighbour));
cellCentres = pointField(cellCentres, cellToDelaunayVertex);
autoPtr<polyMesh> meshPtr
auto meshPtr = autoPtr<polyMesh>::New
(
new polyMesh
IOobject
(
IOobject
(
"foamyHexMesh_temporary",
runTime_.timeName(),
runTime_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
xferCopy(pts),
xferMove(faces),
xferMove(owner),
xferMove(neighbour)
)
"foamyHexMesh_temporary",
runTime_.timeName(),
runTime_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
pointField(pts), // Copy of points
std::move(faces),
std::move(owner),
std::move(neighbour)
);
polyMesh& pMesh = meshPtr();

View File

@ -404,16 +404,7 @@ Foam::autoPtr<Foam::fvMesh> Foam::conformalVoronoiMesh::createDummyMesh
const PtrList<dictionary>& patchDicts
) const
{
autoPtr<fvMesh> meshPtr
(
new fvMesh
(
io,
xferCopy(pointField()),
xferCopy(faceList()),
xferCopy(cellList())
)
);
auto meshPtr = autoPtr<fvMesh>::New(io, Zero);
fvMesh& mesh = meshPtr();
List<polyPatch*> patches(patchDicts.size());
@ -827,10 +818,10 @@ void Foam::conformalVoronoiMesh::writeMesh
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
xferMove(points),
xferMove(faces),
xferMove(owner),
xferMove(neighbour)
std::move(points),
std::move(faces),
std::move(owner),
std::move(neighbour)
);
Info<< indent << "Adding patches to mesh" << endl;

View File

@ -282,20 +282,17 @@ autoPtr<polyMesh> generateHexMesh
word defaultFacesType = polyPatch::typeName;
wordList patchPhysicalTypes(0);
return autoPtr<polyMesh>
return autoPtr<polyMesh>::New
(
new polyMesh
(
io,
xferMoveTo<pointField>(points),
cellShapes,
boundary,
patchNames,
patchTypes,
defaultFacesName,
defaultFacesType,
patchPhysicalTypes
)
io,
std::move(points),
cellShapes,
boundary,
patchNames,
patchTypes,
defaultFacesName,
defaultFacesType,
patchPhysicalTypes
);
}

View File

@ -152,10 +152,10 @@ int main(int argc, char *argv[])
IOobject::NO_WRITE,
false
),
xferMove(poly2DMesh.points()),
xferMove(poly2DMesh.faces()),
xferMove(poly2DMesh.owner()),
xferMove(poly2DMesh.neighbour())
std::move(poly2DMesh.points()),
std::move(poly2DMesh.faces()),
std::move(poly2DMesh.owner()),
std::move(poly2DMesh.neighbour())
);
Info<< "Constructing patches." << endl;

View File

@ -204,7 +204,7 @@ Foam::shortEdgeFilter2D::shortEdgeFilter2D
points2D.clear();
ms_ = MeshedSurface<face>(xferMove(points), xferMove(faces));
ms_ = MeshedSurface<face>(std::move(points), std::move(faces));
Info<< "Meshed surface stats before edge filtering :" << endl;
ms_.writeStats(Info);
@ -533,12 +533,7 @@ Foam::shortEdgeFilter2D::filter()
newFaces.setSize(newFacei);
MeshedSurface<face> fMesh
(
xferMove(newPoints),
xferMove(newFaces),
xferCopy(List<surfZone>())
);
MeshedSurface<face> fMesh(std::move(newPoints), std::move(newFaces));
updateEdgeRegionMap
(

View File

@ -476,7 +476,7 @@ void extractSurface
// Gather all ZoneIDs
List<labelList> gatheredZones(Pstream::nProcs());
gatheredZones[Pstream::myProcNo()] = compactZones.xfer();
gatheredZones[Pstream::myProcNo()].transfer(compactZones);
Pstream::gatherList(gatheredZones);
// On master combine all points, faces, zones
@ -515,10 +515,10 @@ void extractSurface
UnsortedMeshedSurface<face> unsortedFace
(
xferMove(allPoints),
xferMove(allFaces),
xferMove(allZones),
xferMove(surfZones)
std::move(allPoints),
std::move(allFaces),
std::move(allZones),
surfZones
);