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) explicit ispanstream(std::string_view s)
{ {
buffer_type(const_cast<char*>(s.data()), s.size()), buffer_type(const_cast<char*>(s.data()), s.size()),
stream_type(static_cast<buffer_type*>(this)) stream_type(static_cast<buffer_type*>(this));
} }
#endif #endif

View File

@ -83,9 +83,12 @@ public:
// Public Typedefs // Public Typedefs
//- Type of mesh on which this DimensionedField is instantiated //- The mesh type for the DimensionedField
typedef typename GeoMesh::Mesh Mesh; 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 //- Type of the field from which this DimensionedField is derived
typedef Field<Type> FieldType; typedef Field<Type> FieldType;

View File

@ -214,6 +214,11 @@ public:
//- Forced assignment to uniform value //- Forced assignment to uniform value
void operator==(const Type& val); 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>&);
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 // 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 } // End namespace Foam

View File

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

View File

@ -560,9 +560,14 @@ public:
// By generic these do nothing unless the patch actually has boundary // By generic these do nothing unless the patch actually has boundary
// values // values
virtual void operator==(const pointPatchField<Type>&){} virtual void operator==(const pointPatchField<Type>&) {}
virtual void operator==(const Field<Type>&){} virtual void operator==(const Field<Type>&) {}
virtual void operator==(const 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 // Ostream Operator

View File

@ -613,6 +613,11 @@ public:
virtual void operator==(const Field<Type>&); virtual void operator==(const Field<Type>&);
virtual void operator==(const 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 // Ostream Operator

View File

@ -516,6 +516,11 @@ public:
virtual void operator==(const Field<Type>&); virtual void operator==(const Field<Type>&);
virtual void operator==(const 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 // Ostream Operator

View File

@ -198,11 +198,18 @@ public:
virtual void write(Ostream&) const; virtual void write(Ostream&) const;
// Force an assignment irrespective of form of patch // Member Operators
virtual void operator==(const fvPatchField<Type>& ptf); // Force an assignment, applying scaling to refValue
virtual void operator==(const Field<Type>& tf);
virtual void operator==(const Type& t); 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 Field<Type>&);
virtual void operator==(const 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 // Ostream Operator

View File

@ -530,6 +530,11 @@ public:
virtual void operator==(const Field<Type>&); virtual void operator==(const Field<Type>&);
virtual void operator==(const 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 // Ostream Operator

View File

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

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-2022 OpenCFD Ltd. Copyright (C) 2015-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -147,6 +147,9 @@ processSameTypeValues
switch (operation_) switch (operation_)
{ {
case opNone: case opNone:
case typeScalar:
case typeWeighted:
case typeAbsolute:
{ {
break; break;
} }

View File

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

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-2021 OpenCFD Ltd. Copyright (C) 2015-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -91,6 +91,9 @@ Type Foam::functionObjects::fieldValues::volFieldValue::processValues
switch (operation_) switch (operation_)
{ {
case opNone: case opNone:
case typeScalar:
case typeWeighted:
case typeAbsolute:
{ {
break; break;
} }

View File

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

View File

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

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