From 91b64e4ab24fee8bc956e3e00fc0b4ae9e66447f Mon Sep 17 00:00:00 2001
From: Cristian C Lalescu <Cristian.Lalescu@mpcdf.mpg.de>
Date: Thu, 29 Apr 2021 14:41:14 +0200
Subject: [PATCH] fixes rhs additional_data usage for p2p call

---
 .../rhs/tracer_with_collision_counter_rhs.hpp        | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/cpp/particles/rhs/tracer_with_collision_counter_rhs.hpp b/cpp/particles/rhs/tracer_with_collision_counter_rhs.hpp
index 6688264d..9ba41c30 100644
--- a/cpp/particles/rhs/tracer_with_collision_counter_rhs.hpp
+++ b/cpp/particles/rhs/tracer_with_collision_counter_rhs.hpp
@@ -58,11 +58,13 @@ class tracer_with_collision_counter_rhs: public tracer_rhs<rnumber, be, tt>
             // interpolation adds on top of existing values, so result must be cleared.
             std::fill_n(result, pset.getLocalNumberOfParticles()*3, 0);
             int interpolation_result = (*(this->velocity))(t, pset, result);
-            additional_data.push_back(std::unique_ptr<abstract_particle_set::particle_rnumber[]>(
-                    new abstract_particle_set::particle_rnumber[pset.getLocalNumberOfParticles()*pset.getStateSize()]));
+            additional_data.insert(
+                    additional_data.begin(),
+                    std::unique_ptr<abstract_particle_set::particle_rnumber[]>(
+                        new abstract_particle_set::particle_rnumber[pset.getLocalNumberOfParticles()*pset.getStateSize()]));
             // copy rhs values to temporary array
             pset.copy_state_tofrom(
-                    additional_data[additional_data.size()-1].get(),
+                    additional_data[0].get(),
                     result);
             this->p2p_gc.reset_collision_pairs();
             pset.template applyP2PKernel<
@@ -74,9 +76,9 @@ class tracer_with_collision_counter_rhs: public tracer_rhs<rnumber, be, tt>
             // copy shuffled rhs values
             pset.copy_state_tofrom(
                     result,
-                    additional_data[additional_data.size()-1].get());
+                    additional_data[0].get());
             // clear temporary array
-            additional_data.pop_back();
+            additional_data.erase(additional_data.begin());
             return interpolation_result;
         }
 
-- 
GitLab