From 9e1610143f0e96b77ca962a7113d79a2fbcbf6f5 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Fri, 28 Dec 2018 17:33:35 -0500 Subject: partially fixed problems that arise in small systems by reworking the way that boundary edges are identified --- lib/src/graph.cpp | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) (limited to 'lib/src/graph.cpp') diff --git a/lib/src/graph.cpp b/lib/src/graph.cpp index 2fee5fd..7564fa7 100644 --- a/lib/src/graph.cpp +++ b/lib/src/graph.cpp @@ -6,7 +6,6 @@ #define JCV_REAL_TYPE double #define JCV_ATAN2 atan2 #define JCV_FLT_MAX 1.7976931348623157E+308 -#define NDEBUG #include // actual mod for floats @@ -65,27 +64,6 @@ graph::graph(unsigned int Nx, unsigned int Ny) { } } -namespace std -{ - template - struct hash > - { - typedef array argument_type; - typedef size_t result_type; - - result_type operator()(const argument_type& a) const - { - hash hasher; - result_type h = 0; - for (result_type i = 0; i < N; ++i) - { - h = h * 31 + hasher(a[i]); - } - return h; - } - }; -} - class eulerException: public std::exception { virtual const char* what() const throw() @@ -248,9 +226,13 @@ graph::graph(double Lx, double Ly, std::mt19937& rng, double relax, double step) } if (i1 < i2) { + unsigned int nn = neighbor->index % 9; + bool crossed_x = (nn == 1) || (nn == 2) || (nn > 4); + bool crossed_y = nn > 2; edges.push_back({{i1, i2}, {mod((site->p.x + neighbor->p.x) / 2, L.x), - mod((site->p.y + neighbor->p.y) / 2, L.y)} + mod((site->p.y + neighbor->p.y) / 2, L.y)}, + {crossed_x, crossed_y} }); jcv_graphedge *en; @@ -276,9 +258,13 @@ graph::graph(double Lx, double Ly, std::mt19937& rng, double relax, double step) vi2 = it2->second; } + bool dcrossed_x = (unsigned int)floor(e->pos[0].x / L.x) != (unsigned int)floor(e->pos[1].x / L.x); + bool dcrossed_y = (unsigned int)floor(e->pos[0].y / L.y) != (unsigned int)floor(e->pos[1].y / L.y); + dual_edges.push_back({{vi1, vi2}, {mod((e->pos[0].x + e->pos[1].x) / 2, L.x), - mod((e->pos[0].y + e->pos[1].y) / 2, L.y)} + mod((e->pos[0].y + e->pos[1].y) / 2, L.y)}, + {dcrossed_x, dcrossed_y} }); } -- cgit v1.2.3-70-g09d2