diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2022-10-06 12:09:33 +0200 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2022-10-06 12:09:33 +0200 |
commit | 1c246a15a2fce947a2d7c789f57f634d32603ee9 (patch) | |
tree | 1562b6e3339154025d17806259861a121671354e | |
parent | e55894853b0f254588f965fbf39b1e4cc132e7fe (diff) | |
download | code-1c246a15a2fce947a2d7c789f57f634d32603ee9.tar.gz code-1c246a15a2fce947a2d7c789f57f634d32603ee9.tar.bz2 code-1c246a15a2fce947a2d7c789f57f634d32603ee9.zip |
Modified to save data for all vertices, not just one sublattice.
-rw-r--r-- | order.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
@@ -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; } |