diff --git a/applications/test/HashTable1/Test-HashTable1.C b/applications/test/HashTable1/Test-HashTable1.C index 3fa46376d4..6f92ffcd8f 100644 --- a/applications/test/HashTable1/Test-HashTable1.C +++ b/applications/test/HashTable1/Test-HashTable1.C @@ -33,7 +33,7 @@ License #include "IOstreams.H" #include "StringStream.H" #include "ListOps.H" -#include "flipOp.H" +#include "StringListOps.H" using namespace Foam; @@ -216,7 +216,7 @@ int main() ( table1.keys().begin(), table1.keys().end(), - noOp{} + identityOp{} ) ); sort(sortKeys); diff --git a/applications/test/ITstream/Test-ITstream.C b/applications/test/ITstream/Test-ITstream.C index 2066cfbf96..1503a43977 100644 --- a/applications/test/ITstream/Test-ITstream.C +++ b/applications/test/ITstream/Test-ITstream.C @@ -34,7 +34,7 @@ Description #include "argList.H" #include "ITstream.H" #include "ListOps.H" -#include "flipOp.H" +#include "StringListOps.H" using namespace Foam; @@ -172,7 +172,7 @@ int main(int argc, char *argv[]) ( stringInput.cbegin(), stringInput.cend(), - Foam::noOp{} + Foam::identityOp{} ) ); diff --git a/applications/test/mapDistributePolyMesh/Test-mapDistributePolyMesh.C b/applications/test/mapDistributePolyMesh/Test-mapDistributePolyMesh.C index d57628af56..554dbce72b 100644 --- a/applications/test/mapDistributePolyMesh/Test-mapDistributePolyMesh.C +++ b/applications/test/mapDistributePolyMesh/Test-mapDistributePolyMesh.C @@ -85,7 +85,7 @@ int main(int argc, char *argv[]) { const mapDistribute& faceMap = map.faceMap(); pointField fc(mesh.faceCentres()); - faceMap.distribute(fc, noOp()); + faceMap.distribute(fc, identityOp()); Pout<< "Construct size:" << faceMap.constructSize() << endl; forAll(distributedMesh.faceCentres(), facei) { @@ -118,7 +118,7 @@ int main(int argc, char *argv[]) { const mapDistribute& cellMap = map.cellMap(); pointField cc(mesh.cellCentres()); - cellMap.distribute(cc, noOp()); + cellMap.distribute(cc, identityOp()); Pout<< "Construct size:" << cellMap.constructSize() << endl; forAll(distributedMesh.cellCentres(), celli) { @@ -131,7 +131,7 @@ int main(int argc, char *argv[]) { const mapDistribute& pointMap = map.pointMap(); pointField pc(mesh.points()); - pointMap.distribute(pc, noOp()); + pointMap.distribute(pc, identityOp()); Pout<< "Construct size:" << pointMap.constructSize() << endl; forAll(distributedMesh.points(), pointi) { diff --git a/applications/test/syncTools/Test-syncTools.C b/applications/test/syncTools/Test-syncTools.C index bed6124ca8..509ad1d34e 100644 --- a/applications/test/syncTools/Test-syncTools.C +++ b/applications/test/syncTools/Test-syncTools.C @@ -614,7 +614,7 @@ void testEdgeFlip2(const polyMesh& mesh, Random& rndGen) edgePointCombineOp(), PointPair(point::max, point::max), edgePointTransformOp(), - noOp() + identityOp() ); forAll(fld, edgeI) diff --git a/applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L b/applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L index 28c132b335..f7131724fd 100644 --- a/applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L +++ b/applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L @@ -51,7 +51,6 @@ Description #include "wallPolyPatch.H" #include "symmetryPolyPatch.H" #include "oldCyclicPolyPatch.H" -#include "Swap.H" #include "IFstream.H" #include "readHexLabel.H" diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedCell/indexedCell.H b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedCell/indexedCell.H index e25d989036..ceaf04946b 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedCell/indexedCell.H +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedCell/indexedCell.H @@ -45,7 +45,6 @@ SourceFiles #include "List.H" #include "globalIndex.H" #include "Pstream.H" -#include "Swap.H" #include "InfoProxy.H" #include "tetCell.H" #include "typeInfo.H" diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedList.H b/src/OpenFOAM/containers/Lists/FixedList/FixedList.H index 6977f5e33e..17bf3a1e4d 100644 --- a/src/OpenFOAM/containers/Lists/FixedList/FixedList.H +++ b/src/OpenFOAM/containers/Lists/FixedList/FixedList.H @@ -45,9 +45,9 @@ SourceFiles #include "uLabel.H" #include "zero.H" #include "contiguous.H" +#include "stdFoam.H" #include "autoPtr.H" #include "Hash.H" -#include "Swap.H" #include "SLListFwd.H" #include "ListPolicy.H" diff --git a/src/OpenFOAM/containers/Lists/UList/UList.H b/src/OpenFOAM/containers/Lists/UList/UList.H index 8f9eed4b1c..b588a264c8 100644 --- a/src/OpenFOAM/containers/Lists/UList/UList.H +++ b/src/OpenFOAM/containers/Lists/UList/UList.H @@ -42,8 +42,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef UList_H -#define UList_H +#ifndef Foam_UList_H +#define Foam_UList_H #include "bool.H" #include "label.H" @@ -51,10 +51,9 @@ SourceFiles #include "zero.H" #include "one.H" #include "contiguous.H" -#include "nullObject.H" #include "stdFoam.H" +#include "nullObject.H" #include "Hash.H" -#include "Swap.H" #include "ListPolicy.H" #include diff --git a/src/OpenFOAM/fields/Fields/Field/Field.C b/src/OpenFOAM/fields/Fields/Field/Field.C index ba91d0b82b..f7fd4066ad 100644 --- a/src/OpenFOAM/fields/Fields/Field/Field.C +++ b/src/OpenFOAM/fields/Fields/Field/Field.C @@ -346,7 +346,7 @@ void Foam::Field::map } else { - distMap.distribute(newMapF, noOp()); + distMap.distribute(newMapF, identityOp()); } if (mapper.direct() && notNull(mapper.directAddressing())) @@ -417,7 +417,7 @@ void Foam::Field::autoMap } else { - distMap.distribute(fCpy, noOp()); + distMap.distribute(fCpy, identityOp()); } if diff --git a/src/OpenFOAM/fields/Fields/Field/FieldOps.H b/src/OpenFOAM/fields/Fields/Field/FieldOps.H index ebbc9650e9..abbb8264b2 100644 --- a/src/OpenFOAM/fields/Fields/Field/FieldOps.H +++ b/src/OpenFOAM/fields/Fields/Field/FieldOps.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -34,8 +34,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef FieldOps_H -#define FieldOps_H +#ifndef Foam_FieldOps_H +#define Foam_FieldOps_H #include "flipOp.H" #include "ListOps.H" @@ -127,7 +127,7 @@ void ternary //- depending on the conditional. // // The meaning of the conditional is adjusted by the flip operation, -// which is typically Foam::noOp() or Foam::flipBoolOp() +// which is typically Foam::identityOp() or Foam::flipBoolOp() // // Similar parameter requirements as Foam::subset() // @@ -150,7 +150,7 @@ void ternarySelect //- depending on the conditional. // // The meaning of the conditional is adjusted by the flip operation, -// which is typically Foam::noOp() or Foam::flipBoolOp() +// which is typically Foam::identityOp() or Foam::flipBoolOp() template void ternarySelect ( @@ -172,7 +172,7 @@ void ternarySelect const Field& b ) { - ternarySelect(result, cond, a, b, noOp()); + ternarySelect(result, cond, a, b, identityOp{}); } @@ -186,7 +186,7 @@ void ternarySelect const Field& b ) { - ternarySelect(result, cond, a, b, noOp()); + ternarySelect(result, cond, a, b, identityOp{}); } diff --git a/src/OpenFOAM/fields/pointPatchFields/constraint/cyclic/cyclicPointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/constraint/cyclic/cyclicPointPatchField.C index d2a3f506db..8cf4e9b482 100644 --- a/src/OpenFOAM/fields/pointPatchFields/constraint/cyclic/cyclicPointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/constraint/cyclic/cyclicPointPatchField.C @@ -26,7 +26,6 @@ License \*---------------------------------------------------------------------------*/ #include "cyclicPointPatchField.H" -#include "Swap.H" #include "transformField.H" #include "pointFields.H" diff --git a/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.H b/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.H index f2c6a21203..e9c0311460 100644 --- a/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.H +++ b/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.H @@ -386,21 +386,21 @@ protected: template Type scatterList(const UList&, const int, const label comm) const; - template + template Type masterOp ( const fileName& fName, - const fileOp& fop, + const FileOp& fop, const int tag, const label comm ) const; - template + template Type masterOp ( const fileName& src, const fileName& dest, - const fileOp& fop, + const FileOp& fop, const int tag, const label comm ) const; diff --git a/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperationTemplates.C b/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperationTemplates.C index 8fc8fed149..7ff45acaca 100644 --- a/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperationTemplates.C +++ b/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperationTemplates.C @@ -66,11 +66,11 @@ Type Foam::fileOperations::masterUncollatedFileOperation::scatterList } -template +template Type Foam::fileOperations::masterUncollatedFileOperation::masterOp ( const fileName& fName, - const fileOp& fop, + const FileOp& fop, const int tag, const label comm ) const @@ -78,7 +78,7 @@ Type Foam::fileOperations::masterUncollatedFileOperation::masterOp if (IFstream::debug) { Pout<< "masterUncollatedFileOperation::masterOp : Operation " - << typeid(fileOp).name() + << typeid(FileOp).name() << " on " << fName << endl; } if (Pstream::parRun()) @@ -109,12 +109,12 @@ Type Foam::fileOperations::masterUncollatedFileOperation::masterOp } -template +template Type Foam::fileOperations::masterUncollatedFileOperation::masterOp ( const fileName& src, const fileName& dest, - const fileOp& fop, + const FileOp& fop, const int tag, const label comm ) const diff --git a/src/OpenFOAM/include/stdFoam.H b/src/OpenFOAM/include/stdFoam.H index 3a9de87aa9..40c6e673f0 100644 --- a/src/OpenFOAM/include/stdFoam.H +++ b/src/OpenFOAM/include/stdFoam.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2017-2020 OpenCFD Ltd. + Copyright (C) 2017-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -23,28 +23,14 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . -Namespace - stdFoam - Description - Global macros and templates used by OpenFOAM and some standard - C++ headers. - - Some of the templates defined here correspond to useful - std templates that are part of future C++ standards, or that - are in a state of change. Defining them here provides some additional - control over which definitions are used within the OpenFOAM code-base. - -SeeAlso - - http://en.cppreference.com/w/cpp/iterator/begin - - http://en.cppreference.com/w/cpp/iterator/end - - http://en.cppreference.com/w/cpp/iterator/rbegin - - http://en.cppreference.com/w/cpp/iterator/rend + Includes some standard C++ headers, defines global macros and templates + used in multiple places by OpenFOAM. \*---------------------------------------------------------------------------*/ -#ifndef stdFoam_H -#define stdFoam_H +#ifndef Foam_stdFoam_H +#define Foam_stdFoam_H #include #include @@ -71,19 +57,70 @@ SeeAlso //- Namespace for OpenFOAM namespace Foam { - //- Implementation details for various OpenFOAM classes - namespace Detail {} - //- Additional OpenFOAM modules - namespace Module {} +//- Implementation details for various OpenFOAM classes +namespace Detail {} - // Standard items +//- Additional OpenFOAM modules +namespace Module {} - //- Allow use of std::unique_ptr directly as Foam::unique_ptr - using std::unique_ptr; +// Standard items + +//- Allow use of std::unique_ptr directly as Foam::unique_ptr +using std::unique_ptr; + + +//- A functor that returns its argument unchanged (cf. C++20 std::identity) +//- Should \em never be specialized. +struct identityOp +{ + using is_transparent = void; + + template + constexpr T&& operator()(T&& val) const noexcept + { + return std::forward(val); + } +}; + + +//- Swap non-array types as per std::swap, but in Foam namespace. +// \sa http://www.cplusplus.com/reference/utility/swap/ +// +// \note For complex structures, it is usual to provide a swap() member +// function and specialize Swap() +template +void Swap(T& a, T& b) +{ + std::swap(a, b); } +//- Swap array types as per std::swap example, but in Foam namespace. +// \sa http://www.cplusplus.com/reference/utility/swap/ +template +void Swap(T (&a)[N], T (&b)[N]) +{ + for (size_t i = 0; i < N; ++i) + { + Foam::Swap(a[i], b[i]); + } +} + +} // End namespace Foam + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +//- Namespace for std templates that are are part of future C++ standards +//- or that are in a state of change. +// +// SeeAlso +// - http://en.cppreference.com/w/cpp/iterator/begin +// - http://en.cppreference.com/w/cpp/iterator/end +// - http://en.cppreference.com/w/cpp/iterator/rbegin +// - http://en.cppreference.com/w/cpp/iterator/rend + namespace stdFoam { diff --git a/src/OpenFOAM/matrices/scalarMatrices/scalarMatricesTemplates.C b/src/OpenFOAM/matrices/scalarMatrices/scalarMatricesTemplates.C index 4aed28b515..710a3c57c5 100644 --- a/src/OpenFOAM/matrices/scalarMatrices/scalarMatricesTemplates.C +++ b/src/OpenFOAM/matrices/scalarMatrices/scalarMatricesTemplates.C @@ -26,7 +26,6 @@ License \*---------------------------------------------------------------------------*/ #include "scalarMatrices.H" -#include "Swap.H" #include "ListOps.H" // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H index ddeba70662..6ad294043e 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H @@ -487,11 +487,11 @@ public: ) const; //- Distribute data using default commsType. - template + template void distribute ( List& fld, - const negateOp& negOp, + const NegateOp& negOp, const bool dummyTransform = true, const int tag = UPstream::msgType() ) const; diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.C index 42f8eea682..44f8e48953 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.C @@ -961,7 +961,7 @@ void Foam::mapDistributeBase::compact elemIsUsed, map[i], constructHasFlip_, - noOp() // do not flip elemIsUsed value + identityOp() // Do not flip elemIsUsed value ); } @@ -992,7 +992,7 @@ void Foam::mapDistributeBase::compact elemIsUsed, map[i], constructHasFlip_, - noOp() // do not flip elemIsUsed value + identityOp() // Do not flip elemIsUsed value ); } } diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.H b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.H index 64d99e4fc1..ec3b8b94af 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.H +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.H @@ -172,24 +172,24 @@ protected: labelList& compactStart ); - template + template static void flipAndCombine ( const labelUList& map, const bool hasFlip, const UList& rhs, const CombineOp& cop, - const negateOp& negOp, + const NegateOp& negOp, List& lhs ); - template + template static T accessAndFlip ( const UList& fld, const label index, const bool hasFlip, - const negateOp& negOp + const NegateOp& negOp ); public: @@ -390,7 +390,7 @@ public: //- Distribute data. Note:schedule only used for // Pstream::commsTypes::scheduled for now, all others just use // send-to-all, receive-from-all. - template + template static void distribute ( const Pstream::commsTypes commsType, @@ -401,14 +401,14 @@ public: const labelListList& constructMap, const bool constructHasFlip, List&, - const negateOp& negOp, + const NegateOp& negOp, const int tag = UPstream::msgType(), const label comm = UPstream::worldComm ); //- Distribute data. If multiple processors writing to same // position adds contributions using cop. - template + template static void distribute ( const Pstream::commsTypes commsType, @@ -421,7 +421,7 @@ public: List&, const T& nullValue, const CombineOp& cop, - const negateOp& negOp, + const NegateOp& negOp, const int tag = UPstream::msgType(), const label comm = UPstream::worldComm ); @@ -435,11 +435,11 @@ public: ) const; //- Distribute data using default commsType. - template + template void distribute ( List& fld, - const negateOp& negOp, + const NegateOp& negOp, const int tag = UPstream::msgType() ) const; diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBaseTemplates.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBaseTemplates.C index a16a88a2fc..03e6fcf2ea 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBaseTemplates.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBaseTemplates.C @@ -33,14 +33,14 @@ License // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -template +template void Foam::mapDistributeBase::flipAndCombine ( const labelUList& map, const bool hasFlip, const UList& rhs, const CombineOp& cop, - const negateOp& negOp, + const NegateOp& negOp, List& lhs ) { @@ -78,13 +78,13 @@ void Foam::mapDistributeBase::flipAndCombine } -template +template T Foam::mapDistributeBase::accessAndFlip ( const UList& fld, const label index, const bool hasFlip, - const negateOp& negOp + const NegateOp& negOp ) { T t; @@ -117,7 +117,7 @@ T Foam::mapDistributeBase::accessAndFlip // Distribute list. -template +template void Foam::mapDistributeBase::distribute ( const Pstream::commsTypes commsType, @@ -128,7 +128,7 @@ void Foam::mapDistributeBase::distribute const labelListList& constructMap, const bool constructHasFlip, List& field, - const negateOp& negOp, + const NegateOp& negOp, const int tag, const label comm ) @@ -649,7 +649,7 @@ void Foam::mapDistributeBase::distribute // Distribute list. -template +template void Foam::mapDistributeBase::distribute ( const Pstream::commsTypes commsType, @@ -662,7 +662,7 @@ void Foam::mapDistributeBase::distribute List& field, const T& nullValue, const CombineOp& cop, - const negateOp& negOp, + const NegateOp& negOp, const int tag, const label comm ) @@ -1246,11 +1246,11 @@ const //- Distribute data using default commsType. -template +template void Foam::mapDistributeBase::distribute ( List& fld, - const negateOp& negOp, + const NegateOp& negOp, const int tag ) const { diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C index f3f7170e91..c22f8cd01b 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C @@ -127,11 +127,11 @@ void Foam::mapDistribute::applyInverseTransforms } -template +template void Foam::mapDistribute::distribute ( List& fld, - const negateOp& negOp, + const NegateOp& negOp, const bool dummyTransform, const int tag ) const diff --git a/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.H b/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.H index a3e8873e82..08323f6f3a 100644 --- a/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.H +++ b/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.H @@ -280,7 +280,7 @@ public: cop, nullValue, mapDistribute::transform(), - noOp() + identityOp() // No flipping ); } @@ -301,7 +301,7 @@ public: cop, nullValue, mapDistribute::transformPosition(), - noOp() + identityOp() // No flipping ); } @@ -324,7 +324,7 @@ public: cop, nullValue, mapDistribute::transform(), - noOp() + identityOp() // No flipping ); } @@ -347,7 +347,7 @@ public: cop, nullValue, mapDistribute::transformPosition(), - noOp() + identityOp() // No flipping ); } diff --git a/src/OpenFOAM/meshes/primitiveShapes/cut/cut.H b/src/OpenFOAM/meshes/primitiveShapes/cut/cut.H index 2b594ffdb1..dab54db9e8 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/cut/cut.H +++ b/src/OpenFOAM/meshes/primitiveShapes/cut/cut.H @@ -64,9 +64,8 @@ public: // Constructors - //- Construct null - uniformOp() - {} + //- Default construct + uniformOp() = default; //- Construct from data uniformOp(Type data) @@ -75,7 +74,7 @@ public: {} - // Member functions + // Member Functions //- Access the data Type data() const @@ -103,9 +102,8 @@ public: // Constructors - //- Construct null - noOp() - {} + //- Default construct + noOp() = default; //- Construct from base noOp(const uniformOp& op) @@ -114,7 +112,7 @@ public: {} - // Member operators + // Member Operators //- Operate on nothing result operator()() const @@ -149,9 +147,8 @@ public: // Constructors - //- Construct null - areaOp() - {} + //- Default construct + areaOp() = default; //- Construct from base areaOp(const uniformOp& op) @@ -160,7 +157,7 @@ public: {} - // Member operators + // Member Operators //- Operate on nothing result operator()() const @@ -194,9 +191,8 @@ public: // Constructors - //- Construct null - volumeOp() - {} + //- Default construct + volumeOp() = default; //- Construct from base volumeOp(const uniformOp& op) @@ -205,7 +201,7 @@ public: {} - // Member operators + // Member Operators //- Operate on nothing result operator()() const @@ -247,7 +243,7 @@ public: {} - // Member operators + // Member Operators //- Operate on nothing result operator()() const @@ -290,7 +286,7 @@ public: {} - // Member operators + // Member Operators //- Operate on nothing result operator()() const @@ -336,7 +332,7 @@ public: {} - // Member operators + // Member Operators //- Add together two lists result operator+(const result& x) const @@ -350,9 +346,8 @@ public: // Constructors - //- Construct null - listOp() - {} + //- Default construct + listOp() = default; //- Construct from base listOp(const uniformOp& op) @@ -361,7 +356,7 @@ public: {} - // Member operators + // Member Operators //- Operate on nothing result operator()() const @@ -413,7 +408,7 @@ public: {} - // Member operators + // Member Operators //- Operate on nothing result operator()() const diff --git a/src/OpenFOAM/primitives/Swap/Swap.H b/src/OpenFOAM/primitives/Swap/Swap.H index 61ebf0a2b9..b1817d8565 100644 --- a/src/OpenFOAM/primitives/Swap/Swap.H +++ b/src/OpenFOAM/primitives/Swap/Swap.H @@ -1,75 +1,9 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2017-2021 OpenCFD Ltd. -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. +// Compatibility include. For v2112 and earlier - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. +#ifndef FoamCompat_Swap_H +#define FoamCompat_Swap_H - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -InNamespace - Foam - -Description - 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 -#define Swap_H - -#include - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -//- Swap non-array types as per std::swap, but in Foam namespace. -// \sa http://www.cplusplus.com/reference/utility/swap/ -template -void Swap(T& a, T& b) -{ - std::swap(a, b); -} - - -//- Swap array types as per std::swap example, but in Foam namespace. -// \sa http://www.cplusplus.com/reference/utility/swap/ -template -void Swap(T (&a)[N], T (&b)[N]) -{ - for (size_t i = 0; i < N; ++i) - { - Foam::Swap(a[i], b[i]); - } -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#include "stdFoam.H" #endif diff --git a/src/OpenFOAM/primitives/Vector/floats/doubleVector.H b/src/OpenFOAM/primitives/Vector/floats/doubleVector.H index a5ab7a0b03..c758aa63c8 100644 --- a/src/OpenFOAM/primitives/Vector/floats/doubleVector.H +++ b/src/OpenFOAM/primitives/Vector/floats/doubleVector.H @@ -1,7 +1,7 @@ -// Compatibility include +// Compatibility include. For v2112 and earlier -#ifndef doubleVector_H -#define doubleVector_H +#ifndef FoamCompat_doubleVector_H +#define FoamCompat_doubleVector_H #include "vector.H" diff --git a/src/OpenFOAM/primitives/Vector/floats/floatVector.H b/src/OpenFOAM/primitives/Vector/floats/floatVector.H index edf164529a..8f61fbe3f9 100644 --- a/src/OpenFOAM/primitives/Vector/floats/floatVector.H +++ b/src/OpenFOAM/primitives/Vector/floats/floatVector.H @@ -1,7 +1,7 @@ -// Compatibility include +// Compatibility include. For v2112 and earlier -#ifndef floatVector_H -#define floatVector_H +#ifndef FoamCompat_floatVector_H +#define FoamCompat_floatVector_H #include "vector.H" diff --git a/src/OpenFOAM/primitives/ops/flipOp.C b/src/OpenFOAM/primitives/ops/flipOp.C index a9ea570596..ee15a5b84c 100644 --- a/src/OpenFOAM/primitives/ops/flipOp.C +++ b/src/OpenFOAM/primitives/ops/flipOp.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2015-2016 OpenFOAM Foundation + Copyright (C) 2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -29,49 +30,23 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template<> Foam::scalar Foam::flipOp::operator()(const scalar& v) const -{ - return -v; -} +#undef defineNegateOp +#define defineNegateOp(Type) \ + \ + template<> Type Foam::flipOp::operator()(const Type& val) const \ + { \ + return -val; \ + } -template<> Foam::vector Foam::flipOp::operator()(const vector& v) const -{ - return -v; -} +defineNegateOp(Foam::scalar); +defineNegateOp(Foam::vector); +defineNegateOp(Foam::sphericalTensor); +defineNegateOp(Foam::symmTensor); +defineNegateOp(Foam::tensor); +defineNegateOp(Foam::triad); - -template<> Foam::sphericalTensor Foam::flipOp::operator() -( - const sphericalTensor& v -) const -{ - return -v; -} - - -template<> Foam::symmTensor Foam::flipOp::operator() -( - const symmTensor& v -) const -{ - return -v; -} - - -template<> Foam::tensor Foam::flipOp::operator()(const tensor& v) const -{ - return -v; -} - - -template<> Foam::triad Foam::flipOp::operator() -( - const triad& v -) const -{ - return -v; -} +#undef defineNegateOp // ************************************************************************* // diff --git a/src/OpenFOAM/primitives/ops/flipOp.H b/src/OpenFOAM/primitives/ops/flipOp.H index b8500f6ed4..74be8a3fa9 100644 --- a/src/OpenFOAM/primitives/ops/flipOp.H +++ b/src/OpenFOAM/primitives/ops/flipOp.H @@ -37,8 +37,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef flipOp_H -#define flipOp_H +#ifndef Foam_flipOp_H +#define Foam_flipOp_H #include "fieldTypes.H" @@ -47,6 +47,21 @@ SourceFiles namespace Foam { +/*---------------------------------------------------------------------------*\ + Class noOp Declaration +\*---------------------------------------------------------------------------*/ + +//- Same as Foam::identityOp. Should \em never be specialized. +struct noOp +{ + template + const T& operator()(const T& val) const noexcept + { + return val; + } +}; + + /*---------------------------------------------------------------------------*\ Class flipOp Declaration \*---------------------------------------------------------------------------*/ @@ -61,21 +76,10 @@ struct flipOp }; -//- Pass through value. Should never be specialized. -struct noOp -{ - template - const T& operator()(const T& val) const noexcept - { - return val; - } -}; - - //- Invert boolean value struct flipBoolOp { - bool operator()(const bool& val) const noexcept + bool operator()(const bool val) const noexcept { return !val; } @@ -85,7 +89,7 @@ struct flipBoolOp //- Negate integer values struct flipLabelOp { - label operator()(const label& val) const + label operator()(const label val) const { return -val; } diff --git a/src/OpenFOAM/primitives/ops/ops.H b/src/OpenFOAM/primitives/ops/ops.H index 347209d4ce..7ed7dfc40f 100644 --- a/src/OpenFOAM/primitives/ops/ops.H +++ b/src/OpenFOAM/primitives/ops/ops.H @@ -34,8 +34,8 @@ Description \*---------------------------------------------------------------------------*/ -#ifndef ops_H -#define ops_H +#ifndef Foam_ops_H +#define Foam_ops_H // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/primitives/random/Random/RandomTemplates.C b/src/OpenFOAM/primitives/random/Random/RandomTemplates.C index 01027ad590..de1379170d 100644 --- a/src/OpenFOAM/primitives/random/Random/RandomTemplates.C +++ b/src/OpenFOAM/primitives/random/Random/RandomTemplates.C @@ -27,7 +27,6 @@ License \*---------------------------------------------------------------------------*/ #include "Random.H" -#include "Swap.H" #include "Pstream.H" // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/primitives/strings/lists/stringListOps.H b/src/OpenFOAM/primitives/strings/lists/stringListOps.H index 64c8864edc..18a769da2b 100644 --- a/src/OpenFOAM/primitives/strings/lists/stringListOps.H +++ b/src/OpenFOAM/primitives/strings/lists/stringListOps.H @@ -47,7 +47,7 @@ SourceFiles #include "labelList.H" #include "stringList.H" #include "wordRes.H" -#include "flipOp.H" +#include "ops.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -362,12 +362,12 @@ struct foundOp // The filter predicate is a combination of allow and deny lists // // \return List indices for matches -template +template labelList findMatching ( const StringListType& input, const wordRes::filter& pred, - AccessOp aop = noOp() + AccessOp aop = identityOp() ); //- Return ids for items with matching names. @@ -387,13 +387,13 @@ labelList findMatching // \endverbatim // // \return List indices for matches -template +template labelList findMatching ( const StringListType& input, const wordRes& allow, const wordRes& deny = wordRes::null(), - AccessOp aop = noOp() + AccessOp aop = identityOp() ); } // End namespace stringListOps diff --git a/src/OpenFOAM/primitives/strings/wordRes/wordReListMatcher.H b/src/OpenFOAM/primitives/strings/wordRes/wordReListMatcher.H index 6b1ec81af2..b659d1998e 100644 --- a/src/OpenFOAM/primitives/strings/wordRes/wordReListMatcher.H +++ b/src/OpenFOAM/primitives/strings/wordRes/wordReListMatcher.H @@ -1,25 +1,7 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2017 OpenCFD Ltd. -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM, distributed under GPL-3.0-or-later. +// Compatibility include. For v1612 and earlier. -Typedef - Foam::wordReListMatcher - -Description - Compatibility name. Superseded (MAY-2017) by Foam::wordRes - -\*---------------------------------------------------------------------------*/ - -#ifndef wordReListMatcher_H -#define wordReListMatcher_H +#ifndef FoamCompat_wordReListMatcher_H +#define FoamCompat_wordReListMatcher_H #include "wordRes.H" @@ -27,7 +9,11 @@ Description namespace Foam { - typedef wordRes wordReListMatcher; + +//- Superseded (MAY-2017) by Foam::wordRes +// \deprecated(2017-05) - use Foam::wordRes instead +typedef wordRes wordReListMatcher; + } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/primitives/tuples/PairI.H b/src/OpenFOAM/primitives/tuples/PairI.H index 7b72921b42..738fdbb4d9 100644 --- a/src/OpenFOAM/primitives/tuples/PairI.H +++ b/src/OpenFOAM/primitives/tuples/PairI.H @@ -25,8 +25,6 @@ License \*---------------------------------------------------------------------------*/ -#include "Swap.H" - // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // template diff --git a/src/OpenFOAM/primitives/zero/nil.H b/src/OpenFOAM/primitives/zero/nil.H index b331b89636..6caa04dbc8 100644 --- a/src/OpenFOAM/primitives/zero/nil.H +++ b/src/OpenFOAM/primitives/zero/nil.H @@ -1,22 +1,17 @@ -/*---------------------------------------------------------------------------*\ -Compatibility include +// Compatibility include. Superseded (MAY-2017) by Foam::zero::null -Typedef - Foam::nil - -Description - The older name for Foam::zero::null. - -\*---------------------------------------------------------------------------*/ - -#ifndef nil_H -#define nil_H +#ifndef FoamCompat_nil_H +#define FoamCompat_nil_H #include "zero.H" namespace Foam { - typedef zero::null nil; + +//- Superseded (MAY-2017) by Foam::zero::null +// \deprecated(2017-05) - use Foam::zero::null instead +typedef zero::null nil; + } #endif diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C index 434c1360e3..dbed336572 100644 --- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C +++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C @@ -2882,7 +2882,7 @@ void Foam::snappySnapDriver::determineBaffleFeatures listPlusEqOp(), List(), mapDistribute::transform(), - noOp() + identityOp() // No flipping ); } diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/nearestFaceAMI/nearestFaceAMI.C b/src/meshTools/AMIInterpolation/AMIInterpolation/nearestFaceAMI/nearestFaceAMI.C index 5708ef55db..9a9c52fd60 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/nearestFaceAMI/nearestFaceAMI.C +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/nearestFaceAMI/nearestFaceAMI.C @@ -193,7 +193,7 @@ Foam::autoPtr Foam::nearestFaceAMI::calcDistributed mapDistributeBase::distribute ( Pstream::commsTypes::nonBlocking, - List(0), + List(), src.size(), map.constructMap(), map.constructHasFlip(), @@ -202,7 +202,7 @@ Foam::autoPtr Foam::nearestFaceAMI::calcDistributed remoteInfo, nearestZero, nearestEqOp(), - noOp() // no flipping + identityOp() // No flipping ); diff --git a/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPointPatchField/cyclicACMIPointPatchField.C b/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPointPatchField/cyclicACMIPointPatchField.C index 7b2058969b..21d1215447 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPointPatchField/cyclicACMIPointPatchField.C +++ b/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPointPatchField/cyclicACMIPointPatchField.C @@ -26,7 +26,6 @@ License \*---------------------------------------------------------------------------*/ #include "cyclicACMIPointPatchField.H" -#include "Swap.H" #include "transformField.H" #include "pointFields.H" diff --git a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatchField/cyclicAMIPointPatchField.C b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatchField/cyclicAMIPointPatchField.C index 0b4de45961..51c43f4005 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatchField/cyclicAMIPointPatchField.C +++ b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatchField/cyclicAMIPointPatchField.C @@ -26,7 +26,6 @@ License \*---------------------------------------------------------------------------*/ #include "cyclicAMIPointPatchField.H" -#include "Swap.H" #include "transformField.H" #include "pointFields.H" diff --git a/src/overset/cellCellStencil/inverseDistance/inverseDistanceCellCellStencil.C b/src/overset/cellCellStencil/inverseDistance/inverseDistanceCellCellStencil.C index 5ec55fbabb..9d0c0fd557 100644 --- a/src/overset/cellCellStencil/inverseDistance/inverseDistanceCellCellStencil.C +++ b/src/overset/cellCellStencil/inverseDistance/inverseDistanceCellCellStencil.C @@ -1554,7 +1554,7 @@ void Foam::cellCellStencils::inverseDistance::createStencil samples, greatPoint, // nullValue minMagSqrEqOp(), - flipOp(), // negateOp + flipOp(), // NegateOp UPstream::msgType(), cellInterpolationMap().comm() ); diff --git a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C index 13294f8a76..6fd356690f 100644 --- a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C +++ b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C @@ -1385,7 +1385,7 @@ void Foam::distributedTriSurfaceMesh::surfaceSide mapDistributeBase::distribute ( Pstream::commsTypes::nonBlocking, - List(0), + List(), nearestInfo.size(), map.constructMap(), map.constructHasFlip(), @@ -1394,7 +1394,7 @@ void Foam::distributedTriSurfaceMesh::surfaceSide volType, zero, volumeCombineOp(), - noOp(), // no flipping + identityOp(), // No flipping UPstream::msgType(), map.comm() ); @@ -3197,7 +3197,7 @@ void Foam::distributedTriSurfaceMesh::findNearest mapDistributeBase::distribute ( Pstream::commsTypes::nonBlocking, - List(0), + List(), samples.size(), map1.constructMap(), map1.constructHasFlip(), @@ -3206,7 +3206,7 @@ void Foam::distributedTriSurfaceMesh::findNearest nearestInfo, nearestZero, nearestEqOp(), - noOp(), // no flipping + identityOp(), // No flipping UPstream::msgType(), map1.comm() ); @@ -3357,7 +3357,7 @@ void Foam::distributedTriSurfaceMesh::findNearest mapDistributeBase::distribute ( Pstream::commsTypes::nonBlocking, - List(0), + List(), samples.size(), map2.constructMap(), map2.constructHasFlip(), @@ -3366,7 +3366,7 @@ void Foam::distributedTriSurfaceMesh::findNearest localBest, nearestZero, nearestEqOp(), - noOp(), // no flipping + identityOp(), // No flipping UPstream::msgType(), map2.comm() ); @@ -4191,7 +4191,7 @@ void Foam::distributedTriSurfaceMesh::getVolumeType mapDistributeBase::distribute ( Pstream::commsTypes::nonBlocking, - List(0), + List(), samples.size(), map.constructMap(), map.constructHasFlip(), @@ -4200,7 +4200,7 @@ void Foam::distributedTriSurfaceMesh::getVolumeType volType, zero, volumeCombineOp(), - noOp(), // no flipping + identityOp(), // No flipping UPstream::msgType(), map.comm() );