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

Refactoring: generalized BoundaryTags to EntityTags

parent 8708b2e0
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ struct DefaultConfig
   }

   /****
    * Storage of boundary tags of mesh entities. Necessary for the mesh traverser.
    * Storage of mesh entity tags. Boundary tags are necessary for the mesh traverser.
    *
    * The configuration must satisfy the following necessary conditions in
    * order to provide boundary tags:
@@ -80,7 +80,7 @@ struct DefaultConfig
    *      must be stored as subentities of faces
    */
   template< typename EntityTopology >
   static constexpr bool boundaryTagsStorage( EntityTopology )
   static constexpr bool entityTagsStorage( EntityTopology )
   {
      using FaceTopology = typename Topologies::Subtopology< CellTopology, meshDimension - 1 >::Topology;
      return superentityStorage( FaceTopology(), meshDimension ) &&
+3 −3
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@
#include <TNL/Meshes/MeshDetails/ConfigValidator.h>
#include <TNL/Meshes/MeshDetails/traits/MeshTraits.h>
#include <TNL/Meshes/MeshDetails/layers/StorageLayer.h>
#include <TNL/Meshes/MeshDetails/layers/BoundaryTags/LayerFamily.h>
#include <TNL/Meshes/MeshDetails/layers/EntityTags/LayerFamily.h>

#include <TNL/Meshes/DistributedMeshes/DistributedMesh.h>

@@ -68,10 +68,10 @@ class Mesh
     public ConfigValidator< MeshConfig >,
     public MeshInitializableBase< MeshConfig, Device, Mesh< MeshConfig, Device > >,
     public StorageLayerFamily< MeshConfig, Device >,
     public BoundaryTags::LayerFamily< MeshConfig, Device, Mesh< MeshConfig, Device > >
     public EntityTags::LayerFamily< MeshConfig, Device, Mesh< MeshConfig, Device > >
{
      using StorageBaseType = StorageLayerFamily< MeshConfig, Device >;
      using BoundaryTagsLayerFamily = BoundaryTags::LayerFamily< MeshConfig, Device, Mesh >;
      using EntityTagsLayerFamily = EntityTags::LayerFamily< MeshConfig, Device, Mesh >;

   public:
      using Config          = MeshConfig;
+10 −10
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ init( typename MeshTraitsType::PointArrayType& points,
   Initializer< typename MeshType::Config > initializer;
   initializer.createMesh( points, cellSeeds, *mesh );
   // init boundary tags
   static_cast< BoundaryTags::LayerFamily< MeshConfig, Device, MeshType >* >( mesh )->initLayer();
   static_cast< EntityTags::LayerFamily< MeshConfig, Device, MeshType >* >( mesh )->initLayer();
   // init dual graph
   mesh->initializeDualGraph( *mesh );
}
@@ -43,7 +43,7 @@ template< typename MeshConfig, typename Device >
Mesh< MeshConfig, Device >::
Mesh( const Mesh& mesh )
   : StorageBaseType( mesh ),
     BoundaryTagsLayerFamily( mesh )
     EntityTagsLayerFamily( mesh )
{
}

@@ -52,7 +52,7 @@ template< typename MeshConfig, typename Device >
Mesh< MeshConfig, Device >::
Mesh( const Mesh< MeshConfig, Device_ >& mesh )
   : StorageBaseType( mesh ),
     BoundaryTagsLayerFamily( mesh )
     EntityTagsLayerFamily( mesh )
{
}

@@ -62,7 +62,7 @@ Mesh< MeshConfig, Device >::
operator=( const Mesh& mesh )
{
   StorageBaseType::operator=( mesh );
   BoundaryTagsLayerFamily::operator=( mesh );
   EntityTagsLayerFamily::operator=( mesh );
   return *this;
}

@@ -73,7 +73,7 @@ Mesh< MeshConfig, Device >::
operator=( const Mesh< MeshConfig, Device_ >& mesh )
{
   StorageBaseType::operator=( mesh );
   BoundaryTagsLayerFamily::operator=( mesh );
   EntityTagsLayerFamily::operator=( mesh );
   return *this;
}

@@ -261,7 +261,7 @@ reorderEntities( const GlobalIndexVector& perm,

   IndexPermutationApplier< Mesh, Dimension >::exec( *this, perm, iperm );
   // update boundary tags
   static_cast< BoundaryTagsLayerFamily* >( this )->initLayer();
   static_cast< EntityTagsLayerFamily* >( this )->initLayer();
}


@@ -272,7 +272,7 @@ save( File& file ) const
{
   Object::save( file );
   StorageBaseType::save( file );
   BoundaryTagsLayerFamily::save( file );
   EntityTagsLayerFamily::save( file );
}

template< typename MeshConfig, typename Device >
@@ -289,7 +289,7 @@ load( File& file )
   else {
      Object::load( file );
      StorageBaseType::load( file );
      BoundaryTagsLayerFamily::load( file );
      EntityTagsLayerFamily::load( file );
      this->initializeDualGraph( *this );
   }
}
@@ -305,7 +305,7 @@ print( std::ostream& str ) const
   }
   else {
      StorageBaseType::print( str );
      BoundaryTagsLayerFamily::print( str );
      EntityTagsLayerFamily::print( str );
   }
}

@@ -315,7 +315,7 @@ Mesh< MeshConfig, Device >::
operator==( const Mesh& mesh ) const
{
   return StorageBaseType::operator==( mesh ) &&
          BoundaryTagsLayerFamily::operator==( mesh );
          EntityTagsLayerFamily::operator==( mesh );
}

template< typename MeshConfig, typename Device >
+6 −6
Original line number Diff line number Diff line
@@ -15,12 +15,12 @@

namespace TNL {
namespace Meshes {
namespace BoundaryTags {
namespace EntityTags {

template< typename MeshConfig,
          typename EntityTopology,
          bool BoundaryTagsStorage = MeshConfig::boundaryTagsStorage( EntityTopology() ) >
class ConfigValidatorBoundaryTagsLayer
          bool entityTagsStorage = MeshConfig::entityTagsStorage( EntityTopology() ) >
class ConfigValidatorEntityTagsLayer
{
   using FaceTopology = typename Topologies::Subtopology< typename MeshConfig::CellTopology, MeshConfig::meshDimension - 1 >::Topology;

@@ -32,7 +32,7 @@ class ConfigValidatorBoundaryTagsLayer

template< typename MeshConfig,
          typename EntityTopology >
class ConfigValidatorBoundaryTagsLayer< MeshConfig, EntityTopology, false >
class ConfigValidatorEntityTagsLayer< MeshConfig, EntityTopology, false >
{
};

@@ -40,7 +40,7 @@ class ConfigValidatorBoundaryTagsLayer< MeshConfig, EntityTopology, false >
template< typename MeshConfig, int dimension = MeshConfig::meshDimension >
class ConfigValidatorLayer
   : public ConfigValidatorLayer< MeshConfig, dimension - 1 >,
     public ConfigValidatorBoundaryTagsLayer< MeshConfig,
     public ConfigValidatorEntityTagsLayer< MeshConfig,
                                              typename MeshTraits< MeshConfig >::template EntityTraits< dimension >::EntityTopology >
{
};
@@ -56,6 +56,6 @@ class ConfigValidator
{
};

} // namespace BoundaryTags
} // namespace EntityTags
} // namespace Meshes
} // namespace TNL
+18 −16
Original line number Diff line number Diff line
@@ -16,9 +16,11 @@
#include <TNL/Meshes/DimensionTag.h>
#include <TNL/Meshes/MeshDetails/traits/MeshEntityTraits.h>

#include "Traits.h"

namespace TNL {
namespace Meshes {
namespace BoundaryTags {
namespace EntityTags {

template< typename MeshConfig, typename Device, typename Mesh >
class Initializer
@@ -31,18 +33,18 @@ protected:
   // _T is necessary to force *partial* specialization, since explicit specializations
   // at class scope are forbidden
   template< typename CurrentDimension = DimensionTag< MeshConfig::meshDimension >, typename _T = void >
   struct BoundaryTagsNeedInitialization
   struct EntityTagsNeedInitialization
   {
      using EntityTopology = typename MeshEntityTraits< MeshConfig, DeviceType, CurrentDimension::value >::EntityTopology;
      static constexpr bool value = MeshConfig::boundaryTagsStorage( EntityTopology() ) ||
                                    BoundaryTagsNeedInitialization< typename CurrentDimension::Decrement >::value;
      static constexpr bool value = MeshConfig::entityTagsStorage( EntityTopology() ) ||
                                    EntityTagsNeedInitialization< typename CurrentDimension::Decrement >::value;
   };

   template< typename _T >
   struct BoundaryTagsNeedInitialization< DimensionTag< 0 >, _T >
   struct EntityTagsNeedInitialization< DimensionTag< 0 >, _T >
   {
      using EntityTopology = typename MeshEntityTraits< MeshConfig, DeviceType, 0 >::EntityTopology;
      static constexpr bool value = MeshConfig::boundaryTagsStorage( EntityTopology() );
      static constexpr bool value = MeshConfig::entityTagsStorage( EntityTopology() );
   };

   template< int Dimension >
@@ -50,16 +52,16 @@ protected:
   {
      static void exec( Mesh& mesh )
      {
         mesh.template boundaryTagsSetEntitiesCount< Dimension >( mesh.template getEntitiesCount< Dimension >() );
         mesh.template entityTagsSetEntitiesCount< Dimension >( mesh.template getEntitiesCount< Dimension >() );
      }
   };

   template< int Dimension >
   struct ResetBoundaryTags
   struct ResetEntityTags
   {
      static void exec( Mesh& mesh )
      {
         mesh.template resetBoundaryTags< Dimension >();
         mesh.template resetEntityTags< Dimension >();
      }
   };

@@ -67,7 +69,7 @@ protected:
   class InitializeSubentities
   {
      using SubentityTopology = typename MeshEntityTraits< MeshConfig, DeviceType, Subdimension >::EntityTopology;
      static constexpr bool enabled = MeshConfig::boundaryTagsStorage( SubentityTopology() );
      static constexpr bool enabled = MeshConfig::entityTagsStorage( SubentityTopology() );

      // _T is necessary to force *partial* specialization, since explicit specializations
      // at class scope are forbidden
@@ -80,7 +82,7 @@ protected:
            const LocalIndexType subentitiesCount = face.template getSubentitiesCount< Subdimension >();
            for( LocalIndexType i = 0; i < subentitiesCount; i++ ) {
               const GlobalIndexType subentityIndex = face.template getSubentityIndex< Subdimension >( i );
               mesh.template setIsBoundaryEntity< Subdimension >( subentityIndex, true );
               mesh.template addEntityTag< Subdimension >( subentityIndex, EntityTags::BoundaryEntity );
            }
         }
      };
@@ -115,14 +117,14 @@ public:
#endif
   // _T is necessary to force *partial* specialization, since explicit specializations
   // at class scope are forbidden
   template< bool AnyBoundaryTags = BoundaryTagsNeedInitialization<>::value, typename _T = void >
   template< bool AnyEntityTags = EntityTagsNeedInitialization<>::value, typename _T = void >
   class Worker
   {
   public:
      static void exec( Mesh& mesh )
      {
         Algorithms::TemplateStaticFor< int, 0, Mesh::getMeshDimension() + 1, SetEntitiesCount >::execHost( mesh );
         Algorithms::TemplateStaticFor< int, 0, Mesh::getMeshDimension() + 1, ResetBoundaryTags >::execHost( mesh );
         Algorithms::TemplateStaticFor< int, 0, Mesh::getMeshDimension() + 1, ResetEntityTags >::execHost( mesh );

         auto kernel = [] __cuda_callable__
            ( GlobalIndexType faceIndex,
@@ -131,10 +133,10 @@ public:
            const auto& face = mesh->template getEntity< Mesh::getMeshDimension() - 1 >( faceIndex );
            if( face.template getSuperentitiesCount< Mesh::getMeshDimension() >() == 1 ) {
               // initialize the face
               mesh->template setIsBoundaryEntity< Mesh::getMeshDimension() - 1 >( faceIndex, true );
               mesh->template addEntityTag< Mesh::getMeshDimension() - 1 >( faceIndex, EntityTags::BoundaryEntity );
               // initialize the cell superentity
               const GlobalIndexType cellIndex = face.template getSuperentityIndex< Mesh::getMeshDimension() >( 0 );
               mesh->template setIsBoundaryEntity< Mesh::getMeshDimension() >( cellIndex, true );
               mesh->template addEntityTag< Mesh::getMeshDimension() >( cellIndex, EntityTags::BoundaryEntity );
               // initialize all subentities
               Algorithms::TemplateStaticFor< int, 0, Mesh::getMeshDimension() - 1, InitializeSubentities >::exec( *mesh, faceIndex, face );
            }
@@ -163,6 +165,6 @@ public:
   }
};

} // namespace BoundaryTags
} // namespace EntityTags
} // namespace Meshes
} // namespace TNL
Loading