Loading Unstructured_mesh/main.cpp +0 −4 Original line number Original line Diff line number Diff line Loading @@ -982,10 +982,6 @@ void testFPMA_poly(){ int main() int main() { { vector<size_t> v(10,1); DBGVAR(v.data(), ((char *)&*(v.end())) - ((char*)&*(v.begin()))); void* p = 0; testMesh2D(); testMesh2D(); //testMesh2DLoadAndWrite(); //testMesh2DLoadAndWrite(); Loading src/UnstructuredMesh/MeshElements/MeshElements.h +58 −6 Original line number Original line Diff line number Diff line Loading @@ -3,6 +3,21 @@ #include "MeshElement.h" #include "MeshElement.h" /* namespace std { template <typename T> struct hash<std::vector<T>> { size_t operator()(const std::vector<T>& vec) { std::string byteCont(reinterpret_cast<const char*>(vec.data()), vec.size()*sizeof (T)); std::hash<std::string> hasher; return hasher(byteCont); } }; } */ template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> struct MeshElements{ struct MeshElements{ private: private: Loading Loading @@ -218,9 +233,12 @@ public: */ */ private: private: template<unsigned int Dim = Dimension, typename Dummy = void> template<unsigned int Dim = Dimension, typename Void = void> struct HashOfMeshElements{ struct HashOfMeshElements{ static size_t hash(MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){ static size_t hash(MeshElements<Dimension, IndexType, Real, Reserve...>& mesh) { std::hash<IndexType> indexHasher; std::hash<IndexType> indexHasher; // Hash of generic element eg. face // Hash of generic element eg. face Loading @@ -232,6 +250,23 @@ private: } } return elemHash ^ HashOfMeshElements<Dim - 1>::hash(mesh); return elemHash ^ HashOfMeshElements<Dim - 1>::hash(mesh); } } }; template<unsigned int Dim> struct HashOfMeshElements <Dim, typename std::enable_if<(MeshElements<Dimension, IndexType, Real, Reserve...>::template reserve<Dim>() > 0), size_t>::type>{ static size_t hash(MeshElements<Dimension, IndexType, Real, Reserve...>& mesh) { std::hash<std::string> hasher; // Use string as a byte container representing the array std::string tmpString(reinterpret_cast<char*>(mesh.template getElements<Dim>().data()), mesh.template getElements<Dim>().size() * sizeof (MeshElements<Dimension, IndexType, Real, Reserve...>::ElementType<Dim>)); size_t elemHash = hasher(tmpString); return elemHash ^ HashOfMeshElements<Dim - 1>::hash(mesh); } }; }; Loading @@ -243,7 +278,13 @@ private: static size_t hash(MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){ static size_t hash(MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){ // Hash of cells // Hash of cells size_t cHash = std::_Hash_impl::hash(mesh.getCells().data(), mesh.getCells().size() * sizeof (MeshElements<Dimension, IndexType, Real, Reserve...>::Cell)); std::hash<std::string> hasher; // Use string as a byte container representing the array std::string tmpString(reinterpret_cast<char*>(mesh.getCells().data()), mesh.getCells().size() * sizeof (MeshElements<Dimension, IndexType, Real, Reserve...>::Cell)); size_t cHash = hasher(tmpString); return cHash ^ HashOfMeshElements<Dimension -1>::hash(mesh); return cHash ^ HashOfMeshElements<Dimension -1>::hash(mesh); } } Loading @@ -253,8 +294,13 @@ private: struct HashOfMeshElements<1, Dummy>{ struct HashOfMeshElements<1, Dummy>{ static size_t hash(MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){ static size_t hash(MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){ // Hash of cells // Hash of edges size_t eHash = std::_Hash_impl::hash(mesh.getEdges().data(), mesh.getEdges().size() * sizeof (MeshElements<Dimension, IndexType, Real, Reserve...>::Edge)); std::hash<std::string> hasher; // Use string as a byte container representing the array std::string tmpString(reinterpret_cast<char*>(mesh.getEdges().data()), mesh.getEdges().size() * sizeof (MeshElements<Dimension, IndexType, Real, Reserve...>::Edge)); size_t eHash = hasher(tmpString); return eHash ^ HashOfMeshElements<0>::hash(mesh); return eHash ^ HashOfMeshElements<0>::hash(mesh); } } Loading @@ -266,7 +312,13 @@ private: static size_t hash(MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){ static size_t hash(MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){ // Hash of vertices // Hash of vertices size_t vHash = std::_Hash_impl::hash(&mesh.getVertices()[0], mesh.getVertices().size() * sizeof (MeshElements<Dimension, IndexType, Real, Reserve...>::Vertex)); std::hash<std::string> hasher; // Use string as a byte container representing the array std::string tmpString(reinterpret_cast<char*>(mesh.getVertices().data()), mesh.getVertices().size() * sizeof (MeshElements<Dimension, IndexType, Real, Reserve...>::Vertex)); size_t vHash = hasher(tmpString); return vHash; return vHash; } } Loading Loading
Unstructured_mesh/main.cpp +0 −4 Original line number Original line Diff line number Diff line Loading @@ -982,10 +982,6 @@ void testFPMA_poly(){ int main() int main() { { vector<size_t> v(10,1); DBGVAR(v.data(), ((char *)&*(v.end())) - ((char*)&*(v.begin()))); void* p = 0; testMesh2D(); testMesh2D(); //testMesh2DLoadAndWrite(); //testMesh2DLoadAndWrite(); Loading
src/UnstructuredMesh/MeshElements/MeshElements.h +58 −6 Original line number Original line Diff line number Diff line Loading @@ -3,6 +3,21 @@ #include "MeshElement.h" #include "MeshElement.h" /* namespace std { template <typename T> struct hash<std::vector<T>> { size_t operator()(const std::vector<T>& vec) { std::string byteCont(reinterpret_cast<const char*>(vec.data()), vec.size()*sizeof (T)); std::hash<std::string> hasher; return hasher(byteCont); } }; } */ template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> struct MeshElements{ struct MeshElements{ private: private: Loading Loading @@ -218,9 +233,12 @@ public: */ */ private: private: template<unsigned int Dim = Dimension, typename Dummy = void> template<unsigned int Dim = Dimension, typename Void = void> struct HashOfMeshElements{ struct HashOfMeshElements{ static size_t hash(MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){ static size_t hash(MeshElements<Dimension, IndexType, Real, Reserve...>& mesh) { std::hash<IndexType> indexHasher; std::hash<IndexType> indexHasher; // Hash of generic element eg. face // Hash of generic element eg. face Loading @@ -232,6 +250,23 @@ private: } } return elemHash ^ HashOfMeshElements<Dim - 1>::hash(mesh); return elemHash ^ HashOfMeshElements<Dim - 1>::hash(mesh); } } }; template<unsigned int Dim> struct HashOfMeshElements <Dim, typename std::enable_if<(MeshElements<Dimension, IndexType, Real, Reserve...>::template reserve<Dim>() > 0), size_t>::type>{ static size_t hash(MeshElements<Dimension, IndexType, Real, Reserve...>& mesh) { std::hash<std::string> hasher; // Use string as a byte container representing the array std::string tmpString(reinterpret_cast<char*>(mesh.template getElements<Dim>().data()), mesh.template getElements<Dim>().size() * sizeof (MeshElements<Dimension, IndexType, Real, Reserve...>::ElementType<Dim>)); size_t elemHash = hasher(tmpString); return elemHash ^ HashOfMeshElements<Dim - 1>::hash(mesh); } }; }; Loading @@ -243,7 +278,13 @@ private: static size_t hash(MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){ static size_t hash(MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){ // Hash of cells // Hash of cells size_t cHash = std::_Hash_impl::hash(mesh.getCells().data(), mesh.getCells().size() * sizeof (MeshElements<Dimension, IndexType, Real, Reserve...>::Cell)); std::hash<std::string> hasher; // Use string as a byte container representing the array std::string tmpString(reinterpret_cast<char*>(mesh.getCells().data()), mesh.getCells().size() * sizeof (MeshElements<Dimension, IndexType, Real, Reserve...>::Cell)); size_t cHash = hasher(tmpString); return cHash ^ HashOfMeshElements<Dimension -1>::hash(mesh); return cHash ^ HashOfMeshElements<Dimension -1>::hash(mesh); } } Loading @@ -253,8 +294,13 @@ private: struct HashOfMeshElements<1, Dummy>{ struct HashOfMeshElements<1, Dummy>{ static size_t hash(MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){ static size_t hash(MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){ // Hash of cells // Hash of edges size_t eHash = std::_Hash_impl::hash(mesh.getEdges().data(), mesh.getEdges().size() * sizeof (MeshElements<Dimension, IndexType, Real, Reserve...>::Edge)); std::hash<std::string> hasher; // Use string as a byte container representing the array std::string tmpString(reinterpret_cast<char*>(mesh.getEdges().data()), mesh.getEdges().size() * sizeof (MeshElements<Dimension, IndexType, Real, Reserve...>::Edge)); size_t eHash = hasher(tmpString); return eHash ^ HashOfMeshElements<0>::hash(mesh); return eHash ^ HashOfMeshElements<0>::hash(mesh); } } Loading @@ -266,7 +312,13 @@ private: static size_t hash(MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){ static size_t hash(MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){ // Hash of vertices // Hash of vertices size_t vHash = std::_Hash_impl::hash(&mesh.getVertices()[0], mesh.getVertices().size() * sizeof (MeshElements<Dimension, IndexType, Real, Reserve...>::Vertex)); std::hash<std::string> hasher; // Use string as a byte container representing the array std::string tmpString(reinterpret_cast<char*>(mesh.getVertices().data()), mesh.getVertices().size() * sizeof (MeshElements<Dimension, IndexType, Real, Reserve...>::Vertex)); size_t vHash = hasher(tmpString); return vHash; return vHash; } } Loading