]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix a second place where particles compute the size of a buffer. 16815/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Fri, 29 Mar 2024 19:21:50 +0000 (13:21 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Fri, 29 Mar 2024 20:38:29 +0000 (14:38 -0600)
include/deal.II/particles/particle_accessor.h
source/particles/particle_handler.cc

index 447af7832d61437754ae4c9e142d43b024a442d9..8e5af0e47b38db8deaa0953fb9aeb4794d1ac62a 100644 (file)
@@ -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())
       {
index e3ba25194ca0557264017f85afe452fa0e706f62..7280ba15e2a3684bb4b86368e71d6514236d7c4d 100644 (file)
@@ -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(

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.