From ff496c99bda48e13397195be08d6a5edb9db2a3c Mon Sep 17 00:00:00 2001
From: Rafael Ravedutti <rafaelravedutti@gmail.com>
Date: Fri, 22 Mar 2024 21:54:44 +0100
Subject: [PATCH] Check particle capacity on ParticleDataHandling

Signed-off-by: Rafael Ravedutti <rafaelravedutti@gmail.com>
---
 runtime/domain/ParticleDataHandling.hpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/runtime/domain/ParticleDataHandling.hpp b/runtime/domain/ParticleDataHandling.hpp
index 490b0b3..7636fdf 100644
--- a/runtime/domain/ParticleDataHandling.hpp
+++ b/runtime/domain/ParticleDataHandling.hpp
@@ -175,14 +175,16 @@ public:
 
     void deserializeImpl(IBlock *const, const BlockDataID&, mpi::RecvBuffer& buffer) {
         int nlocal = ps->getTrackedVariableAsInteger("nlocal");
+        int particle_capacity = ps->getTrackedVariableAsInteger("particle_capacity");
         real_t real_tmp;
         int int_tmp;
         uint_t nrecv;
 
         buffer >> nrecv;
 
-        // TODO: Check if there is enough particle capacity for the new particles
-        // md_resize_recv_buffer_capacity((int) nparticles);
+        // TODO: Check if there is enough particle capacity for the new particles, when there is not,
+        // all properties and arrays which have particle_capacity as one of their dimensions must be reallocated
+        PAIRS_ASSERT(nlocal + nrecv < particle_capacity);
 
         for(int i = 0; i < nrecv; ++i) {
             for(auto &prop: ps->getProperties()) {
-- 
GitLab