From b880d863747f6eec41a109ceb9dc8b523c89874c Mon Sep 17 00:00:00 2001
From: Cristian C Lalescu <Cristian.Lalescu@ds.mpg.de>
Date: Sun, 31 Jan 2016 22:11:24 +0100
Subject: [PATCH] simplify grwo_particle_datasets

---
 bfps/NavierStokes.py |  7 ++-----
 bfps/_fluid_base.py  | 12 +++++-------
 2 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/bfps/NavierStokes.py b/bfps/NavierStokes.py
index ebae77dc..7f82de44 100644
--- a/bfps/NavierStokes.py
+++ b/bfps/NavierStokes.py
@@ -75,7 +75,6 @@ class NavierStokes(_fluid_particle_base):
         self.parameters['max_R_estimate'] = 1.0
         self.file_datasets_grow = """
                 //begincpp
-                std::string temp_string;
                 hsize_t dims[4];
                 hid_t group;
                 hid_t Cspace, Cdset;
@@ -491,10 +490,8 @@ class NavierStokes(_fluid_particle_base):
             self.parameters['tracers{0}_integration_steps'.format(s0 + s)] = integration_steps[s]
             self.file_datasets_grow += """
                         //begincpp
-                        temp_string = (std::string("/") +
-                                       std::string(ps{0}->name));
-                        group = H5Gopen(particle_file, temp_string.c_str(), H5P_DEFAULT);
-                        grow_particle_datasets(group, temp_string.c_str(), NULL, NULL);
+                        group = H5Gopen(particle_file, ps{0}->name, H5P_DEFAULT);
+                        grow_particle_datasets(group, "", NULL, NULL);
                         H5Gclose(group);
                         //endcpp
                         """.format(s0 + s)
diff --git a/bfps/_fluid_base.py b/bfps/_fluid_base.py
index 92aa5822..aece5819 100644
--- a/bfps/_fluid_base.py
+++ b/bfps/_fluid_base.py
@@ -117,17 +117,15 @@ class _fluid_particle_base(_code):
                              'H5Dclose(dset);\n}\n' +
                              'return 0;\n}\n')
         self.definitions += ('herr_t grow_particle_datasets(hid_t g_id, const char *name, const H5L_info_t *info, void *op_data)\n{\n' +
-                             'std::string full_name;\n' +
                              'hsize_t dset;\n')
         for key in ['state', 'velocity', 'acceleration']:
-            self.definitions += ('full_name = (std::string(name) + std::string("/{0}"));\n'.format(key) +
-                                 'if (H5Lexists(g_id, full_name.c_str(), H5P_DEFAULT))\n{\n' +
-                                 'dset = H5Dopen(g_id, full_name.c_str(), H5P_DEFAULT);\n' +
+            self.definitions += ('if (H5Lexists(g_id, "{0}", H5P_DEFAULT))\n'.format(key) +
+                                 '{\n' +
+                                 'dset = H5Dopen(g_id, "{0}", H5P_DEFAULT);\n'.format(key) +
                                  'grow_single_dataset(dset, niter_todo/niter_part);\n' +
                                  'H5Dclose(dset);\n}\n')
-        self.definitions += ('full_name = (std::string(name) + std::string("/rhs"));\n' +
-                             'if (H5Lexists(g_id, full_name.c_str(), H5P_DEFAULT))\n{\n' +
-                             'dset = H5Dopen(g_id, full_name.c_str(), H5P_DEFAULT);\n' +
+        self.definitions += ('if (H5Lexists(g_id, "rhs", H5P_DEFAULT))\n{\n' +
+                             'dset = H5Dopen(g_id, "rhs", H5P_DEFAULT);\n' +
                              'grow_single_dataset(dset, 1);\n' +
                              'H5Dclose(dset);\n}\n' +
                              'return 0;\n}\n')
-- 
GitLab