Commit b75fd3f2 authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Added static assertion to MeshEntity

parent ed40305c
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -37,6 +37,9 @@ class MeshEntity
     protected MeshSuperentityAccess< MeshConfig, EntityTopology_ >,
     public MeshEntityIndex< typename MeshConfig::IdType >
{
   static_assert( is_compatible_topology< typename MeshConfig::CellTopology, EntityTopology_ >::value,
                  "Specified entity topology is not compatible with the MeshConfig." );

   public:
      using MeshTraitsType  = MeshTraits< MeshConfig >;
      using EntityTopology  = EntityTopology_;
+19 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

#pragma once

#include <type_traits>

#include <TNL/Meshes/DimensionTag.h>

namespace TNL {
@@ -50,5 +52,22 @@ struct MeshEntityTopology< MeshConfig, DimensionTag< MeshConfig::CellTopology::d
   using Topology = typename MeshConfig::CellTopology;
};


/* Helper struct to determine if one topology is compatible with another one. */
template< typename Supertopology, typename Subtopology >
struct is_compatible_topology
{
   static_assert( Supertopology::dimension >= Subtopology::dimension,
                  "wrong order of topologies in template parameters" );
   static constexpr bool value = std::is_same< typename MeshSubtopology< Supertopology, Subtopology::dimension >::Topology,
                                               Subtopology >::value;
};

template< typename Supertopology >
struct is_compatible_topology< Supertopology, Supertopology >
{
   static constexpr bool value = true;
};

} // namespace Meshes
} // namespace TNL