COMP: avoid issues with new compilers and/or new C++ standards

- prevent automatic comparison rewriting (c++20)
- no bitwise operations between different enumerations
- template instantiation

ENH: add DimensionedField Internal typedef (simplifies handling)
This commit is contained in:
Mark Olesen
2023-10-19 10:38:11 +02:00
parent e4745d09ec
commit a7bb8edbad
18 changed files with 130 additions and 114 deletions

View File

@ -122,7 +122,7 @@ public:
explicit ispanstream(std::string_view s)
{
buffer_type(const_cast<char*>(s.data()), s.size()),
stream_type(static_cast<buffer_type*>(this))
stream_type(static_cast<buffer_type*>(this));
}
#endif

View File

@ -83,9 +83,12 @@ public:
// Public Typedefs
//- Type of mesh on which this DimensionedField is instantiated
//- The mesh type for the DimensionedField
typedef typename GeoMesh::Mesh Mesh;
//- The DimensionedField is usually synonymous with an internal field
typedef DimensionedField<Type, GeoMesh> Internal;
//- Type of the field from which this DimensionedField is derived
typedef Field<Type> FieldType;

View File

@ -214,6 +214,11 @@ public:
//- Forced assignment to uniform value
void operator==(const Type& val);
// Prevent automatic comparison rewriting (c++20)
bool operator!=(const GeometricBoundaryField&) = delete;
bool operator!=(const FieldField<PatchField, Type>&) = delete;
bool operator!=(const Type&) = delete;
};

View File

@ -758,6 +758,17 @@ public:
void operator*=(const dimensioned<scalar>&);
void operator/=(const dimensioned<scalar>&);
// Prevent automatic comparison rewriting (c++20)
bool operator!=
(
const GeometricField<Type, PatchField, GeoMesh>&
) = delete;
bool operator!=
(
const tmp<GeometricField<Type, PatchField, GeoMesh>>&
) = delete;
bool operator!=(const dimensioned<Type>&) = delete;
// Ostream Operators
@ -810,15 +821,6 @@ public:
};
template<class Type, template<class> class PatchField, class GeoMesh>
Ostream& operator<<
(
Ostream&,
const typename GeometricField<Type, PatchField, GeoMesh>::
Boundary&
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

View File

@ -227,34 +227,23 @@ public:
// Assignment operators
virtual void operator=
(
const valuePointPatchField<Type>&
);
virtual void operator=
(
const pointPatchField<Type>&
);
virtual void operator=(const Field<Type>&);
virtual void operator=(const Type&);
virtual void operator=(const valuePointPatchField<Type>&);
virtual void operator=(const pointPatchField<Type>&);
virtual void operator=(const Field<Type>&);
virtual void operator=(const Type&);
// Force an assignment irrespective of form of patch
virtual void operator==
(
const valuePointPatchField<Type>&
);
virtual void operator==(const valuePointPatchField<Type>&);
virtual void operator==(const pointPatchField<Type>&);
virtual void operator==(const Field<Type>&);
virtual void operator==(const Type&);
virtual void operator==
(
const pointPatchField<Type>&
);
virtual void operator==(const Field<Type>&);
virtual void operator==(const Type&);
// Prevent automatic comparison rewriting (c++20)
bool operator!=(const valuePointPatchField<Type>&) const = delete;
bool operator!=(const pointPatchField<Type>&) const = delete;
bool operator!=(const Field<Type>&) const = delete;
bool operator!=(const Type&) const = delete;
};

View File

@ -560,9 +560,14 @@ public:
// By generic these do nothing unless the patch actually has boundary
// values
virtual void operator==(const pointPatchField<Type>&){}
virtual void operator==(const Field<Type>&){}
virtual void operator==(const Type&){}
virtual void operator==(const pointPatchField<Type>&) {}
virtual void operator==(const Field<Type>&) {}
virtual void operator==(const Type&) {}
// Prevent automatic comparison rewriting (c++20)
bool operator!=(const pointPatchField<Type>&) const = delete;
bool operator!=(const Field<Type>&) const = delete;
bool operator!=(const Type&) const = delete;
// Ostream Operator

