Commit fb71dff8 authored by Ján Bobot's avatar Ján Bobot Committed by Jakub Klinkovský
Browse files

mesh refactoring: moved points from StorageLayerFamily to Mesh, replaced...

mesh refactoring: moved points from StorageLayerFamily to Mesh, replaced template argument EntityTopology of SubentityStorageLayerFamily and SuperentityStorageLayerFamily by DimensionTag
parent 2a391c06
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -126,6 +126,9 @@ class Mesh
      __cuda_callable__
      EntityType< Dimension > getEntity( const GlobalIndexType entityIndex ) const;

      template< int Dimension >
      void setEntitiesCount( const typename MeshTraitsType::GlobalIndexType& entitiesCount );

      // duplicated for compatibility with grids
      template< typename EntityType >
      __cuda_callable__
@@ -138,6 +141,10 @@ class Mesh
      /**
       * \brief Returns the spatial coordinates of the vertex with given index.
       */
      const typename MeshTraitsType::PointArrayType& getPoints() const;

      typename MeshTraitsType::PointArrayType& getPoints();

      __cuda_callable__
      const PointType& getPoint( const GlobalIndexType vertexIndex ) const;

@@ -268,9 +275,7 @@ class Mesh
      void writeProlog( Logger& logger ) const;

   protected:
      // Methods for the mesh initializer
      using StorageBaseType::getPoints;
      using StorageBaseType::setEntitiesCount;
      typename MeshTraitsType::PointArrayType points;

      friend Initializer< MeshConfig >;

+32 −1
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ Mesh( const Mesh& mesh )
   : StorageBaseType( mesh ),
     EntityTagsLayerFamily( mesh )
{
   points = mesh.getPoints();
}

template< typename MeshConfig, typename Device >
@@ -54,6 +55,7 @@ Mesh( const Mesh< MeshConfig, Device_ >& mesh )
   : StorageBaseType( mesh ),
     EntityTagsLayerFamily( mesh )
{
   points = mesh.getPoints();
}

template< typename MeshConfig, typename Device >
@@ -61,6 +63,7 @@ Mesh< MeshConfig, Device >&
Mesh< MeshConfig, Device >::
operator=( const Mesh& mesh )
{
   points = mesh.getPoints();
   StorageBaseType::operator=( mesh );
   EntityTagsLayerFamily::operator=( mesh );
   return *this;
@@ -72,6 +75,7 @@ Mesh< MeshConfig, Device >&
Mesh< MeshConfig, Device >::
operator=( const Mesh< MeshConfig, Device_ >& mesh )
{
   points = mesh.getPoints();
   StorageBaseType::operator=( mesh );
   EntityTagsLayerFamily::operator=( mesh );
   return *this;
@@ -106,6 +110,16 @@ getEntity( const GlobalIndexType entityIndex ) const
   return EntityType< Dimension >( *this, entityIndex );
}

template< typename MeshConfig, typename Device >
   template< int Dimension >
void
Mesh< MeshConfig, Device >:: 
setEntitiesCount( const typename MeshTraitsType::GlobalIndexType& entitiesCount )
{
   StorageBaseType::setEntitiesCount( DimensionTag< Dimension >(), entitiesCount );
   if( Dimension == 0 )
      points.setSize( entitiesCount );
}

// duplicated for compatibility with grids
template< typename MeshConfig, typename Device >
@@ -128,6 +142,21 @@ getEntity( const GlobalIndexType entityIndex ) const
   return getEntity< Entity::getEntityDimension() >( entityIndex );
}

template< typename MeshConfig, typename Device >
const typename Mesh< MeshConfig, Device >::MeshTraitsType::PointArrayType&
Mesh< MeshConfig, Device >::
getPoints() const
{
   return points;
}

template< typename MeshConfig, typename Device >
typename Mesh< MeshConfig, Device >::MeshTraitsType::PointArrayType&
Mesh< MeshConfig, Device >::
getPoints()
{
   return points;
}

template< typename MeshConfig, typename Device >
__cuda_callable__
@@ -330,6 +359,7 @@ void
Mesh< MeshConfig, Device >::
print( std::ostream& str ) const
{
   str << "Vertex coordinates are: " << points << std::endl;
   StorageBaseType::print( str );
   EntityTagsLayerFamily::print( str );
}
@@ -339,7 +369,8 @@ bool
Mesh< MeshConfig, Device >::
operator==( const Mesh& mesh ) const
{
   return StorageBaseType::operator==( mesh ) &&
   return points == mesh.points &&
          StorageBaseType::operator==( mesh ) &&
          EntityTagsLayerFamily::operator==( mesh );
}

+19 −45
Original line number Diff line number Diff line
@@ -48,9 +48,6 @@ class StorageLayerFamily
   template< int Dimension, int Superdimension >
   using SuperentityTraits = typename MeshTraitsType::template SuperentityTraits< typename EntityTraits< Dimension >::EntityTopology, Superdimension >;

protected:
   typename MeshTraitsType::PointArrayType points;

public:
   StorageLayerFamily() = default;

@@ -67,7 +64,6 @@ public:

   StorageLayerFamily& operator=( const StorageLayerFamily& layer )
   {
      points = layer.getPoints();
      BaseType::operator=( layer );
      DualGraphLayer< MeshConfig, Device >::operator=( layer );
      return *this;
@@ -76,7 +72,6 @@ public:
   template< typename Device_ >
   StorageLayerFamily& operator=( const StorageLayerFamily< MeshConfig, Device_ >& layer )
   {
      points = layer.getPoints();
      BaseType::operator=( layer );
      DualGraphLayer< MeshConfig, Device >::operator=( layer );
      return *this;
@@ -84,35 +79,10 @@ public:

   bool operator==( const StorageLayerFamily& layer ) const
   {
      return ( points == layer.points &&
               BaseType::operator==( layer ) &&
      return ( BaseType::operator==( layer ) &&
               DualGraphLayer< MeshConfig, Device >::operator==( layer ) );
   }

   void print( std::ostream& str ) const
   {
      str << "Vertex coordinates are: " << points << std::endl;
      BaseType::print( str );
   }

   const typename MeshTraitsType::PointArrayType& getPoints() const
   {
      return points;
   }

   typename MeshTraitsType::PointArrayType& getPoints()
   {
      return points;
   }

   template< int Dimension >
   void setEntitiesCount( const typename MeshTraitsType::GlobalIndexType& entitiesCount )
   {
      BaseType::setEntitiesCount( DimensionTag< Dimension >(), entitiesCount );
      if( Dimension == 0 )
         points.setSize( entitiesCount );
   }

   template< int Dimension, int Subdimension >
   __cuda_callable__
   typename MeshTraitsType::LocalIndexType
@@ -123,7 +93,7 @@ public:
                     "You try to get subentities count for subentities which are disabled in the mesh configuration." );
      using BaseType = SubentityStorageLayerFamily< MeshConfig,
                                                    Device,
                                                   typename EntityTraits< Dimension >::EntityTopology >;
                                                    DimensionTag< Dimension > >;
      return BaseType::template getSubentitiesCount< Subdimension >();
   }

@@ -137,7 +107,7 @@ public:
                     "You try to get subentities matrix which is disabled in the mesh configuration." );
      using BaseType = SubentityStorageLayerFamily< MeshConfig,
                                                    Device,
                                                   typename EntityTraits< Dimension >::EntityTopology >;
                                                    DimensionTag< Dimension > >;
      return BaseType::template getSubentitiesMatrix< Subdimension >();
   }

@@ -151,7 +121,7 @@ public:
                     "You try to get subentities matrix which is disabled in the mesh configuration." );
      using BaseType = SubentityStorageLayerFamily< MeshConfig,
                                                    Device,
                                                   typename EntityTraits< Dimension >::EntityTopology >;
                                                    DimensionTag< Dimension > >;
      return BaseType::template getSubentitiesMatrix< Subdimension >();
   }

@@ -165,7 +135,7 @@ public:
                     "You try to get superentities counts array which is disabled in the mesh configuration." );
      using BaseType = SuperentityStorageLayerFamily< MeshConfig,
                                                     Device,
                                                     typename EntityTraits< Dimension >::EntityTopology >;
                                                     DimensionTag< Dimension > >;
      return BaseType::template getSuperentitiesCountsArray< Superdimension >();
   }

@@ -179,7 +149,7 @@ public:
                     "You try to get superentities counts array which is disabled in the mesh configuration." );
      using BaseType = SuperentityStorageLayerFamily< MeshConfig,
                                                     Device,
                                                     typename EntityTraits< Dimension >::EntityTopology >;
                                                     DimensionTag< Dimension > >;
      return BaseType::template getSuperentitiesCountsArray< Superdimension >();
   }

@@ -193,7 +163,7 @@ public:
                     "You try to get superentities matrix which is disabled in the mesh configuration." );
      using BaseType = SuperentityStorageLayerFamily< MeshConfig,
                                                     Device,
                                                     typename EntityTraits< Dimension >::EntityTopology >;
                                                     DimensionTag< Dimension > >;
      return BaseType::template getSuperentitiesMatrix< Superdimension >();
   }

@@ -207,7 +177,7 @@ public:
                     "You try to get superentities matrix which is disabled in the mesh configuration." );
      using BaseType = SuperentityStorageLayerFamily< MeshConfig,
                                                     Device,
                                                     typename EntityTraits< Dimension >::EntityTopology >;
                                                     DimensionTag< Dimension > >;
      return BaseType::template getSuperentitiesMatrix< Superdimension >();
   }
};
@@ -221,11 +191,14 @@ class StorageLayer< MeshConfig,
                    DimensionTag,
                    true >
   : public SubentityStorageLayerFamily< MeshConfig,
                                         Device,
                                         DimensionTag >,
     public SubentityOrientationsLayerFamily< MeshConfig,
                                              Device,
                                              typename MeshTraits< MeshConfig, Device >::template EntityTraits< DimensionTag::value >::EntityTopology >,
     public SuperentityStorageLayerFamily< MeshConfig,
                                           Device,
                                           typename MeshTraits< MeshConfig, Device >::template EntityTraits< DimensionTag::value >::EntityTopology >,
                                           DimensionTag >,
     public StorageLayer< MeshConfig, Device, typename DimensionTag::Increment >
{
public:
@@ -235,8 +208,9 @@ public:
   using EntityTraitsType = typename MeshTraitsType::template EntityTraits< DimensionTag::value >;
   using EntityType       = typename EntityTraitsType::EntityType;
   using EntityTopology   = typename EntityTraitsType::EntityTopology;
   using SubentityStorageBaseType = SubentityStorageLayerFamily< MeshConfig, Device, EntityTopology >;
   using SuperentityStorageBaseType = SuperentityStorageLayerFamily< MeshConfig, Device, EntityTopology >;
   using SubentityStorageBaseType = SubentityStorageLayerFamily< MeshConfig, Device, DimensionTag >;
   using SubentityOrientationsBaseType = SubentityOrientationsLayerFamily< MeshConfig, Device, EntityTopology >;
   using SuperentityStorageBaseType = SuperentityStorageLayerFamily< MeshConfig, Device, DimensionTag >;

   StorageLayer() = default;

+27 −26
Original line number Diff line number Diff line
@@ -26,18 +26,18 @@ namespace Meshes {

template< typename MeshConfig,
          typename Device,
          typename EntityTopology,
          typename EntityTopologyDimensionTag,
          typename SubdimensionTag,
          bool SubentityStorage = WeakSubentityStorageTrait< MeshConfig, Device, EntityTopology, SubdimensionTag >::storageEnabled >
          bool SubentityStorage = WeakSubentityStorageTrait< MeshConfig, Device, typename MeshTraits< MeshConfig, Device >::template EntityTraits< EntityTopologyDimensionTag::value >::EntityTopology, SubdimensionTag >::storageEnabled >
class SubentityStorageLayer;

template< typename MeshConfig,
          typename Device,
          typename EntityTopology >
          typename EntityTopologyDimensionTag >
class SubentityStorageLayerFamily
   : public SubentityStorageLayer< MeshConfig, Device, EntityTopology, DimensionTag< 0 > >
   : public SubentityStorageLayer< MeshConfig, Device, EntityTopologyDimensionTag, DimensionTag< 0 > >
{
   using BaseType = SubentityStorageLayer< MeshConfig, Device, EntityTopology, DimensionTag< 0 > >;
   using BaseType = SubentityStorageLayer< MeshConfig, Device, EntityTopologyDimensionTag, DimensionTag< 0 > >;
   using MeshTraitsType = MeshTraits< MeshConfig, Device >;

public:
@@ -51,7 +51,7 @@ protected:
   typename MeshTraitsType::LocalIndexType
   getSubentitiesCount() const
   {
      static_assert( EntityTopology::dimension > Subdimension, "Invalid combination of Dimension and Subdimension." );
      static_assert( EntityTopologyDimensionTag::value > Subdimension, "Invalid combination of Dimension and Subdimension." );
      return BaseType::getSubentitiesCount( DimensionTag< Subdimension >() );
   }

@@ -60,7 +60,7 @@ protected:
   typename MeshTraitsType::SubentityMatrixType&
   getSubentitiesMatrix()
   {
      static_assert( EntityTopology::dimension > Subdimension, "Invalid combination of Dimension and Subdimension." );
      static_assert( EntityTopologyDimensionTag::value > Subdimension, "Invalid combination of Dimension and Subdimension." );
      return BaseType::getSubentitiesMatrix( DimensionTag< Subdimension >() );
   }

@@ -69,23 +69,23 @@ protected:
   const typename MeshTraitsType::SubentityMatrixType&
   getSubentitiesMatrix() const
   {
      static_assert( EntityTopology::dimension > Subdimension, "Invalid combination of Dimension and Subdimension." );
      static_assert( EntityTopologyDimensionTag::value > Subdimension, "Invalid combination of Dimension and Subdimension." );
      return BaseType::getSubentitiesMatrix( DimensionTag< Subdimension >() );
   }
};

template< typename MeshConfig,
          typename Device,
          typename EntityTopology,
          typename EntityTopologyDimensionTag,
          typename SubdimensionTag >
class SubentityStorageLayer< MeshConfig,
                             Device,
                             EntityTopology,
                             EntityTopologyDimensionTag,
                             SubdimensionTag,
                             true >
   : public SubentityStorageLayer< MeshConfig, Device, EntityTopology, typename SubdimensionTag::Increment >
   : public SubentityStorageLayer< MeshConfig, Device, EntityTopologyDimensionTag, typename SubdimensionTag::Increment >
{
   using BaseType = SubentityStorageLayer< MeshConfig, Device, EntityTopology, typename SubdimensionTag::Increment >;
   using BaseType = SubentityStorageLayer< MeshConfig, Device, EntityTopologyDimensionTag, typename SubdimensionTag::Increment >;
   using MeshTraitsType      = MeshTraits< MeshConfig, Device >;

protected:
@@ -101,7 +101,7 @@ protected:
   }

   template< typename Device_ >
   SubentityStorageLayer( const SubentityStorageLayer< MeshConfig, Device_, EntityTopology, SubdimensionTag >& other )
   SubentityStorageLayer( const SubentityStorageLayer< MeshConfig, Device_, EntityTopologyDimensionTag, SubdimensionTag >& other )
   {
      operator=( other );
   }
@@ -114,7 +114,7 @@ protected:
   }

   template< typename Device_ >
   SubentityStorageLayer& operator=( const SubentityStorageLayer< MeshConfig, Device_, EntityTopology, SubdimensionTag >& other )
   SubentityStorageLayer& operator=( const SubentityStorageLayer< MeshConfig, Device_, EntityTopologyDimensionTag, SubdimensionTag >& other )
   {
      BaseType::operator=( other );
      matrix = other.matrix;
@@ -125,7 +125,7 @@ protected:
   void print( std::ostream& str ) const
   {
      BaseType::print( str );
      str << "Adjacency matrix for subentities with dimension " << SubdimensionTag::value << " of entities with dimension " << EntityTopology::dimension << " is: " << std::endl;
      str << "Adjacency matrix for subentities with dimension " << SubdimensionTag::value << " of entities with dimension " << EntityTopologyDimensionTag::value << " is: " << std::endl;
      str << matrix << std::endl;
   }

@@ -140,6 +140,7 @@ protected:
   __cuda_callable__
   LocalIndexType getSubentitiesCount( SubdimensionTag ) const
   {
      using EntityTopology = typename MeshTraits< MeshConfig, Device >::template EntityTraits< EntityTopologyDimensionTag::value >::EntityTopology;
      using SubentityTraitsType = typename MeshTraitsType::template SubentityTraits< EntityTopology, SubdimensionTag::value >;
      return SubentityTraitsType::count;
   }
@@ -161,22 +162,22 @@ private:
   SubentityMatrixType matrix;

   // friend class is needed for templated assignment operators
   template< typename MeshConfig_, typename Device_, typename EntityTopology_, typename SubdimensionTag_, bool Storage_ >
   template< typename MeshConfig_, typename Device_, typename EntityTopologyDimensionTag_, typename SubdimensionTag_, bool Storage_ >
   friend class SubentityStorageLayer;
};

template< typename MeshConfig,
          typename Device,
          typename EntityTopology,
          typename EntityTopologyDimensionTag,
          typename SubdimensionTag >
class SubentityStorageLayer< MeshConfig,
                             Device,
                             EntityTopology,
                             EntityTopologyDimensionTag,
                             SubdimensionTag,
                             false >
   : public SubentityStorageLayer< MeshConfig, Device, EntityTopology, typename SubdimensionTag::Increment >
   : public SubentityStorageLayer< MeshConfig, Device, EntityTopologyDimensionTag, typename SubdimensionTag::Increment >
{
   using BaseType = SubentityStorageLayer< MeshConfig, Device, EntityTopology, typename SubdimensionTag::Increment >;
   using BaseType = SubentityStorageLayer< MeshConfig, Device, EntityTopologyDimensionTag, typename SubdimensionTag::Increment >;
public:
   // inherit constructors and assignment operators (including templated versions)
   using BaseType::BaseType;
@@ -186,14 +187,14 @@ public:
// termination of recursive inheritance (everything is reduced to EntityStorage == false thanks to the WeakSubentityStorageTrait)
template< typename MeshConfig,
          typename Device,
          typename EntityTopology >
          typename EntityTopologyDimensionTag >
class SubentityStorageLayer< MeshConfig,
                             Device,
                             EntityTopology,
                             DimensionTag< EntityTopology::dimension >,
                             EntityTopologyDimensionTag,
                             DimensionTag< EntityTopologyDimensionTag::value >,
                             false >
{
   using SubdimensionTag = DimensionTag< EntityTopology::dimension >;
   using SubdimensionTag = EntityTopologyDimensionTag;

protected:
   using GlobalIndexType = typename MeshConfig::GlobalIndexType;
@@ -201,9 +202,9 @@ protected:
   SubentityStorageLayer() = default;
   explicit SubentityStorageLayer( const SubentityStorageLayer& other ) {}
   template< typename Device_ >
   SubentityStorageLayer( const SubentityStorageLayer< MeshConfig, Device_, EntityTopology, SubdimensionTag >& other ) {}
   SubentityStorageLayer( const SubentityStorageLayer< MeshConfig, Device_, EntityTopologyDimensionTag, SubdimensionTag >& other ) {}
   template< typename Device_ >
   SubentityStorageLayer& operator=( const SubentityStorageLayer< MeshConfig, Device_, EntityTopology, SubdimensionTag >& other ) { return *this; }
   SubentityStorageLayer& operator=( const SubentityStorageLayer< MeshConfig, Device_, EntityTopologyDimensionTag, SubdimensionTag >& other ) { return *this; }

   void print( std::ostream& str ) const {}

+25 −25

File changed.

Preview size limit exceeded, changes collapsed.