@@ -63,7 +63,10 @@ namespace aspect
63
63
const auto &particle_handler = this ->get_particle_manager (particle_manager_index).get_particle_handler ();
64
64
65
65
Particle::ParticlePDF<dim> pdf (granularity,bandwidth,kernel_function);
66
+ // This should be filled with this cell's particles and neighboring cells particles
67
+ std::vector<typename Particles::ParticleHandler<dim>::particle_iterator_range> particle_ranges_to_sum_over = {particle_handler.particles_in_cell (cell)};
66
68
pdf.fill_from_particle_range (particle_handler.particles_in_cell (cell),
69
+ particle_ranges_to_sum_over,
67
70
particle_handler.n_particles_in_cell (cell));
68
71
pdf.compute_statistical_values ();
69
72
@@ -79,12 +82,32 @@ namespace aspect
79
82
}
80
83
else
81
84
{
85
+ GridTools::Cache<dim>grid_cache (this ->get_triangulation (), this ->get_mapping ());
82
86
for (unsigned int particle_manager_index = 0 ; particle_manager_index < this ->n_particle_managers (); ++particle_manager_index)
83
87
{
84
88
const auto &particle_handler = this ->get_particle_manager (particle_manager_index).get_particle_handler ();
85
89
86
90
Particle::ParticlePDF<dim> pdf (bandwidth,kernel_function);
91
+
92
+ // This should be filled with this cell's particles and neighboring cells particles
93
+ std::vector<typename Particles::ParticleHandler<dim>::particle_iterator_range> particle_ranges_to_sum_over = {particle_handler.particles_in_cell (cell)};
94
+
95
+ std::set<typename Triangulation<dim>::active_cell_iterator> neighboring_cells;
96
+ const auto &vertex_to_cell_map = grid_cache.get_vertex_to_cell_map ();
97
+ for (const auto v : cell->vertex_indices ())
98
+ {
99
+ const unsigned int vertex_index = cell->vertex_index (v);
100
+ neighboring_cells.insert (vertex_to_cell_map[vertex_index].begin (),
101
+ vertex_to_cell_map[vertex_index].end ());
102
+ }
103
+
104
+ for (const auto &neighbor_cell: neighboring_cells)
105
+ {
106
+ particle_ranges_to_sum_over.push_back (particle_handler.particles_in_cell (neighbor_cell));
107
+ }
108
+
87
109
pdf.fill_from_particle_range (particle_handler.particles_in_cell (cell),
110
+ particle_ranges_to_sum_over,
88
111
particle_handler.n_particles_in_cell (cell));
89
112
pdf.compute_statistical_values ();
90
113
0 commit comments