From eec00ff2196d739d5ee1524eb8af9959b31d74a4 Mon Sep 17 00:00:00 2001
From: sniklas142 <niklas.schnierstein@googlemail.com>
Date: Thu, 5 Dec 2019 20:20:06 +0100
Subject: [PATCH] can read arbitrary iteration

---
 cpp/full_code/NSVE_field_stats.cpp | 27 +++++++++++++++++++++++++++
 cpp/full_code/NSVE_field_stats.hpp |  1 +
 2 files changed, 28 insertions(+)

diff --git a/cpp/full_code/NSVE_field_stats.cpp b/cpp/full_code/NSVE_field_stats.cpp
index 0969175c..9c6ea1c1 100644
--- a/cpp/full_code/NSVE_field_stats.cpp
+++ b/cpp/full_code/NSVE_field_stats.cpp
@@ -101,6 +101,33 @@ int NSVE_field_stats<rnumber>::read_current_cvorticity(void)
     }
     return EXIT_SUCCESS;
 }
+template <typename rnumber>
+int NSVE_field_stats<rnumber>::read_arbitrary_cvorticity(int iter)
+{
+    TIMEZONE("NSVE_field_stats::read_arbitrary_cvorticity");
+    this->vorticity->real_space_representation = false;
+    if (this->bin_IO != NULL)
+    {
+        char itername[16];
+        sprintf(itername, "i%.5x", iter);
+        std::string native_binary_fname = (
+                this->simname +
+                std::string("_cvorticity_") +
+                std::string(itername));
+        this->bin_IO->read(
+                native_binary_fname,
+                this->vorticity->get_cdata());
+    }
+    else
+    {
+        this->vorticity->io(
+                this->simname + std::string("_fields.h5"),
+                "vorticity",
+                iter,
+                true);
+    }
+    return EXIT_SUCCESS;
+}
 
 template <typename rnumber>
 int NSVE_field_stats<rnumber>::finalize(void)
diff --git a/cpp/full_code/NSVE_field_stats.hpp b/cpp/full_code/NSVE_field_stats.hpp
index 28a2376f..0939ba03 100644
--- a/cpp/full_code/NSVE_field_stats.hpp
+++ b/cpp/full_code/NSVE_field_stats.hpp
@@ -59,6 +59,7 @@ class NSVE_field_stats: public postprocess
         virtual int finalize(void);
 
         int read_current_cvorticity(void);
+        int read_arbitrary_cvorticity(int iter);
 };
 
 #endif//NSVE_FIELD_STATS_HPP
-- 
GitLab