Commit 98e54256 authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Refactoring mesh configuration: removed entityStorage

Consequently, we always store the numbers of all entities, even those
that don't have any subentity or superentity mappings enabled.
parent a266aaf4
Loading
Loading
Loading
Loading
+7 −30
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

#pragma once

#include <TNL/String.h>
#include <TNL/TypeInfo.h>
#include <TNL/Meshes/Topologies/SubentityVertexMap.h>

namespace TNL {
@@ -25,9 +23,6 @@ namespace Meshes {

/****
 * Basic structure for mesh configuration.
 * Setting Id to GlobalIndex enables storage of entity Id.
 * It means that each mesh entity stores its index in its
 * mesh storage layer.
 */
template< typename Cell,
          int WorldDimension = Cell::dimension,
@@ -44,30 +39,16 @@ struct DefaultConfig
   static constexpr int worldDimension = WorldDimension;
   static constexpr int meshDimension = Cell::dimension;

   /****
    * Storage of mesh entities.
    */
   static constexpr bool entityStorage( int dimension )
   {
      /****
       * Vertices and cells must always be stored.
       */
      return true;
      //return ( dimension == 0 || dimension == cellDimension );
   }

   /****
    * Storage of subentities of mesh entities.
    */
   template< typename EntityTopology >
   static constexpr bool subentityStorage( EntityTopology, int SubentityDimension )
   {
      /****
       *  Subvertices of all stored entities must always be stored
       */
      return entityStorage( EntityTopology::dimension );
      //return entityStorage( EntityTopology::dimension ) &&
      //       SubentityDimension == 0;
      return true;
      // Subvertices must be stored for all entities which appear in other
      // subentity or superentity mappings.
      //return SubentityDimension == 0;
   }

   /****
@@ -77,7 +58,7 @@ struct DefaultConfig
   template< typename EntityTopology >
   static constexpr bool subentityOrientationStorage( EntityTopology, int SubentityDimension )
   {
      return ( SubentityDimension > 0 );
      return SubentityDimension > 0 && SubentityDimension < meshDimension;
   }

   /****
@@ -86,8 +67,7 @@ struct DefaultConfig
   template< typename EntityTopology >
   static constexpr bool superentityStorage( EntityTopology, int SuperentityDimension )
   {
      return entityStorage( EntityTopology::dimension );
      //return false;
      return true;
   }

   /****
@@ -95,18 +75,15 @@ struct DefaultConfig
    *
    * The configuration must satisfy the following necessary conditions in
    * order to provide boundary tags:
    *    - faces must be stored
    *    - faces must store the cell indices in the superentity layer
    *    - if dim(entity) < dim(face), the entities on which the tags are stored
    *      must be stored as subentities of faces
    * TODO: check this in the ConfigValidator
    */
   template< typename EntityTopology >
   static constexpr bool boundaryTagsStorage( EntityTopology )
   {
      using FaceTopology = typename Topologies::Subtopology< CellTopology, meshDimension - 1 >::Topology;
      return entityStorage( meshDimension - 1 ) &&
             superentityStorage( FaceTopology(), meshDimension ) &&
      return superentityStorage( FaceTopology(), meshDimension ) &&
             ( EntityTopology::dimension >= meshDimension - 1 || subentityStorage( FaceTopology(), EntityTopology::dimension ) );
      //return false;
   }
+0 −3
Original line number Diff line number Diff line
@@ -117,9 +117,6 @@ class Mesh
      /**
       * Entities
       */
      template< int Dimension >
      static constexpr bool entitiesAvailable();

      template< int Dimension >
      __cuda_callable__
      GlobalIndexType getEntitiesCount() const;
+13 −25
Original line number Diff line number Diff line
@@ -29,11 +29,11 @@ class ConfigValidatorSubtopologyLayer
   : public ConfigValidatorSubtopologyLayer< MeshConfig, EntityTopology, typename DimensionTag::Decrement >
{
   static_assert( ! MeshConfig::subentityStorage( EntityTopology(), DimensionTag::value ) ||
                    MeshConfig::entityStorage( EntityTopology::dimension ),
                  "entities of which subentities are stored must be stored" );
                    MeshConfig::subentityStorage( EntityTopology(), 0 ),
                  "entities of which subentities are stored must store their subvertices" );
   static_assert( ! MeshConfig::subentityStorage( EntityTopology(), DimensionTag::value ) ||
                    MeshConfig::entityStorage( DimensionTag::value ),
                  "entities that are stored as subentities must be stored");
                    MeshConfig::subentityStorage( EntityTopology(), 0 ),
                  "entities that are stored as subentities must store their subvertices" );
   static_assert( ! MeshConfig::subentityOrientationStorage( EntityTopology(), DimensionTag::value ) ||
                    MeshConfig::subentityStorage( EntityTopology(), DimensionTag::value ),
                  "orientation can be stored only for subentities that are stored");
@@ -43,9 +43,6 @@ template< typename MeshConfig,
          typename EntityTopology >
class ConfigValidatorSubtopologyLayer< MeshConfig, EntityTopology, DimensionTag< 0 > >
{
   static_assert( ! MeshConfig::subentityStorage( EntityTopology(), 0 ) ||
                    MeshConfig::entityStorage( EntityTopology::dimension ),
                  "entities of which subvertices are stored must be stored" );
   static_assert( ! MeshConfig::subentityOrientationStorage( EntityTopology(), 0 ),
                  "storage of vertex orientation does not make sense" );
};
@@ -58,11 +55,11 @@ class ConfigValidatorSupertopologyLayer
   : public ConfigValidatorSupertopologyLayer< MeshConfig, EntityTopology, typename DimensionTag::Decrement >
{
   static_assert( ! MeshConfig::superentityStorage( EntityTopology(), DimensionTag::value ) ||
                    MeshConfig::entityStorage( EntityTopology::dimension ),
                  "entities of which superentities are stored must be stored");
                    MeshConfig::subentityStorage( EntityTopology(), 0 ),
                  "entities of which superentities are stored must store their subvertices");
   static_assert( ! MeshConfig::superentityStorage( EntityTopology(), DimensionTag::value ) ||
                    MeshConfig::entityStorage( DimensionTag::value ),
                  "entities that are stored as superentities must be stored");
                    MeshConfig::subentityStorage( EntityTopology(), 0 ),
                  "entities that are stored as superentities must store their subvertices");
};