View File

@ -613,6 +613,11 @@ public:
virtual void operator==(const Field<Type>&);
virtual void operator==(const Type&);
// Prevent automatic comparison rewriting (c++20)
bool operator!=(const faPatchField<Type>&) const = delete;
bool operator!=(const Field<Type>&) const = delete;
bool operator!=(const Type&) const = delete;
// Ostream Operator

View File

@ -516,6 +516,11 @@ public:
virtual void operator==(const Field<Type>&);
virtual void operator==(const Type&);
// Prevent automatic comparison rewriting (c++20)
bool operator!=(const faePatchField<Type>&) const = delete;
bool operator!=(const Field<Type>&) const = delete;
bool operator!=(const Type&) const = delete;
// Ostream Operator

View File

@ -198,11 +198,18 @@ public:
virtual void write(Ostream&) const;
// Force an assignment irrespective of form of patch
// Member Operators
virtual void operator==(const fvPatchField<Type>& ptf);
virtual void operator==(const Field<Type>& tf);
virtual void operator==(const Type& t);
// Force an assignment, applying scaling to refValue
virtual void operator==(const fvPatchField<Type>&);
virtual void operator==(const Field<Type>&);
virtual void operator==(const Type&);
// Prevent automatic comparison rewriting (c++20)
bool operator!=(const fvPatchField<Type>&) const = delete;
bool operator!=(const Field<Type>&) const = delete;
bool operator!=(const Type&) const = delete;
};

View File

@ -734,6 +734,11 @@ public:
virtual void operator==(const Field<Type>&);
virtual void operator==(const Type&);
// Prevent automatic comparison rewriting (c++20)
bool operator!=(const fvPatchField<Type>&) const = delete;
bool operator!=(const Field<Type>&) const = delete;
bool operator!=(const Type&) const = delete;
// Ostream Operator

View File

@ -530,6 +530,11 @@ public:
virtual void operator==(const Field<Type>&);
virtual void operator==(const Type&);
// Prevent automatic comparison rewriting (c++20)
bool operator!=(const fvsPatchField<Type>&) const = delete;
bool operator!=(const Field<Type>&) const = delete;
bool operator!=(const Type&) const = delete;
// Ostream Operator

View File

