++particle_index_within_cell;
+
if (particle_index_within_cell > (*particles)[active_cell_index].size() - 1)
{
+ const bool initial_cell_is_owned = cell->is_locally_owned();
+
particle_index_within_cell = 0;
do
++active_cell_index;
}
while (cell.state() == IteratorState::valid &&
- (*particles)[active_cell_index].size() == 0);
+ ((*particles)[active_cell_index].size() == 0 ||
+ cell->is_locally_owned() != initial_cell_is_owned));
}
}
--particle_index_within_cell;
else
{
+ const bool initial_cell_is_owned = cell->is_locally_owned();
+
do
{
--cell;
break;
}
- if ((*particles)[active_cell_index].size() > 0)
+ if ((*particles)[active_cell_index].size() > 0 &&
+ cell->is_locally_owned() == initial_cell_is_owned)
{
particle_index_within_cell =
(*particles)[active_cell_index].size() - 1;
break;
}
}
- while ((*particles)[active_cell_index].size() == 0);
+ while ((*particles)[active_cell_index].size() == 0 &&
+ cell->is_locally_owned() != initial_cell_is_owned);
}
}
/**
* Return the number of particles that live on the given cell.
*
- * @note While this function is used in step-19, it is not an efficient
+ * @note
+ * //TODO this not true now no?
+ * 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
std::unique_ptr<PropertyPool<dim, spacedim>> property_pool;
/**
- * Set of particles currently living in the local domain, organized by
- * the level/index of the cell they are in.
+ * Set of particles currently living in the local domain including ghost
+ * cells , organized by the level/index of the cell they are in.
*/
particle_container particles;
- /**
- * Set of particles currently living in the local domain, organized by
- * the level/index of the cell they are in.
- */
- particle_container ghost_particles;
-
/**
* This variable stores how many particles are stored globally. It is
* calculated by update_cached_numbers().
for (const auto &cell : triangulation->active_cell_iterators())
if (cell->is_locally_owned() == false &&
- ghost_particles[cell->active_cell_index()].size() != 0)
- return particle_iterator(ghost_particles, *property_pool, cell, 0);
+ particles[cell->active_cell_index()].size() != 0)
+ return particle_iterator(particles, *property_pool, cell, 0);
return end_ghost();
}
inline typename ParticleHandler<dim, spacedim>::particle_iterator
ParticleHandler<dim, spacedim>::end_ghost()
{
- return particle_iterator(ghost_particles,
+ return particle_iterator(particles,
*property_pool,
triangulation->end(),
0);
, mapping()
, property_pool(std::make_unique<PropertyPool<dim, spacedim>>(0))
, particles()
- , ghost_particles()
, global_number_of_particles(0)
, local_number_of_particles(0)
, global_max_particles_per_cell(0)
, mapping(&mapping, typeid(*this).name())
, property_pool(std::make_unique<PropertyPool<dim, spacedim>>(n_properties))
, particles(triangulation.n_active_cells())
- , ghost_particles(triangulation.n_active_cells())
, global_number_of_particles(0)
, local_number_of_particles(0)
, global_max_particles_per_cell(0)
new_mapping);
particles.resize(triangulation->n_active_cells());
- ghost_particles.resize(triangulation->n_active_cells());
}
particle_handler.global_max_particles_per_cell;
next_free_particle_index = particle_handler.next_free_particle_index;
particles = particle_handler.particles;
- ghost_particles = particle_handler.ghost_particles;
ghost_particles_cache.ghost_particles_by_domain =
particle_handler.ghost_particles_cache.ghost_particles_by_domain;
if (triangulation != nullptr)
particles.resize(triangulation->n_active_cells());
- for (auto &particles_in_cell : ghost_particles)
- for (auto &particle : particles_in_cell)
- if (particle != PropertyPool<dim, spacedim>::invalid_handle)
- property_pool->deregister_particle(particle);
-
- ghost_particles.clear();
- if (triangulation != nullptr)
- ghost_particles.resize(triangulation->n_active_cells());
-
// the particle properties have already been deleted by their destructor,
// but the memory is still allocated. Return the memory as well.
property_pool->clear();
if (cell->is_artificial() == false)
{
- if (cell->is_locally_owned() == true)
- return particles[cell->active_cell_index()].size();
- else
- return ghost_particles[cell->active_cell_index()].size();
+ return particles[cell->active_cell_index()].size();
}
else
AssertThrow(false,
if (cell->is_artificial() == false)
{
- particle_container &container =
- (cell->is_locally_owned() == true) ? particles : ghost_particles;
+ particle_container &container = particles;
if (container[active_cell_index].size() == 0)
{
#ifndef DEAL_II_WITH_MPI
(void)enable_cache;
#else
- // First clear the current ghost_particle information
- for (auto &particles_in_cell : ghost_particles)
- for (auto &particle : particles_in_cell)
- if (particle != PropertyPool<dim, spacedim>::invalid_handle)
- property_pool->deregister_particle(particle);
- ghost_particles.clear();
- ghost_particles.resize(triangulation->n_active_cells());
-
- // Clear ghost particles data structures and invalidate cache
ghost_particles_cache.ghost_particles_by_domain.clear();
ghost_particles_cache.valid = false;
}
}
+
+ // TODO - To fix
send_recv_particles(
ghost_particles_cache.ghost_particles_by_domain,
- ghost_particles,
+ particles,
std::map<
types::subdomain_id,
std::vector<
send_recv_particles_properties_and_location(
- ghost_particles_cache.ghost_particles_by_domain, ghost_particles);
+ ghost_particles_cache.ghost_particles_by_domain, particles);
#endif
}