]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Avoid memory allocations in step 68 15832/head
authorRene Gassmoeller <rene.gassmoeller@mailbox.org>
Wed, 2 Aug 2023 20:43:36 +0000 (16:43 -0400)
committerRene Gassmoeller <rene.gassmoeller@mailbox.org>
Wed, 2 Aug 2023 21:08:11 +0000 (17:08 -0400)
examples/step-68/step-68.cc
tests/performance/timing_step_68.cc

index 38bd36561bb040bc0a5d7a8e66cd08eb05c3c745..58d49c5bd7f0f24045be37035d1f72bbca24ecc0 100644 (file)
@@ -541,6 +541,7 @@ namespace Step68
     Vector<double> local_dof_values(fluid_fe.dofs_per_cell);
 
     FEPointEvaluation<dim, dim> evaluator(mapping, fluid_fe, update_values);
+    std::vector<Point<dim>>     particle_positions;
 
     // We loop over all the local particles. Although this could be achieved
     // directly by looping over all the cells, this would force us
@@ -564,7 +565,7 @@ namespace Step68
         // This is achieved using FEPointEvaluation object.
         const auto pic = particle_handler.particles_in_cell(cell);
         Assert(pic.begin() == particle, ExcInternalError());
-        std::vector<Point<dim>> particle_positions;
+        particle_positions.clear();
         for (auto &p : pic)
           particle_positions.push_back(p.get_reference_location());
 
index 632fbf971169786365a8bd48d64059d1d495cdc2..3527985f4f853250adbf07ca9b1eedbe7d81fff9 100644 (file)
@@ -324,6 +324,7 @@ namespace Step68
     Vector<double> local_dof_values(fluid_fe.dofs_per_cell);
 
     FEPointEvaluation<dim, dim> evaluator(mapping, fluid_fe, update_values);
+    std::vector<Point<dim>>     particle_positions;
 
     const double this_mpi_process =
       static_cast<double>(Utilities::MPI::this_mpi_process(mpi_communicator));
@@ -339,7 +340,7 @@ namespace Step68
 
         const auto pic = particle_handler.particles_in_cell(cell);
         Assert(pic.begin() == particle, ExcInternalError());
-        std::vector<Point<dim>> particle_positions;
+        particle_positions.clear();
         for (auto &p : pic)
           particle_positions.push_back(p.get_reference_location());
 

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.