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

View File

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

View File

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

View File

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

View File

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

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2019 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -661,9 +661,9 @@ void Foam::HashTable<T, Key, Hash>::swap(HashTable<T, Key, Hash>& rhs)
return; // Self-swap is a no-op return; // Self-swap is a no-op
} }
Foam::Swap(size_, rhs.size_); std::swap(size_, rhs.size_);
Foam::Swap(capacity_, rhs.capacity_); std::swap(capacity_, rhs.capacity_);
Foam::Swap(table_, rhs.table_); std::swap(table_, rhs.table_);
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -294,9 +294,9 @@ void Foam::Matrix<Form, Type>::swap(Matrix<Form, Type>& mat)
return; // Self-swap is a no-op return; // Self-swap is a no-op
} }
Foam::Swap(mRows_, mat.mRows_); std::swap(mRows_, mat.mRows_);
Foam::Swap(nCols_, mat.nCols_); std::swap(nCols_, mat.nCols_);
Foam::Swap(v_, mat.v_); std::swap(v_, mat.v_);
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -717,7 +717,7 @@ void Foam::GAMGAgglomeration::calculateRegionMaster
const label index = const label index =
agglomProcIDs.find(agglomToMaster[myAgglom]); agglomProcIDs.find(agglomToMaster[myAgglom]);
Swap(agglomProcIDs[0], agglomProcIDs[index]); std::swap(agglomProcIDs[0], agglomProcIDs[index]);
} }

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -474,7 +475,7 @@ void Foam::face::flip()
{ {
for (label i=1; i < (n+1)/2; ++i) for (label i=1; i < (n+1)/2; ++i)
{ {
Swap(operator[](i), operator[](n-i)); std::swap(operator[](i), operator[](n-i));
} }
} }
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2013 OpenFOAM Foundation Copyright (C) 2011-2013 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -140,7 +140,7 @@ inline Foam::label Foam::triFace::collapse()
inline void Foam::triFace::flip() inline void Foam::triFace::flip()
{ {
Swap(operator[](1), operator[](2)); std::swap(operator[](1), operator[](2));
} }

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -100,7 +101,7 @@ inline Foam::triFace Foam::tetIndices::faceTriIs
if (mesh.faceOwner()[face()] != cell()) if (mesh.faceOwner()[face()] != cell())
{ {
Swap(facePtI, faceOtherPtI); std::swap(facePtI, faceOtherPtI);
} }
return triFace(f[faceBasePtI], f[facePtI], f[faceOtherPtI]); return triFace(f[faceBasePtI], f[facePtI], f[faceOtherPtI]);
@ -144,7 +145,7 @@ inline Foam::triFace Foam::tetIndices::triIs
if (mesh.faceOwner()[face()] != cell()) if (mesh.faceOwner()[face()] != cell())
{ {
Swap(facePtI, faceOtherPtI); std::swap(facePtI, faceOtherPtI);
} }
return triFace(faceBasePtI, facePtI, faceOtherPtI); return triFace(faceBasePtI, facePtI, faceOtherPtI);

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -57,7 +58,7 @@ typename Foam::cut::opAddResult<AboveOp, BelowOp>::type Foam::triCut
{ {
if (level[(i + 1)%3]*level[(i + 2)%3] >= 0) if (level[(i + 1)%3]*level[(i + 2)%3] >= 0)
{ {
Swap(indices[0], indices[i]); std::swap(indices[0], indices[i]);
break; break;
} }
} }
@ -71,7 +72,7 @@ typename Foam::cut::opAddResult<AboveOp, BelowOp>::type Foam::triCut
// Correct the sign // Correct the sign
if (indices[0] != 0) if (indices[0] != 0)
{ {
Swap(indices[1], indices[2]); std::swap(indices[1], indices[2]);
} }
// Permute the data // Permute the data
@ -165,7 +166,7 @@ typename Foam::cut::opAddResult<AboveOp, BelowOp>::type Foam::tetCut
{ {
break; break;
} }
Swap(indices[i], indices[j]); std::swap(indices[i], indices[j]);
signChange = !signChange; signChange = !signChange;
} }
@ -179,14 +180,14 @@ typename Foam::cut::opAddResult<AboveOp, BelowOp>::type Foam::tetCut
n = 4 - n; n = 4 - n;
for (label i = 0; i < 2; ++i) for (label i = 0; i < 2; ++i)
{ {
Swap(indices[i], indices[3-i]); std::swap(indices[i], indices[3-i]);
} }
} }
// Correct the sign // Correct the sign
if (signChange) if (signChange)
{ {
Swap(indices[2], indices[3]); std::swap(indices[2], indices[3]);
} }
// Permute the data // Permute the data

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -29,12 +29,14 @@ InNamespace
Description Description
Swap arguments as per std::swap, but in Foam namespace. Swap arguments as per std::swap, but in Foam namespace.
For complex structures, it is usual to provide a member swap() method
and a function specialization for Swap().
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef Swap_H #ifndef Swap_H
#define Swap_H #define Swap_H
#include <type_traits>
#include <utility> #include <utility>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -42,26 +44,12 @@ Description
namespace Foam namespace Foam
{ {
//- Swap non-array types as per std::swap example, but in Foam namespace. //- Swap non-array types as per std::swap, but in Foam namespace.
// \sa http://www.cplusplus.com/reference/utility/swap/ // \sa http://www.cplusplus.com/reference/utility/swap/
template<class T> template<class T>
void Swap(T& a, T& b) void Swap(T& a, T& b)
{ {
// compile-time resolution with std::enable_if not yet working std::swap(a, b);
if (std::is_fundamental<T>::value || std::is_pointer<T>::value)
{
// Use copy/assign for simple types
const T tmp = a;
a = b;
b = tmp;
}
else
{
// Use move/assignment
T tmp(std::move(a));
a = std::move(b);
b = std::move(tmp);
}
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2020 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -2291,7 +2291,7 @@ void Foam::ccm::reader::reorderMesh()
{ {
faceOwner_[faceI] = faceNeighbour_[faceI]; faceOwner_[faceI] = faceNeighbour_[faceI];
faceNeighbour_[faceI] = own; faceNeighbour_[faceI] = own;
faces_[faceI] = faces_[faceI].reverseFace(); faces_[faceI].flip();
} }
// And check the face // And check the face

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2019 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -214,7 +214,7 @@ void Foam::fileFormats::FIREMeshReader::reorganize()
if (owner_[faceI] > neigh_[faceI]) if (owner_[faceI] > neigh_[faceI])
{ {
Swap(owner_[faceI], neigh_[faceI]); std::swap(owner_[faceI], neigh_[faceI]);
} }
} }
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -756,8 +756,8 @@ void Foam::createShellMesh::setRefinement
if (minCelli > maxCelli) if (minCelli > maxCelli)
{ {
// Swap // Swap
Swap(minCelli, maxCelli); std::swap(minCelli, maxCelli);
newF = newF.reverseFace(); newF.flip();
} }
patchi = -1; patchi = -1;
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2019 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -407,7 +407,7 @@ Foam::labelListList Foam::combineFaces::getMergeSets
} }
if (maxIndex != 0) if (maxIndex != 0)
{ {
Swap(faceIDs[0], faceIDs[maxIndex]); std::swap(faceIDs[0], faceIDs[maxIndex]);
} }
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2018-2019 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -907,9 +907,9 @@ void Foam::vtkUnstructuredReader::read(ISstream& inFile)
if (((topCc - bottomCc) & bottomNormal) < 0) if (((topCc - bottomCc) & bottomNormal) < 0)
{ {
// Flip top and bottom // Flip top and bottom
Swap(shape[0], shape[3]); std::swap(shape[0], shape[3]);
Swap(shape[1], shape[4]); std::swap(shape[1], shape[4]);
Swap(shape[2], shape[5]); std::swap(shape[2], shape[5]);
nSwapped++; nSwapped++;
} }
} }

