From adc3778844b8c3ff74ec61d876109d18187e28bc Mon Sep 17 00:00:00 2001
From: Chichi Lalescu <clalesc1@jhu.edu>
Date: Sun, 19 Jul 2015 14:06:17 +0200
Subject: [PATCH] fix real space energy error

---
 bfps/NavierStokes.py |  2 +-
 src/fluid_solver.cpp |  1 +
 test.py              | 40 ++++++++++++++++++++--------------------
 3 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/bfps/NavierStokes.py b/bfps/NavierStokes.py
index 2c0bb8bb..5beaf742 100644
--- a/bfps/NavierStokes.py
+++ b/bfps/NavierStokes.py
@@ -78,7 +78,7 @@ class NavierStokes(bfps.code):
                                fsolver->ru[1]*fsolver->ru[1] +
                                fsolver->ru[2]*fsolver->ru[2]);
                     stats[2] = sqrt(val_tmp);
-                    stats[3] = val_tmp*.5;
+                    stats[3] = 0.0; //val_tmp*.5;
                     //for (ptrdiff_t rindex = 0; rindex < (fsolver->cd->local_size/3)*2; rindex++)
                     RLOOP_FOR_OBJECT(
                         fsolver,
diff --git a/src/fluid_solver.cpp b/src/fluid_solver.cpp
index a9f201d9..20ebf3d9 100644
--- a/src/fluid_solver.cpp
+++ b/src/fluid_solver.cpp
@@ -21,6 +21,7 @@
 
 #include <cassert>
 #include <cmath>
+#include <cstring>
 #include "fluid_solver.hpp"
 #include "fftw_tools.hpp"
 
diff --git a/test.py b/test.py
index 55c7114a..5d2e6de4 100755
--- a/test.py
+++ b/test.py
@@ -280,24 +280,24 @@ if __name__ == '__main__':
     #test_curl(opt)
     NStest(opt)
     #resize_test(opt)
-    Rdata = np.fromfile(
-            'data/test_rvorticity_i00000',
-            dtype = np.float32).reshape(opt.n,
-                                        opt.n,
-                                        opt.n, 3)
-    tdata = Rdata.transpose(3, 0, 1, 2).copy()
-    tdata.tofile('../vortex/input_split_per_component')
-    stats_vortex = np.loadtxt('../vortex/sim_000000.log')
-    dtype = pickle.load(open('data/NavierStokes_dtype.pickle', 'r'))
-    stats = np.fromfile('data/test_stats.bin', dtype = dtype)
-    fig = plt.figure(figsize = (12, 6))
-    a = fig.add_subplot(121)
-    a.plot(stats['t'], stats['energy'])
-    a.plot(stats_vortex[:, 2], stats_vortex[:, 3], dashes = (2, 4))
-    a.set_xlim(0, 2)
-    a = fig.add_subplot(122)
-    a.plot(stats['t'], stats['enstrophy'])
-    a.plot(stats_vortex[:, 2], stats_vortex[:, 9]/2, dashes = (2, 4))
-    a.set_xlim(0, 2)
-    fig.savefig('vortex_comparison.pdf', format = 'pdf')
+    #Rdata = np.fromfile(
+    #        'data/test_rvorticity_i00000',
+    #        dtype = np.float32).reshape(opt.n,
+    #                                    opt.n,
+    #                                    opt.n, 3)
+    #tdata = Rdata.transpose(3, 0, 1, 2).copy()
+    #tdata.tofile('../vortex/input_split_per_component')
+    #stats_vortex = np.loadtxt('../vortex/sim_000000.log')
+    #dtype = pickle.load(open('data/NavierStokes_dtype.pickle', 'r'))
+    #stats = np.fromfile('data/test_stats.bin', dtype = dtype)
+    #fig = plt.figure(figsize = (12, 6))
+    #a = fig.add_subplot(121)
+    #a.plot(stats['t'], stats['energy'])
+    #a.plot(stats_vortex[:, 2], stats_vortex[:, 3], dashes = (2, 4))
+    #a.set_xlim(0, 2)
+    #a = fig.add_subplot(122)
+    #a.plot(stats['t'], stats['enstrophy'])
+    #a.plot(stats_vortex[:, 2], stats_vortex[:, 9]/2, dashes = (2, 4))
+    #a.set_xlim(0, 2)
+    #fig.savefig('vortex_comparison.pdf', format = 'pdf')
 
-- 
GitLab