From b6fd6847624506ad35c43c2c9394cc99776a08f6 Mon Sep 17 00:00:00 2001
From: Cristian C Lalescu <Cristian.Lalescu@ds.mpg.de>
Date: Wed, 24 May 2017 15:13:33 +0200
Subject: [PATCH] add empty postprocessing class

---
 bfps/cpp/full_code/NSVE.cpp                   |  4 +-
 bfps/cpp/full_code/code_base.hpp              |  5 ++
 .../full_code/direct_numerical_simulation.hpp |  2 +-
 bfps/cpp/full_code/native_binary_to_hdf5.cpp  | 33 ++++++++++
 bfps/cpp/full_code/native_binary_to_hdf5.hpp  | 60 +++++++++++++++++++
 bfps/cpp/full_code/postprocess.cpp            | 28 +++++++++
 bfps/cpp/full_code/postprocess.hpp            | 59 ++++++++++++++++++
 setup.py                                      |  2 +
 8 files changed, 190 insertions(+), 3 deletions(-)
 create mode 100644 bfps/cpp/full_code/native_binary_to_hdf5.cpp
 create mode 100644 bfps/cpp/full_code/native_binary_to_hdf5.hpp
 create mode 100644 bfps/cpp/full_code/postprocess.cpp
 create mode 100644 bfps/cpp/full_code/postprocess.hpp

diff --git a/bfps/cpp/full_code/NSVE.cpp b/bfps/cpp/full_code/NSVE.cpp
index 0b82a781..9c40968a 100644
--- a/bfps/cpp/full_code/NSVE.cpp
+++ b/bfps/cpp/full_code/NSVE.cpp
@@ -36,11 +36,11 @@ int NSVE<rnumber>::initialize(void)
             simname.c_str(),
             nx, ny, nz,
             dkx, dky, dkz,
-            FFTW_MEASURE);
+            DEFAULT_FFTW_FLAG);
     this->tmp_vec_field = new field<rnumber, FFTW, THREE>(
             nx, ny, nz,
             this->comm,
-            FFTW_MEASURE);
+            DEFAULT_FFTW_FLAG);
 
 
     this->fs->checkpoints_per_file = checkpoints_per_file;
diff --git a/bfps/cpp/full_code/code_base.hpp b/bfps/cpp/full_code/code_base.hpp
index 6fc29ff1..08a234b7 100644
--- a/bfps/cpp/full_code/code_base.hpp
+++ b/bfps/cpp/full_code/code_base.hpp
@@ -41,6 +41,7 @@ class code_base
         MPI_Comm comm;
 
         std::string simname;
+        int iteration;
 
         bool stop_code_now;
 
@@ -91,6 +92,10 @@ class code_base
             this->time0 = this->time1;
             return EXIT_SUCCESS;
         }
+
+        virtual int initialize(void) = 0;
+        virtual int main_loop(void) = 0;
+        virtual int finalize(void) = 0;
 };
 
 #endif//CODE_BASE_HPP
diff --git a/bfps/cpp/full_code/direct_numerical_simulation.hpp b/bfps/cpp/full_code/direct_numerical_simulation.hpp
index 978f91b2..8050bb04 100644
--- a/bfps/cpp/full_code/direct_numerical_simulation.hpp
+++ b/bfps/cpp/full_code/direct_numerical_simulation.hpp
@@ -36,7 +36,7 @@
 class direct_numerical_simulation: public code_base
 {
     public:
-        int iteration, checkpoint;
+        int checkpoint;
         int checkpoints_per_file;
         int niter_out;
         int niter_stat;
diff --git a/bfps/cpp/full_code/native_binary_to_hdf5.cpp b/bfps/cpp/full_code/native_binary_to_hdf5.cpp
new file mode 100644
index 00000000..ee1b6f9d
--- /dev/null
+++ b/bfps/cpp/full_code/native_binary_to_hdf5.cpp
@@ -0,0 +1,33 @@
+#include <string>
+#include <cmath>
+#include "native_binary_to_hdf5.hpp"
+#include "scope_timer.hpp"
+
+
+template <typename rnumber>
+int native_binary_to_hdf5<rnumber>::initialize(void)
+{
+    this->read_parameters();
+    this->vec_field = new field<rnumber, FFTW, THREE>(
+            nx, ny, nz,
+            this->comm,
+            DEFAULT_FFTW_FLAG);
+    return EXIT_SUCCESS;
+}
+
+template <typename rnumber>
+int native_binary_to_hdf5<rnumber>::work_on_current_iteration(void)
+{
+    return EXIT_SUCCESS;
+}
+
+template <typename rnumber>
+int native_binary_to_hdf5<rnumber>::finalize(void)
+{
+    delete this->vec_field;
+    return EXIT_SUCCESS;
+}
+
+template class native_binary_to_hdf5<float>;
+template class native_binary_to_hdf5<double>;
+
diff --git a/bfps/cpp/full_code/native_binary_to_hdf5.hpp b/bfps/cpp/full_code/native_binary_to_hdf5.hpp
new file mode 100644
index 00000000..2235e4fc
--- /dev/null
+++ b/bfps/cpp/full_code/native_binary_to_hdf5.hpp
@@ -0,0 +1,60 @@
+/**********************************************************************
+*                                                                     *
+*  Copyright 2017 Max Planck Institute                                *
+*                 for Dynamics and Self-Organization                  *
+*                                                                     *
+*  This file is part of bfps.                                         *
+*                                                                     *
+*  bfps is free software: you can redistribute it and/or modify       *
+*  it under the terms of the GNU General Public License as published  *
+*  by the Free Software Foundation, either version 3 of the License,  *
+*  or (at your option) any later version.                             *
+*                                                                     *
+*  bfps is distributed in the hope that it will be useful,            *
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of     *
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      *
+*  GNU General Public License for more details.                       *
+*                                                                     *
+*  You should have received a copy of the GNU General Public License  *
+*  along with bfps.  If not, see <http://www.gnu.org/licenses/>       *
+*                                                                     *
+* Contact: Cristian.Lalescu@ds.mpg.de                                 *
+*                                                                     *
+**********************************************************************/
+
+
+
+#ifndef NATIVE_BINARY_TO_HDF5_HPP
+#define NATIVE_BINARY_TO_HDF5_HPP
+
+#include <cstdlib>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <vector>
+#include "base.hpp"
+#include "field.hpp"
+#include "full_code/postprocess.hpp"
+
+template <typename rnumber>
+class native_binary_to_hdf5: public postprocess
+{
+    public:
+
+        field<rnumber, FFTW, THREE> *vec_field;
+
+        native_binary_to_hdf5(
+                const MPI_Comm COMMUNICATOR,
+                const std::string &simulation_name):
+            postprocess(
+                    COMMUNICATOR,
+                    simulation_name){}
+        virtual ~native_binary_to_hdf5(){}
+
+        int initialize(void);
+        int work_on_current_iteration(void);
+        int finalize(void);
+        virtual int read_parameters(void);
+};
+
+#endif//NATIVE_BINARY_TO_HDF5_HPP
+
diff --git a/bfps/cpp/full_code/postprocess.cpp b/bfps/cpp/full_code/postprocess.cpp
new file mode 100644
index 00000000..3c6eed59
--- /dev/null
+++ b/bfps/cpp/full_code/postprocess.cpp
@@ -0,0 +1,28 @@
+#include <cstdlib>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include "scope_timer.hpp"
+#include "hdf5_tools.hpp"
+#include "full_code/postprocess.hpp"
+
+
+int postprocess::main_loop(void)
+{
+    this->start_simple_timer();
+    for (unsigned int iteration_counter = 0;
+         iteration_counter < iteration_list.size();
+         iteration_counter++)
+    {
+        this->iteration = iteration_list[iteration_counter];
+    #ifdef USE_TIMINGOUTPUT
+        const std::string loopLabel = ("postprocess::main_loop-" +
+                                       std::to_string(this->iteration));
+        TIMEZONE(loopLabel.c_str());
+    #endif
+        this->work_on_current_iteration();
+        this->print_simple_timer(
+                "iteration " + std::to_string(this->iteration));
+    }
+    return EXIT_SUCCESS;
+}
+
diff --git a/bfps/cpp/full_code/postprocess.hpp b/bfps/cpp/full_code/postprocess.hpp
new file mode 100644
index 00000000..5d3e578d
--- /dev/null
+++ b/bfps/cpp/full_code/postprocess.hpp
@@ -0,0 +1,59 @@
+/**********************************************************************
+*                                                                     *
+*  Copyright 2017 Max Planck Institute                                *
+*                 for Dynamics and Self-Organization                  *
+*                                                                     *
+*  This file is part of bfps.                                         *
+*                                                                     *
+*  bfps is free software: you can redistribute it and/or modify       *
+*  it under the terms of the GNU General Public License as published  *
+*  by the Free Software Foundation, either version 3 of the License,  *
+*  or (at your option) any later version.                             *
+*                                                                     *
+*  bfps is distributed in the hope that it will be useful,            *
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of     *
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      *
+*  GNU General Public License for more details.                       *
+*                                                                     *
+*  You should have received a copy of the GNU General Public License  *
+*  along with bfps.  If not, see <http://www.gnu.org/licenses/>       *
+*                                                                     *
+* Contact: Cristian.Lalescu@ds.mpg.de                                 *
+*                                                                     *
+**********************************************************************/
+
+
+
+#ifndef POSTPROCESS_HPP
+#define POSTPROCESS_HPP
+
+#include <cstdlib>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <vector>
+#include "base.hpp"
+#include "full_code/code_base.hpp"
+
+class postprocess: public code_base
+{
+    public:
+        std::vector<int> iteration_list;
+        hid_t stat_file;
+
+        postprocess(
+                const MPI_Comm COMMUNICATOR,
+                const std::string &simulation_name):
+            code_base(
+                    COMMUNICATOR,
+                    simulation_name){}
+        virtual ~postprocess(){}
+
+        virtual int initialize(void) = 0;
+        virtual int work_on_current_iteration(void) = 0;
+        virtual int finalize(void) = 0;
+
+        int main_loop(void);
+};
+
+#endif//POSTPROCESS_HPP
+
diff --git a/setup.py b/setup.py
index f9574c84..cd2dd02a 100644
--- a/setup.py
+++ b/setup.py
@@ -89,6 +89,8 @@ print('This is bfps version ' + VERSION)
 
 ### lists of files and MANIFEST.in
 src_file_list = ['hdf5_tools',
+                 'full_code/native_binary_to_hdf5',
+                 'full_code/postprocess',
                  'full_code/code_base',
                  'full_code/direct_numerical_simulation',
                  'full_code/NSVE',
-- 
GitLab