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

Mesh: renamed GlobalIndexVector to GlobalIndexArray

parent ebe8ba38
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -18,10 +18,10 @@ namespace Containers {
namespace Multimaps {

template< typename Multimap,
          typename PermutationVector >
void permuteMultimapKeys( Multimap& multimap, const PermutationVector& perm )
          typename PermutationArray >
void permuteMultimapKeys( Multimap& multimap, const PermutationArray& perm )
{
   static_assert( std::is_same< typename Multimap::DeviceType, typename PermutationVector::DeviceType >::value,
   static_assert( std::is_same< typename Multimap::DeviceType, typename PermutationArray::DeviceType >::value,
                  "The multimap and permutation vector must be stored on the same device." );
   using IndexType = typename Multimap::IndexType;
   using DeviceType = typename Multimap::DeviceType;
@@ -38,7 +38,7 @@ void permuteMultimapKeys( Multimap& multimap, const PermutationVector& perm )
      ( IndexType i,
        const Multimap* multimap,
        Multimap* multimapCopy,
        const typename PermutationVector::RealType* perm )
        const typename PermutationArray::ValueType* perm )
   {
      const auto srcValues = multimap->getValues( perm[ i ] );
      auto destValues = multimapCopy->getValues( i );
@@ -59,10 +59,10 @@ void permuteMultimapKeys( Multimap& multimap, const PermutationVector& perm )
}

template< typename Multimap,
          typename PermutationVector >
void permuteMultimapValues( Multimap& multimap, const PermutationVector& iperm )
          typename PermutationArray >
void permuteMultimapValues( Multimap& multimap, const PermutationArray& iperm )
{
   static_assert( std::is_same< typename Multimap::DeviceType, typename PermutationVector::DeviceType >::value,
   static_assert( std::is_same< typename Multimap::DeviceType, typename PermutationArray::DeviceType >::value,
                  "The multimap and permutation vector must be stored on the same device." );
   using IndexType = typename Multimap::IndexType;
   using DeviceType = typename Multimap::DeviceType;
@@ -71,7 +71,7 @@ void permuteMultimapValues( Multimap& multimap, const PermutationVector& iperm )
   auto kernel = [] __cuda_callable__
      ( IndexType i,
        Multimap* multimap,
        const typename PermutationVector::RealType* iperm )
        const typename PermutationArray::ValueType* iperm )
   {
      auto values = multimap->getValues( i );
      for( typename Multimap::LocalIndexType v = 0; v < values.getSize(); v++ )
+3 −3
Original line number Diff line number Diff line
@@ -81,7 +81,7 @@ class Mesh
      using LocalIndexType  = typename MeshTraitsType::LocalIndexType;
      using PointType       = typename MeshTraitsType::PointType;
      using RealType        = typename PointType::RealType;
      using GlobalIndexVector = Containers::Vector< GlobalIndexType, DeviceType, GlobalIndexType >;
      using GlobalIndexArray = Containers::Array< GlobalIndexType, DeviceType, GlobalIndexType >;

      template< int Dimension >
      using EntityTraits = typename MeshTraitsType::template EntityTraits< Dimension >;
@@ -182,8 +182,8 @@ class Mesh
       * M is the entity with index iperm[j] in M'.
       */
      template< int Dimension >
      void reorderEntities( const GlobalIndexVector& perm,
                            const GlobalIndexVector& iperm );
      void reorderEntities( const GlobalIndexArray& perm,
                            const GlobalIndexArray& iperm );


      void save( File& file ) const;
+13 −8
Original line number Diff line number Diff line
@@ -237,8 +237,8 @@ template< typename MeshConfig, typename Device >
   template< int Dimension >
void
Mesh< MeshConfig, Device >::
reorderEntities( const GlobalIndexVector& perm,
                 const GlobalIndexVector& iperm )
reorderEntities( const GlobalIndexArray& perm,
                 const GlobalIndexArray& iperm )
{
   const GlobalIndexType entitiesCount = getEntitiesCount< Dimension >();

@@ -248,16 +248,21 @@ reorderEntities( const GlobalIndexVector& perm,
                              "perm size = " + std::to_string( perm.getSize() ) + ", "
                              "iperm size = " + std::to_string( iperm.getSize() ) );
   }
   TNL_ASSERT( min( perm ) == 0 && max( perm ) == entitiesCount - 1,
               std::cerr << "Given array is not a permutation: min = " << min( perm )
                         << ", max = " << max( perm )
#ifndef NDEBUG
   using View = Containers::VectorView< const GlobalIndexType, DeviceType, GlobalIndexType >;
   const View perm_view = perm.getConstView();
   const View iperm_view = iperm.getConstView();
   TNL_ASSERT( min( perm_view ) == 0 && max( perm_view ) == entitiesCount - 1,
               std::cerr << "Given array is not a permutation: min = " << min( perm_view )
                         << ", max = " << max( perm_view )
                         << ", number of entities = " << entitiesCount
                         << ", array = " << perm << std::endl; );
   TNL_ASSERT( min( iperm ) == 0 && max( iperm ) == entitiesCount - 1,
               std::cerr << "Given array is not a permutation: min = " << min( iperm )
                         << ", max = " << max( iperm )
   TNL_ASSERT( min( iperm_view ) == 0 && max( iperm_view ) == entitiesCount - 1,
               std::cerr << "Given array is not a permutation: min = " << min( iperm_view )
                         << ", max = " << max( iperm_view )
                         << ", number of entities = " << entitiesCount
                         << ", array = " << iperm << std::endl; );
#endif

   IndexPermutationApplier< Mesh, Dimension >::exec( *this, perm, iperm );
   // update boundary tags
+14 −14
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ template< typename Mesh, int Dimension >
struct IndexPermutationApplier
{
private:
   using GlobalIndexVector = typename Mesh::GlobalIndexVector;
   using GlobalIndexArray = typename Mesh::GlobalIndexArray;

   template< int Subdimension,
             bool Enabled =
@@ -30,7 +30,7 @@ private:
             >
   struct _SubentitiesStorageWorker
   {
      static void exec( Mesh& mesh, const GlobalIndexVector& perm )
      static void exec( Mesh& mesh, const GlobalIndexArray& perm )
      {
         auto& subentitiesStorage = mesh.template getSubentityStorageNetwork< Dimension, Subdimension >();
         Containers::Multimaps::permuteMultimapKeys( subentitiesStorage, perm );
@@ -40,7 +40,7 @@ private:
   template< int Subdimension >
   struct _SubentitiesStorageWorker< Subdimension, false >
   {
      static void exec( Mesh& mesh, const GlobalIndexVector& iperm ) {}
      static void exec( Mesh& mesh, const GlobalIndexArray& iperm ) {}
   };


@@ -51,7 +51,7 @@ private:
             >
   struct _SuperentitiesStorageWorker
   {
      static void exec( Mesh& mesh, const GlobalIndexVector& perm )
      static void exec( Mesh& mesh, const GlobalIndexArray& perm )
      {
         auto& superentitiesStorage = mesh.template getSuperentityStorageNetwork< Dimension, Superdimension >();
         Containers::Multimaps::permuteMultimapKeys( superentitiesStorage, perm );
@@ -61,7 +61,7 @@ private:
   template< int Superdimension >
   struct _SuperentitiesStorageWorker< Superdimension, false >
   {
      static void exec( Mesh& mesh, const GlobalIndexVector& iperm ) {}
      static void exec( Mesh& mesh, const GlobalIndexArray& iperm ) {}
   };


@@ -72,7 +72,7 @@ private:
             >
   struct IndexPermutationApplierSubentitiesWorker
   {
      static void exec( Mesh& mesh, const GlobalIndexVector& iperm )
      static void exec( Mesh& mesh, const GlobalIndexArray& iperm )
      {
         auto& superentitiesStorage = mesh.template getSuperentityStorageNetwork< Subdimension, Dimension >();
         Containers::Multimaps::permuteMultimapValues( superentitiesStorage, iperm );
@@ -82,7 +82,7 @@ private:
   template< int Subdimension >
   struct IndexPermutationApplierSubentitiesWorker< Subdimension, false >
   {
      static void exec( Mesh& mesh, const GlobalIndexVector& iperm ) {}
      static void exec( Mesh& mesh, const GlobalIndexArray& iperm ) {}
   };


@@ -93,7 +93,7 @@ private:
             >
   struct IndexPermutationApplierSuperentitiesWorker
   {
      static void exec( Mesh& mesh, const GlobalIndexVector& iperm )
      static void exec( Mesh& mesh, const GlobalIndexArray& iperm )
      {
         auto& subentitiesStorage = mesh.template getSubentityStorageNetwork< Superdimension, Dimension >();
         Containers::Multimaps::permuteMultimapValues( subentitiesStorage, iperm );
@@ -103,7 +103,7 @@ private:
   template< int Superdimension >
   struct IndexPermutationApplierSuperentitiesWorker< Superdimension, false >
   {
      static void exec( Mesh& mesh, const GlobalIndexVector& iperm ) {}
      static void exec( Mesh& mesh, const GlobalIndexArray& iperm ) {}
   };


@@ -121,7 +121,7 @@ private:
   using SuperentitiesWorker = IndexPermutationApplierSuperentitiesWorker< Superdimension >;

   template< typename Mesh_, std::enable_if_t< Mesh_::Config::dualGraphStorage(), bool > = true >
   static void permuteDualGraph( Mesh_& mesh, const GlobalIndexVector& perm, const GlobalIndexVector& iperm )
   static void permuteDualGraph( Mesh_& mesh, const GlobalIndexArray& perm, const GlobalIndexArray& iperm )
   {
      permuteArray( mesh.getNeighborCounts(), perm );
      auto& graph = mesh.getDualGraph();
@@ -130,11 +130,11 @@ private:
   }

   template< typename Mesh_, std::enable_if_t< ! Mesh_::Config::dualGraphStorage(), bool > = true >
   static void permuteDualGraph( Mesh_& mesh, const GlobalIndexVector& perm, const GlobalIndexVector& iperm ) {}
   static void permuteDualGraph( Mesh_& mesh, const GlobalIndexArray& perm, const GlobalIndexArray& iperm ) {}

public:
   template< typename Array >
   static void permuteArray( Array& array, const GlobalIndexVector& perm )
   static void permuteArray( Array& array, const GlobalIndexArray& perm )
   {
      using IndexType = typename Array::IndexType;
      using DeviceType = typename Array::DeviceType;
@@ -172,8 +172,8 @@ public:
   }

   static void exec( Mesh& mesh,
                     const GlobalIndexVector& perm,
                     const GlobalIndexVector& iperm )
                     const GlobalIndexArray& perm,
                     const GlobalIndexArray& iperm )
   {
      using IndexType = typename Mesh::GlobalIndexType;
      using DeviceType = typename Mesh::DeviceType;
+13 −13
Original line number Diff line number Diff line
@@ -85,11 +85,11 @@ bool buildTriangleMesh( Mesh< TestTriangleMeshConfig, Device >& mesh )
   return meshBuilder.build( mesh );
}

template< typename PermutationVector >
template< typename PermutationArray >
void testMesh( const Mesh< TestTriangleMeshConfig, Devices::Host >& mesh,
               const PermutationVector& vertexPermutation,
               const PermutationVector& edgePermutation,
               const PermutationVector& cellPermutation )
               const PermutationArray& vertexPermutation,
               const PermutationArray& edgePermutation,
               const PermutationArray& cellPermutation )
{
   using MeshType = Mesh< TestTriangleMeshConfig, Devices::Host >;
   using PointType = typename MeshType::PointType;
@@ -253,8 +253,8 @@ TEST( MeshOrderingTest, OrderingOnHost )
   MeshHost mesh;
   ASSERT_TRUE( buildTriangleMesh( mesh ) );

   using PermutationVector = typename MeshHost::GlobalIndexVector;
   PermutationVector vertexIdentity, edgeIdentity, cellIdentity,
   using PermutationArray = typename MeshHost::GlobalIndexArray;
   PermutationArray vertexIdentity, edgeIdentity, cellIdentity,
                    vertexPermutation, edgePermutation, cellPermutation,
                    vertexInversePermutation, edgeInversePermutation, cellInversePermutation;
   setPermutation( vertexIdentity, _vertexIdentity );
@@ -288,7 +288,7 @@ TEST( MeshOrderingTest, OrderingOnCuda )
   ASSERT_TRUE( buildTriangleMesh( meshHost ) );
   mesh = meshHost;

   using PermutationCuda = typename MeshCuda::GlobalIndexVector;
   using PermutationCuda = typename MeshCuda::GlobalIndexArray;
   PermutationCuda vertexIdentity, edgeIdentity, cellIdentity,
                   vertexPermutation, edgePermutation, cellPermutation,
                   vertexInversePermutation, edgeInversePermutation, cellInversePermutation;
@@ -309,8 +309,8 @@ TEST( MeshOrderingTest, OrderingOnCuda )
   // test is on host
   {
      // local scope so we can use the same names
      using PermutationVector = typename MeshHost::GlobalIndexVector;
      PermutationVector vertexIdentity, edgeIdentity, cellIdentity,
      using PermutationArray = typename MeshHost::GlobalIndexArray;
      PermutationArray vertexIdentity, edgeIdentity, cellIdentity,
                       vertexPermutation, edgePermutation, cellPermutation,
                       vertexInversePermutation, edgeInversePermutation, cellInversePermutation;
      setPermutation( vertexIdentity, _vertexIdentity );