]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Extend documentation. Refactor loops.
authorRene Gassmoeller <rene.gassmoeller@mailbox.org>
Thu, 15 Aug 2019 01:56:47 +0000 (18:56 -0700)
committerRene Gassmoeller <rene.gassmoeller@mailbox.org>
Thu, 15 Aug 2019 02:06:47 +0000 (19:06 -0700)
include/deal.II/particles/particle_generator.h
source/particles/particle_generator.cc

index e4cab73ff9186f48fef1463e5122a571ca6626f4..acec16a7384bb07dd51f27e07f37a5fd4d512b2e 100644 (file)
@@ -35,6 +35,22 @@ namespace Particles
   {
     /**
      * A function that generates particles in every cell at specified @p particle_reference_locations.
+     * The total number of particles that is added to the @p partiche_handler object is
+     * the number of locally owned cells of the @p triangulation times the number of
+     * locations in @p particle_reference_locations. An optional @p mapping argument
+     * can be used to map from @p particle_reference_locations to the real particle locations.
+     *
+     * @param triangulation The triangulation associated with the @p particle_handler.
+     *
+     * @param particle_reference_locations A vector of positions in the unit cell.
+     * Particles will be generated in every cell at these locations.
+     *
+     * @param particle_handler The particle handler that will take ownership
+     *  of the generated particles.
+     *
+     * @param mapping An optional mapping object that is used to map reference
+     * location in the unit cell to the real cells of the triangulation. If no
+     * mapping is provided a MappingQ1 is assumed.
      */
     template <int dim, int spacedim = dim>
     void
index de923d07ecce80dd416590583f29fecdace3bae1..b6378cd3998b749cb27e66b9f14d2cfe52fd40a5 100644 (file)
@@ -48,27 +48,20 @@ namespace Particles
 
       types::particle_index particle_index = local_start_index;
 
-      typename Triangulation<dim, spacedim>::active_cell_iterator
-        cell = triangulation.begin_active(),
-        endc = triangulation.end();
-
-      for (; cell != endc; cell++)
+      for (const auto &cell : triangulation.active_cell_iterators())
         {
           if (cell->is_locally_owned())
             {
-              for (typename std::vector<Point<dim>>::const_iterator
-                     itr_particles_in_unit_cell =
-                       particle_reference_locations.begin();
-                   itr_particles_in_unit_cell !=
-                   particle_reference_locations.end();
-                   itr_particles_in_unit_cell++)
+              for (const auto &reference_location :
+                   particle_reference_locations)
                 {
                   const Point<spacedim> position_real =
-                    mapping.transform_unit_to_real_cell(
-                      cell, *itr_particles_in_unit_cell);
+                    mapping.transform_unit_to_real_cell(cell,
+                                                        reference_location);
 
-                  const Particle<dim, spacedim> particle(
-                    position_real, *itr_particles_in_unit_cell, particle_index);
+                  const Particle<dim, spacedim> particle(position_real,
+                                                         reference_location,
+                                                         particle_index);
                   particle_handler.insert_particle(particle, cell);
                   ++particle_index;
                 }

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.