From 5ebfbd6da0bc37867cd51ec782acefb7af947731 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Klinkovsk=C3=BD?= <klinkjak@fjfi.cvut.cz> Date: Wed, 19 Oct 2016 22:05:41 +0200 Subject: [PATCH] Rewritten mesh traits using type aliases instead of typedefs --- .../MeshDetails/traits/MeshEntityTraits.h | 56 +++++++++--------- .../MeshDetails/traits/MeshSubentityTraits.h | 58 +++++++++---------- .../traits/MeshSuperentityTraits.h | 36 +++++------- .../Meshes/MeshDetails/traits/MeshTraits.h | 58 +++++++++---------- 4 files changed, 100 insertions(+), 108 deletions(-) diff --git a/src/TNL/Meshes/MeshDetails/traits/MeshEntityTraits.h b/src/TNL/Meshes/MeshDetails/traits/MeshEntityTraits.h index c8c8be6b9a..50c8b853d4 100644 --- a/src/TNL/Meshes/MeshDetails/traits/MeshEntityTraits.h +++ b/src/TNL/Meshes/MeshDetails/traits/MeshEntityTraits.h @@ -43,11 +43,11 @@ class MeshEntityOrientationNeeded typedef typename MeshTraits< MeshConfig >::template EntityTraits< SuperDimensionTag::value >::EntityTopology SuperentityTopology; - static const bool previousSuperDimensionValue = MeshEntityOrientationNeeded< MeshConfig, DimensionTag, typename SuperDimensionTag::Decrement >::value; - static const bool thisSuperDimensionValue = MeshTraits< MeshConfig >::template SubentityTraits< SuperentityTopology, DimensionTag::value >::orientationEnabled; + static constexpr bool previousSuperDimensionsValue = MeshEntityOrientationNeeded< MeshConfig, DimensionsTag, typename SuperDimensionsTag::Decrement >::value; + static constexpr bool thisSuperDimensionsValue = MeshTraits< MeshConfig >::template SubentityTraits< SuperentityTopology, DimensionsTag::value >::orientationEnabled; - public: - static const bool value = ( previousSuperDimensionValue || thisSuperDimensionValue ); +public: + static constexpr bool value = ( previousSuperDimensionsValue || thisSuperDimensionsValue ); }; template< typename MeshConfig, typename DimensionTag > @@ -55,8 +55,8 @@ class MeshEntityOrientationNeeded< MeshConfig, DimensionTag, DimensionTag > { static_assert( 0 <= DimensionTag::value && DimensionTag::value <= MeshConfig::CellTopology::dimensions, "invalid dimensions" ); - public: - static const bool value = false; +public: + static constexpr bool value = false; }; @@ -64,29 +64,27 @@ template< typename MeshConfig, int Dimension > class MeshEntityTraits { - public: - - static const bool storageEnabled = MeshConfig::entityStorage( Dimension ); - static const bool orientationNeeded = MeshEntityOrientationNeeded< MeshConfig, MeshDimensionTag< Dimension > >::value; - - typedef typename MeshConfig::GlobalIndexType GlobalIndexType; - typedef typename MeshConfig::LocalIndexType LocalIndexType; - typedef typename MeshEntityTopology< MeshConfig, Dimension >::Topology EntityTopology; - - typedef MeshEntity< MeshConfig, EntityTopology > EntityType; - typedef MeshEntitySeed< MeshConfig, EntityTopology > SeedType; - typedef MeshEntityReferenceOrientation< MeshConfig, EntityTopology > ReferenceOrientationType; - typedef MeshEntitySeedKey< MeshConfig, EntityTopology > Key; - - - typedef Containers::Array< EntityType, Devices::Host, GlobalIndexType > StorageArrayType; - typedef Containers::SharedArray< EntityType, Devices::Host, GlobalIndexType > AccessArrayType; - typedef Containers::IndexedSet< EntityType, GlobalIndexType, Key > UniqueContainerType; - typedef Containers::IndexedSet< SeedType, GlobalIndexType, Key > SeedIndexedSetType; - typedef Containers::Array< SeedType, Devices::Host, GlobalIndexType > SeedArrayType; - typedef Containers::Array< ReferenceOrientationType, Devices::Host, GlobalIndexType > ReferenceOrientationArrayType; - - typedef Containers::tnlConstSharedArray< EntityType, Devices::Host, GlobalIndexType > SharedArrayType; +public: + static constexpr bool storageEnabled = MeshConfig::entityStorage( Dimensions ); + static constexpr bool orientationNeeded = MeshEntityOrientationNeeded< MeshConfig, MeshDimensionsTag< Dimensions > >::value; + + using GlobalIndexType = typename MeshConfig::GlobalIndexType; + using LocalIndexType = typename MeshConfig::LocalIndexType; + using EntityTopology = typename MeshEntityTopology< MeshConfig, Dimensions >::Topology; + + using EntityType = MeshEntity< MeshConfig, EntityTopology >; + using SeedType = MeshEntitySeed< MeshConfig, EntityTopology >; + using ReferenceOrientationType = MeshEntityReferenceOrientation< MeshConfig, EntityTopology >; + using Key = MeshEntitySeedKey< MeshConfig, EntityTopology >; + + using StorageArrayType = Containers::Array< EntityType, Devices::Host, GlobalIndexType >; + using AccessArrayType = Containers::SharedArray< EntityType, Devices::Host, GlobalIndexType >; + using UniqueContainerType = Containers::IndexedSet< EntityType, GlobalIndexType, Key >; + using SeedIndexedSetType = Containers::IndexedSet< SeedType, GlobalIndexType, Key >; + using SeedArrayType = Containers::Array< SeedType, Devices::Host, GlobalIndexType >; + using ReferenceOrientationArrayType = Containers::Array< ReferenceOrientationType, Devices::Host, GlobalIndexType >; + + using SharedArrayType = Containers::tnlConstSharedArray< EntityType, Devices::Host, GlobalIndexType >; }; } // namespace Meshes diff --git a/src/TNL/Meshes/MeshDetails/traits/MeshSubentityTraits.h b/src/TNL/Meshes/MeshDetails/traits/MeshSubentityTraits.h index cbdd144932..d18704ec27 100644 --- a/src/TNL/Meshes/MeshDetails/traits/MeshSubentityTraits.h +++ b/src/TNL/Meshes/MeshDetails/traits/MeshSubentityTraits.h @@ -32,42 +32,40 @@ template< typename MeshConfig, int Dimension > class MeshSubentityTraits { - public: - static const bool storageEnabled = MeshConfig::subentityStorage( EntityTopology(), Dimension ); - static const bool orientationEnabled = MeshConfig::subentityOrientationStorage( EntityTopology(), Dimension ); +public: + static constexpr bool storageEnabled = MeshConfig::subentityStorage( EntityTopology(), Dimensions ); + static constexpr bool orientationEnabled = MeshConfig::subentityOrientationStorage( EntityTopology(), Dimensions ); - typedef typename MeshConfig::GlobalIndexType GlobalIndexType; - typedef typename MeshConfig::LocalIndexType LocalIndexType; - typedef MeshSubtopology< EntityTopology, Dimension > Subtopology; - typedef typename Subtopology::Topology SubentityTopology; - typedef MeshEntity< MeshConfig, SubentityTopology > SubentityType; - typedef MeshEntitySeed< MeshConfig, SubentityTopology > Seed; - typedef MeshEntityOrientation< MeshConfig, SubentityTopology > Orientation; + using GlobalIndexType = typename MeshConfig::GlobalIndexType; + using LocalIndexType = typename MeshConfig::LocalIndexType; + using Subtopology = MeshSubtopology< EntityTopology, Dimensions >; + using SubentityTopology = typename Subtopology::Topology; + using SubentityType = MeshEntity< MeshConfig, SubentityTopology >; + using Seed = MeshEntitySeed< MeshConfig, SubentityTopology >; + using Orientation = MeshEntityOrientation< MeshConfig, SubentityTopology >; - static const int count = Subtopology::count; + static constexpr int count = Subtopology::count; - typedef Containers::StaticArray< count, GlobalIndexType > StorageArrayType; - typedef Containers::SharedArray< GlobalIndexType, - Devices::Host, - LocalIndexType > AccessArrayType; - typedef Containers::StaticArray< count, GlobalIndexType > IdArrayType; - typedef Containers::StaticArray< count, SubentityType > SubentityContainerType; - typedef Containers::StaticArray< count, Seed > SeedArrayType; - typedef Containers::StaticArray< count, Orientation > OrientationArrayType; - typedef Containers::StaticArray< count, LocalIndexType > IdPermutationArrayType; + using StorageArrayType = Containers::StaticArray< count, GlobalIndexType >; + using AccessArrayType = Containers::SharedArray< GlobalIndexType, Devices::Host, LocalIndexType >; + using IdArrayType = Containers::StaticArray< count, GlobalIndexType >; + using SubentityContainerType = Containers::StaticArray< count, SubentityType >; + using SeedArrayType = Containers::StaticArray< count, Seed >; + using OrientationArrayType = Containers::StaticArray< count, Orientation >; + using IdPermutationArrayType = Containers::StaticArray< count, LocalIndexType >; - template< LocalIndexType subentityIndex, - LocalIndexType subentityPointIndex > - struct Point - { - enum { index = tnlSubentityPoint< EntityTopology, - SubentityTopology, - subentityIndex, - subentityPointIndex>::index }; - }; + template< LocalIndexType subentityIndex, + LocalIndexType subentityVertexIndex > + struct Vertex + { + enum { index = tnlSubentityVertex< EntityTopology, + SubentityTopology, + subentityIndex, + subentityVertexIndex>::index }; + }; - static_assert( EntityTopology::dimensions > Dimension, "You try to create subentities traits where subentity dimension are not smaller than the entity dimension." ); + static_assert( EntityTopology::dimensions > Dimensions, "You try to create subentities traits where subentity dimensions are not smaller than the entity dimensions." ); }; } // namespace Meshes diff --git a/src/TNL/Meshes/MeshDetails/traits/MeshSuperentityTraits.h b/src/TNL/Meshes/MeshDetails/traits/MeshSuperentityTraits.h index 325847d59d..89de533c6f 100644 --- a/src/TNL/Meshes/MeshDetails/traits/MeshSuperentityTraits.h +++ b/src/TNL/Meshes/MeshDetails/traits/MeshSuperentityTraits.h @@ -33,40 +33,36 @@ template< typename MeshConfig, int Dimension > class MeshSuperentityTraits { - public: - - typedef typename MeshConfig::GlobalIndexType GlobalIndexType; - typedef typename MeshConfig::LocalIndexType LocalIndexType; +public: + static constexpr bool storageEnabled = MeshConfig::template superentityStorage< EntityTopology >( EntityTopology(), Dimensions ); - - static const bool storageEnabled = MeshConfig::template superentityStorage< EntityTopology >( EntityTopology(), Dimension ); - //typedef tnlStorageTraits< storageEnabled > SuperentityStorageTag; - typedef MeshEntity< MeshConfig, EntityTopology > EntityType; - typedef MeshEntityTraits< MeshConfig, Dimension > EntityTraits; - typedef typename EntityTraits::EntityTopology SuperentityTopology; - typedef typename EntityTraits::EntityType SuperentityType; + using GlobalIndexType = typename MeshConfig::GlobalIndexType; + using LocalIndexType = typename MeshConfig::LocalIndexType; + using EntityType = MeshEntity< MeshConfig, EntityTopology >; + using EntityTraits = MeshEntityTraits< MeshConfig, Dimensions >; + using SuperentityTopology = typename EntityTraits::EntityTopology; + using SuperentityType = typename EntityTraits::EntityType; /**** - * Type of container for storing of the superentities indecis. + * Type of container for storing of the superentities indices. */ - typedef Containers::Array< GlobalIndexType, Devices::Host, LocalIndexType > StorageArrayType; - - typedef EllpackIndexMultimap< GlobalIndexType, Devices::Host, LocalIndexType > StorageNetworkType; - typedef typename StorageNetworkType::ValuesAccessorType SuperentityAccessorType; - + using StorageArrayType = Containers::Array< GlobalIndexType, Devices::Host, LocalIndexType >; + + using StorageNetworkType = EllpackIndexMultimap< GlobalIndexType, Devices::Host, LocalIndexType >; + using SuperentityAccessorType = typename StorageNetworkType::ValuesAccessorType; + /**** * Type for passing the superentities indices by the getSuperentityIndices() * method. We introduce it because of the compatibility with the subentities * which are usually stored in static array. */ - typedef Containers::SharedArray< GlobalIndexType, Devices::Host, LocalIndexType > AccessArrayType; + using AccessArrayType = Containers::SharedArray< GlobalIndexType, Devices::Host, LocalIndexType >; /**** * This is used by the mesh initializer. */ - typedef Containers::List< GlobalIndexType > GrowableContainerType; - + using GrowableContainerType = List< GlobalIndexType >; }; } // namespace Meshes diff --git a/src/TNL/Meshes/MeshDetails/traits/MeshTraits.h b/src/TNL/Meshes/MeshDetails/traits/MeshTraits.h index 75e6fc6640..70e77bf506 100644 --- a/src/TNL/Meshes/MeshDetails/traits/MeshTraits.h +++ b/src/TNL/Meshes/MeshDetails/traits/MeshTraits.h @@ -36,36 +36,36 @@ template< typename MeshConfig, typename Device = Devices::Host > class MeshTraits { - public: - static const int meshDimensions = MeshConfig::CellTopology::dimensions; - static const int worldDimensions = MeshConfig::worldDimensions; +public: + static constexpr int meshDimensions = MeshConfig::CellTopology::dimensions; + static constexpr int worldDimensions = MeshConfig::worldDimensions; - typedef Device DeviceType; - typedef typename MeshConfig::GlobalIndexType GlobalIndexType; - typedef typename MeshConfig::LocalIndexType LocalIndexType; - - typedef typename MeshConfig::CellTopology CellTopology; - typedef MeshEntity< MeshConfig, CellTopology > CellType; - typedef MeshEntity< MeshConfig, MeshVertexTopology > VertexType; - typedef Containers::StaticVector< worldDimensions, typename MeshConfig::RealType > PointType; - typedef MeshEntitySeed< MeshConfig, CellTopology > CellSeedType; - - typedef Containers::Array< PointType, Devices::Host, GlobalIndexType > PointArrayType; - typedef Containers::Array< CellSeedType, Devices::Host, GlobalIndexType > CellSeedArrayType; - typedef Containers::Array< GlobalIndexType, Devices::Host, GlobalIndexType > GlobalIdArrayType; - typedef Containers::tnlConstSharedArray< GlobalIndexType, Devices::Host, LocalIndexType > IdArrayAccessorType; - typedef Containers::tnlConstSharedArray< LocalIndexType, Devices::Host, LocalIndexType > IdPermutationArrayAccessorType; - - template< int Dimensions > - using EntityTraits = MeshEntityTraits< MeshConfig, Dimensions >; - - template< typename EntityTopology, int SubDimensions > - using SubentityTraits = MeshSubentityTraits< MeshConfig, EntityTopology, SubDimensions >; - - template< typename EntityTopology, int SuperDimensions > - using SuperentityTraits = MeshSuperentityTraits< MeshConfig, EntityTopology, SuperDimensions >; - - typedef MeshDimensionsTag< meshDimensions > DimensionsTag; + using DeviceType = Device; + using GlobalIndexType = typename MeshConfig::GlobalIndexType; + using LocalIndexType = typename MeshConfig::LocalIndexType; + + using CellTopology = typename MeshConfig::CellTopology; + using CellType = MeshEntity< MeshConfig, CellTopology >; + using VertexType = MeshEntity< MeshConfig, MeshVertexTopology >; + using PointType = Containers::StaticVector< worldDimensions, typename MeshConfig::RealType >; + using CellSeedType = MeshEntitySeed< MeshConfig, CellTopology >; + + using PointArrayType = Containers::Array< PointType, Devices::Host, GlobalIndexType >; + using CellSeedArrayType = Containers::Array< CellSeedType, Devices::Host, GlobalIndexType >; + using GlobalIdArrayType = Containers::Array< GlobalIndexType, Devices::Host, GlobalIndexType >; + using IdArrayAccessorType = Containers::tnlConstSharedArray< GlobalIndexType, Devices::Host, LocalIndexType >; + using IdPermutationArrayAccessorType = Containers::tnlConstSharedArray< LocalIndexType, Devices::Host, LocalIndexType >; + + template< int Dimensions > + using EntityTraits = MeshEntityTraits< MeshConfig, Dimensions >; + + template< typename EntityTopology, int SubDimensions > + using SubentityTraits = MeshSubentityTraits< MeshConfig, EntityTopology, SubDimensions >; + + template< typename EntityTopology, int SuperDimensions > + using SuperentityTraits = MeshSuperentityTraits< MeshConfig, EntityTopology, SuperDimensions >; + + using DimensionsTag = MeshDimensionsTag< meshDimensions >; }; } // namespace Meshes -- GitLab