ENH: identityOp as equivalent to std::identity (C++20)

- similar to how noOp was defined, but with perfect forwarding

STYLE: combine Swap into stdFoam

STYLE: capitalize FileOp, NegateOp template parameters
This commit is contained in:
Mark Olesen
2022-03-13 18:12:58 +01:00
parent ed73bcbc33
commit 327c43f3e8
39 changed files with 221 additions and 305 deletions

View File

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

View File

@ -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{}
)
);

View File

@ -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)
{

View File

@ -614,7 +614,7 @@ void testEdgeFlip2(const polyMesh& mesh, Random& rndGen)
edgePointCombineOp(),
PointPair(point::max, point::max),
edgePointTransformOp(),
noOp()
identityOp()
);
forAll(fld, edgeI)

View File

@ -51,7 +51,6 @@ Description
#include "wallPolyPatch.H"
#include "symmetryPolyPatch.H"
#include "oldCyclicPolyPatch.H"
#include "Swap.H"
#include "IFstream.H"
#include "readHexLabel.H"

View File

@ -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"

View File

@ -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"

View File

@ -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 <initializer_list>

View File

@ -346,7 +346,7 @@ void Foam::Field<Type>::map
}
else
{
distMap.distribute(newMapF, noOp());
distMap.distribute(newMapF, identityOp());
}
if (mapper.direct() && notNull(mapper.directAddressing()))
@ -417,7 +417,7 @@ void Foam::Field<Type>::autoMap
}
else
{
distMap.distribute(fCpy, noOp());
distMap.distribute(fCpy, identityOp());
}
if

View File

@ -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<class T, class FlipOp>
void ternarySelect
(
@ -172,7 +172,7 @@ void ternarySelect
const Field<T>& b
)
{
ternarySelect(result, cond, a, b, noOp());
ternarySelect(result, cond, a, b, identityOp{});
}
@ -186,7 +186,7 @@ void ternarySelect
const Field<T>& b
)
{
ternarySelect(result, cond, a, b, noOp());
ternarySelect(result, cond, a, b, identityOp{});
}

View File

@ -26,7 +26,6 @@ License
\*---------------------------------------------------------------------------*/
#include "cyclicPointPatchField.H"
#include "Swap.H"
#include "transformField.H"
#include "pointFields.H"

View File

@ -386,21 +386,21 @@ protected:
template<class Type>
Type scatterList(const UList<Type>&, const int, const label comm) const;
template<class Type, class fileOp>
template<class Type, class FileOp>
Type masterOp
(
const fileName& fName,
const fileOp& fop,
const FileOp& fop,
const int tag,
const label comm
) const;
template<class Type, class fileOp>
template<class Type, class FileOp>
Type masterOp
(
const fileName& src,
const fileName& dest,
const fileOp& fop,
const FileOp& fop,
const int tag,
const label comm
) const;

View File

@ -66,11 +66,11 @@ Type Foam::fileOperations::masterUncollatedFileOperation::scatterList
}
template<class Type, class fileOp>
template<class Type, class FileOp>
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<class Type, class fileOp>
template<class Type, class FileOp>
Type Foam::fileOperations::masterUncollatedFileOperation::masterOp
(
const fileName& src,
const fileName& dest,
const fileOp& fop,
const FileOp& fop,
const int tag,
const label comm
) const

View File

@ -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 <http://www.gnu.org/licenses/>.
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 <initializer_list>
#include <memory>
@ -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<class T>
constexpr T&& operator()(T&& val) const noexcept
{
return std::forward<T>(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<class T>
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<class T, size_t N>
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
{

View File

@ -26,7 +26,6 @@ License
\*---------------------------------------------------------------------------*/
#include "scalarMatrices.H"
#include "Swap.H"
#include "ListOps.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

View File

@ -487,11 +487,11 @@ public:
) const;
//- Distribute data using default commsType.
template<class T, class negateOp>
template<class T, class NegateOp>
void distribute
(
List<T>& fld,
const negateOp& negOp,
const NegateOp& negOp,
const bool dummyTransform = true,
const int tag = UPstream::msgType()
) const;

View File

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

View File

@ -172,24 +172,24 @@ protected:
labelList& compactStart
);
template<class T, class CombineOp, class negateOp>
template<class T, class CombineOp, class NegateOp>
static void flipAndCombine
(
const labelUList& map,
const bool hasFlip,
const UList<T>& rhs,
const CombineOp& cop,
const negateOp& negOp,
const NegateOp& negOp,
List<T>& lhs
);
template<class T, class negateOp>
template<class T, class NegateOp>
static T accessAndFlip
(
const UList<T>& 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<class T, class negateOp>
template<class T, class NegateOp>
static void distribute
(
const Pstream::commsTypes commsType,
@ -401,14 +401,14 @@ public:
const labelListList& constructMap,
const bool constructHasFlip,
List<T>&,
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<class T, class CombineOp, class negateOp>
template<class T, class CombineOp, class NegateOp>
static void distribute
(
const Pstream::commsTypes commsType,
@ -421,7 +421,7 @@ public:
List<T>&,
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<class T, class negateOp>
template<class T, class NegateOp>
void distribute
(
List<T>& fld,
const negateOp& negOp,
const NegateOp& negOp,
const int tag = UPstream::msgType()
) const;

View File

@ -33,14 +33,14 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class T, class CombineOp, class negateOp>
template<class T, class CombineOp, class NegateOp>
void Foam::mapDistributeBase::flipAndCombine
(
const labelUList& map,
const bool hasFlip,
const UList<T>& rhs,
const CombineOp& cop,
const negateOp& negOp,
const NegateOp& negOp,
List<T>& lhs
)
{
@ -78,13 +78,13 @@ void Foam::mapDistributeBase::flipAndCombine
}
template<class T, class negateOp>
template<class T, class NegateOp>
T Foam::mapDistributeBase::accessAndFlip
(
const UList<T>& 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<class T, class negateOp>
template<class T, class NegateOp>
void Foam::mapDistributeBase::distribute
(
const Pstream::commsTypes commsType,
@ -128,7 +128,7 @@ void Foam::mapDistributeBase::distribute
const labelListList& constructMap,
const bool constructHasFlip,
List<T>& field,
const negateOp& negOp,
const NegateOp& negOp,
const int tag,
const label comm
)
@ -649,7 +649,7 @@ void Foam::mapDistributeBase::distribute
// Distribute list.
template<class T, class CombineOp, class negateOp>
template<class T, class CombineOp, class NegateOp>
void Foam::mapDistributeBase::distribute
(
const Pstream::commsTypes commsType,
@ -662,7 +662,7 @@ void Foam::mapDistributeBase::distribute
List<T>& 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<class T, class negateOp>
template<class T, class NegateOp>
void Foam::mapDistributeBase::distribute
(
List<T>& fld,
const negateOp& negOp,
const NegateOp& negOp,
const int tag
) const
{

View File

@ -127,11 +127,11 @@ void Foam::mapDistribute::applyInverseTransforms
}
template<class T, class negateOp>
template<class T, class NegateOp>
void Foam::mapDistribute::distribute
(
List<T>& fld,
const negateOp& negOp,
const NegateOp& negOp,
const bool dummyTransform,
const int tag
) const

View File

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

View File

@ -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<zero::null>& 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<zero::null>& 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<zero::null>& 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<zero::null>& 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

View File

@ -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 <http://www.gnu.org/licenses/>.
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 <utility>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
//- Swap non-array types as per std::swap, but in Foam namespace.
// \sa http://www.cplusplus.com/reference/utility/swap/
template<class T>
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<class T, size_t N>
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

View File

@ -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"

View File

@ -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"

View File

@ -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
// ************************************************************************* //

View File

@ -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<class T>
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<class T>
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;
}

View File

@ -34,8 +34,8 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef ops_H
#define ops_H
#ifndef Foam_ops_H
#define Foam_ops_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -27,7 +27,6 @@ License
\*---------------------------------------------------------------------------*/
#include "Random.H"
#include "Swap.H"
#include "Pstream.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

View File

@ -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<class StringListType, class AccessOp = noOp>
template<class StringListType, class AccessOp = identityOp>
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<class StringListType, class AccessOp = noOp>
template<class StringListType, class AccessOp = identityOp>
labelList findMatching
(
const StringListType& input,
const wordRes& allow,
const wordRes& deny = wordRes::null(),
AccessOp aop = noOp()
AccessOp aop = identityOp()
);
} // End namespace stringListOps

View File

@ -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;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -25,8 +25,6 @@ License
\*---------------------------------------------------------------------------*/
#include "Swap.H"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
template<class T>

View File

@ -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

View File

@ -2882,7 +2882,7 @@ void Foam::snappySnapDriver::determineBaffleFeatures
listPlusEqOp<point>(),
List<point>(),
mapDistribute::transform(),
noOp()
identityOp() // No flipping
);
}

View File

@ -193,7 +193,7 @@ Foam::autoPtr<Foam::mapDistribute> Foam::nearestFaceAMI::calcDistributed
mapDistributeBase::distribute
(
Pstream::commsTypes::nonBlocking,
List<labelPair>(0),
List<labelPair>(),
src.size(),
map.constructMap(),
map.constructHasFlip(),
@ -202,7 +202,7 @@ Foam::autoPtr<Foam::mapDistribute> Foam::nearestFaceAMI::calcDistributed
remoteInfo,
nearestZero,
nearestEqOp(),
noOp() // no flipping
identityOp() // No flipping
);

View File

@ -26,7 +26,6 @@ License
\*---------------------------------------------------------------------------*/
#include "cyclicACMIPointPatchField.H"
#include "Swap.H"
#include "transformField.H"
#include "pointFields.H"

View File

@ -26,7 +26,6 @@ License
\*---------------------------------------------------------------------------*/
#include "cyclicAMIPointPatchField.H"
#include "Swap.H"
#include "transformField.H"
#include "pointFields.H"

View File

@ -1554,7 +1554,7 @@ void Foam::cellCellStencils::inverseDistance::createStencil
samples,
greatPoint, // nullValue
minMagSqrEqOp<point>(),
flipOp(), // negateOp
flipOp(), // NegateOp
UPstream::msgType(),
cellInterpolationMap().comm()
);

View File

@ -1385,7 +1385,7 @@ void Foam::distributedTriSurfaceMesh::surfaceSide
mapDistributeBase::distribute
(
Pstream::commsTypes::nonBlocking,
List<labelPair>(0),
List<labelPair>(),
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<labelPair>(0),
List<labelPair>(),
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<labelPair>(0),
List<labelPair>(),
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<labelPair>(0),
List<labelPair>(),
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()
);