View File

@ -146,7 +146,7 @@ void Foam::particle::movingTetReverseTransform
void Foam::particle::reflect() void Foam::particle::reflect()
{ {
Swap(coordinates_.c(), coordinates_.d()); std::swap(coordinates_.c(), coordinates_.d());
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2020 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -795,7 +795,7 @@ void Foam::lumpedPointMovement::setInterpolator
{ {
// Order by distance, which is not really needed, // Order by distance, which is not really needed,
// but helps with diagnostics // but helps with diagnostics
Swap(nei1, nei2); std::swap(nei1, nei2);
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd. Copyright (C) 2015-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -1166,7 +1166,7 @@ Foam::label Foam::meshRefinement::markSurfaceCurvatureRefinement
if (!isMasterFace[faceI]) if (!isMasterFace[faceI])
{ {
Swap(start[i], end[i]); std::swap(start[i], end[i]);
} }
minLevel[i] = min(cellLevel[own], neiLevel[bFaceI]); minLevel[i] = min(cellLevel[own], neiLevel[bFaceI]);

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd. Copyright (C) 2015-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -1197,7 +1197,7 @@ void Foam::polyTopoChange::compact
) )
{ {
faces_[facei].flip(); faces_[facei].flip();
Swap(faceOwner_[facei], faceNeighbour_[facei]); std::swap(faceOwner_[facei], faceNeighbour_[facei]);
flipFaceFlux_.flip(facei); flipFaceFlux_.flip(facei);
faceZoneFlip_.flip(facei); faceZoneFlip_.flip(facei);
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015-2020 OpenCFD Ltd. Copyright (C) 2015-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -383,7 +383,7 @@ void Foam::searchableCone::findLineAll
if (tPoint2 < tPoint1) if (tPoint2 < tPoint1)
{ {
Swap(tPoint1, tPoint2); std::swap(tPoint1, tPoint2);
} }
if (tPoint1 > magV || tPoint2 < 0) if (tPoint1 > magV || tPoint2 < 0)
{ {
@ -546,7 +546,7 @@ void Foam::searchableCone::findLineAll
t2 = (-b + sqrtDisc)/(2.0*a); t2 = (-b + sqrtDisc)/(2.0*a);
if (t2 < t1) if (t2 < t1)
{ {
Swap(t1, t2); std::swap(t1, t2);
} }
if (t1 >= 0.0 && t1 <= magV && t1 >= tPoint1 && t1 <= tPoint2) if (t1 >= 0.0 && t1 <= magV && t1 >= tPoint1 && t1 <= tPoint2)

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -253,7 +253,7 @@ void Foam::searchableCylinder::findLineAll
tPoint2 = -(point2Start&unitDir_)/s; tPoint2 = -(point2Start&unitDir_)/s;
if (tPoint2 < tPoint1) if (tPoint2 < tPoint1)
{ {
Swap(tPoint1, tPoint2); std::swap(tPoint1, tPoint2);
} }
if (tPoint1 > magV || tPoint2 < 0) if (tPoint1 > magV || tPoint2 < 0)
{ {
@ -365,7 +365,7 @@ void Foam::searchableCylinder::findLineAll
t2 = (-b + sqrtDisc)/(2*a); t2 = (-b + sqrtDisc)/(2*a);
if (t2 < t1) if (t2 < t1)
{ {
Swap(t1, t2); std::swap(t1, t2);
} }
if (t1 >= 0 && t1 <= magV && t1 >= tPoint1 && t1 <= tPoint2) if (t1 >= 0 && t1 <= magV && t1 >= tPoint1 && t1 <= tPoint2)

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2012 OpenFOAM Foundation Copyright (C) 2011-2012 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -68,7 +69,7 @@ Foam::labelList Foam::randomRenumber::renumber
forAll(newToOld, i) forAll(newToOld, i)
{ {
label j = rndGen.position<label>(0, newToOld.size()-1); label j = rndGen.position<label>(0, newToOld.size()-1);
Swap(newToOld[i], newToOld[j]); std::swap(newToOld[i], newToOld[j]);
} }
} }
return newToOld; return newToOld;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -225,7 +225,7 @@ void Foam::patchSeedSet::calcSamples
forAll(subset, i) forAll(subset, i)
{ {
label j = rndGen.position<label>(0, subset.size()-1); label j = rndGen.position<label>(0, subset.size()-1);
Swap(subset[i], subset[j]); std::swap(subset[i], subset[j]);
} }
} }
// Truncate // Truncate

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -134,7 +134,7 @@ void Foam::isoSurfaceCell::generateTriPoints
{ {
// Flip normals // Flip normals
const label sz = pts.size(); const label sz = pts.size();
Swap(pts[sz-2], pts[sz-1]); std::swap(pts[sz-2], pts[sz-1]);
} }
} }
break; break;
@ -150,7 +150,7 @@ void Foam::isoSurfaceCell::generateTriPoints
{ {
// Flip normals // Flip normals
const label sz = pts.size(); const label sz = pts.size();
Swap(pts[sz-2], pts[sz-1]); std::swap(pts[sz-2], pts[sz-1]);
} }
} }
break; break;
@ -176,8 +176,8 @@ void Foam::isoSurfaceCell::generateTriPoints
{ {
// Flip normals // Flip normals
const label sz = pts.size(); const label sz = pts.size();
Swap(pts[sz-5], pts[sz-4]); std::swap(pts[sz-5], pts[sz-4]);
Swap(pts[sz-2], pts[sz-1]); std::swap(pts[sz-2], pts[sz-1]);
} }
} }
break; break;
@ -193,7 +193,7 @@ void Foam::isoSurfaceCell::generateTriPoints
{ {
// Flip normals // Flip normals
const label sz = pts.size(); const label sz = pts.size();
Swap(pts[sz-2], pts[sz-1]); std::swap(pts[sz-2], pts[sz-1]);
} }
} }
break; break;
@ -216,8 +216,8 @@ void Foam::isoSurfaceCell::generateTriPoints
{ {
// Flip normals // Flip normals
const label sz = pts.size(); const label sz = pts.size();
Swap(pts[sz-5], pts[sz-4]); std::swap(pts[sz-5], pts[sz-4]);
Swap(pts[sz-2], pts[sz-1]); std::swap(pts[sz-2], pts[sz-1]);
} }
} }
break; break;
@ -240,8 +240,8 @@ void Foam::isoSurfaceCell::generateTriPoints
{ {
// Flip normals // Flip normals
const label sz = pts.size(); const label sz = pts.size();
Swap(pts[sz-5], pts[sz-4]); std::swap(pts[sz-5], pts[sz-4]);
Swap(pts[sz-2], pts[sz-1]); std::swap(pts[sz-2], pts[sz-1]);
} }
} }
break; break;
@ -256,7 +256,7 @@ void Foam::isoSurfaceCell::generateTriPoints
{ {
// Flip normals // Flip normals
const label sz = pts.size(); const label sz = pts.size();
Swap(pts[sz-2], pts[sz-1]); std::swap(pts[sz-2], pts[sz-1]);
} }
} }
break; break;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -264,7 +264,7 @@ void Foam::isoSurfacePoint::generateTriPoints
{ {
// Flip normals // Flip normals
const label sz = pts.size(); const label sz = pts.size();
Swap(pts[sz-2], pts[sz-1]); std::swap(pts[sz-2], pts[sz-1]);
} }
} }
break; break;
@ -288,7 +288,7 @@ void Foam::isoSurfacePoint::generateTriPoints
{ {
// Flip normals // Flip normals
const label sz = pts.size(); const label sz = pts.size();
Swap(pts[sz-2], pts[sz-1]); std::swap(pts[sz-2], pts[sz-1]);
} }
} }
break; break;
@ -319,8 +319,8 @@ void Foam::isoSurfacePoint::generateTriPoints
{ {
// Flip normals // Flip normals
const label sz = pts.size(); const label sz = pts.size();
Swap(pts[sz-5], pts[sz-4]); std::swap(pts[sz-5], pts[sz-4]);
Swap(pts[sz-2], pts[sz-1]); std::swap(pts[sz-2], pts[sz-1]);
} }
} }
break; break;
@ -345,7 +345,7 @@ void Foam::isoSurfacePoint::generateTriPoints
{ {
// Flip normals // Flip normals
const label sz = pts.size(); const label sz = pts.size();
Swap(pts[sz-2], pts[sz-1]); std::swap(pts[sz-2], pts[sz-1]);
} }
} }
break; break;
@ -376,8 +376,8 @@ void Foam::isoSurfacePoint::generateTriPoints
{ {
// Flip normals // Flip normals
const label sz = pts.size(); const label sz = pts.size();
Swap(pts[sz-5], pts[sz-4]); std::swap(pts[sz-5], pts[sz-4]);
Swap(pts[sz-2], pts[sz-1]); std::swap(pts[sz-2], pts[sz-1]);
} }
} }
break; break;
@ -408,8 +408,8 @@ void Foam::isoSurfacePoint::generateTriPoints
{ {
// Flip normals // Flip normals
const label sz = pts.size(); const label sz = pts.size();
Swap(pts[sz-5], pts[sz-4]); std::swap(pts[sz-5], pts[sz-4]);
Swap(pts[sz-2], pts[sz-1]); std::swap(pts[sz-2], pts[sz-1]);
} }
} }
break; break;
@ -434,7 +434,7 @@ void Foam::isoSurfacePoint::generateTriPoints
{ {
// Flip normals // Flip normals
const label sz = pts.size(); const label sz = pts.size();
Swap(pts[sz-2], pts[sz-1]); std::swap(pts[sz-2], pts[sz-1]);
} }
} }
break; break;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2019 OpenFOAM Foundation Copyright (C) 2011-2019 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -328,7 +328,7 @@ void Foam::isoSurfaceTopo::generateTriPoints
{ {
// Flip normals // Flip normals
const label sz = verts.size(); const label sz = verts.size();
Swap(verts[sz-2], verts[sz-1]); std::swap(verts[sz-2], verts[sz-1]);
} }
} }
break; break;
@ -371,7 +371,7 @@ void Foam::isoSurfaceTopo::generateTriPoints
{ {
// Flip normals // Flip normals
const label sz = verts.size(); const label sz = verts.size();
Swap(verts[sz-2], verts[sz-1]); std::swap(verts[sz-2], verts[sz-1]);
} }
} }
break; break;
@ -429,8 +429,8 @@ void Foam::isoSurfaceTopo::generateTriPoints
{ {
// Flip normals // Flip normals
const label sz = verts.size(); const label sz = verts.size();
Swap(verts[sz-5], verts[sz-4]); std::swap(verts[sz-5], verts[sz-4]);
Swap(verts[sz-2], verts[sz-1]); std::swap(verts[sz-2], verts[sz-1]);
} }
} }
break; break;
@ -473,7 +473,7 @@ void Foam::isoSurfaceTopo::generateTriPoints
{ {
// Flip normals // Flip normals
const label sz = verts.size(); const label sz = verts.size();
Swap(verts[sz-2], verts[sz-1]); std::swap(verts[sz-2], verts[sz-1]);
} }
} }
break; break;
@ -531,8 +531,8 @@ void Foam::isoSurfaceTopo::generateTriPoints
{ {
// Flip normals // Flip normals
const label sz = verts.size(); const label sz = verts.size();
Swap(verts[sz-5], verts[sz-4]); std::swap(verts[sz-5], verts[sz-4]);
Swap(verts[sz-2], verts[sz-1]); std::swap(verts[sz-2], verts[sz-1]);
} }
} }
break; break;
@ -590,8 +590,8 @@ void Foam::isoSurfaceTopo::generateTriPoints
{ {
// Flip normals // Flip normals
const label sz = verts.size(); const label sz = verts.size();
Swap(verts[sz-5], verts[sz-4]); std::swap(verts[sz-5], verts[sz-4]);
Swap(verts[sz-2], verts[sz-1]); std::swap(verts[sz-2], verts[sz-1]);
} }
} }
break; break;
@ -633,7 +633,7 @@ void Foam::isoSurfaceTopo::generateTriPoints
{ {
// Flip normals // Flip normals
const label sz = verts.size(); const label sz = verts.size();
Swap(verts[sz-2], verts[sz-1]); std::swap(verts[sz-2], verts[sz-1]);
} }
} }
break; break;
@ -688,7 +688,7 @@ void Foam::isoSurfaceTopo::generateTriPoints
if (faceOwner[facei] == celli) if (faceOwner[facei] == celli)
{ {
Swap(p1, p2); std::swap(p1, p2);
} }
generateTriPoints generateTriPoints
@ -754,7 +754,7 @@ void Foam::isoSurfaceTopo::generateTriPoints
label p2 = f[nextFp]; label p2 = f[nextFp];
if (faceOwner[facei] == celli) if (faceOwner[facei] == celli)
{ {
Swap(p1, p2); std::swap(p1, p2);
if (i != 2) edgeIsDiag[1] = true; if (i != 2) edgeIsDiag[1] = true;
if (i != f.size()-1) edgeIsDiag[0] = true; if (i != f.size()-1) edgeIsDiag[0] = true;
} }