From bedc9346a485b02f4a3f63707426c2b347aafb5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Klinkovsk=C3=BD?= <klinkjak@fjfi.cvut.cz> Date: Wed, 19 Oct 2016 21:32:47 +0200 Subject: [PATCH] Moved wrapper methods from MeshEntity to MeshSuperentityAccess --- src/TNL/Meshes/MeshDetails/MeshEntity_impl.h | 94 ++----------------- .../layers/MeshSuperentityAccess.h | 31 +++++- src/TNL/Meshes/MeshEntity.h | 40 ++++---- src/UnitTests/Meshes/MeshEntityTest.h | 9 +- 4 files changed, 60 insertions(+), 114 deletions(-) diff --git a/src/TNL/Meshes/MeshDetails/MeshEntity_impl.h b/src/TNL/Meshes/MeshDetails/MeshEntity_impl.h index d21d58267a..d5d5da30b5 100644 --- a/src/TNL/Meshes/MeshDetails/MeshEntity_impl.h +++ b/src/TNL/Meshes/MeshDetails/MeshEntity_impl.h @@ -189,33 +189,8 @@ getSubentityIndices() const template< typename MeshConfig, typename EntityTopology > - template< int SuperDimension > -typename MeshEntity< MeshConfig, EntityTopology >::LocalIndexType -MeshEntity< MeshConfig, EntityTopology >:: -getNumberOfSuperentities() const -{ - static_assert( SuperentityTraits< SuperDimensions >::storageEnabled, "You try to get number of superentities which are not configured for storage." ); - typedef MeshSuperentityAccess< MeshConfig, EntityTopology > SuperentityBaseType; - return SuperentityBaseType::getNumberOfSuperentities( MeshDimensionTag< SuperDimension >() ); -} - -template< typename MeshConfig, - typename EntityTopology > - template< int SuperDimension > -typename MeshEntity< MeshConfig, EntityTopology >::GlobalIndexType -MeshEntity< MeshConfig, EntityTopology >:: -getSuperentityIndex( const LocalIndexType localIndex ) const -{ - static_assert( SuperentityTraits< SuperDimensions >::storageEnabled, "You try to get superentities which are not configured for storage." ); - typedef MeshSuperentityAccess< MeshConfig, EntityTopology > SuperentityBaseType; - return SuperentityBaseType::getSuperentityIndex( MeshDimensionsTag< SuperDimensions >(), - localIndex ); -} - -template< typename MeshConfig, - typename EntityTopology > - template< int SuperDimension > -typename MeshEntity< MeshConfig, EntityTopology >::template SuperentityTraits< SuperDimension >::AccessArrayType& + template< int SuperDimensions > +typename MeshEntity< MeshConfig, EntityTopology >::template SuperentityTraits< SuperDimensions >::AccessArrayType& MeshEntity< MeshConfig, EntityTopology >:: getSuperentityIndices() { @@ -282,7 +257,8 @@ subentityOrientation( LocalIndexType index ) const static const LocalIndexType subentitiesCount = SubentityTraits< Dimension >::count; TNL_ASSERT( 0 <= index && index < subentitiesCount, ); - return SubentityStorageLayers::subentityOrientation( MeshDimensionTag< Dimension >(), index ); + typedef MeshSubentityStorageLayers< MeshConfig, EntityTopology > SubentityStorageLayers; + return SubentityStorageLayers::subentityOrientation( MeshDimensionsTag< Dimensions >(), index ); } /**** @@ -308,21 +284,6 @@ setSubentityIndex( const LocalIndexType& localIndex, globalIndex ); } -template< typename MeshConfig, - typename EntityTopology > - template< int Superdimensions > -void -MeshEntity< MeshConfig, EntityTopology >:: -setSuperentityIndex( const LocalIndexType& localIndex, - const GlobalIndexType& globalIndex ) -{ - static_assert( SuperentityTraits< Superdimensions >::storageEnabled, "You try to set number of superentities which are not configured for storage." ); - typedef MeshSuperentityAccess< MeshConfig, EntityTopology > SuperentityBaseType; - SuperentityBaseType::setSuperentityIndex( MeshDimensionsTag< Superdimensions >(), - localIndex, - globalIndex ); -} - template< typename MeshConfig, typename EntityTopology > template< int Subdimensions > @@ -330,7 +291,8 @@ typename MeshEntity< MeshConfig, EntityTopology >::template SubentityTraits< Sub MeshEntity< MeshConfig, EntityTopology >:: subentityIdsArray() { - return SubentityStorageLayers::subentityIdsArray( MeshDimensionTag< Subdimensions >() ); + typedef MeshSubentityStorageLayers< MeshConfig, EntityTopology > SubentityStorageLayers; + return SubentityStorageLayers::subentityIdsArray( MeshDimensionsTag< Subdimensions >() ); } template< typename MeshConfig, @@ -340,7 +302,8 @@ typename MeshEntity< MeshConfig, EntityTopology >::IdArrayAccessorType& MeshEntity< MeshConfig, EntityTopology >:: superentityIdsArray() { - return SuperentityAccessBase::superentityIdsArray( MeshDimensionTag< Superdimensions >()); + typedef MeshSuperentityAccess< MeshConfig, EntityTopology > SuperentityAccessBase; + return SuperentityAccessBase::superentityIdsArray( MeshDimensionsTag< Superdimensions >()); } template< typename MeshConfig, @@ -350,7 +313,8 @@ typename MeshEntity< MeshConfig, EntityTopology >::template SubentityTraits< Sub MeshEntity< MeshConfig, EntityTopology >:: subentityOrientationsArray() { - return SubentityStorageLayers::subentityOrientationsArray( MeshDimensionTag< Subdimensions >() ); + typedef MeshSubentityStorageLayers< MeshConfig, EntityTopology > SubentityStorageLayers; + return SubentityStorageLayers::subentityOrientationsArray( MeshDimensionsTag< Subdimensions >() ); } /**** @@ -430,16 +394,6 @@ getEntityDimension() const return EntityTopology::dimensions; } -template< typename MeshConfig > - template< int Superdimensions > -typename MeshEntity< MeshConfig, MeshVertexTopology >::LocalIndexType -MeshEntity< MeshConfig, MeshVertexTopology >:: -getNumberOfSuperentities() const -{ - typedef MeshSuperentityAccess< MeshConfig, MeshVertexTopology > SuperentityBaseType; - return SuperentityBaseType::getNumberOfSuperentities( MeshDimensionTag< Superdimensions >() ); -} - template< typename MeshConfig > template< int Superdimensions > typename MeshEntity< MeshConfig, MeshVertexTopology >::template SuperentityTraits< Superdimensions >::AccessArrayType& @@ -460,20 +414,6 @@ getSuperentityIndices() const return SuperentityBaseType::getSuperentityIndices( MeshDimensionsTag< Superdimensions >() ); } -template< typename MeshConfig > - template< int Dimension > -typename MeshEntity< MeshConfig, MeshVertexTopology >::GlobalIndexType -MeshEntity< MeshConfig, MeshVertexTopology >:: -getSuperentityIndex( const LocalIndexType localIndex ) const -{ - TNL_ASSERT( localIndex < this->getNumberOfSuperentities< Dimension >(), - std::cerr << " localIndex = " << localIndex - << " this->getNumberOfSuperentities< Dimensions >() = " << this->getNumberOfSuperentities< Dimensions >() << std::endl; ); - typedef MeshSuperentityAccess< MeshConfig, MeshVertexTopology > SuperentityBaseType; - return SuperentityBaseType::getSuperentityIndex( MeshDimensionTag< Dimension >(), - localIndex ); -} - template< typename MeshConfig > typename MeshEntity< MeshConfig, MeshVertexTopology >::PointType MeshEntity< MeshConfig, MeshVertexTopology >:: @@ -490,20 +430,6 @@ setPoint( const PointType& point ) this->point = point; } -template< typename MeshConfig > - template< int Superdimensions > -void -MeshEntity< MeshConfig, MeshVertexTopology >:: -setSuperentityIndex( const LocalIndexType& localIndex, - const GlobalIndexType& globalIndex ) -{ - static_assert( SuperentityTraits< Superdimensions >::storageEnabled, "You try to set number of superentities which are not configured for storage." ); - typedef MeshSuperentityAccess< MeshConfig, MeshVertexTopology > SuperentityBaseType; - SuperentityBaseType::setSuperentityIndex( MeshDimensionsTag< Superdimensions >(), - localIndex, - globalIndex ); -} - template< typename MeshConfig > template< int Superdimensions > typename MeshEntity< MeshConfig, MeshVertexTopology >::MeshTraitsType::IdArrayAccessorType& diff --git a/src/TNL/Meshes/MeshDetails/layers/MeshSuperentityAccess.h b/src/TNL/Meshes/MeshDetails/layers/MeshSuperentityAccess.h index f41cc24fc4..41396f42de 100644 --- a/src/TNL/Meshes/MeshDetails/layers/MeshSuperentityAccess.h +++ b/src/TNL/Meshes/MeshDetails/layers/MeshSuperentityAccess.h @@ -54,7 +54,6 @@ public: BaseType::print( str ); } - // TODO: probably should be moved to MeshEntity itself - or the related methods could be moved here template< int SuperDimensions > void bindSuperentitiesStorageNetwork( const typename SuperentityTraits< SuperDimensions >::SuperentityAccessorType& storage ) { @@ -66,10 +65,38 @@ public: template< int SuperDimensions > bool setNumberOfSuperentities( const typename SuperentityTraits< SuperDimensions >::LocalIndexType size ) { - static_assert( SuperentityTraits< SuperDimensions >::storageEnabled, "You try to get number of superentities which are not configured for storage." ); + static_assert( SuperentityTraits< SuperDimensions >::storageEnabled, "You try to set number of superentities which are not configured for storage." ); return BaseType::setNumberOfSuperentities( MeshDimensionsTag< SuperDimensions >(), size ); } + + template< int SuperDimensions > + typename SuperentityTraits< SuperDimensions >::LocalIndexType + getNumberOfSuperentities() const + { + static_assert( SuperentityTraits< SuperDimensions >::storageEnabled, "You try to get number of superentities which are not configured for storage." ); + return BaseType::getNumberOfSuperentities( MeshDimensionsTag< SuperDimensions >() ); + } + + template< int SuperDimensions > + void + setSuperentityIndex( const typename SuperentityTraits< SuperDimensions >::LocalIndexType& localIndex, + const typename SuperentityTraits< SuperDimensions >::GlobalIndexType& globalIndex ) + { + static_assert( SuperentityTraits< SuperDimensions >::storageEnabled, "You try to set superentities which are not configured for storage." ); + BaseType::setSuperentityIndex( MeshDimensionsTag< SuperDimensions >(), + localIndex, + globalIndex ); + } + + template< int SuperDimensions > + typename SuperentityTraits< SuperDimensions >::GlobalIndexType + getSuperentityIndex( const typename SuperentityTraits< SuperDimensions >::LocalIndexType localIndex ) const + { + static_assert( SuperentityTraits< SuperDimensions >::storageEnabled, "You try to get superentities which are not configured for storage." ); + return BaseType::getSuperentityIndex( MeshDimensionsTag< SuperDimensions >(), + localIndex ); + } }; template< typename MeshConfig, diff --git a/src/TNL/Meshes/MeshEntity.h b/src/TNL/Meshes/MeshEntity.h index d7963e2945..bd6f30ba4e 100644 --- a/src/TNL/Meshes/MeshEntity.h +++ b/src/TNL/Meshes/MeshEntity.h @@ -37,7 +37,7 @@ template< typename MeshConfig, typename EntityTopology_ > class MeshEntity : public MeshSubentityStorageLayers< MeshConfig, EntityTopology_ >, - public MeshSuperentityAccess< MeshConfig, EntityTopology_ >, + protected MeshSuperentityAccess< MeshConfig, EntityTopology_ >, public MeshEntityId< typename MeshConfig::IdType, typename MeshConfig::GlobalIndexType > { @@ -97,12 +97,10 @@ class MeshEntity /**** * Superentities */ - template< int SuperDimension > - LocalIndexType getNumberOfSuperentities() const; - - template< int SuperDimension > - GlobalIndexType getSuperentityIndex( const LocalIndexType localIndex ) const; + using MeshSuperentityAccess< MeshConfig, EntityTopology_ >::getNumberOfSuperentities; + using MeshSuperentityAccess< MeshConfig, EntityTopology_ >::getSuperentityIndex; + // TODO: used only in MeshInitializer, should be removed template< int SuperDimensions > typename SuperentityTraits< SuperDimensions >::AccessArrayType& getSuperentityIndices(); @@ -124,22 +122,19 @@ class MeshEntity IdPermutationArrayAccessorType subentityOrientation( LocalIndexType index ) const; protected: - /**** * Methods for the mesh initialization */ - typedef MeshSuperentityAccess< MeshConfig, EntityTopology > SuperentityAccessBase; typedef typename MeshTraitsType::IdArrayAccessorType IdArrayAccessorType; - typedef MeshSubentityStorageLayers< MeshConfig, EntityTopology > SubentityStorageLayers; + + using MeshSuperentityAccess< MeshConfig, EntityTopology_ >::bindSuperentitiesStorageNetwork; + using MeshSuperentityAccess< MeshConfig, EntityTopology_ >::setNumberOfSuperentities; + using MeshSuperentityAccess< MeshConfig, EntityTopology_ >::setSuperentityIndex; template< int Subdimensions > void setSubentityIndex( const LocalIndexType& localIndex, const GlobalIndexType& globalIndex ); - template< int Superdimensions > - void setSuperentityIndex( const LocalIndexType& localIndex, - const GlobalIndexType& globalIndex ); - template< int Subdimensions > typename SubentityTraits< Subdimensions >::IdArrayType& subentityIdsArray(); @@ -157,7 +152,7 @@ class MeshEntity */ template< typename MeshConfig > class MeshEntity< MeshConfig, MeshVertexTopology > - : public MeshSuperentityAccess< MeshConfig, MeshVertexTopology >, + : protected MeshSuperentityAccess< MeshConfig, MeshVertexTopology >, public MeshEntityId< typename MeshConfig::IdType, typename MeshConfig::GlobalIndexType > { @@ -190,17 +185,19 @@ class MeshEntity< MeshConfig, MeshVertexTopology > constexpr int getEntityDimension() const; - template< int Superdimensions > LocalIndexType getNumberOfSuperentities() const; + /**** + * Superentities + */ + using MeshSuperentityAccess< MeshConfig, MeshVertexTopology >::getNumberOfSuperentities; + using MeshSuperentityAccess< MeshConfig, MeshVertexTopology >::getSuperentityIndex; + // TODO: used only in MeshInitializer, should be removed template< int Superdimensions > typename SuperentityTraits< Superdimensions >::AccessArrayType& getSuperentityIndices(); template< int Superdimensions > const typename SuperentityTraits< Superdimensions >::AccessArrayType& getSuperentityIndices() const; - template< int Dimension > - GlobalIndexType getSuperentityIndex( const LocalIndexType localIndex ) const; - /**** * Points */ @@ -209,14 +206,13 @@ class MeshEntity< MeshConfig, MeshVertexTopology > void setPoint( const PointType& point ); protected: + using MeshSuperentityAccess< MeshConfig, MeshVertexTopology >::bindSuperentitiesStorageNetwork; + using MeshSuperentityAccess< MeshConfig, MeshVertexTopology >::setNumberOfSuperentities; + using MeshSuperentityAccess< MeshConfig, MeshVertexTopology >::setSuperentityIndex; typedef typename MeshTraitsType::IdArrayAccessorType IdArrayAccessorType; typedef MeshSuperentityAccess< MeshConfig, MeshVertexTopology > SuperentityAccessBase; - template< int Superdimensions > - void setSuperentityIndex( const LocalIndexType& localIndex, - const GlobalIndexType& globalIndex ); - template< int Superdimensions > IdArrayAccessorType& superentityIdsArray(); diff --git a/src/UnitTests/Meshes/MeshEntityTest.h b/src/UnitTests/Meshes/MeshEntityTest.h index a2cf73efbb..ad332c894d 100644 --- a/src/UnitTests/Meshes/MeshEntityTest.h +++ b/src/UnitTests/Meshes/MeshEntityTest.h @@ -67,12 +67,9 @@ public: BaseType::template setSubentityIndex< Subdimensions >( localIndex, globalIndex ); } - template< int Superdimensions > - void setSuperentityIndex( const typename BaseType::LocalIndexType& localIndex, - const typename BaseType::GlobalIndexType& globalIndex ) - { - BaseType::template setSuperentityIndex< Superdimensions >( localIndex, globalIndex ); - } + using BaseType::bindSuperentitiesStorageNetwork; + using BaseType::setNumberOfSuperentities; + using BaseType::setSuperentityIndex; }; using RealType = double; -- GitLab