particle_iterator
end_ghost();
+ /**
+ * Return the number of particles that live on the given cell.
+ */
+ types::particle_index
+ n_particles_in_cell(
+ const typename Triangulation<dim, spacedim>::active_cell_iterator &cell)
+ const;
+
/**
* Return a pair of particle iterators that mark the begin and end of
* the particles in a particular cell. The last iterator is the first
* particle that is no longer in the cell.
+ *
+ * The number of elements in the returned range equals what the
+ * n_particles_in_cell() function returns.
*/
particle_iterator_range
particles_in_cell(
const typename Triangulation<dim, spacedim>::active_cell_iterator &cell);
-
/**
* Return a pair of particle iterators that mark the begin and end of
* the particles in a particular cell. The last iterator is the first
* particle that is no longer in the cell.
+ *
+ * The number of elements in the returned range equals what the
+ * n_particles_in_cell() function returns.
*/
particle_iterator_range
particles_in_cell(
PropertyPool &
get_property_pool() const;
- /**
- * Return the number of particles in the given cell.
- */
- unsigned int
- n_particles_in_cell(
- const typename Triangulation<dim, spacedim>::active_cell_iterator &cell)
- const;
-
/**
* Find and update the cells containing each particle for all locally owned
* particles. If particles moved out of the local subdomain
+ template <int dim, int spacedim>
+ unsigned int
+ ParticleHandler<dim, spacedim>::n_particles_in_cell(
+ const typename Triangulation<dim, spacedim>::active_cell_iterator &cell)
+ const
+ {
+ const internal::LevelInd found_cell =
+ std::make_pair(cell->level(), cell->index());
+
+ if (cell->is_locally_owned())
+ return particles.count(found_cell);
+ else if (cell->is_ghost())
+ return ghost_particles.count(found_cell);
+ else
+ AssertThrow(false,
+ ExcMessage("You can't ask for the particles on an artificial "
+ "cell since we don't know what exists on these "
+ "kinds of cells."));
+
+ return numbers::invalid_unsigned_int;
+ }
+
+
+
template <int dim, int spacedim>
typename ParticleHandler<dim, spacedim>::particle_iterator_range
ParticleHandler<dim, spacedim>::particles_in_cell(
particle_iterator(ghost_particles, particles_in_cell.first),
particle_iterator(ghost_particles, particles_in_cell.second));
}
+ else if (cell->is_locally_owned())
+ {
+ const auto particles_in_cell = particles.equal_range(level_index);
+ return boost::make_iterator_range(
+ particle_iterator(particles, particles_in_cell.first),
+ particle_iterator(particles, particles_in_cell.second));
+ }
+ else
+ AssertThrow(false,
+ ExcMessage("You can't ask for the particles on an artificial "
+ "cell since we don't know what exists on these "
+ "kinds of cells."));
- const auto particles_in_cell = particles.equal_range(level_index);
- return boost::make_iterator_range(
- particle_iterator(particles, particles_in_cell.first),
- particle_iterator(particles, particles_in_cell.second));
+ return {};
}
- template <int dim, int spacedim>
- unsigned int
- ParticleHandler<dim, spacedim>::n_particles_in_cell(
- const typename Triangulation<dim, spacedim>::active_cell_iterator &cell)
- const
- {
- const internal::LevelInd found_cell =
- std::make_pair(cell->level(), cell->index());
-
- if (cell->is_locally_owned())
- return particles.count(found_cell);
- else if (cell->is_ghost())
- return ghost_particles.count(found_cell);
- else if (cell->is_artificial())
- AssertThrow(false, ExcInternalError());
-
- return 0;
- }
-
-
-
template <int dim, int spacedim>
types::particle_index
ParticleHandler<dim, spacedim>::get_next_free_particle_index() const