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) 2017-2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2012-2015 OpenFOAM Foundation

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-2015 OpenFOAM Foundation
@ -36,6 +36,7 @@ SourceFiles
#ifndef indexedCellEnum_H
#define indexedCellEnum_H
#include "contiguous.H"
#include "Enum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -63,11 +64,10 @@ public:
};
template<>
inline bool contiguous<indexedCellEnum>()
{
return true;
}
// * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
//- Contiguous data for indexedCellEnum
template<> struct is_contiguous<indexedCellEnum> : 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
@ -323,32 +323,26 @@ public:
} // End namespace CGAL
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
#ifdef CGAL_INEXACT
namespace Foam
{
// For inexact representations where the storage type is a double, the data
// is contiguous. This may not be true for exact number types.
template<>
inline bool contiguous
struct is_contiguous
<
CGAL::indexedVertex
<
K,
CGAL::Triangulation_vertex_base_3<K>
>
>()
{
return true;
}
CGAL::indexedVertex<K, CGAL::Triangulation_vertex_base_3<K>>
> : std::true_type {};
template<>
inline bool contiguous<CGAL::Triangulation_vertex_base_3<K>::Point>()
{
return true;
}
struct is_contiguous
<
CGAL::Triangulation_vertex_base_3<K>::Point
> : std::true_type {};
} // End namespace Foam
#endif

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
@ -84,15 +84,17 @@ public:
};
// * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
//- Contiguous data for indexedVertexEnum
template<> struct is_contiguous<indexedVertexEnum> : std::true_type {};
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
Istream& operator>>(Istream&, indexedVertexEnum::vertexType&);
Ostream& operator<<(Ostream&, const indexedVertexEnum::vertexType&);
template<>
inline bool contiguous<indexedVertexEnum>()
{
return true;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //