Skip to content
Snippets Groups Projects
Commit 3eefaa99 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

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

parent e8a608d8
No related branches found
No related tags found
No related merge requests found
...@@ -61,6 +61,11 @@ class tnlMeshInitializer ...@@ -61,6 +61,11 @@ class tnlMeshInitializer
typedef typename MeshTraits::PointArrayType PointArrayType; typedef typename MeshTraits::PointArrayType PointArrayType;
typedef typename MeshTraits::CellSeedArrayType CellSeedArrayType; typedef typename MeshTraits::CellSeedArrayType CellSeedArrayType;
typedef typename MeshTraits::GlobalIndexType GlobalIndexType; 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() tnlMeshInitializer()
...@@ -125,6 +130,13 @@ class tnlMeshInitializer ...@@ -125,6 +130,13 @@ class tnlMeshInitializer
{ {
return mesh->template superentityIdsArray< DimensionsTag, SuperDimensionsTag >(); 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 static void
setVertexPoint( typename MeshType::VertexType& vertex, const typename MeshType::PointType& point ) setVertexPoint( typename MeshType::VertexType& vertex, const typename MeshType::PointType& point )
......
...@@ -51,14 +51,17 @@ class tnlMeshSuperentityStorageInitializerLayer< MeshConfig, ...@@ -51,14 +51,17 @@ class tnlMeshSuperentityStorageInitializerLayer< MeshConfig,
EntityTopology, EntityTopology,
typename DimensionsTag::Decrement > BaseType; typename DimensionsTag::Decrement > BaseType;
static const int Dimensions = DimensionsTag::value;
typedef tnlDimensionsTag< EntityTopology::dimensions > EntityDimensions; typedef tnlDimensionsTag< EntityTopology::dimensions > EntityDimensions;
typedef tnlMeshTraits< MeshConfig > MeshTraits; typedef tnlMeshTraits< MeshConfig > MeshTraits;
typedef typename MeshTraits::GlobalIdArrayType GlobalIdArrayType; typedef typename MeshTraits::GlobalIdArrayType GlobalIdArrayType;
typedef typename MeshTraits::GlobalIndexType GlobalIndexType; typedef typename MeshTraits::GlobalIndexType GlobalIndexType;
typedef tnlMeshInitializer< MeshConfig > MeshInitializer; typedef typename MeshTraits::LocalIndexType LocalIndexType;
typedef tnlMeshInitializer< MeshConfig > MeshInitializer;
typedef typename MeshTraits::template SuperentityTraits< EntityTopology, Dimensions > SuperentityTraits;
typedef typename SuperentityTraits::StorageNetworkType SuperentityStorageNetwork;
public: public:
using BaseType::addSuperentity; using BaseType::addSuperentity;
...@@ -76,7 +79,7 @@ class tnlMeshSuperentityStorageInitializerLayer< MeshConfig, ...@@ -76,7 +79,7 @@ class tnlMeshSuperentityStorageInitializerLayer< MeshConfig,
indexPairs.end(), indexPairs.end(),
[]( IndexPair pair0, IndexPair pair1 ){ return ( pair0.entityIndex < pair1.entityIndex ); } ); []( IndexPair pair0, IndexPair pair1 ){ return ( pair0.entityIndex < pair1.entityIndex ); } );
GlobalIdArrayType &superentityIdsArray = meshInitializer.template meshSuperentityIdsArray< EntityDimensions, DimensionsTag >(); GlobalIdArrayType &superentityIdsArray = meshInitializer.template meshSuperentityIdsArray< EntityDimensions, DimensionsTag >();
superentityIdsArray.setSize( static_cast< GlobalIndexType >( indexPairs.size() ) ); superentityIdsArray.setSize( static_cast< GlobalIndexType >( indexPairs.size() ) );
GlobalIndexType currentBegin = 0; GlobalIndexType currentBegin = 0;
GlobalIndexType lastEntityIndex = 0; GlobalIndexType lastEntityIndex = 0;
...@@ -100,8 +103,36 @@ class tnlMeshSuperentityStorageInitializerLayer< MeshConfig, ...@@ -100,8 +103,36 @@ class tnlMeshSuperentityStorageInitializerLayer< MeshConfig,
/**** /****
* Network initializer * 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 ); BaseType::initSuperentities( meshInitializer );
} }
......
...@@ -58,6 +58,7 @@ class tnlMeshStorageLayer< MeshConfig, ...@@ -58,6 +58,7 @@ class tnlMeshStorageLayer< MeshConfig,
typedef typename EntityTraits::AccessArrayType AccessArrayType; typedef typename EntityTraits::AccessArrayType AccessArrayType;
typedef typename EntityTraits::GlobalIndexType GlobalIndexType; typedef typename EntityTraits::GlobalIndexType GlobalIndexType;
typedef typename EntityTraits::EntityType EntityType; typedef typename EntityTraits::EntityType EntityType;
typedef typename EntityTraits::EntityTopology EntityTopology;
using BaseType::getNumberOfEntities; using BaseType::getNumberOfEntities;
...@@ -162,6 +163,14 @@ class tnlMeshStorageLayer< MeshConfig, ...@@ -162,6 +163,14 @@ class tnlMeshStorageLayer< MeshConfig,
{ {
return SuperentityStorageBaseType::superentityIdsArray( SuperDimensionsTag() ); 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, template< typename MeshConfig,
...@@ -192,7 +201,8 @@ class tnlMeshStorageLayer< MeshConfig, tnlDimensionsTag< 0 >, true > : ...@@ -192,7 +201,8 @@ class tnlMeshStorageLayer< MeshConfig, tnlDimensionsTag< 0 >, true > :
typedef typename EntityTraits::GlobalIndexType GlobalIndexType; typedef typename EntityTraits::GlobalIndexType GlobalIndexType;
typedef typename EntityTraits::EntityType VertexType; typedef typename EntityTraits::EntityType VertexType;
typedef typename VertexType::PointType PointType; typedef typename VertexType::PointType PointType;
typedef tnlMeshVertexTopology EntityTopology;
tnlMeshStorageLayer() tnlMeshStorageLayer()
{ {
this->vertices.setName( tnlString( "tnlMeshStorageLayer < " ) + tnlString( DimensionsTag::value ) + " >::vertices" ); this->vertices.setName( tnlString( "tnlMeshStorageLayer < " ) + tnlString( DimensionsTag::value ) + " >::vertices" );
...@@ -316,6 +326,12 @@ class tnlMeshStorageLayer< MeshConfig, tnlDimensionsTag< 0 >, true > : ...@@ -316,6 +326,12 @@ class tnlMeshStorageLayer< MeshConfig, tnlDimensionsTag< 0 >, true > :
return SuperentityStorageBaseType::superentityIdsArray( SuperDimensionsTag() ); return SuperentityStorageBaseType::superentityIdsArray( SuperDimensionsTag() );
} }
template< typename SuperdimensionsTag >
typename MeshTraits::template SuperentityTraits< EntityTopology, SuperdimensionsTag::value >::StorageNetworkType& getSuperentityStorageNetwork( tnlDimensionsTag< EntityTopology::dimensions > )
{
return SuperentityStorageBaseType::getStorageNetwork( SuperdimensionsTag() );
}
}; };
/**** /****
......
...@@ -37,10 +37,16 @@ class tnlMeshSuperentityAccess : ...@@ -37,10 +37,16 @@ class tnlMeshSuperentityAccess :
tnlDimensionsTag< tnlMeshTraits< MeshConfig >::meshDimensions > > tnlDimensionsTag< tnlMeshTraits< MeshConfig >::meshDimensions > >
{ {
public: public:
typedef tnlMeshSuperentityAccessLayer< MeshConfig,
MeshEntity,
tnlDimensionsTag< tnlMeshTraits< MeshConfig >::meshDimensions > > BaseType;
bool operator == ( const tnlMeshSuperentityAccess< MeshConfig, MeshEntity>& a ) const { return true; } // TODO: fix 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 );
};
}; };
...@@ -58,9 +64,11 @@ class tnlMeshSuperentityAccessLayer< MeshConfig, ...@@ -58,9 +64,11 @@ class tnlMeshSuperentityAccessLayer< MeshConfig,
public: public:
typedef tnlMeshTraits< MeshConfig > MeshTraits; typedef tnlMeshTraits< MeshConfig > MeshTraits;
typedef typename MeshTraits::template SuperentityTraits< MeshEntity, Dimensions::value > SuperentityTraits; 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 SuperentityTraits::SuperentityAccessorType SuperentityAccessorType;
typedef typename tnlMeshTraits< MeshConfig >::IdArrayAccessorType IdArrayAccessorType; //typedef typename StorageNetworkType::PortsType SuperentityAccessorType;
using BaseType::superentityIds; using BaseType::superentityIds;
IdArrayAccessorType superentityIds( Dimensions ) const { return m_superentityIndices; } IdArrayAccessorType superentityIds( Dimensions ) const { return m_superentityIndices; }
...@@ -71,14 +79,22 @@ class tnlMeshSuperentityAccessLayer< MeshConfig, ...@@ -71,14 +79,22 @@ class tnlMeshSuperentityAccessLayer< MeshConfig,
using BaseType::getSuperentityIndices; using BaseType::getSuperentityIndices;
const SuperentityAccessorType& getSuperentityIndices( Dimensions ) const const SuperentityAccessorType& getSuperentityIndices( Dimensions ) const
{ {
cerr << "###" << endl;
return this->superentityIndices; return this->superentityIndices;
} }
SuperentityAccessorType& getSuperentityIndices( Dimensions ) SuperentityAccessorType& getSuperentityIndices( Dimensions )
{ {
cerr << "######" << endl;
return this->superentityIndices; 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 //bool operator == ( const tnlMeshSuperentityAccessLayer< MeshConfig, MeshEntity, Dimensions, tnlStorageTraits< true > >& l ) { return true; } // TODO: fix
...@@ -86,6 +102,7 @@ class tnlMeshSuperentityAccessLayer< MeshConfig, ...@@ -86,6 +102,7 @@ class tnlMeshSuperentityAccessLayer< MeshConfig,
IdArrayAccessorType m_superentityIndices; IdArrayAccessorType m_superentityIndices;
SuperentityAccessorType superentityIndices; SuperentityAccessorType superentityIndices;
}; };
template< typename MeshConfig, template< typename MeshConfig,
...@@ -114,6 +131,8 @@ class tnlMeshSuperentityAccessLayer< MeshConfig, ...@@ -114,6 +131,8 @@ class tnlMeshSuperentityAccessLayer< MeshConfig,
void superentityIdsArray() {} void superentityIdsArray() {}
void getSuperentityIndices() {}; void getSuperentityIndices() {};
void print( ostream& str ) const {};
}; };
template< typename MeshConfig, template< typename MeshConfig,
...@@ -131,6 +150,8 @@ class tnlMeshSuperentityAccessLayer< MeshConfig, ...@@ -131,6 +150,8 @@ class tnlMeshSuperentityAccessLayer< MeshConfig,
void superentityIdsArray() {} void superentityIdsArray() {}
void getSuperentityIndices() {}; void getSuperentityIndices() {};
void print( ostream& str ) const {};
}; };
......
...@@ -54,12 +54,23 @@ class tnlMeshSuperentityAccessor ...@@ -54,12 +54,23 @@ class tnlMeshSuperentityAccessor
return this->ports[ localIndex ]; return this->ports[ localIndex ];
} }
void print( ostream& str ) const
{
str << ports;
}
protected: protected:
NetworkPorts ports; NetworkPorts ports;
}; };
template< typename NetworkPorts >
ostream& operator << ( ostream& str, const tnlMeshSuperentityAccessor< NetworkPorts >& superentityAccessor )
{
superentityAccessor.print( str );
return str;
}
#endif /* TNLMESHSUPERENTITYACCESSOR_H */ #endif /* TNLMESHSUPERENTITYACCESSOR_H */
...@@ -88,6 +88,13 @@ class tnlMesh : public tnlObject/*, ...@@ -88,6 +88,13 @@ class tnlMesh : public tnlObject/*,
template< typename DimensionsTag, typename SuperDimensionsTag > template< typename DimensionsTag, typename SuperDimensionsTag >
typename tnlMeshTraits< MeshConfig >::GlobalIdArrayType& superentityIdsArray(); typename tnlMeshTraits< MeshConfig >::GlobalIdArrayType& superentityIdsArray();
template< typename EntityTopology, typename SuperdimensionsTag >
typename MeshTraits::template SuperentityTraits< EntityTopology, SuperdimensionsTag::value >::StorageNetworkType&
getSuperentityStorageNetwork()
{
return entitiesStorage.template getSuperentityStorageNetwork< SuperdimensionsTag >( tnlDimensionsTag< EntityTopology::dimensions >() );
}
bool init( const typename MeshTraits::PointArrayType& points, bool init( const typename MeshTraits::PointArrayType& points,
const typename MeshTraits::CellSeedArrayType& cellSeeds ); const typename MeshTraits::CellSeedArrayType& cellSeeds );
......
...@@ -65,6 +65,7 @@ class tnlMeshTraits ...@@ -65,6 +65,7 @@ class tnlMeshTraits
template< typename EntityTopology, int SuperDimensions > using SuperentityTraits = template< typename EntityTopology, int SuperDimensions > using SuperentityTraits =
tnlMeshSuperentityTraits< MeshConfig, EntityTopology, SuperDimensions >; tnlMeshSuperentityTraits< MeshConfig, EntityTopology, SuperDimensions >;
typedef tnlDimensionsTag< meshDimensions > DimensionsTag; typedef tnlDimensionsTag< meshDimensions > DimensionsTag;
}; };
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#ifndef TNLELLPACKNETWORKPORTS_H #ifndef TNLELLPACKNETWORKPORTS_H
#define TNLELLPACKNETWORKPORTS_H #define TNLELLPACKNETWORKPORTS_H
#include <ostream>
#include <networks/tnlEllpackNetwork.h> #include <networks/tnlEllpackNetwork.h>
template< typename Index, template< typename Index,
...@@ -43,6 +44,8 @@ class tnlEllpackNetworkPorts ...@@ -43,6 +44,8 @@ class tnlEllpackNetworkPorts
const IndexType& operator[]( const IndexType portIndex ) const; const IndexType& operator[]( const IndexType portIndex ) const;
void print( std::ostream& str ) const;
protected: protected:
tnlEllpackNetworkPorts( IndexType* ports, tnlEllpackNetworkPorts( IndexType* ports,
...@@ -56,6 +59,10 @@ class tnlEllpackNetworkPorts ...@@ -56,6 +59,10 @@ class tnlEllpackNetworkPorts
friend tnlEllpackNetwork< IndexType, DeviceType >; friend tnlEllpackNetwork< IndexType, DeviceType >;
}; };
template< typename Index,
typename Device >
std::ostream& operator << ( std::ostream& str, const tnlEllpackNetworkPorts< Index, Device>& ports );
#include <networks/tnlEllpackNetworkPorts_impl.h> #include <networks/tnlEllpackNetworkPorts_impl.h>
......
...@@ -85,6 +85,30 @@ operator[]( const IndexType portIndex ) const ...@@ -85,6 +85,30 @@ operator[]( const IndexType portIndex ) const
return this->ports[ portIndex ]; return this->ports[ portIndex ];
} }
template< typename Index,
typename Device >
void
tnlEllpackNetworkPorts< Index, Device >::
print( std::ostream& str ) const
{
if( this->getPortsCount() == 0 )
{
str << "[]";
return;
}
str << "[ " << this->getOutput( 0 );
for( Index i = 1; i < this->getPortsCount(); i++ )
str << ", " << this->getOutput( i );
str << " ]";
}
template< typename Index,
typename Device >
std::ostream& operator << ( std::ostream& str, const tnlEllpackNetworkPorts< Index, Device>& ports )
{
ports.print( str );
return str;
}
#endif /* TNLELLPACKGRAPHLINKSACCESSOR_IMPL_H */ #endif /* TNLELLPACKGRAPHLINKSACCESSOR_IMPL_H */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment