Skip to content
Snippets Groups Projects
Commit 99ecd94b authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Slight connectivity performances improvement by unordered_map

parent 9e0f0343
No related branches found
No related tags found
No related merge requests found
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <ConnectivityUtils.hpp> #include <ConnectivityUtils.hpp>
#include <vector> #include <vector>
#include <map> #include <map>
#include <unordered_map>
#include <algorithm> #include <algorithm>
#include <RefId.hpp> #include <RefId.hpp>
...@@ -59,6 +60,18 @@ private: ...@@ -59,6 +60,18 @@ private:
class Face class Face
{ {
public:
friend struct Hash;
struct Hash {
size_t operator()(const Face& f) const
{
size_t hash = 0;
for (size_t i=0; i<f.m_node_id_list.size(); ++i) {
hash ^= std::hash<unsigned int>()(f.m_node_id_list[i]) >> i;
}
return hash;
}
};
private: private:
bool m_reversed; bool m_reversed;
std::vector<unsigned int> m_node_id_list; std::vector<unsigned int> m_node_id_list;
...@@ -156,7 +169,7 @@ private: ...@@ -156,7 +169,7 @@ private:
~Face() = default; ~Face() = default;
}; };
std::map<Face,unsigned int> m_face_number_map; std::unordered_map<Face,unsigned int, Face::Hash> m_face_number_map;
void _computeFaceCellConnectivities() void _computeFaceCellConnectivities()
{ {
...@@ -346,7 +359,7 @@ private: ...@@ -346,7 +359,7 @@ private:
} }
m_face_cell_local_face = face_cell_local_face; m_face_cell_local_face = face_cell_local_face;
std::map<unsigned int, std::vector<unsigned int>> node_faces_map; std::unordered_map<unsigned int, std::vector<unsigned int>> node_faces_map;
for (size_t l=0; l<m_number_of_faces; ++l) { for (size_t l=0; l<m_number_of_faces; ++l) {
for (size_t lr=0; lr<face_nb_nodes(l); ++lr) { for (size_t lr=0; lr<face_nb_nodes(l); ++lr) {
const unsigned int r = face_nodes(l, lr); const unsigned int r = face_nodes(l, lr);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment