Skip to content

Commit

Permalink
Merge pull request #16815 from bangerth/fix-particle-size-2
Browse files Browse the repository at this point in the history
Fix a second place where particles compute the size of a buffer.
  • Loading branch information
tamiko committed Mar 30, 2024
2 parents 3648bae + f63778c commit ff1ac3b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
5 changes: 3 additions & 2 deletions include/deal.II/particles/particle_accessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down
14 changes: 13 additions & 1 deletion source/particles/particle_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit ff1ac3b

Please sign in to comment.