template< typename MeshConfig,
@@ -80,13 +77,7 @@ class ConfigValidatorLayer
     public ConfigValidatorSupertopologyLayer< MeshConfig,
                                               typename Topologies::Subtopology< typename MeshConfig::CellTopology, dimension >::Topology,
                                               DimensionTag< MeshConfig::CellTopology::dimension > >
{
   using Topology = typename Topologies::Subtopology< typename MeshConfig::CellTopology, dimension >::Topology;

   static_assert( ! MeshConfig::entityStorage( dimension ) ||
                    MeshConfig::subentityStorage( Topology(), 0 ),
                  "subvertices of all stored entities must be stored");
};
{};

template< typename MeshConfig >
class ConfigValidatorLayer< MeshConfig, 0 >
@@ -101,11 +92,11 @@ class ConfigValidatorLayerCell
                                             DimensionTag< MeshConfig::CellTopology::dimension - 1 > >
{
   using CellTopology = typename MeshConfig::CellTopology;
   static constexpr int dimension = CellTopology::dimension;

   static_assert( ! MeshConfig::entityStorage( dimension ) ||
                    MeshConfig::subentityStorage( CellTopology(), 0 ),
                  "subvertices of all stored entities must be stored" );
   static_assert( MeshConfig::subentityStorage( CellTopology(), 0 ),
                  "subvertices of cells must be stored" );
   static_assert( ! MeshConfig::subentityOrientationStorage( CellTopology(), 0 ),
                  "storage of cell orientation does not make sense" );
};

