Commit 015d4a1e authored by Marcel Koch's avatar Marcel Koch
Browse files

use unordered_map for primitive storage

parent fabdf3a8
...@@ -107,17 +107,18 @@ inline std::ostream& operator<<(std::ostream &os, const MigrationInfo & migratio ...@@ -107,17 +107,18 @@ inline std::ostream& operator<<(std::ostream &os, const MigrationInfo & migratio
return os; return os;
} }
class PrimitiveStorage : private walberla::NonCopyable class PrimitiveStorage : private walberla::NonCopyable
{ {
public: public:
typedef std::map< PrimitiveID::IDType, std::shared_ptr< Primitive > > PrimitiveMap; template < typename P >
typedef std::map< PrimitiveID::IDType, std::shared_ptr< Vertex > > VertexMap; using GenericPrimitiveMap = std::unordered_map< PrimitiveID::IDType, std::shared_ptr< P > >;
typedef std::map< PrimitiveID::IDType, std::shared_ptr< Edge > > EdgeMap; typedef GenericPrimitiveMap< Primitive > PrimitiveMap;
typedef std::map< PrimitiveID::IDType, std::shared_ptr< Face > > FaceMap; typedef GenericPrimitiveMap< Vertex > VertexMap;
typedef std::map< PrimitiveID::IDType, std::shared_ptr< Cell > > CellMap; typedef GenericPrimitiveMap< Edge > EdgeMap;
typedef GenericPrimitiveMap< Face > FaceMap;
explicit PrimitiveStorage( const SetupPrimitiveStorage& setupStorage, const uint_t& additionalHaloDepth = 0 ); typedef GenericPrimitiveMap< Cell > CellMap;
explicit PrimitiveStorage( const SetupPrimitiveStorage& setupStorage, const uint_t& additionalHaloDepth = 0 );
PrimitiveStorage( const SetupPrimitiveStorage& setupStorage, PrimitiveStorage( const SetupPrimitiveStorage& setupStorage,
const std::shared_ptr< walberla::WcTimingTree >& timingTree, const std::shared_ptr< walberla::WcTimingTree >& timingTree,
const uint_t& additionalHaloDepth = 0 ); const uint_t& additionalHaloDepth = 0 );
...@@ -568,10 +569,10 @@ class PrimitiveStorage : private walberla::NonCopyable ...@@ -568,10 +569,10 @@ class PrimitiveStorage : private walberla::NonCopyable
typename PrimitiveType, typename PrimitiveType,
typename DataHandlingType, typename DataHandlingType,
typename = typename std::enable_if< std::is_base_of< Primitive, PrimitiveType >::value >::type > typename = typename std::enable_if< std::is_base_of< Primitive, PrimitiveType >::value >::type >
inline void addPrimitiveData( const std::shared_ptr< DataHandlingType >& dataHandling, inline void addPrimitiveData( const std::shared_ptr< DataHandlingType >& dataHandling,
const std::string& identifier, const std::string& identifier,
const std::map< PrimitiveID::IDType, std::shared_ptr< PrimitiveType > >& primitives, const GenericPrimitiveMap< PrimitiveType >& primitives,
const PrimitiveDataID< DataType, PrimitiveType >& dataID ); const PrimitiveDataID< DataType, PrimitiveType >& dataID );
VertexMap vertices_; VertexMap vertices_;
EdgeMap edges_; EdgeMap edges_;
...@@ -764,8 +765,8 @@ template < typename DataType, typename PrimitiveType, typename DataHandlingType, ...@@ -764,8 +765,8 @@ template < typename DataType, typename PrimitiveType, typename DataHandlingType,
inline void inline void
PrimitiveStorage::addPrimitiveData( const std::shared_ptr< DataHandlingType >& dataHandling, PrimitiveStorage::addPrimitiveData( const std::shared_ptr< DataHandlingType >& dataHandling,
const std::string& identifier, // TODO remark: identifier not used in this function const std::string& identifier, // TODO remark: identifier not used in this function
const std::map< PrimitiveID::IDType, std::shared_ptr< PrimitiveType > >& primitives, const GenericPrimitiveMap< PrimitiveType >& primitives,
const PrimitiveDataID< DataType, PrimitiveType >& dataID ) const PrimitiveDataID< DataType, PrimitiveType >& dataID )
{ {
#ifndef NDEBUG #ifndef NDEBUG
for ( auto it = primitives.begin(); it != primitives.end(); it++ ) for ( auto it = primitives.begin(); it != primitives.end(); it++ )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment