]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Apply Rene comments
authorBruno Blais <blais.bruno@gmail.com>
Tue, 8 Jun 2021 17:31:00 +0000 (13:31 -0400)
committerBruno Blais <blais.bruno@gmail.com>
Tue, 8 Jun 2021 21:14:25 +0000 (17:14 -0400)
include/deal.II/particles/particle_accessor.h
include/deal.II/particles/particle_handler.h
source/particles/particle_handler.cc

index 41c9e125ee5672e3d1ac0ea0f2bbe6b940112faa..3e6a860797631d7ae97ffd04772cddf80bb65e11 100644 (file)
@@ -716,7 +716,7 @@ namespace Particles
 
     if (particle_index_within_cell > (*particles)[active_cell_index].size() - 1)
       {
-        const bool initial_cell_is_owned = cell->is_locally_owned();
+        const bool particle_is_locally_owned = cell->is_locally_owned();
 
         particle_index_within_cell = 0;
 
@@ -727,7 +727,7 @@ namespace Particles
           }
         while (cell.state() == IteratorState::valid &&
                ((*particles)[active_cell_index].size() == 0 ||
-                cell->is_locally_owned() != initial_cell_is_owned));
+                cell->is_locally_owned() != particle_is_locally_owned));
       }
   }
 
@@ -743,7 +743,7 @@ namespace Particles
       --particle_index_within_cell;
     else
       {
-        const bool initial_cell_is_owned = cell->is_locally_owned();
+        const bool particle_is_locally_owned = cell->is_locally_owned();
 
         do
           {
@@ -757,15 +757,15 @@ namespace Particles
               }
 
             if ((*particles)[active_cell_index].size() > 0 &&
-                cell->is_locally_owned() == initial_cell_is_owned)
+                cell->is_locally_owned() == particle_is_locally_owned)
               {
                 particle_index_within_cell =
                   (*particles)[active_cell_index].size() - 1;
                 break;
               }
           }
-        while ((*particles)[active_cell_index].size() == 0 &&
-               cell->is_locally_owned() != initial_cell_is_owned);
+        while ((*particles)[active_cell_index].size() == 0 ||
+               cell->is_locally_owned() != particle_is_locally_owned);
       }
   }
 
index b86a57e9dcfcda29ff1aec0a1a29795fefbe5a99..678b6e282950218e492b17eb80e9df29a386268c 100644 (file)
@@ -273,25 +273,6 @@ namespace Particles
      *
      * The number of elements in the returned range equals what the
      * n_particles_in_cell() function returns.
-     *
-     * @note While this function is used in step-19, it is not an efficient
-     *   function to use if the number of particles is large. That is because
-     *   to find the particles that are located in one cell costs
-     *   ${\cal O}(\log N)$ where $N$ is the number of overall particles. Since
-     *   you will likely do this for every cell, and assuming that the number
-     *   of particles and the number of cells are roughly proportional,
-     *   you end up with an ${\cal O}(N \log N)$ algorithm. A better approach
-     *   is to use the fact that internally, particles are arranged in the
-     *   order of the active cells they are in. In other words, if you iterate
-     *   over all particles, you will encounter them in the same order as
-     *   you walk over the active cells. You can exploit this by keeping an
-     *   iterator to the first particle of the first cell, and when you move
-     *   to the next cell, you increment the particle iterator as well until
-     *   you find a particle located on that next cell. This is the approach
-     *   used in step-70, for example, and has an overall cost of
-     *   ${\cal O}(\log N)$ when accumulated over all cells. The approach is
-     *   also detailed in the "Possibilities for extensions section"
-     *   of step-19.
      */
     particle_iterator_range
     particles_in_cell(
@@ -850,7 +831,7 @@ namespace Particles
 
     /**
      * Set of particles currently living in the local domain including ghost
-     * cells , organized by the level/index of the cell they are in.
+     * cells , organized by the active cell of the cell they are in.
      */
     particle_container particles;
 
index e7158cc600d25aac0fea054ff8c5f11066126a8d..a8ca1601030700917f72fd9d7f3462649adaa719 100644 (file)
@@ -335,21 +335,19 @@ namespace Particles
 
     if (cell->is_artificial() == false)
       {
-        particle_container &container = particles;
-
-        if (container[active_cell_index].size() == 0)
+        if (particles[active_cell_index].size() == 0)
           {
             return boost::make_iterator_range(
-              particle_iterator(container, *property_pool, cell, 0),
-              particle_iterator(container, *property_pool, cell, 0));
+              particle_iterator(particles, *property_pool, cell, 0),
+              particle_iterator(particles, *property_pool, cell, 0));
           }
         else
           {
-            particle_iterator begin(container, *property_pool, cell, 0);
-            particle_iterator end(container,
+            particle_iterator begin(particles, *property_pool, cell, 0);
+            particle_iterator end(particles,
                                   *property_pool,
                                   cell,
-                                  container[active_cell_index].size() - 1);
+                                  particles[active_cell_index].size() - 1);
             // end needs to point to the particle after the last one in the
             // cell.
             ++end;
@@ -1354,8 +1352,6 @@ namespace Particles
           }
       }
 
-
-    // TODO - To fix
     send_recv_particles(
       ghost_particles_cache.ghost_particles_by_domain,
       particles,

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.