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

@ -1,8 +1,5 @@
Info<< "Constructing single cell mesh" << nl << endl;
labelList owner(6, label(0));
labelList neighbour(0);
pointField points(8);
points[0] = vector(0, 0, 0);
points[1] = vector(1, 0, 0);
@ -24,10 +21,10 @@ fvMesh mesh
runTime,
IOobject::READ_IF_PRESENT
),
xferMove<pointField>(points),
faces.xfer(),
owner.xfer(),
neighbour.xfer()
std::move(points),
std::move(faces),
labelList(6, Zero), // owner
labelList() // neighbour
);
List<polyPatch*> patches(1);

View File

@ -180,7 +180,7 @@ int main(int argc, char *argv[])
{
std::cout<< "iter: " << typeid(*iter).name() << '\n';
Info<< "elem = " << *(*iter) << endl;
// Info<< "elem = " << *(*iter) << endl;
}
std::cout<< "iter type: "

View File

@ -194,13 +194,13 @@ int main(int argc, char *argv[])
printInfo("dlC", dlC, true);
List<label> lstB(dlC.xfer());
List<label> lstB(std::move(dlC));
Info<< "Transferred to normal list via the xfer() method" << endl;
Info<< "Move construct to normal list" << endl;
printInfo("lstB", lstB, true);
printInfo("dlC", dlC, true);
DynamicList<label> dlD(lstB.xfer());
DynamicList<label> dlD(std::move(lstB));
Info<< "Transfer construct from normal list" << endl;
printInfo("lstB", lstB, true);
@ -279,7 +279,7 @@ int main(int argc, char *argv[])
Info<< "list in: " << flatOutput(list1) << nl
<< "list out: " << flatOutput(list2) << endl;
input2 = std::move(identity(15));
input2 = identity(15); // don't need std::move() on temporary object
list2 = std::move(input2);
Info<< "list in: " << flatOutput(input2) << nl
<< "list out: " << flatOutput(list2) << endl;

View File

@ -102,7 +102,14 @@ int main(int argc, char *argv[])
Info<< "transfer contents to a List" << endl;
IListStream ibuf(obuf.xfer());
IListStream ibuf;
// Reclaim data storage from OListStream -> IListStream
{
List<char> data;
obuf.swap(data);
ibuf.swap(data);
}
Info<< nl;
Info<< nl << "input string:";

View File

@ -95,7 +95,7 @@ int main(int argc, char *argv[])
inplaceReverseList(addresses);
idl1.resetAddressing(addresses.xfer());
idl1.resetAddressing(std::move(addresses));
printInfo(idl1);

View File

@ -190,8 +190,8 @@ int main(int argc, char *argv[])
list2.setSize(10, vector(1, 2, 3));
Info<< "list2: " << list2 << endl;
List<vector> list3(list2.xfer());
Info<< "Transferred via the xfer() method" << endl;
List<vector> list3(std::move(list2));
Info<< "Move construct" << endl;
Info<< "list2: " << list2 << nl
<< "list3: " << list3 << endl;

View File

@ -129,7 +129,13 @@ int main(int argc, char *argv[])
Info<< "transfer contents to a List or IListStream" << nl;
IListStream ibuf(obuf.xfer());
IListStream ibuf;
// Reclaim data storage from OListStream -> IListStream
{
List<char> data;
obuf.swap(data);
ibuf.swap(data);
}
Info<<"original:";
printInfo(obuf);
@ -141,6 +147,7 @@ int main(int argc, char *argv[])
// Create from other storage types
List<char> written;
Info<< nl;
{
Info<<"create std::move(List)" << endl;
@ -163,35 +170,9 @@ int main(int argc, char *argv[])
toString(Info, list) << endl;
printInfo(buf1);
}
Info<< nl;
List<char> written;
{
Info<<"create List.xfer()" << endl;
List<char> list(16, 'B');
Info<<"input:";
toString(Info, list) << endl;
OListStream buf1(list.xfer());
for (label i = 0; i < 26; ++i)
{
buf1 << char('A' + i);
}
for (label i = 0; i < 26; ++i)
{
buf1 << char('a' +i);
}
Info<<"orig:";
toString(Info, list) << endl;
printInfo(buf1);
// Move back to written
written = buf1.xfer();
buf1.swap(written);
printInfo(buf1);
}

View File

@ -147,8 +147,8 @@ int main(int argc, char *argv[])
Info<<"list1: " << list1 << endl;
PtrList<Scalar> list3(list1.xfer());
Info<< "Transferred via the xfer() method" << endl;
PtrList<Scalar> list3(std::move(list1));
Info<<"Move constructed" << endl;
Info<<"list1: " << list1 << nl
<<"list2: " << list2 << nl

View File

@ -71,7 +71,7 @@ int main(int argc, char *argv[])
<< "keys: " << dict1.keys() << nl
<< "patterns: " << dict1.keys(true) << endl;
dictionary dict2(dict1.xfer());
dictionary dict2(std::move(dict1));
Info<< "dict1.toc(): " << dict1.name() << " " << dict1.toc() << nl
<< "dict2.toc(): " << dict2.name() << " " << dict2.toc()

View File

@ -51,19 +51,20 @@ int main(int argc, char *argv[])
const scalar instanceValue(0.005);
IOobject io
IOmapDistributePolyMesh map
(
"procAddressing",
instance,
fvMesh::meshSubDir,
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
IOobject
(
"procAddressing",
instance,
fvMesh::meshSubDir,
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
IOmapDistributePolyMesh map(io);
{
// Load the instance mesh
runTime.setTime(instanceValue, 0);
@ -112,7 +113,6 @@ int main(int argc, char *argv[])
}
}
{
const mapDistribute& cellMap = map.cellMap();
pointField cc(mesh.cellCentres());

View File

@ -91,7 +91,7 @@ int main(int argc, char *argv[])
runTime,
Foam::IOobject::NO_READ
),
Xfer<pointField>(points),
std::move(points),
shapes,
boundaryFaces,
boundaryPatchNames,

View File

@ -111,7 +111,7 @@ void testMapDistribute()
}
// Construct distribute map (destructively)
mapDistribute map(constructSize, sendMap.xfer(), recvMap.xfer());
mapDistribute map(constructSize, std::move(sendMap), std::move(recvMap));
// Distribute complexData
map.distribute(complexData);

View File

@ -246,15 +246,16 @@ int main(int argc, char *argv[])
writeFaceFaces(localPoints, localFaces, faceFaces);
}
// Test construction from Xfer
// Move construct
{
faceList patchFaces = patch;
pointField allPoints = patch.points();
PrimitivePatch<face, List, pointField, point> storedPatch
(
patchFaces.xfer(),
allPoints.xfer()
patchFaces,
allPoints,
true
);
}

View File

@ -413,9 +413,9 @@ int main(int argc, char *argv[])
surf.writeStats(Info);
Info<< endl;
ModifiableMeshedSurface<face> tsurf(surf.xfer());
// ModifiableMeshedSurface<face> tsurf;
// tsurf.reset(surf.xfer());
ModifiableMeshedSurface<face> tsurf(std::move(surf));
// ModifiableMeshedSurface<face> xtsurf;
// xtsurf.transfer(surf);
Info<< "in-progress" << nl;
surf.writeStats(Info);
@ -515,7 +515,7 @@ int main(int argc, char *argv[])
IOobject::NO_WRITE,
false
),
surf.xfer()
std::move(surf)
);
Info<< "writing surfMesh as well: " << surfOut.objectPath() << endl;
@ -546,7 +546,6 @@ int main(int argc, char *argv[])
surfOut.setInstance(runTime.timeName());
Info<< "writing surfMesh again well: " << surfOut.objectPath()
<< endl;
surfOut.write();

View File

@ -214,9 +214,9 @@ int main(int argc, char *argv[])
runTime.timeName(),
runTime
),
xferCopy(mesh.points()), // could we safely re-use the data?
xferCopy(mesh.faces()),
xferCopy(mesh.cells())
pointField(mesh.points()), // Could we safely re-use the data?
faceList(mesh.faces()),
cellList(mesh.cells())
);
// Add the boundary patches

View File

@ -446,27 +446,23 @@ int main(int argc, char *argv[])
const word defaultFacesName = "defaultFaces";
word defaultFacesType = emptyPolyPatch::typeName;
// Create dummy mesh just to find out what are internal/external
// faces
autoPtr<polyMesh> dummyMesh
// Create dummy mesh just to find out what are internal/external faces
auto dummyMesh = autoPtr<polyMesh>::New
(
new polyMesh
IOobject
(
IOobject
(
"dummyMesh",
runTime.constant(),
runTime
),
xferCopy(points),
cellShapes,
faceListList(0),
wordList(0),
wordList(0),
defaultFacesName,
defaultFacesType,
wordList(0)
)
"dummyMesh",
runTime.constant(),
runTime
),
pointField(points), // copy
cellShapes,
faceListList(),
wordList(),
wordList(),
defaultFacesName,
defaultFacesType,
wordList()
);
@ -605,7 +601,7 @@ int main(int argc, char *argv[])
runTime.constant(),
runTime
),
xferMove(points),
std::move(points),
cellShapes,
patchFaces,
patchNames,
@ -615,7 +611,7 @@ int main(int argc, char *argv[])
);
if (cellTypes.size() > 0 || patchNames.size() > 0)
if (cellTypes.size() || patchNames.size())
{
DynamicList<pointZone*> pz;
DynamicList<faceZone*> fz;

View File

@ -739,7 +739,7 @@ int main(int argc, char *argv[])
runTime.constant(),
runTime
),
xferMove(points),
std::move(points),
cellShapes,
boundary,
patchNames,

View File

@ -945,10 +945,7 @@ int main(int argc, char *argv[])
runTime.constant(),
runTime
),
xferCopy(pointField()),
xferCopy(faceList()),
xferCopy(labelList()),
xferCopy(labelList())
Zero
);

View File

@ -1175,7 +1175,7 @@ int main(int argc, char *argv[])
runTime.constant(),
runTime
),
xferMove(points),
std::move(points),
cellShapes,
patches,
patchNames,

View File

@ -853,7 +853,7 @@ int main(int argc, char *argv[])
runTime.constant(),
runTime
),
xferMove(points),
std::move(points),
cells,
boundary,
patchNames,

View File

@ -931,7 +931,7 @@ int main(int argc, char *argv[])
runTime.constant(),
runTime
),
xferMove(points),
std::move(points),
cells,
boundaryFaces,
boundaryPatchNames,

View File

@ -1128,17 +1128,13 @@ int main(int argc, char *argv[])
<< nl << endl;
// Create globally numbered surface
meshedSurface rawSurface
(
xferCopy(polyPoints),
xferCopyTo<faceList>(boundaryFaces)
);
meshedSurface rawSurface(polyPoints, boundaryFaces);
// Write locally numbered surface
meshedSurface
(
xferCopy(rawSurface.localPoints()),
xferCopy(rawSurface.localFaces())
rawSurface.localPoints(),
rawSurface.localFaces()
).write(runTime.path()/"boundaryFaces.obj");
}
@ -1171,14 +1167,14 @@ int main(int argc, char *argv[])
runTime.constant(),
runTime
),
xferMove(polyPoints),
std::move(polyPoints),
cellVerts,
usedPatchFaceVerts, // boundaryFaces,
usedPatchNames, // boundaryPatchNames,
usedPatchFaceVerts, // boundaryFaces,
usedPatchNames, // boundaryPatchNames,
wordList(patchNames.size(), polyPatch::typeName), // boundaryPatchTypes,
"defaultFaces", // defaultFacesName
polyPatch::typeName, // defaultFacesType,
wordList(0) // boundaryPatchPhysicalTypes
"defaultFaces", // defaultFacesName
polyPatch::typeName, // defaultFacesType,
wordList() // boundaryPatchPhysicalTypes
);
// Remove files now, to ensure all mesh files written are consistent.

View File

@ -565,7 +565,7 @@ polyMesh pShapeMesh
runTime.constant(),
runTime
),
xferMove(points),
std::move(points),
cellShapes,
boundary,
patchNames,

View File

@ -144,14 +144,14 @@ int main(int argc, char *argv[])
runTime.constant(),
runTime
),
xferMove(points),
std::move(points),
cells,
faceListList(0),
wordList(0),
wordList(0),
faceListList(),
wordList(),
wordList(),
"defaultFaces",
polyPatch::typeName,
wordList(0)
wordList()
);
// Set the precision of the points data to 10

View File

@ -303,7 +303,7 @@ int main(int argc, char *argv[])
runTime.constant(),
runTime
),
xferMove(points),
std::move(points),
cells,
patchFaces,
patchNames,

View File

@ -247,7 +247,7 @@ int main(int argc, char *argv[])
runTime.constant(),
runTime
),
xferMove(newPoints),
std::move(newPoints),
cellShapes,
boundary,
patchNames,

View File

@ -318,25 +318,22 @@ int main(int argc, char *argv[])
// Construct mesh with default boundary only
//
autoPtr<polyMesh> meshPtr
auto meshPtr = autoPtr<polyMesh>::New
(
new polyMesh
IOobject
(
IOobject
(
polyMesh::defaultRegion,
runTime.constant(),
runTime
),
xferCopy(points),
cells,
faceListList(0),
wordList(0), // boundaryPatchNames
wordList(0), // boundaryPatchTypes
"defaultFaces",
polyPatch::typeName,
wordList(0)
)
polyMesh::defaultRegion,
runTime.constant(),
runTime
),
pointField(points), // Copy of points
cells,
faceListList(),
wordList(), // boundaryPatchNames
wordList(), // boundaryPatchTypes
"defaultFaces",
polyPatch::typeName,
wordList()
);
const polyMesh& mesh = *meshPtr;
@ -531,7 +528,7 @@ int main(int argc, char *argv[])
runTime.constant(),
runTime
),
xferMove(points),
std::move(points),
cells,
patchFaces,
patchNames,

View File

@ -68,14 +68,14 @@ int main(int argc, char *argv[])
runTime.constant(),
runTime
),
xferMove(reader.points()),
std::move(reader.points()),
reader.cells(),
faceListList(0),
wordList(0),
wordList(0),
faceListList(),
wordList(),
wordList(),
"defaultFaces",
polyPatch::typeName,
wordList(0)
wordList()
);
// Set the precision of the points data to 10

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
);

View File

@ -353,12 +353,12 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
Info<< "Mirroring cell shapes." << endl;
Info<< nl << "Creating new mesh" << endl;
mirrorMeshPtr_ = new fvMesh
mirrorMeshPtr_ = autoPtr<fvMesh>::New
(
io,
xferMove(newPoints),
xferMove(newFaces),
xferMove(newCells)
std::move(newPoints),
std::move(newFaces),
std::move(newCells)
);
fvMesh& pMesh = *mirrorMeshPtr_;
@ -381,10 +381,4 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::mirrorFvMesh::~mirrorFvMesh()
{}
// ************************************************************************* //

View File

@ -55,21 +55,20 @@ class mirrorFvMesh
IOdictionary mirrorMeshDict_;
//- Mirrored mesh
fvMesh* mirrorMeshPtr_;
autoPtr<fvMesh> mirrorMeshPtr_;
// Private Member Functions
//- Disallow default bitwise copy construct
mirrorFvMesh(const mirrorFvMesh&);
//- Disallow copy construct
mirrorFvMesh(const mirrorFvMesh&) = delete;
//- Disallow default bitwise assignment
void operator=(const mirrorFvMesh&);
//- Disallow copy assignment
void operator=(const mirrorFvMesh&) = delete;
public:
// Constructors
//- Construct from IOobject
@ -77,7 +76,7 @@ public:
//- Destructor
~mirrorFvMesh();
~mirrorFvMesh() = default;
// Member Functions

View File

@ -461,10 +461,10 @@ autoPtr<mapPolyMesh> reorderMesh
mesh.resetPrimitives
(
Xfer<pointField>::null(),
xferMove(newFaces),
xferMove(newOwner),
xferMove(newNeighbour),
autoPtr<pointField>(), // <- null: leaves points untouched
autoPtr<faceList>::New(std::move(newFaces)),
autoPtr<labelList>::New(std::move(newOwner)),
autoPtr<labelList>::New(std::move(newNeighbour)),
patchSizes,
patchStarts,
true

View File

@ -521,7 +521,7 @@ int main(int argc, char *argv[])
(
cutZoneName,
true // verbose
).resetAddressing(faceIds.xfer(), false);
).resetAddressing(std::move(faceIds), false);
// Add the perfect interface mesh modifier
@ -551,7 +551,7 @@ int main(int argc, char *argv[])
(
mergePatchName + "MasterZone",
true // verbose
).resetAddressing(faceIds.xfer(), false);
).resetAddressing(std::move(faceIds), false);
// Markup slave face ids
faceIds.setSize(slavePatch.size());
@ -561,7 +561,7 @@ int main(int argc, char *argv[])
(
mergePatchName + "SlaveZone",
true // verbose
).resetAddressing(faceIds.xfer(), false);
).resetAddressing(std::move(faceIds), false);
// Add empty zone for cut faces
mesh.faceZones()

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
(

View File

@ -49,7 +49,7 @@ Foam::tmp<Foam::Field<Type>> Foam::readParticleField
if (obj != nullptr)
{
IOField<Type> newField(*obj);
return tmp<Field<Type>>::New(newField.xfer());
return tmp<Field<Type>>::New(std::move(newField));
}
FatalErrorInFunction
@ -77,7 +77,7 @@ void Foam::readFields
{
Info<< " reading field " << fieldNames[j] << endl;
IOField<Type> newField(*obj);
values.set(j, new List<Type>(newField.xfer()));
values.set(j, new List<Type>(std::move(newField)));
}
else
{

View File

@ -865,7 +865,7 @@ int main(int argc, char *argv[])
IOobject::NO_WRITE,
false
),
globalFaceFaces
std::move(globalFaceFaces)
);
IOglobalFaceFaces.write();
@ -881,7 +881,7 @@ int main(int argc, char *argv[])
IOobject::NO_WRITE,
false
),
visibleFaceFaces
std::move(visibleFaceFaces)
);
IOvisibleFaceFaces.write();
@ -895,7 +895,7 @@ int main(int argc, char *argv[])
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
map.xfer()
std::move(map)
);
IOmapDist.write();

View File

@ -287,7 +287,7 @@ int main(int argc, char *argv[])
runTime.constant(),
runTime
),
surf.xfer()
std::move(surf)
);

View File

@ -364,7 +364,7 @@ int main(int argc, char *argv[])
// 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
@ -404,10 +404,10 @@ int main(int argc, char *argv[])
UnsortedMeshedSurface<face> unsortedFace
(
xferMove(allPoints),
xferMove(allFaces),
xferMove(allZones),
xferMove(surfZones)
std::move(allPoints),
std::move(allFaces),
std::move(allZones),
surfZones
);

View File

@ -80,7 +80,7 @@ void Foam::searchableSurfaceModifiers::cut::triangulate
patchI
);
}
cutSurf = triSurface(tris.xfer(), patches, pts.xfer());
cutSurf = triSurface(tris, patches, pts, true);
}
@ -331,12 +331,12 @@ bool Foam::searchableSurfaceModifiers::cut::modify
{
if (volTypes[i] == volumeType::INSIDE)
{
nInside++;
++nInside;
}
}
// Add a patch for inside the box
if (nInside > 0 && surf3.patches().size() > 0)
if (nInside && surf3.patches().size() > 0)
{
geometricSurfacePatchList newPatches(surf3.patches());
label sz = newPatches.size();
@ -362,7 +362,7 @@ bool Foam::searchableSurfaceModifiers::cut::modify
}
}
pointField newPoints(surf3.points());
surf = triSurface(newTris.xfer(), newPatches, newPoints.xfer());
surf = triSurface(newTris, newPatches, newPoints, true);
changed = true;
}