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

Merge branch 'JK/mesh' into 'develop'

Mesh configuration refactoring

See merge request !106
parents 65f92e99 9fa0f157
Loading
Loading
Loading
Loading
+12 −15
Original line number Diff line number Diff line
@@ -24,10 +24,10 @@ template<> struct MeshCellTopologyTag< MyConfigTag, Topologies::Quadrangle > { e
//template<> struct MeshCellTopologyTag< MyConfigTag, Topologies::Tetrahedron > { enum { enabled = true }; };
//template<> struct MeshCellTopologyTag< MyConfigTag, Topologies::Hexahedron > { enum { enabled = true }; };

// Meshes are enabled only for the world dimension equal to the cell dimension.
template< typename CellTopology, int WorldDimension >
struct MeshWorldDimensionTag< MyConfigTag, CellTopology, WorldDimension >
{ enum { enabled = ( WorldDimension == CellTopology::dimension ) }; };
// Meshes are enabled only for the space dimension equal to the cell dimension.
template< typename CellTopology, int SpaceDimension >
struct MeshSpaceDimensionTag< MyConfigTag, CellTopology, SpaceDimension >
{ enum { enabled = ( SpaceDimension == CellTopology::dimension ) }; };

// Meshes are enabled only for types explicitly listed below.
template<> struct MeshRealTag< MyConfigTag, float > { enum { enabled = false }; };
@@ -41,31 +41,28 @@ template<>
struct MeshConfigTemplateTag< MyConfigTag >
{
   template< typename Cell,
             int WorldDimension = Cell::dimension,
             int SpaceDimension = Cell::dimension,
             typename Real = double,
             typename GlobalIndex = int,
             typename LocalIndex = short int >
   struct MeshConfig
      : public DefaultConfig< Cell, WorldDimension, Real, GlobalIndex, LocalIndex >
      : public DefaultConfig< Cell, SpaceDimension, Real, GlobalIndex, LocalIndex >
   {
      template< typename EntityTopology >
      static constexpr bool subentityStorage( EntityTopology, int SubentityDimension )
      static constexpr bool subentityStorage( int entityDimension, int SubentityDimension )
      {
         return SubentityDimension == 0 && EntityTopology::dimension >= Cell::dimension - 1;
         return SubentityDimension == 0 && entityDimension >= Cell::dimension - 1;
      }

      template< typename EntityTopology >
      static constexpr bool superentityStorage( EntityTopology, int SuperentityDimension )
      static constexpr bool superentityStorage( int entityDimension, int SuperentityDimension )
      {
//         return false;
         return (EntityTopology::dimension == 0 || EntityTopology::dimension == Cell::dimension - 1) && SuperentityDimension == Cell::dimension;
         return (entityDimension == 0 || entityDimension == Cell::dimension - 1) && SuperentityDimension == Cell::dimension;
      }

      template< typename EntityTopology >
      static constexpr bool entityTagsStorage( EntityTopology )
      static constexpr bool entityTagsStorage( int entityDimension )
      {
//         return false;
         return EntityTopology::dimension == 0 || EntityTopology::dimension >= Cell::dimension - 1;
         return entityDimension == 0 || entityDimension >= Cell::dimension - 1;
      }

      static constexpr bool dualGraphStorage()
+4 −5
Original line number Diff line number Diff line
@@ -13,17 +13,16 @@ template<>
struct MeshConfigTemplateTag< MyConfigTag >
{
   template< typename Cell,
             int WorldDimension = Cell::dimension,
             int SpaceDimension = Cell::dimension,
             typename Real = double,
             typename GlobalIndex = int,
             typename LocalIndex = short int >
   struct MeshConfig
      : public DefaultConfig< Cell, WorldDimension, Real, GlobalIndex, LocalIndex >
      : public DefaultConfig< Cell, SpaceDimension, Real, GlobalIndex, LocalIndex >
   {
      template< typename EntityTopology >
      static constexpr bool subentityStorage( EntityTopology, int SubentityDimension )
      static constexpr bool subentityStorage( int entityDimension, int subentityDimension )
      {
         return SubentityDimension == 0 && EntityTopology::dimension >= Cell::dimension - 1;
         return subentityDimension == 0 && entityDimension >= Cell::dimension - 1;
      }
   };
};
+7 −11
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ namespace Meshes {
 * Basic structure for mesh configuration.
 */
template< typename Cell,
          int WorldDimension = Cell::dimension,
          int SpaceDimension = Cell::dimension,
          typename Real = double,
          typename GlobalIndex = int,
          typename LocalIndex = short int >
@@ -36,14 +36,13 @@ struct DefaultConfig
   using GlobalIndexType = GlobalIndex;
   using LocalIndexType = LocalIndex;

   static constexpr int worldDimension = WorldDimension;
   static constexpr int spaceDimension = SpaceDimension;
   static constexpr int meshDimension = Cell::dimension;

   /****
    * Storage of subentities of mesh entities.
    */
   template< typename EntityTopology >
   static constexpr bool subentityStorage( EntityTopology, int SubentityDimension )
   static constexpr bool subentityStorage( int entityDimension, int subentityDimension )
   {
      return true;
      // Subvertices must be stored for all entities which appear in other
@@ -54,8 +53,7 @@ struct DefaultConfig
   /****
    * Storage of superentities of mesh entities.
    */
   template< typename EntityTopology >
   static constexpr bool superentityStorage( EntityTopology, int SuperentityDimension )
   static constexpr bool superentityStorage( int entityDimension, int superentityDimension )
   {
      return true;
   }
@@ -69,12 +67,10 @@ struct DefaultConfig
    *    - if dim(entity) < dim(face), the entities on which the tags are stored
    *      must be stored as subentities of faces
    */
   template< typename EntityTopology >
   static constexpr bool entityTagsStorage( EntityTopology )
   static constexpr bool entityTagsStorage( int entityDimension )
   {
      using FaceTopology = typename Topologies::Subtopology< CellTopology, meshDimension - 1 >::Topology;
      return superentityStorage( FaceTopology(), meshDimension ) &&
             ( EntityTopology::dimension >= meshDimension - 1 || subentityStorage( FaceTopology(), EntityTopology::dimension ) );
      return superentityStorage( meshDimension - 1, meshDimension ) &&
             ( entityDimension >= meshDimension - 1 || subentityStorage( meshDimension - 1, entityDimension ) );
      //return false;
   }

+2 −2
Original line number Diff line number Diff line
@@ -90,9 +90,9 @@ public:
   using Face = typename MeshType::template EntityType< getMeshDimension() - 1 >;
   using Vertex = typename MeshType::template EntityType< 0 >;

   static_assert( Mesh::Config::entityTagsStorage( typename Cell::EntityTopology{} ),
   static_assert( Mesh::Config::entityTagsStorage( getMeshDimension() ),
                  "DistributedMesh must store entity tags on cells" );
   static_assert( Mesh::Config::entityTagsStorage( typename Vertex::EntityTopology{} ),
   static_assert( Mesh::Config::entityTagsStorage( 0 ),
                  "DistributedMesh must store entity tags on vertices" );


+2 −2
Original line number Diff line number Diff line
@@ -99,7 +99,7 @@ getOutwardNormalVector( const Mesh< MeshConfig, Device > & mesh,
   using FaceType = MeshEntity< MeshConfig, Device, Topologies::Edge >;
   using PointType = typename MeshTraits< MeshConfig >::PointType;
   static_assert( std::is_same< typename MeshType::Face, FaceType >::value, "getOutwardNormalVector called for an entity which is not a face" );
   static_assert( MeshConfig::worldDimension == 2, "TODO: normal vectors for 2D meshes in a 3D space are not implemented yet" );
   static_assert( MeshConfig::spaceDimension == 2, "TODO: normal vectors for 2D meshes in a 3D space are not implemented yet" );

   const auto& v0 = mesh.getPoint( face.template getSubentityIndex< 0 >( 0 ) );
   const auto& v1 = mesh.getPoint( face.template getSubentityIndex< 0 >( 1 ) );
@@ -125,7 +125,7 @@ getOutwardNormalVector( const Mesh< MeshConfig, Device > & mesh,
   using FaceType = MeshEntity< MeshConfig, Device, EntityTopology >;
   using PointType = typename MeshTraits< MeshConfig >::PointType;
   static_assert( std::is_same< typename MeshType::Face, FaceType >::value, "getOutwardNormalVector called for an entity which is not a face" );
   static_assert( MeshConfig::worldDimension == 3, "general overload intended for 3D was called with the wrong world dimension" );
   static_assert( MeshConfig::spaceDimension == 3, "general overload intended for 3D was called with the wrong space dimension" );

   const auto& v0 = mesh.getPoint( face.template getSubentityIndex< 0 >( 0 ) );
   const auto& v1 = mesh.getPoint( face.template getSubentityIndex< 0 >( 1 ) );
Loading