From: Wolfgang Bangerth Date: Fri, 29 Mar 2024 19:21:50 +0000 (-0600) Subject: Fix a second place where particles compute the size of a buffer. X-Git-Tag: v9.6.0-rc1~427^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f63778cf09ffd05bb3a61c8ff100245d9edfb9ff;p=dealii.git Fix a second place where particles compute the size of a buffer. --- diff --git a/include/deal.II/particles/particle_accessor.h b/include/deal.II/particles/particle_accessor.h index 447af7832d..8e5af0e47b 100644 --- a/include/deal.II/particles/particle_accessor.h +++ b/include/deal.II/particles/particle_accessor.h @@ -883,8 +883,9 @@ namespace Particles { Assert(state() == IteratorState::valid, ExcInternalError()); - std::size_t size = sizeof(get_id()) + sizeof(get_location()) + - sizeof(get_reference_location()); + std::size_t size = sizeof(get_id()) + + sizeof(double) * spacedim + // get_location() + sizeof(double) * dim; // get_reference_location() if (has_properties()) { diff --git a/source/particles/particle_handler.cc b/source/particles/particle_handler.cc index e3ba25194c..7280ba15e2 100644 --- a/source/particles/particle_handler.cc +++ b/source/particles/particle_handler.cc @@ -2366,7 +2366,19 @@ namespace Particles &(*data_range.begin()) + (data_range.end() - data_range.begin())); while (data < end) - insert_particle(data, cell_to_store_particles); + { + const void *old_data = data; + const auto x = insert_particle(data, cell_to_store_particles); + + // Ensure that the particle read exactly as much data as + // it promised it needs to store its data + const void *new_data = data; + (void)old_data; + (void)new_data; + (void)x; + AssertDimension((const char *)new_data - (const char *)old_data, + x->serialized_size_in_bytes()); + } Assert(data == end, ExcMessage(