From 6d101209408d93f072c0ee9ee138d43e8286916b Mon Sep 17 00:00:00 2001 From: Rene Gassmoeller Date: Mon, 16 Oct 2017 10:25:46 -0600 Subject: [PATCH] Fixes --- include/deal.II/particles/particle_handler.h | 42 +++++++++++--------- source/particles/particle_accessor.cc | 12 ++++++ source/particles/particle_handler.cc | 19 ++++++--- 3 files changed, 49 insertions(+), 24 deletions(-) diff --git a/include/deal.II/particles/particle_handler.h b/include/deal.II/particles/particle_handler.h index 094e3b8798..271fd2fea4 100644 --- a/include/deal.II/particles/particle_handler.h +++ b/include/deal.II/particles/particle_handler.h @@ -105,7 +105,7 @@ namespace Particles * (e.g. insert_particle). This is done because the update is * expensive compared to single operations. */ - void update_cache(); + void update_cached_numbers(); /** * Return an iterator to the first particle. @@ -217,6 +217,12 @@ namespace Particles */ types::particle_index n_locally_owned_particles() const; + /** + * Return the number of particles in the local part of the + * triangulation. + */ + types::particle_index get_next_free_particle_index() const; + /** * Return the number of properties each particle has. */ @@ -258,6 +264,22 @@ namespace Particles void exchange_ghost_particles(); + /** + * Callback function that should be called before every + * refinement and when writing checkpoints. + * Allows registering store_particles() in the triangulation. + */ + void + register_store_callback_function(const bool serialization); + + /** + * Callback function that should be called after every + * refinement and after resuming from a checkpoint. + * Allows registering load_particles() in the triangulation. + */ + void + register_load_callback_function(const bool serialization); + /** * Serialize the contents of this class. */ @@ -388,24 +410,6 @@ namespace Particles std::multimap > &received_particles, const std::vector::active_cell_iterator> > &new_cells_for_particles = std::vector::active_cell_iterator> > ()); - - - /** - * Callback function that should be called before every - * refinement and when writing checkpoints. - * Allows registering store_particles() in the triangulation. - */ - void - register_store_callback_function(const bool serialization); - - /** - * Callback function that should be called after every - * refinement and after resuming from a checkpoint. - * Allows registering load_particles() in the triangulation. - */ - void - register_load_callback_function(const bool serialization); - /** * Called by listener functions from Triangulation for every cell * before a refinement step. All particles have to be attached to their diff --git a/source/particles/particle_accessor.cc b/source/particles/particle_accessor.cc index 42fabc1469..92c0026e6b 100644 --- a/source/particles/particle_accessor.cc +++ b/source/particles/particle_accessor.cc @@ -122,6 +122,18 @@ namespace Particles + template + bool + ParticleAccessor::has_properties () const + { + Assert(particle != map->end(), + ExcInternalError()); + + return particle->second.has_properties(); + } + + + template void ParticleAccessor::set_properties (const std::vector &new_properties) diff --git a/source/particles/particle_handler.cc b/source/particles/particle_handler.cc index 13839888cc..e57a824e8f 100644 --- a/source/particles/particle_handler.cc +++ b/source/particles/particle_handler.cc @@ -105,7 +105,7 @@ namespace Particles template void - ParticleHandler::update_cache() + ParticleHandler::update_cached_numbers() { types::particle_index locally_highest_index = 0; @@ -232,7 +232,7 @@ namespace Particles ParticleHandler::insert_particles(const std::multimap > &new_particles) { particles.insert(new_particles.begin(),new_particles.end()); - update_cache(); + update_cached_numbers(); } @@ -282,6 +282,15 @@ namespace Particles + template + types::particle_index + ParticleHandler::get_next_free_particle_index() const + { + return next_free_particle_index; + } + + + template PropertyPool & ParticleHandler::get_property_pool () const @@ -526,7 +535,7 @@ namespace Particles remove_particle(particles_out_of_cell[i]); particles.insert(sorted_particles_map.begin(),sorted_particles_map.end()); - update_cache(); + update_cached_numbers(); } @@ -756,7 +765,7 @@ namespace Particles // Only save and load particles if there are any, we might get here for // example if somebody created a ParticleHandler but generated 0 particles. - update_cache(); + update_cached_numbers(); if (global_max_particles_per_cell > 0) { @@ -856,7 +865,7 @@ namespace Particles // Reset offset and update global number of particles. The number // can change because of discarded or newly generated particles data_offset = numbers::invalid_unsigned_int; - update_cache(); + update_cached_numbers(); } } -- 2.39.5