template< typename MeshConfig >
@@ -116,9 +107,6 @@ class ConfigValidator

   static_assert( 1 <= meshDimension, "zero dimensional meshes are not supported" );
   static_assert( meshDimension <= MeshConfig::worldDimension, "world dimension must not be less than mesh dimension" );

   static_assert( MeshConfig::entityStorage( 0 ), "mesh vertices must be stored" );
   static_assert( MeshConfig::entityStorage( meshDimension ), "mesh cells must be stored" );
};

} // namespace Meshes
+0 −2
Original line number Diff line number Diff line
@@ -24,8 +24,6 @@ class ConfigValidatorBoundaryTagsLayer
{
   using FaceTopology = typename Topologies::Subtopology< typename MeshConfig::CellTopology, MeshConfig::meshDimension - 1 >::Topology;

   static_assert( MeshConfig::entityStorage( MeshConfig::meshDimension - 1 ),
                  "Faces must be stored when any entity has boundary tags." );
   static_assert( MeshConfig::superentityStorage( FaceTopology(), MeshConfig::meshDimension ),
                  "Faces must store the cell superentity indices when any entity has boundary tags." );
   static_assert( EntityTopology::dimension >= MeshConfig::meshDimension - 1 || MeshConfig::subentityStorage( FaceTopology(), EntityTopology::dimension ),
+16 −22
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ namespace Meshes {
template< typename MeshConfig,
          typename Device,
          typename DimensionTag,
          bool EntityStorage = WeakEntityStorageTrait< MeshConfig, Device, DimensionTag >::storageEnabled >
          bool EntityStorage = (DimensionTag::value <= MeshConfig::meshDimension) >
class StorageLayer;


@@ -44,6 +44,9 @@ class StorageLayerFamily
   template< int Dimension, int Subdimension >
   using SubentityTraits = typename MeshTraitsType::template SubentityTraits< typename EntityTraits< Dimension >::EntityTopology, Subdimension >;

   template< int Dimension, int Superdimension >
   using SuperentityTraits = typename MeshTraitsType::template SuperentityTraits< typename EntityTraits< Dimension >::EntityTopology, Superdimension >;

protected:
   typename MeshTraitsType::PointArrayType points;

@@ -113,7 +116,6 @@ public:
   template< int Dimension >
   void setEntitiesCount( const typename MeshTraitsType::GlobalIndexType& entitiesCount )
   {
      static_assert( EntityTraits< Dimension >::storageEnabled, "You try to set number of entities which are not configured for storage." );
      BaseType::setEntitiesCount( DimensionTag< Dimension >(), entitiesCount );
      if( Dimension == 0 )
         points.setSize( entitiesCount );
@@ -124,8 +126,9 @@ public:
   typename MeshTraitsType::template SubentityTraits< typename EntityTraits< Dimension >::EntityTopology, Subdimension >::StorageNetworkType&
   getSubentityStorageNetwork()
   {
      static_assert( EntityTraits< Dimension >::storageEnabled, "You try to get subentity storage of entities which are not configured for storage." );
      static_assert( Dimension > Subdimension, "Invalid combination of Dimension and Subdimension." );
      static_assert( SubentityTraits< Dimension, Subdimension >::storageEnabled,
                     "You try to get subentity storage network which is disabled in the mesh configuration." );
      using BaseType = SubentityStorageLayerFamily< MeshConfig,
                                                   Device,
                                                   typename EntityTraits< Dimension >::EntityTopology >;
@@ -137,8 +140,9 @@ public:
   const typename MeshTraitsType::template SubentityTraits< typename EntityTraits< Dimension >::EntityTopology, Subdimension >::StorageNetworkType&
   getSubentityStorageNetwork() const
   {
      static_assert( EntityTraits< Dimension >::storageEnabled, "You try to get subentity storage of entities which are not configured for storage." );
      static_assert( Dimension > Subdimension, "Invalid combination of Dimension and Subdimension." );
      static_assert( SubentityTraits< Dimension, Subdimension >::storageEnabled,
                     "You try to get subentity storage network which is disabled in the mesh configuration." );
      using BaseType = SubentityStorageLayerFamily< MeshConfig,
                                                   Device,
                                                   typename EntityTraits< Dimension >::EntityTopology >;
@@ -150,8 +154,9 @@ public:
   typename MeshTraitsType::template SuperentityTraits< typename EntityTraits< Dimension >::EntityTopology, Superdimension >::StorageNetworkType&
   getSuperentityStorageNetwork()
   {
      static_assert( EntityTraits< Dimension >::storageEnabled, "You try to get superentity storage of entities which are not configured for storage." );
      static_assert( Dimension < Superdimension, "Invalid combination of Dimension and Superdimension." );
      static_assert( SuperentityTraits< Dimension, Superdimension >::storageEnabled,
                     "You try to get superentity storage network which is disabled in the mesh configuration." );
      using BaseType = SuperentityStorageLayerFamily< MeshConfig,
                                                     Device,
                                                     typename EntityTraits< Dimension >::EntityTopology >;
@@ -163,8 +168,9 @@ public:
   const typename MeshTraitsType::template SuperentityTraits< typename EntityTraits< Dimension >::EntityTopology, Superdimension >::StorageNetworkType&
   getSuperentityStorageNetwork() const
   {
      static_assert( EntityTraits< Dimension >::storageEnabled, "You try to get superentity storage of entities which are not configured for storage." );
      static_assert( Dimension < Superdimension, "Invalid combination of Dimension and Superdimension." );
      static_assert( SuperentityTraits< Dimension, Superdimension >::storageEnabled,
                     "You try to get superentity storage network which is disabled in the mesh configuration." );
      using BaseType = SuperentityStorageLayerFamily< MeshConfig,
                                                     Device,
                                                     typename EntityTraits< Dimension >::EntityTopology >;
@@ -176,7 +182,8 @@ public:
   typename SubentityTraits< Dimension, Subdimension >::IdPermutationArrayType
   getSubentityOrientation( typename MeshTraitsType::GlobalIndexType entityIndex, typename MeshTraitsType::LocalIndexType localIndex ) const
   {
      static_assert( SubentityTraits< Dimension, Subdimension >::orientationEnabled, "You try to get subentity orientation which is not configured for storage." );
      static_assert( SubentityTraits< Dimension, Subdimension >::orientationEnabled,
                     "You try to get subentity orientation which is not configured for storage." );
      return BaseType::getSubentityOrientation( DimensionTag< Dimension >(), DimensionTag< Subdimension >(), entityIndex, localIndex );
   }

@@ -185,7 +192,8 @@ public:
   typename SubentityTraits< Dimension, Subdimension >::OrientationArrayType&
   subentityOrientationsArray( typename MeshTraitsType::GlobalIndexType entityIndex )
   {
      static_assert( SubentityTraits< Dimension, Subdimension >::orientationEnabled, "You try to get subentity orientation which is not configured for storage." );
      static_assert( SubentityTraits< Dimension, Subdimension >::orientationEnabled,
                     "You try to get subentity orientation which is not configured for storage." );
      return BaseType::subentityOrientationsArray( DimensionTag< Dimension >(), DimensionTag< Subdimension >(), entityIndex );
   }
};
@@ -313,20 +321,6 @@ protected:
   friend class StorageLayer;
};

template< typename MeshConfig,
          typename Device,
          typename DimensionTag >
class StorageLayer< MeshConfig, Device, DimensionTag, false >
   : public StorageLayer< MeshConfig, Device, typename DimensionTag::Increment >
{
   using BaseType = StorageLayer< MeshConfig, Device, typename DimensionTag::Increment >;
public:
   // inherit constructors and assignment operators (including templated versions)
   using BaseType::BaseType;
   using BaseType::operator=;
};

// termination of recursive inheritance (everything is reduced to EntityStorage == false thanks to the WeakEntityStorageTrait)
template< typename MeshConfig,
          typename Device >
class StorageLayer< MeshConfig, Device, DimensionTag< MeshConfig::meshDimension + 1 >, false >
Loading