@ -262,15 +262,6 @@ public:
//- Region type names
static const Enum<regionTypes> regionTypeNames_;
//- Bitmask values for operation variants
enum operationVariant
{
typeBase = 0, //!< Base operation
typeScalar = 0x100, //!< Operation returns a scalar
typeWeighted = 0x200, //!< Operation using weighting
typeAbsolute = 0x400, //!< Operation using mag (eg, for weighting)
};
//- Operation type enumeration
enum operationType
{
@ -291,10 +282,11 @@ public:
opAreaIntegrate, //!< Area integral
opCoV, //!< Coefficient of variation
// Scalar return values
// Operations returning scalar - bitmask value
typeScalar = 0x100,
//! Area average in normal direction (output is always scalar)
opAreaNormalAverage = typeScalar,
opAreaNormalAverage = (1 | typeScalar),
//! Area integral in normal direction (output is always scalar)
opAreaNormalIntegrate,
@ -303,6 +295,8 @@ public:
opUniformity,
// Weighted variants
// Operations using weighting - bitmask value
typeWeighted = 0x200,
//! Weighted sum
opWeightedSum = (opSum | typeWeighted),
@ -320,6 +314,8 @@ public:
opWeightedUniformity = (opUniformity | typeWeighted),
// Variants using absolute weighting
// Operation using mag (eg, for weighting) - bitmask value
typeAbsolute = 0x400,
//! Sum using abs weighting
opAbsWeightedSum = (opWeightedSum | typeAbsolute),

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2022 OpenCFD Ltd.
Copyright (C) 2015-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -147,6 +147,9 @@ processSameTypeValues
switch (operation_)
{
case opNone:
case typeScalar:
case typeWeighted:
case typeAbsolute:
{
break;
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd.
Copyright (C) 2016-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -148,15 +148,6 @@ public:
// Public Data Types
//- Bitmask values for operation variants
enum operationVariant
{
typeBase = 0, //!< Base operation
typeScalar = 0x100, //!< Operation returns a scalar
typeWeighted = 0x200, //!< Operation using weighting
typeAbsolute = 0x400, //!< Operation using mag (eg, for weighting)
};
//- Operation type enumeration
enum operationType
{
@ -172,7 +163,12 @@ public:
opVolIntegrate, //!< Volume integral
opCoV, //!< Coefficient of variation
// Operations returning scalar - bitmask value
typeScalar = 0x100,
// Weighted variants
// Operations using weighting - bitmask value
typeWeighted = 0x200,
//! Weighted sum
opWeightedSum = (opSum | typeWeighted),
@ -187,6 +183,8 @@ public:
opWeightedVolIntegrate = (opVolIntegrate | typeWeighted),
// Variants using absolute weighting
// Operation using mag (eg, for weighting) - bitmask value
typeAbsolute = 0x400,
};
//- Operation type names

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2021 OpenCFD Ltd.
Copyright (C) 2015-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -91,6 +91,9 @@ Type Foam::functionObjects::fieldValues::volFieldValue::processValues
switch (operation_)
{
case opNone:
case typeScalar:
case typeWeighted:
case typeAbsolute:
{
break;
}

View File

@ -131,7 +131,7 @@ class icoUncoupledKinematicCloud
icoUncoupledKinematicCloud(const icoUncoupledKinematicCloud&) = delete;
//- No copy assignment
void operator==(const icoUncoupledKinematicCloud&) = delete;
void operator=(const icoUncoupledKinematicCloud&) = delete;
public:

View File

@ -40,8 +40,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef MeshedSurfaceProxy_H
#define MeshedSurfaceProxy_H
#ifndef Foam_MeshedSurfaceProxy_H
#define Foam_MeshedSurfaceProxy_H
#include "pointField.H"
#include "surfZoneList.H"
@ -160,60 +160,42 @@ public:
// Member Functions
// Access
// Access
//- The surface size is the number of faces
label size() const
{
return faces_.size();
}
//- The surface size is the number of faces
label size() const noexcept { return faces_.size(); }
//- Return const access to the points
const pointField& points() const
{
return points_;
}
//- Return const access to the points
const pointField& points() const noexcept { return points_; }
//- Return const access to the faces
const UList<Face>& surfFaces() const
{
return faces_;
}
//- Return const access to the faces
const UList<Face>& surfFaces() const noexcept { return faces_; }
//- Const access to the surface zones.
// If zones are defined, they must be contiguous and cover the
// entire surface
const UList<surfZone>& surfZones() const
{
return zones_;
}
//- Const access to the surface zones.
// If zones are defined, they must be contiguous and cover the
// entire surface
const UList<surfZone>& surfZones() const noexcept { return zones_; }
//- Const access to the faceMap, zero-sized when unused
const labelUList& faceMap() const
{
return faceMap_;
}
//- Const access to the faceMap, zero-sized when unused
const labelUList& faceMap() const noexcept { return faceMap_; }
//- Const access to the faceIds, zero-sized when unused
const labelUList& faceIds() const
{
return faceIds_;
}
//- Const access to the faceIds, zero-sized when unused
const labelUList& faceIds() const noexcept { return faceIds_; }
//- Can/should use faceMap?
bool useFaceMap() const
{
return faceMap_.size() == faces_.size();
}
//- Can/should use faceMap?
bool useFaceMap() const noexcept
{
return faceMap_.size() == faces_.size();
}
//- Possible to use faceIds?
bool useFaceIds() const
{
return faceIds_.size() == faces_.size();
}
//- Possible to use faceIds?
bool useFaceIds() const noexcept
{
return faceIds_.size() == faces_.size();
}
//- Count number of triangles.
inline label nTriangles() const;
//- Count number of triangles.
inline label nTriangles() const;
// Write

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016 OpenCFD Ltd.
Copyright (C) 2016-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -27,6 +27,9 @@ License
\*---------------------------------------------------------------------------*/
#include "MeshedSurfaceProxy.H"
#include "face.H"
#include "triFace.H"
#include "labelledTri.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //