diff --git a/CHANGELOG.md b/CHANGELOG.md index 44201a024a7cdca2c51ee5d443352c6372ccc056..ed95b403b9e689ff941a5a959f0ceb4c3998d894 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,10 +41,11 @@ `CompositeQuadratureRule(QuadratureRule, Dune::refinement{Intervals|Levels}(int))` instead. -- Deprecated all structs from `Impl` dealing with the recursive topology construction: `TopologyFactory`, `TopologySingletonFactory`, +- Removed all structs from `Impl` dealing with the recursive topology construction: `TopologyFactory`, `TopologySingletonFactory`, `Point`, `Prism`, `Pyramid`, `IsSimplex`, `IsCube`, `SimplexTopology`, `CubeTopology`, `PyramidTopology`, `PrismTopology`, `IfTopology`. Deprecated the free function `Impl::isTopology`. Use the geometries provided by `GeometryType` and `GeometryTypes` instead. + To simplify the transition you can include the header "dune/geometry/deprecated_topology.hh". # Release 2.7 diff --git a/dune/geometry/CMakeLists.txt b/dune/geometry/CMakeLists.txt index fb46bed5e7b9ece7fce4866fbd4b734923498e3d..134cb9571857ac49589ee09f69240785c10bcdbf 100644 --- a/dune/geometry/CMakeLists.txt +++ b/dune/geometry/CMakeLists.txt @@ -19,6 +19,7 @@ install(FILES typeindex.hh virtualrefinement.hh virtualrefinement.cc + deprecated_topology.hh DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dune/geometry ) diff --git a/dune/geometry/deprecated_topology.hh b/dune/geometry/deprecated_topology.hh new file mode 100644 index 0000000000000000000000000000000000000000..9a0fbbcfd055b13eef684ba5e8002b75a00643a7 --- /dev/null +++ b/dune/geometry/deprecated_topology.hh @@ -0,0 +1,166 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: +#ifndef DUNE_DEPRECATED_TOPOLOGY_HH +#define DUNE_DEPRECATED_TOPOLOGY_HH + + namespace Impl + { + + // Basic Topology Types + // -------------------- + + struct [[deprecated("Use GeometryTypes::vertex instead.")]] Point + { + static const unsigned int dimension = 0; + static const unsigned int numCorners = 1; + + static const unsigned int id = 0; + + static std::string name () { return "p"; } + }; + + + template< class BaseTopology > + struct [[deprecated("Use GeometryTypes::prismaticExtension(GeometryType gt) instead.")]] Prism + { + static const unsigned int dimension = BaseTopology::dimension + 1; + static const unsigned int numCorners = 2 * BaseTopology::numCorners; + + static const unsigned int id = BaseTopology::id | ((unsigned int)prismConstruction << (dimension-1)); + + static std::string name () { return BaseTopology::name() + "l"; } + }; + + + template< class BaseTopology > + struct [[deprecated("Use GeometryTypes::conicalExtension(GeometryType gt) instead.")]] Pyramid + { + static const unsigned int dimension = BaseTopology::dimension + 1; + static const unsigned int numCorners = BaseTopology::numCorners + 1; + + static const unsigned int id = BaseTopology::id | ((unsigned int)pyramidConstruction << (dimension-1)); + + static std::string name () { return BaseTopology::name() + "o"; } + }; + + + + // Properties of Topologies + // ------------------------ + + template< class Topology > + struct [[deprecated("Use GeometryType::isSimplex() instead.")]] IsSimplex + : public std::integral_constant< bool, (Topology::id >> 1) == 0 > + {}; + + template< class Topology > + struct [[deprecated("Use GeometryType::isCube() instead.")]] IsCube + : public std::integral_constant< bool, (Topology::id | 1) == (1 << Topology::dimension) - 1 > + {}; + + /** \brief check whether a specific topology construction was used to create a + * given codimension + * + * \param[in] construction construction to check for + * \param[in] topologyId id of the topology + * \param[in] dim dimension of the topology + * \param[in] codim codimension for which the information is desired + * (defaults to 0) + * + * \returns true, if construction was used to generate the codimension the + * topology. + */ + [[deprecated("Use GeometryType::isPrismatic() or GeometryType::isConical() instead.")]] + inline static bool isTopology ( TopologyConstruction construction, unsigned int topologyId, int dim, int codim = 0 ) noexcept + { + assert( (dim > 0) && (topologyId < numTopologies( dim )) ); + assert( (0 <= codim) && (codim <= dim) ); + return (codim >= (dim-1)) || (((topologyId >> (dim-codim-1)) & 1) == (unsigned int)construction); + } + + + // SimplexTopology + // --------------- + + template< unsigned int dim > + struct [[deprecated("Use GeometryTypes::simplex(dim) instead.")]] SimplexTopology + { + typedef Pyramid< typename SimplexTopology< dim-1 >::type > type; + }; + + template<> + struct [[deprecated("Use GeometryTypes::simplex(dim) instead.")]] SimplexTopology< 0 > + { + typedef Point type; + }; + + + + // CubeTopology + // ------------ + + template< unsigned int dim > + struct [[deprecated("Use GeometryTypes::cube(dim) instead.")]] CubeTopology + { + typedef Prism< typename CubeTopology< dim-1 >::type > type; + }; + + template<> + struct [[deprecated("Use GeometryTypes::simplex(dim) instead.")]] CubeTopology< 0 > + { + typedef Point type; + }; + + + + // PyramidTopology + // --------------- + + template< unsigned int dim > + struct [[deprecated]] PyramidTopology + { + typedef Pyramid< typename CubeTopology< dim-1 >::type > type; + }; + + + + // PrismTopology + // ------------- + + template< unsigned int dim > + struct [[deprecated]] PrismTopology + { + typedef Prism< typename SimplexTopology< dim-1 >::type > type; + }; + + + + + // IfTopology + // ---------- + + template< template< class > class Operation, int dim, class Topology = Point > + struct [[deprecated("Use IfGeometryType instead.")]] IfTopology + { + template< class... Args > + static auto apply ( unsigned int topologyId, Args &&... args ) + { + if( topologyId & 1 ) + return IfTopology< Operation, dim-1, Prism< Topology > >::apply( topologyId >> 1, std::forward< Args >( args )... ); + else + return IfTopology< Operation, dim-1, Pyramid< Topology > >::apply( topologyId >> 1, std::forward< Args >( args )... ); + } + }; + + template< template< class > class Operation, class Topology > + struct [[deprecated("Use IfGeometryType instead.")]] IfTopology< Operation, 0, Topology > + { + template< class... Args > + static auto apply ([[maybe_unused]] unsigned int topologyId, Args &&... args) + { + return Operation< Topology >::apply( std::forward< Args >( args )... ); + } + }; + + } // namespace Impl +#endif diff --git a/dune/geometry/topologyfactory.hh b/dune/geometry/topologyfactory.hh index 1b68cd06eb710bdbdacec4539c6e8fd4b6d8a3b9..8d5f83dae2f605c8438c73e01f6688d89863eb39 100644 --- a/dune/geometry/topologyfactory.hh +++ b/dune/geometry/topologyfactory.hh @@ -36,7 +36,7 @@ namespace Dune * method. **/ template <class Traits> - struct [[deprecated("Use the new version from dune/localfunctions/utility/topologyfactory.hh instead.")]] TopologyFactory + struct TopologyFactory { // extract types from Traits class static const unsigned int dimension = Traits::dimension; @@ -51,6 +51,12 @@ namespace Dune return create<decltype(id)::value>(key); }); } + //! statically create objects + template< GeometryType::Id geometryId > + static Object *create ( const Key &key ) + { + return Factory::template createObject< geometryId >( key ); + } //! statically create objects template< class Topology > @@ -70,7 +76,7 @@ namespace Dune * but with empty release method an internal storage. **/ template <class Factory> - struct [[deprecated("Use the new version from dune/localfunctions/utility/topologyfactory.hh instead.")]] TopologySingletonFactory + struct TopologySingletonFactory { static const unsigned int dimension = Factory::dimension; typedef typename Factory::Key Key; @@ -82,6 +88,13 @@ namespace Dune assert( gt.id() < numTopologies ); return instance().getObject( gt, key ); } + //! @copydoc TopologyFactory::create(const Key &key) + template< GeometryType::Id geometryId > + static auto create ( const Key &key ) + -> std::enable_if_t< static_cast<GeometryType>(geometryId).dim() == dimension, Object * > + { + return instance().template getObject< geometryId >( key ); + } //! @copydoc TopologyFactory::create(const Key &key) template< class Topology > @@ -126,6 +139,16 @@ namespace Dune return object.get(); } + template< GeometryType::Id geometryId > + Object *getObject ( const Key &key ) + { + static constexpr GeometryType geometry = geometryId; + auto &object = find( geometry.id(), key ); + if( !object ) + object.reset( Factory::template create< geometry >( key ) ); + return object.get(); + } + template< class Topology > Object *getObject ( const Key &key ) { diff --git a/dune/geometry/type.hh b/dune/geometry/type.hh index 2a596908bd188bc3b85a24ab91c9feac5d936f5b..51375c17c0b0d09fb57c485c8d322562965d6e11 100644 --- a/dune/geometry/type.hh +++ b/dune/geometry/type.hh @@ -25,62 +25,6 @@ namespace Dune enum TopologyConstruction { pyramidConstruction = 0, prismConstruction = 1 }; - - - // Basic Topology Types - // -------------------- - - struct [[deprecated("Use GeometryTypes::vertex instead.")]] Point - { - static const unsigned int dimension = 0; - static const unsigned int numCorners = 1; - - static const unsigned int id = 0; - - static std::string name () { return "p"; } - }; - - - template< class BaseTopology > - struct [[deprecated("Use GeometryTypes::prismaticExtension(GeometryType gt) instead.")]] Prism - { - static const unsigned int dimension = BaseTopology::dimension + 1; - static const unsigned int numCorners = 2 * BaseTopology::numCorners; - - static const unsigned int id = BaseTopology::id | ((unsigned int)prismConstruction << (dimension-1)); - - static std::string name () { return BaseTopology::name() + "l"; } - }; - - - template< class BaseTopology > - struct [[deprecated("Use GeometryTypes::conicalExtension(GeometryType gt) instead.")]] Pyramid - { - static const unsigned int dimension = BaseTopology::dimension + 1; - static const unsigned int numCorners = BaseTopology::numCorners + 1; - - static const unsigned int id = BaseTopology::id | ((unsigned int)pyramidConstruction << (dimension-1)); - - static std::string name () { return BaseTopology::name() + "o"; } - }; - - - - // Properties of Topologies - // ------------------------ - - template< class Topology > - struct [[deprecated("Use GeometryType::isSimplex() instead.")]] IsSimplex - : public std::integral_constant< bool, (Topology::id >> 1) == 0 > - {}; - - template< class Topology > - struct [[deprecated("Use GeometryType::isCube() instead.")]] IsCube - : public std::integral_constant< bool, (Topology::id | 1) == (1 << Topology::dimension) - 1 > - {}; - - - // Dynamic Topology Properties // --------------------------- @@ -133,26 +77,6 @@ namespace Dune return (( (topologyId | 1) & (1u << (dim-codim-1))) != 0); } - /** \brief check whether a specific topology construction was used to create a - * given codimension - * - * \param[in] construction construction to check for - * \param[in] topologyId id of the topology - * \param[in] dim dimension of the topology - * \param[in] codim codimension for which the information is desired - * (defaults to 0) - * - * \returns true, if construction was used to generate the codimension the - * topology. - */ - [[deprecated("Use GeometryType::isPrismatic() or GeometryType::isConical() instead.")]] - inline static bool isTopology ( TopologyConstruction construction, unsigned int topologyId, int dim, int codim = 0 ) noexcept - { - assert( (dim > 0) && (topologyId < numTopologies( dim )) ); - assert( (0 <= codim) && (codim <= dim) ); - return (codim >= (dim-1)) || (((topologyId >> (dim-codim-1)) & 1) == (unsigned int)construction); - } - /** \brief obtain the base topology of a given codimension * * \param[in] topologyId id of the topology @@ -167,94 +91,18 @@ namespace Dune return topologyId & ((1u << (dim-codim)) - 1); } - - - // SimplexTopology - // --------------- - - template< unsigned int dim > - struct [[deprecated("Use GeometryTypes::simplex(dim) instead.")]] SimplexTopology - { - typedef Pyramid< typename SimplexTopology< dim-1 >::type > type; - }; - - template<> - struct [[deprecated("Use GeometryTypes::simplex(dim) instead.")]] SimplexTopology< 0 > - { - typedef Point type; - }; - - - - // CubeTopology - // ------------ - - template< unsigned int dim > - struct [[deprecated("Use GeometryTypes::cube(dim) instead.")]] CubeTopology - { - typedef Prism< typename CubeTopology< dim-1 >::type > type; - }; - - template<> - struct [[deprecated("Use GeometryTypes::simplex(dim) instead.")]] CubeTopology< 0 > - { - typedef Point type; - }; - - - - // PyramidTopology - // --------------- - - template< unsigned int dim > - struct [[deprecated]] PyramidTopology - { - typedef Pyramid< typename CubeTopology< dim-1 >::type > type; - }; - - - - // PrismTopology - // ------------- - - template< unsigned int dim > - struct [[deprecated]] PrismTopology - { - typedef Prism< typename SimplexTopology< dim-1 >::type > type; - }; - - - - - // IfTopology - // ---------- - - template< template< class > class Operation, int dim, class Topology = Point > - struct [[deprecated("Use IfGeometryType instead.")]] IfTopology - { - template< class... Args > - static auto apply ( unsigned int topologyId, Args &&... args ) - { - if( topologyId & 1 ) - return IfTopology< Operation, dim-1, Prism< Topology > >::apply( topologyId >> 1, std::forward< Args >( args )... ); - else - return IfTopology< Operation, dim-1, Pyramid< Topology > >::apply( topologyId >> 1, std::forward< Args >( args )... ); - } - }; - - template< template< class > class Operation, class Topology > - struct [[deprecated("Use IfGeometryType instead.")]] IfTopology< Operation, 0, Topology > - { - template< class... Args > - static auto apply ([[maybe_unused]] unsigned int topologyId, Args &&... args) - { - return Operation< Topology >::apply( std::forward< Args >( args )... ); - } - }; - } // namespace Impl - +// the Topology classes are deprecated and will be removed for the 2.8. +// Temporarily a header 'deprecated_topology.hh' is provided which will be removed after the 2.9 release. +#if __GNUC__ >= 7 +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif +#include <dune/geometry/deprecated_topology.hh> +#if __GNUC__ >= 7 +# pragma GCC diagnostic pop +#endif // GeometryType // -------------