ENH: replace base implementation of Foam::Swap with std::swap

- eliminates a potentially invalid code branch.
  Since it essentially had the same internals as std::swap anyhow,
  make that more evident.

ENH: use std::swap for basic types

- makes it clearer that they do not rely on any special semantics
This commit is contained in:
Mark Olesen
2021-02-16 10:18:16 +01:00
parent 8c460d8ec9
commit f8a0677a66
30 changed files with 108 additions and 113 deletions

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -889,7 +890,7 @@ int main(int argc, char *argv[])
{
faces[facei].flip();
}
Swap(owner[facei], neighbour[facei]);
std::swap(owner[facei], neighbour[facei]);
}
}

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -889,8 +890,8 @@ int main(int argc, char *argv[])
if (own[facei] == -1 && nei[facei] != -1)
{
// Boundary face with incorrect orientation
boundaryFaces[facei] = boundaryFaces[facei].reverseFace();
Swap(own[facei], nei[facei]);
boundaryFaces[facei].flip();
std::swap(own[facei], nei[facei]);
nReverse++;
}
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd.
Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -2348,7 +2348,7 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
{
forAll(procPatchFaces, fI)
{
procPatchFaces[fI] = procPatchFaces[fI].reverseFace();
procPatchFaces[fI].flip();
}
}

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -325,7 +326,7 @@ inline Foam::tetCell CGAL::indexedCell<Gt, Cb>::vertexGlobalIndices
{
if (tVGI[j - 1] > tVGI[j])
{
Foam::Swap(tVGI[j - 1], tVGI[j]);
std::swap(tVGI[j - 1], tVGI[j]);
}
}
}
@ -354,8 +355,8 @@ CGAL::indexedCell<Gt, Cb>::globallyOrderedCellVertices
{
if (tVGI[j - 1] > tVGI[j])
{
Foam::Swap(tVGI[j - 1], tVGI[j]);
Foam::Swap(vertexMap[j - 1], vertexMap[j]);
std::swap(tVGI[j - 1], tVGI[j]);
std::swap(vertexMap[j - 1], vertexMap[j]);
}
}
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd.
Copyright (C) 2016-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -441,7 +441,7 @@ autoPtr<mapPolyMesh> reorderMesh
if (nei < own)
{
newFaces[facei].flip();
Swap(newOwner[facei], newNeighbour[facei]);
std::swap(newOwner[facei], newNeighbour[facei]);
flipFaceFlux.insert(facei);
}
}