diff --git a/src/TNL/Meshes/MeshConfigBase.h b/src/TNL/Meshes/MeshConfigBase.h index cad2bb1c92166eee80bd1f776ac295f5e8a9f02b..1595c17cc88b7124e673a1e01229f4e69ec3ea57 100644 --- a/src/TNL/Meshes/MeshConfigBase.h +++ b/src/TNL/Meshes/MeshConfigBase.h @@ -45,6 +45,7 @@ struct MeshConfigBase static const int meshDimensions = Cell::dimensions; static_assert( worldDimensions >= meshDimensions, "The cell dimension cannot be larger than the world dimension." ); + static_assert( meshDimensions > 0, "The cell dimension must be at least 1." ); static String getType() { @@ -54,47 +55,50 @@ struct MeshConfigBase /**** * Storage of mesh entities. */ - static constexpr bool entityStorage( int dimensions ) - { + static constexpr bool entityStorage( int dimensions ) + { /**** * Vertices and cells must always be stored */ return true; - //return ( dimensions == 0 || dimensions == cellDimension ); - } + //return ( dimensions == 0 || dimensions == cellDimensions ); + } /**** * Storage of subentities of mesh entities */ - template< typename MeshEntity > - static constexpr bool subentityStorage( MeshEntity, int SubentityDimension ) - { + // TODO: MeshEntity -> EntityTopology + template< typename MeshEntity > + static constexpr bool subentityStorage( MeshEntity, int SubentityDimensions ) + { /**** * Vertices must always be stored */ return true; - //return ( SubentityDimension == 0 ); - } + //return ( SubentityDimensions == 0 ); + } - /**** + /**** * Storage of subentity orientations of mesh entities. * It must be false for vertices and cells. */ - template< typename MeshEntity > - static constexpr bool subentityOrientationStorage( MeshEntity, int SubentityDimension ) - { - return ( SubentityDimension > 0 ); - } + // TODO: MeshEntity -> EntityTopology + template< typename MeshEntity > + static constexpr bool subentityOrientationStorage( MeshEntity, int SubentityDimensions ) + { + return ( SubentityDimensions > 0 ); + } - /**** + /**** * Storage of superentities of mesh entities */ - template< typename MeshEntity > - static constexpr bool superentityStorage( MeshEntity, int SuperentityDimension ) - { + // TODO: MeshEntity -> EntityTopology + template< typename MeshEntity > + static constexpr bool superentityStorage( MeshEntity, int SuperentityDimensions ) + { return true; - //return false; - } + //return false; + } }; } // namespace Meshes diff --git a/src/TNL/Meshes/Topologies/MeshEntityTopology.h b/src/TNL/Meshes/Topologies/MeshEntityTopology.h index 589bec5db38d2cc7a406b8abd3092251f8247628..1ba29cb49538948f496e061e3684fa3f5214479b 100644 --- a/src/TNL/Meshes/Topologies/MeshEntityTopology.h +++ b/src/TNL/Meshes/Topologies/MeshEntityTopology.h @@ -33,23 +33,18 @@ struct tnlSubentityVertex; template< typename MeshConfig, - int Dimension > -class MeshEntityTopology + int Dimensions > +struct MeshEntityTopology { - public: - - typedef typename MeshSubtopology< typename MeshConfig::CellTopology, - Dimension >::Topology Topology; + static_assert( Dimensions <= MeshConfig::meshDimensions, "There are no entities with dimension higher than the mesh dimension." ); + using Topology = typename MeshSubtopology< typename MeshConfig::CellTopology, Dimensions >::Topology; }; template< typename MeshConfig > -class MeshEntityTopology< MeshConfig, - MeshConfig::CellTopology::dimensions > +struct MeshEntityTopology< MeshConfig, MeshConfig::CellTopology::dimensions > { - public: - - typedef typename MeshConfig::CellTopology Topology; + using Topology = typename MeshConfig::CellTopology; }; } // namespace Meshes -} // namespace TNL \ No newline at end of file +} // namespace TNL diff --git a/src/UnitTests/Meshes/MeshEntityTest.h b/src/UnitTests/Meshes/MeshEntityTest.h index 8d28ac959419517ac8cf726e9d8fa070f0ce5aaf..112ed6519ddda4ccaf6a7f2ee924ccaf4bc43996 100644 --- a/src/UnitTests/Meshes/MeshEntityTest.h +++ b/src/UnitTests/Meshes/MeshEntityTest.h @@ -15,8 +15,7 @@ using RealType = double; using Device = Devices::Host; using IndexType = int; -using TestVertexMeshConfig = MeshConfigBase< MeshVertexTopology, 2, RealType, IndexType, IndexType, void >; -using TestEdgeMeshConfig = MeshConfigBase< MeshEdgeTopology, 2, RealType, IndexType, IndexType, void >; +using TestEdgeMeshConfig = MeshConfigBase< MeshEdgeTopology, 2, RealType, IndexType, IndexType, void >; class TestTriangleMeshConfig : public MeshConfigBase< MeshTriangleTopology > { @@ -77,13 +76,14 @@ public: TEST( MeshEntityTest, VertexMeshEntityTest ) { - typedef TestMeshEntity< TestVertexMeshConfig, MeshVertexTopology > VertexMeshEntityType; - typedef typename VertexMeshEntityType::PointType PointType; + using EdgeMeshEntityType = TestMeshEntity< TestEdgeMeshConfig, MeshEdgeTopology >; + using VertexMeshEntityType = TestMeshEntity< TestEdgeMeshConfig, typename EdgeMeshEntityType::SubentityTraits< 0 >::SubentityTopology >; + using PointType = typename VertexMeshEntityType::PointType; ASSERT_TRUE( PointType::getType() == ( Containers::StaticVector< 2, RealType >::getType() ) ); + VertexMeshEntityType vertexEntity; PointType point; - point.x() = 1.0; point.y() = 2.0; vertexEntity.setPoint( point ); @@ -92,14 +92,13 @@ TEST( MeshEntityTest, VertexMeshEntityTest ) TEST( MeshEntityTest, EdgeMeshEntityTest ) { - typedef TestMeshEntity< TestVertexMeshConfig, MeshVertexTopology > VertexMeshEntityType; - typedef TestMeshEntity< TestEdgeMeshConfig, MeshEdgeTopology > EdgeMeshEntityType; + using EdgeMeshEntityType = TestMeshEntity< TestEdgeMeshConfig, MeshEdgeTopology >; + using VertexMeshEntityType = TestMeshEntity< TestEdgeMeshConfig, typename EdgeMeshEntityType::SubentityTraits< 0 >::SubentityTopology >; + static_assert( EdgeMeshEntityType::SubentityTraits< 0 >::storageEnabled, "Testing edge entity does not store vertices as required." ); - typedef typename VertexMeshEntityType::PointType PointType; + using PointType = typename VertexMeshEntityType::PointType; ASSERT_TRUE( PointType::getType() == ( Containers::StaticVector< 2, RealType >::getType() ) ); - ASSERT_TRUE( EdgeMeshEntityType().template subentitiesAvailable< 0 >() ); - /**** * * Here we test the following simple example: @@ -157,13 +156,15 @@ TEST( MeshEntityTest, EdgeMeshEntityTest ) TEST( MeshEntityTest, TriangleMeshEntityTest ) { - typedef TestMeshEntity< TestVertexMeshConfig, MeshVertexTopology > VertexMeshEntityType; - typedef TestMeshEntity< TestEdgeMeshConfig, MeshEdgeTopology > EdgeMeshEntityType; - typedef TestMeshEntity< TestTriangleMeshConfig, MeshTriangleTopology > TriangleMeshEntityType; + using TriangleMeshEntityType = TestMeshEntity< TestTriangleMeshConfig, MeshTriangleTopology >; + using EdgeMeshEntityType = TestMeshEntity< TestTriangleMeshConfig, typename TriangleMeshEntityType::SubentityTraits< 1 >::SubentityTopology >; + using VertexMeshEntityType = TestMeshEntity< TestTriangleMeshConfig, typename TriangleMeshEntityType::SubentityTraits< 0 >::SubentityTopology >; + + static_assert( TriangleMeshEntityType::SubentityTraits< 1 >::storageEnabled, "Testing triangle entity does not store edges as required." ); + static_assert( TriangleMeshEntityType::SubentityTraits< 0 >::storageEnabled, "Testing triangle entity does not store vertices as required." ); + static_assert( EdgeMeshEntityType::SubentityTraits< 0 >::storageEnabled, "Testing edge entity does not store vertices as required." ); - static_assert( TriangleMeshEntityType::SubentityTraits< 1 >::storageEnabled, "Testing triangular mesh does not store edges as required." ); - static_assert( TriangleMeshEntityType::SubentityTraits< 0 >::storageEnabled, "" ); - typedef typename VertexMeshEntityType::PointType PointType; + using PointType = typename VertexMeshEntityType::PointType; ASSERT_TRUE( PointType::getType() == ( Containers::StaticVector< 2, RealType >::getType() ) ); /**** @@ -218,16 +219,19 @@ TEST( MeshEntityTest, TriangleMeshEntityTest ) TEST( MeshEntityTest, TetragedronMeshEntityTest ) { - //typedef MeshConfigBase< MeshTetrahedronTopology, 3, RealType, IndexType, IndexType, void > TestTetrahedronEntityTopology; - typedef MeshConfigBase< MeshTriangleTopology, 3, RealType, IndexType, IndexType, void > TestTriangleEntityTopology; - typedef MeshConfigBase< MeshEdgeTopology, 3, RealType, IndexType, IndexType, void > TestEdgeEntityTopology; - typedef MeshConfigBase< MeshVertexTopology, 3, RealType, IndexType, IndexType, void > TestVertexEntityTopology; - - typedef TestMeshEntity< TestTetrahedronMeshConfig, MeshTetrahedronTopology > TetrahedronMeshEntityType; - typedef TestMeshEntity< TestTriangleMeshConfig, MeshTriangleTopology > TriangleMeshEntityType; - typedef TestMeshEntity< TestEdgeEntityTopology, MeshEdgeTopology > EdgeMeshEntityType; - typedef TestMeshEntity< TestVertexEntityTopology, MeshVertexTopology > VertexMeshEntityType; - typedef typename VertexMeshEntityType::PointType PointType; + using TetrahedronMeshEntityType = TestMeshEntity< TestTetrahedronMeshConfig, MeshTetrahedronTopology >; + using TriangleMeshEntityType = TestMeshEntity< TestTetrahedronMeshConfig, typename TetrahedronMeshEntityType::SubentityTraits< 2 >::SubentityTopology >; + using EdgeMeshEntityType = TestMeshEntity< TestTetrahedronMeshConfig, typename TetrahedronMeshEntityType::SubentityTraits< 1 >::SubentityTopology >; + using VertexMeshEntityType = TestMeshEntity< TestTetrahedronMeshConfig, typename TetrahedronMeshEntityType::SubentityTraits< 0 >::SubentityTopology >; + + static_assert( TetrahedronMeshEntityType::SubentityTraits< 2 >::storageEnabled, "Testing tetrahedron entity does not store triangles as required." ); + static_assert( TetrahedronMeshEntityType::SubentityTraits< 1 >::storageEnabled, "Testing tetrahedron entity does not store edges as required." ); + static_assert( TetrahedronMeshEntityType::SubentityTraits< 0 >::storageEnabled, "Testing tetrahedron entity does not store vertices as required." ); + static_assert( TriangleMeshEntityType::SubentityTraits< 1 >::storageEnabled, "Testing triangle entity does not store edges as required." ); + static_assert( TriangleMeshEntityType::SubentityTraits< 0 >::storageEnabled, "Testing triangle entity does not store vertices as required." ); + static_assert( EdgeMeshEntityType::SubentityTraits< 0 >::storageEnabled, "Testing edge entity does not store vertices as required." ); + + using PointType = typename VertexMeshEntityType::PointType; ASSERT_TRUE( PointType::getType() == ( Containers::StaticVector< 3, RealType >::getType() ) ); /**** @@ -343,10 +347,18 @@ TEST( MeshEntityTest, TetragedronMeshEntityTest ) TEST( MeshEntityTest, TwoTrianglesMeshEntityTest ) { - typedef TestMeshEntity< TestTriangleMeshConfig, MeshTriangleTopology > TriangleMeshEntityType; - typedef TestMeshEntity< TestTriangleMeshConfig, MeshEdgeTopology > EdgeMeshEntityType; - typedef TestMeshEntity< TestTriangleMeshConfig, MeshVertexTopology > VertexMeshEntityType; - typedef typename VertexMeshEntityType::PointType PointType; + using TriangleMeshEntityType = TestMeshEntity< TestTriangleMeshConfig, MeshTriangleTopology >; + using EdgeMeshEntityType = TestMeshEntity< TestTriangleMeshConfig, typename TriangleMeshEntityType::SubentityTraits< 1 >::SubentityTopology >; + using VertexMeshEntityType = TestMeshEntity< TestTriangleMeshConfig, typename TriangleMeshEntityType::SubentityTraits< 0 >::SubentityTopology >; + + static_assert( TriangleMeshEntityType::SubentityTraits< 1 >::storageEnabled, "Testing triangle entity does not store edges as required." ); + static_assert( TriangleMeshEntityType::SubentityTraits< 0 >::storageEnabled, "Testing triangle entity does not store vertices as required." ); + static_assert( EdgeMeshEntityType::SubentityTraits< 0 >::storageEnabled, "Testing edge entity does not store vertices as required." ); + static_assert( EdgeMeshEntityType::SuperentityTraits< 2 >::storageEnabled, "Testing edge entity does not store triangles as required." ); + static_assert( VertexMeshEntityType::SuperentityTraits< 2 >::storageEnabled, "Testing vertex entity does not store triangles as required." ); + static_assert( VertexMeshEntityType::SuperentityTraits< 1 >::storageEnabled, "Testing vertex entity does not store edges as required." ); + + using PointType = typename VertexMeshEntityType::PointType; ASSERT_TRUE( PointType::getType() == ( Containers::StaticVector< 2, RealType >::getType() ) ); /****