From 1c246a15a2fce947a2d7c789f57f634d32603ee9 Mon Sep 17 00:00:00 2001
From: Jaron Kent-Dobias <jaron@kent-dobias.com>
Date: Thu, 6 Oct 2022 12:09:33 +0200
Subject: Modified to save data for all vertices, not just one sublattice.

---
 order.cpp | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/order.cpp b/order.cpp
index 21335ad..22e08f6 100644
--- a/order.cpp
+++ b/order.cpp
@@ -30,18 +30,21 @@ int main(int argc, char* argv[]) {
                                   std::transform(omp_out.begin(), omp_out.end(), omp_in.begin(), omp_out.begin(), std::plus<long int>())) \
                       initializer(omp_priv = decltype(omp_orig)(omp_orig.size()))
 
-  std::vector<long int> data_x(G.vertices.size() / 2);
-  std::vector<long int> data_y(G.vertices.size() / 2);
+  std::vector<long int> data_x(G.vertices.size());
+  std::vector<long int> data_y(G.vertices.size());
 
   std::string filename = "order_" + std::to_string(n) + ".dat";
   std::ifstream input(filename);
 
-  for (unsigned i = 0; i < G.vertices.size() / 2; i++) {
-    input >> data_x[i];
-    input >> data_y[i];
+  if (input.is_open()) {
+    for (unsigned i = 0; i < G.vertices.size(); i++) {
+      input >> data_x[i];
+      input >> data_y[i];
+    }
+
+    input.close();
   }
 
-  input.close();
 
 #pragma omp parallel for reduction(vec_int_plus : data_x) reduction(vec_int_plus : data_y)
   for (unsigned i = 0; i < m; i++) {
@@ -61,12 +64,17 @@ int main(int argc, char* argv[]) {
       data_y[i] += G.vertices[i].coordinate[1];
       data_x[i] -= G.vertices[j].coordinate[0];
       data_y[i] -= G.vertices[j].coordinate[1];
+
+      data_x[j] += G.vertices[i].coordinate[0];
+      data_y[j] += G.vertices[i].coordinate[1];
+      data_x[j] -= G.vertices[j].coordinate[0];
+      data_y[j] -= G.vertices[j].coordinate[1];
     }
   }
 
   std::ofstream output(filename);
 
-  for (unsigned i = 0; i < G.vertices.size() / 2; i++) {
+  for (unsigned i = 0; i < G.vertices.size(); i++) {
     output << data_x[i] << " " << data_y[i] << std::endl;
   }
 
-- 
cgit v1.2.3-70-g09d2