diff --git a/src/TNL/Meshes/MeshDetails/initializer/Initializer.h b/src/TNL/Meshes/MeshDetails/initializer/Initializer.h index eb8e54564c160644aebab7a4206d27fe579fdc17..8dfd3c0dba31ba515f85879667ca0208f6b73db4 100644 --- a/src/TNL/Meshes/MeshDetails/initializer/Initializer.h +++ b/src/TNL/Meshes/MeshDetails/initializer/Initializer.h @@ -84,7 +84,7 @@ class Initializer using NeighborCountsArray = typename MeshTraitsType::NeighborCountsArray; template< int Dimension, int Subdimension > - using SubentityMatrixRowsCapacitiesType = typename MeshTraitsType::template SubentityMatrixType< Dimension, Subdimension >::RowsCapacitiesType; + using SubentityMatrixRowsCapacitiesType = typename MeshTraitsType::template SubentityMatrixType< Dimension >::RowsCapacitiesType; // The points and cellSeeds arrays will be reset when not needed to save memory. void createMesh( PointArrayType& points, diff --git a/src/TNL/Meshes/MeshDetails/layers/StorageLayer.h b/src/TNL/Meshes/MeshDetails/layers/StorageLayer.h index 8423cc722d59b2b01e4ad87edb3f0cc386680963..84f3128341102a59af81456b1c9409e2692b8fcc 100644 --- a/src/TNL/Meshes/MeshDetails/layers/StorageLayer.h +++ b/src/TNL/Meshes/MeshDetails/layers/StorageLayer.h @@ -113,7 +113,7 @@ public: template< int Dimension, int Subdimension > __cuda_callable__ - typename MeshTraitsType::template SubentityMatrixType< Dimension, Subdimension >& + typename MeshTraitsType::template SubentityMatrixType< Dimension >& getSubentitiesMatrix() { static_assert( Dimension > Subdimension, "Invalid combination of Dimension and Subdimension." ); @@ -127,7 +127,7 @@ public: template< int Dimension, int Subdimension > __cuda_callable__ - const typename MeshTraitsType::template SubentityMatrixType< Dimension, Subdimension >& + const typename MeshTraitsType::template SubentityMatrixType< Dimension >& getSubentitiesMatrix() const { static_assert( Dimension > Subdimension, "Invalid combination of Dimension and Subdimension." ); diff --git a/src/TNL/Meshes/MeshDetails/layers/SubentityStorageLayer.h b/src/TNL/Meshes/MeshDetails/layers/SubentityStorageLayer.h index b00fed83280082b94f0095f622fe41d3ab24d96c..e3b63c480078b6099112b8b21154b28829b56e27 100644 --- a/src/TNL/Meshes/MeshDetails/layers/SubentityStorageLayer.h +++ b/src/TNL/Meshes/MeshDetails/layers/SubentityStorageLayer.h @@ -67,7 +67,7 @@ protected: template< int Subdimension > __cuda_callable__ - typename MeshTraitsType::template SubentityMatrixType< EntityTopology::dimension, Subdimension >& + typename MeshTraitsType::template SubentityMatrixType< EntityTopology::dimension >& getSubentitiesMatrix() { static_assert( EntityTopology::dimension > Subdimension, "Invalid combination of Dimension and Subdimension." ); @@ -76,7 +76,7 @@ protected: template< int Subdimension > __cuda_callable__ - const typename MeshTraitsType::template SubentityMatrixType< EntityTopology::dimension, Subdimension >& + const typename MeshTraitsType::template SubentityMatrixType< EntityTopology::dimension >& getSubentitiesMatrix() const { static_assert( EntityTopology::dimension > Subdimension, "Invalid combination of Dimension and Subdimension." ); @@ -108,7 +108,7 @@ class SubentityStorageLayer< MeshConfig, protected: using GlobalIndexType = typename MeshTraitsType::GlobalIndexType; using LocalIndexType = typename MeshTraitsType::LocalIndexType; - using SubentityMatrixType = typename MeshTraitsType::template SubentityMatrixType< EntityTopology::dimension, SubdimensionTag::value >; + using SubentityMatrixType = typename MeshTraitsType::template SubentityMatrixType< EntityTopology::dimension >; SubentityStorageLayer() = default; @@ -210,7 +210,7 @@ protected: using GlobalIndexType = typename MeshTraitsType::GlobalIndexType; using LocalIndexType = typename MeshTraitsType::LocalIndexType; using NeighborCountsArray = typename MeshTraitsType::NeighborCountsArray; - using SubentityMatrixType = typename MeshTraitsType::template SubentityMatrixType< EntityTopology::dimension, SubdimensionTag::value >; + using SubentityMatrixType = typename MeshTraitsType::template SubentityMatrixType< EntityTopology::dimension >; SubentityStorageLayer() = default; @@ -330,7 +330,7 @@ protected: using GlobalIndexType = typename MeshTraitsType::GlobalIndexType; using LocalIndexType = typename MeshTraitsType::LocalIndexType; using NeighborCountsArray = typename MeshTraitsType::NeighborCountsArray; - using SubentityMatrixType = typename MeshTraitsType::template SubentityMatrixType< EntityTopology::dimension, SubdimensionTag::value >; + using SubentityMatrixType = typename MeshTraitsType::template SubentityMatrixType< EntityTopology::dimension >; SubentityStorageLayer() = default; @@ -444,7 +444,7 @@ protected: using GlobalIndexType = typename MeshTraitsType::GlobalIndexType; using LocalIndexType = typename MeshTraitsType::LocalIndexType; using NeighborCountsArray = typename MeshTraitsType::NeighborCountsArray; - using SubentityMatrixType = typename MeshTraitsType::template SubentityMatrixType< EntityTopology::dimension, SubdimensionTag::value >; + using SubentityMatrixType = typename MeshTraitsType::template SubentityMatrixType< EntityTopology::dimension >; SubentityStorageLayer() = default; diff --git a/src/TNL/Meshes/MeshDetails/traits/MeshEntityTraits.h b/src/TNL/Meshes/MeshDetails/traits/MeshEntityTraits.h index 2bf7f856fc6cc8c7ad0a2963b308f8b4c9fb2421..db54ac8278e0bc6f1c708a782059b4b84309cc49 100644 --- a/src/TNL/Meshes/MeshDetails/traits/MeshEntityTraits.h +++ b/src/TNL/Meshes/MeshDetails/traits/MeshEntityTraits.h @@ -29,25 +29,43 @@ namespace Meshes { template< typename MeshConfig, typename Device, typename EntityTopology > class MeshEntity; +/**** + * Mesh entity traits with specializations + * + * DYNAMIC TOPOLOGY + * FALSE + */ template< typename MeshConfig, - typename DimensionTag > -struct EntityTopologyGetter + typename Device, + int Dimension > +class MeshEntityTraits< MeshConfig, Device, Dimension, false > { - static_assert( DimensionTag::value <= MeshConfig::meshDimension, "There are no entities with dimension higher than the mesh dimension." ); - using Topology = typename Topologies::Subtopology< typename MeshConfig::CellTopology, DimensionTag::value >::Topology; -}; + using GlobalIndexType = typename MeshConfig::GlobalIndexType; -template< typename MeshConfig > -struct EntityTopologyGetter< MeshConfig, DimensionTag< MeshConfig::CellTopology::dimension > > -{ - using Topology = typename MeshConfig::CellTopology; -}; +public: + static_assert( 0 <= Dimension && Dimension <= MeshConfig::meshDimension, "invalid dimension" ); + using EntityTopology = typename EntityTopologyGetter< MeshConfig, DimensionTag< Dimension > >::Topology; + using EntityType = MeshEntity< MeshConfig, Device, EntityTopology >; + using SeedType = EntitySeed< MeshConfig, EntityTopology >; + + using SeedIndexedSetType = Containers::UnorderedIndexedSet< SeedType, GlobalIndexType, typename SeedType::HashType, typename SeedType::KeyEqual >; + using SeedSetType = std::unordered_set< typename SeedIndexedSetType::key_type, typename SeedIndexedSetType::hasher, typename SeedIndexedSetType::key_equal >; + // container for storing the subentity indices + using SubentityMatrixType = Matrices::SparseMatrix< bool, Device, GlobalIndexType, Matrices::GeneralMatrix, EllpackSegments >; +}; + +/**** + * Mesh entity traits with specializations + * + * DYNAMIC TOPOLOGY + * TRUE + */ template< typename MeshConfig, typename Device, int Dimension > -class MeshEntityTraits +class MeshEntityTraits< MeshConfig, Device, Dimension, true > { using GlobalIndexType = typename MeshConfig::GlobalIndexType; @@ -60,6 +78,9 @@ public: using SeedIndexedSetType = Containers::UnorderedIndexedSet< SeedType, GlobalIndexType, typename SeedType::HashType, typename SeedType::KeyEqual >; using SeedSetType = std::unordered_set< typename SeedIndexedSetType::key_type, typename SeedIndexedSetType::hasher, typename SeedIndexedSetType::key_equal >; + + // container for storing the subentity indices + using SubentityMatrixType = Matrices::SparseMatrix< bool, Device, GlobalIndexType, Matrices::GeneralMatrix, SlicedEllpackSegments >; }; } // namespace Meshes diff --git a/src/TNL/Meshes/MeshDetails/traits/MeshSubentityTraits.h b/src/TNL/Meshes/MeshDetails/traits/MeshSubentityTraits.h index 7ab39d200a843da071fb372651428e535df9344e..0f191784e6e4b3c731ca43cb416a5415ac24aa30 100644 --- a/src/TNL/Meshes/MeshDetails/traits/MeshSubentityTraits.h +++ b/src/TNL/Meshes/MeshDetails/traits/MeshSubentityTraits.h @@ -48,9 +48,6 @@ public: using SubentityTopology = typename MeshEntityTraits< MeshConfig, Device, Dimension >::EntityTopology; using SubentityType = typename MeshEntityTraits< MeshConfig, Device, Dimension >::EntityType; - // container for storing the subentity indices - using SubentityMatrixType = Matrices::SparseMatrix< bool, Device, GlobalIndexType, Matrices::GeneralMatrix, EllpackSegments >; - template< LocalIndexType subentityIndex, LocalIndexType subentityVertexIndex > struct Vertex @@ -86,9 +83,6 @@ public: using SubentityTopology = typename MeshEntityTraits< MeshConfig, Device, Dimension >::EntityTopology; using SubentityType = typename MeshEntityTraits< MeshConfig, Device, Dimension >::EntityType; - - // container for storing the subentity indices - using SubentityMatrixType = Matrices::SparseMatrix< bool, Device, GlobalIndexType, Matrices::GeneralMatrix, SlicedEllpackSegments >; }; } // namespace Meshes diff --git a/src/TNL/Meshes/MeshDetails/traits/MeshTraits.h b/src/TNL/Meshes/MeshDetails/traits/MeshTraits.h index d2f128f8e27b36f36144d0f0ab48b9e0385cc193..df079e40b34f58635e176942151dd507e737ee51 100644 --- a/src/TNL/Meshes/MeshDetails/traits/MeshTraits.h +++ b/src/TNL/Meshes/MeshDetails/traits/MeshTraits.h @@ -33,11 +33,28 @@ template< typename MeshConfig, typename Device, typename EntityTopology > class template< typename MeshConfig, typename EntityTopology, - bool variableSize = std::is_same< EntityTopology, Topologies::Polygon >::value || - std::is_same< EntityTopology, Topologies::Polyhedron >::value > + bool IsDynamicTopology = Topologies::IsDynamicTopology< EntityTopology >::value > class EntitySeed; -template< typename MeshConfig, typename Device, int Dimension > class MeshEntityTraits; +template< typename MeshConfig, + typename DimensionTag > +struct EntityTopologyGetter +{ + static_assert( DimensionTag::value <= MeshConfig::meshDimension, "There are no entities with dimension higher than the mesh dimension." ); + using Topology = typename Topologies::Subtopology< typename MeshConfig::CellTopology, DimensionTag::value >::Topology; +}; + +template< typename MeshConfig > +struct EntityTopologyGetter< MeshConfig, DimensionTag< MeshConfig::CellTopology::dimension > > +{ + using Topology = typename MeshConfig::CellTopology; +}; + +template< typename MeshConfig, + typename Device, + int Dimension, + bool IsDynamicTopology = Topologies::IsDynamicTopology< typename EntityTopologyGetter< MeshConfig, DimensionTag< Dimension > >::Topology >::value > +class MeshEntityTraits; template< typename MeshConfig, typename Device, @@ -93,8 +110,8 @@ public: using DimensionTag = Meshes::DimensionTag< meshDimension >; // container for storing the subentity indices - template< int Dimension, int Subdimension > - using SubentityMatrixType = typename SubentityTraits< typename EntityTraits< Dimension >::EntityTopology, Subdimension >::SubentityMatrixType; + template< int Dimension > + using SubentityMatrixType = typename EntityTraits< Dimension >::SubentityMatrixType; // container for storing the superentity indices using SuperentityMatrixType = Matrices::SparseMatrix< bool, Device, GlobalIndexType, Matrices::GeneralMatrix, SlicedEllpackSegments >;