ENH: additional contiguous traits (#1378)

- change contiguous from a series of global functions to separate
  templated traits classes:

    - is_contiguous
    - is_contiguous_label
    - is_contiguous_scalar

  The static constexpr 'value' and a constexpr conversion operator
  allow use in template expressions.  The change also makes it much
  easier to define general traits and to inherit from them.

  The is_contiguous_label and is_contiguous_scalar are special traits
  for handling data of homogeneous components of the respective types.
This commit is contained in:
Mark Olesen
2019-07-29 11:36:30 +02:00
committed by Andrew Heather
parent 3c07a1bb6f
commit 1d79c0452c
120 changed files with 950 additions and 900 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
@ -49,14 +49,9 @@ SourceFiles
namespace Foam
{
// Forward declaration of classes
// Forward Declarations
class polyPatch;
class polyMesh;
// Forward declaration of friend functions and operators
class patchEdgeFaceInfo;
Istream& operator>>(Istream&, patchEdgeFaceInfo&);
@ -201,12 +196,13 @@ public:
};
//- Data associated with patchEdgeFaceInfo type are contiguous
template<>
inline bool contiguous<patchEdgeFaceInfo>()
{
return true;
}
// * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
//- Contiguous data for patchEdgeFaceInfo
template<> struct is_contiguous<patchEdgeFaceInfo> : std::true_type {};
//- Contiguous scalar data for patchEdgeFaceInfo
template<> struct is_contiguous_scalar<patchEdgeFaceInfo> : std::true_type {};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2012-2016 OpenFOAM Foundation
@ -51,13 +51,9 @@ SourceFiles
namespace Foam
{
// Forward declaration of classes
// Forward Declarations
class polyPatch;
class polyMesh;
// Forward declaration of friend functions and operators
class patchEdgeFaceRegion;
Istream& operator>>(Istream&, patchEdgeFaceRegion&);
@ -181,12 +177,13 @@ public:
};
//- Data associated with patchEdgeFaceRegion type are contiguous
template<>
inline bool contiguous<patchEdgeFaceRegion>()
{
return true;
}
// * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
//- Contiguous data for patchEdgeFaceRegion
template<> struct is_contiguous<patchEdgeFaceRegion> : std::true_type {};
//- Contiguous label data for patchEdgeFaceRegion
template<> struct is_contiguous_label<patchEdgeFaceRegion> : std::true_type {};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2015 OpenFOAM Foundation
@ -46,13 +46,11 @@ SourceFiles
namespace Foam
{
// Forward declaration of classes
// Forward Declarations
class Istream;
class Ostream;
template<class DataType>
class PointData;
template<class DataType> class PointData;
// Forward declaration of friend functions and operators
template<class DataType>
Ostream& operator<<(Ostream&, const PointData<DataType>&);
template<class DataType>
@ -67,8 +65,6 @@ class PointData
:
public pointEdgePoint
{
private:
// Private data
//- Additional transported data
@ -178,21 +174,20 @@ public:
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Data associated with PointData types is contiguous
// * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
template<>
inline bool contiguous<PointData<scalar>>()
{
return true;
}
//- Data are contiguous if data type is contiguous
template<class DataType>
struct is_contiguous<PointData<DataType>> : is_contiguous<DataType> {};
//- Contiguous scalar only when data type is also scalar
template<class DataType>
struct is_contiguous_scalar<PointData<DataType>>
:
is_contiguous_scalar<DataType>
{};
template<>
inline bool contiguous<PointData<vector>>()
{
return true;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
@ -51,13 +51,9 @@ SourceFiles
namespace Foam
{
// Forward declaration of classes
// Forward Declarations
class polyPatch;
class polyMesh;
// Forward declaration of friend functions and operators
class pointEdgePoint;
Istream& operator>>(Istream&, pointEdgePoint&);
@ -237,12 +233,13 @@ public:
};
//- Data associated with pointEdgePoint type are contiguous
template<>
inline bool contiguous<pointEdgePoint>()
{
return true;
}
// * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
//- Contiguous data for pointEdgePoint
template<> struct is_contiguous<pointEdgePoint> : std::true_type {};
//- Contiguous scalar data for pointEdgePoint
template<> struct is_contiguous_scalar<pointEdgePoint> : std::true_type {};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //