Commit 3eefaa99 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Implementing superentity indecis storage in storage network (=indexed multimap)

parent e8a608d8
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -62,6 +62,11 @@ class tnlMeshInitializer
      typedef typename MeshTraits::CellSeedArrayType                 CellSeedArrayType;
      typedef typename MeshTraits::GlobalIndexType                   GlobalIndexType;
      
      template< typename DimensionsTag, typename SuperdimensionsTag > using SuperentityStorageNetwork =
      typename MeshTraits::template SuperentityTraits< 
         typename MeshTraits::template EntityTraits< DimensionsTag::value >::EntityTopology,
         SuperdimensionsTag::value >::StorageNetworkType;


      tnlMeshInitializer()
      : verbose( false ), mesh( 0 )
@@ -126,6 +131,13 @@ class tnlMeshInitializer
         return mesh->template superentityIdsArray< DimensionsTag, SuperDimensionsTag >();
      }
      
      template< typename EntityTopology, typename SuperdimensionsTag >
      typename MeshTraits::template SuperentityTraits< EntityTopology, SuperdimensionsTag::value >::StorageNetworkType&
      meshSuperentityStorageNetwork()
      {
         return mesh->template getSuperentityStorageNetwork< EntityTopology, SuperdimensionsTag >();
      }

      static void
      setVertexPoint( typename MeshType::VertexType& vertex, const typename MeshType::PointType& point )
      {
+39 −8
Original line number Diff line number Diff line
@@ -51,14 +51,17 @@ class tnlMeshSuperentityStorageInitializerLayer< MeshConfig,
                                                      EntityTopology,
                                                      typename DimensionsTag::Decrement >      BaseType;

   static const int Dimensions = DimensionsTag::value;
   typedef tnlDimensionsTag< EntityTopology::dimensions >                                    EntityDimensions;
	
   typedef tnlMeshTraits< MeshConfig >                                                      MeshTraits;
   typedef typename MeshTraits::GlobalIdArrayType                                           GlobalIdArrayType;
      
      
   typedef typename MeshTraits::GlobalIndexType                                             GlobalIndexType;
   typedef typename MeshTraits::LocalIndexType                                              LocalIndexType;
   typedef tnlMeshInitializer< MeshConfig >                                                 MeshInitializer;
   typedef typename MeshTraits::template SuperentityTraits< EntityTopology, Dimensions >    SuperentityTraits;
   typedef typename SuperentityTraits::StorageNetworkType                                   SuperentityStorageNetwork;

   public:      
      using BaseType::addSuperentity;
@@ -100,8 +103,36 @@ class tnlMeshSuperentityStorageInitializerLayer< MeshConfig,
         /****
          * Network initializer
          */
         

         SuperentityStorageNetwork& superentityStorageNetwork = meshInitializer.template meshSuperentityStorageNetwork< EntityTopology, DimensionsTag >();
         //GlobalIndexType lastEntityIndex( 0 );
         superentityStorageNetwork.setDimensions(
            meshInitializer.template meshEntitiesArray< EntityDimensions >().getSize(),
            meshInitializer.template meshEntitiesArray< DimensionsTag >().getSize() );
         lastEntityIndex = 0;
         typename SuperentityStorageNetwork::PortsAllocationVectorType storageNetworkAllocationVector;
         storageNetworkAllocationVector.setSize( meshInitializer.template meshEntitiesArray< EntityDimensions >().getSize() );
         storageNetworkAllocationVector.setValue( 0 );
         for( GlobalIndexType i = 0; i < superentityIdsArray.getSize(); i++)
         {
            if( indexPairs[ i ].entityIndex == lastEntityIndex )
               storageNetworkAllocationVector[ lastEntityIndex ]++;
            else
               lastEntityIndex++;                           
         }
         superentityStorageNetwork.allocatePorts( storageNetworkAllocationVector );
         lastEntityIndex = 0;
         LocalIndexType superentitiesCount( 0 );
         typename SuperentityStorageNetwork::PortsType superentitiesIndecis = 
            superentityStorageNetwork.getPorts( lastEntityIndex );
         for( GlobalIndexType i = 0; i < superentityIdsArray.getSize(); i++)
         {
            if( indexPairs[ i ].entityIndex != lastEntityIndex )
            {
               superentitiesIndecis = superentityStorageNetwork.getPorts( ++lastEntityIndex );
               superentitiesCount = 0;
            }
            superentitiesIndecis[ superentitiesCount++ ] =  indexPairs[ i ].superentityIndex;
         }
         BaseType::initSuperentities( meshInitializer );
      }

+17 −1
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ class tnlMeshStorageLayer< MeshConfig,
      typedef typename EntityTraits::AccessArrayType                               AccessArrayType;
      typedef typename EntityTraits::GlobalIndexType                               GlobalIndexType;
      typedef typename EntityTraits::EntityType                                    EntityType;
      typedef typename EntityTraits::EntityTopology                                EntityTopology;


      using BaseType::getNumberOfEntities;
@@ -162,6 +163,14 @@ class tnlMeshStorageLayer< MeshConfig,
      {
         return SuperentityStorageBaseType::superentityIdsArray( SuperDimensionsTag() );
      }
      
      using BaseType::getSuperentityStorageNetwork;
      template< typename SuperdimensionsTag >
      typename MeshTraits::template SuperentityTraits< EntityTopology, SuperdimensionsTag::value >::StorageNetworkType& 
      getSuperentityStorageNetwork( tnlDimensionsTag< EntityTopology::dimensions > )
      {
         return SuperentityStorageBaseType::getStorageNetwork( SuperdimensionsTag() );
      }
};

template< typename MeshConfig,
@@ -192,6 +201,7 @@ class tnlMeshStorageLayer< MeshConfig, tnlDimensionsTag< 0 >, true > :
   typedef typename EntityTraits::GlobalIndexType                               GlobalIndexType;
   typedef typename EntityTraits::EntityType                                    VertexType;
   typedef typename VertexType::PointType                                       PointType;
   typedef tnlMeshVertexTopology                                                EntityTopology;
   
   tnlMeshStorageLayer()
   {
@@ -316,6 +326,12 @@ class tnlMeshStorageLayer< MeshConfig, tnlDimensionsTag< 0 >, true > :
         return SuperentityStorageBaseType::superentityIdsArray( SuperDimensionsTag() );
      }

      template< typename SuperdimensionsTag >
      typename MeshTraits::template SuperentityTraits< EntityTopology, SuperdimensionsTag::value >::StorageNetworkType& getSuperentityStorageNetwork( tnlDimensionsTag< EntityTopology::dimensions > )
      {
         return SuperentityStorageBaseType::getStorageNetwork( SuperdimensionsTag() );
      }

};

/****
+25 −4
Original line number Diff line number Diff line
@@ -37,10 +37,16 @@ class tnlMeshSuperentityAccess :
                                         tnlDimensionsTag< tnlMeshTraits< MeshConfig >::meshDimensions > >
{
   public:
      typedef tnlMeshSuperentityAccessLayer< MeshConfig, 
                                             MeshEntity,
                                             tnlDimensionsTag< tnlMeshTraits< MeshConfig >::meshDimensions > > BaseType;
      
      bool operator == ( const tnlMeshSuperentityAccess< MeshConfig, MeshEntity>& a ) const { return true; } // TODO: fix
      
      void print( ostream& str ) const{};
      void print( ostream& str ) const
      {
         BaseType::print( str );
      };

};

@@ -59,8 +65,10 @@ class tnlMeshSuperentityAccessLayer< MeshConfig,
      
      typedef tnlMeshTraits< MeshConfig >                                   MeshTraits;
      typedef typename MeshTraits::template SuperentityTraits< MeshEntity, Dimensions::value > SuperentityTraits;      
	   typedef typename MeshTraits::IdArrayAccessorType                          IdArrayAccessorType;            
      typedef typename SuperentityTraits::StorageNetworkType                    StorageNetworkType;
      typedef typename SuperentityTraits::SuperentityAccessorType               SuperentityAccessorType;
	   typedef typename tnlMeshTraits< MeshConfig >::IdArrayAccessorType    IdArrayAccessorType;            
      //typedef typename StorageNetworkType::PortsType                            SuperentityAccessorType;

	   using BaseType::superentityIds;
	   IdArrayAccessorType superentityIds( Dimensions ) const { return m_superentityIndices; }
@@ -71,14 +79,22 @@ class tnlMeshSuperentityAccessLayer< MeshConfig,
      using BaseType::getSuperentityIndices;
      const SuperentityAccessorType& getSuperentityIndices( Dimensions ) const
      {
         cerr << "###" << endl;
         return this->superentityIndices;
      }
      
      SuperentityAccessorType& getSuperentityIndices( Dimensions )
      {
         cerr << "######" << endl;
         return this->superentityIndices;
      }
      
      void print( ostream& str ) const
      {
         str << "Superentities with " << Dimensions::value << " dimensions are: " << 
            this->superentityIndices << endl;
         BaseType::print( str );
      }
      
      //bool operator == ( const tnlMeshSuperentityAccessLayer< MeshConfig, MeshEntity, Dimensions, tnlStorageTraits< true > >& l ) { return true; } // TODO: fix

@@ -86,6 +102,7 @@ class tnlMeshSuperentityAccessLayer< MeshConfig,
	   IdArrayAccessorType m_superentityIndices;
      
      SuperentityAccessorType superentityIndices;
                  
};

template< typename MeshConfig,
@@ -114,6 +131,8 @@ class tnlMeshSuperentityAccessLayer< MeshConfig,
	   void superentityIdsArray() {}
      
      void getSuperentityIndices() {};
      
      void print( ostream& str ) const {};
};

template< typename MeshConfig,
@@ -131,6 +150,8 @@ class tnlMeshSuperentityAccessLayer< MeshConfig,
	   void superentityIdsArray() {}
      
      void getSuperentityIndices() {};
      
      void print( ostream& str ) const {};
};


+11 −0
Original line number Diff line number Diff line
@@ -54,12 +54,23 @@ class tnlMeshSuperentityAccessor
         return this->ports[ localIndex ];
      }
      
      void print( ostream& str ) const
      {
         str << ports;
      }
      
   protected:
      
      NetworkPorts ports;
      
};

template< typename NetworkPorts >
ostream& operator << ( ostream& str, const tnlMeshSuperentityAccessor< NetworkPorts >& superentityAccessor )
{
   superentityAccessor.print( str );
   return str;
}

#endif	/* TNLMESHSUPERENTITYACCESSOR_H */
Loading