@@ -362,7 +362,25 @@ namespace aspect
362
362
if (deletion_algorithm == DeletionAlgorithm::point_density_function)
363
363
{
364
364
ParticlePDF<dim> pdf (0.3 ,kernel_function);
365
- pdf.fill_from_particle_range (particle_handler->particles_in_cell (cell),current_n_particles_in_cell);
365
+ /*
366
+ 'particle_ranges_to_sum_over' includes this cell's and neighboring cell's particles.
367
+ If neighboring cell's particles are not included in the KDE, particles at cell boundaries will
368
+ have artificially low point density values.
369
+ */
370
+ std::vector<typename Particles::ParticleHandler<dim>::particle_iterator_range> particle_ranges_to_sum_over;
371
+
372
+ std::vector<typename Triangulation<dim>::active_cell_iterator> neighboring_cells;
373
+ GridTools::get_active_neighbors<Triangulation<dim>>(cell, neighboring_cells);
374
+ for (const auto &neighbor_cell: neighboring_cells)
375
+ {
376
+ particle_ranges_to_sum_over.push_back (particle_handler->particles_in_cell (neighbor_cell));
377
+ }
378
+
379
+ // std::vector<typename Particles::ParticleHandler<dim>::particle_iterator_range> particle_ranges_to_sum_over = {particle_handler->particles_in_cell(cell)};
380
+
381
+ pdf.fill_from_particle_range (particle_handler->particles_in_cell (cell),
382
+ particle_ranges_to_sum_over,
383
+ current_n_particles_in_cell);
366
384
pdf.compute_statistical_values ();
367
385
368
386
const types::particle_index index_max = pdf.get_max_particle ();
@@ -834,13 +852,13 @@ namespace aspect
834
852
" Strategy that is used to balance the computational "
835
853
" load across processors for adaptive meshes." );
836
854
prm.declare_entry (" Particle removal algorithm" , " random" ,
837
- Patterns::MultipleSelection (" random|point density function" ),
855
+ Patterns::Selection (" random|point density function" ),
838
856
" Algorithm used to delete excess particles from cells. If point density function "
839
857
" is chosen, the particle manager as the removal algorithm, the particle manager "
840
858
" will generate a point density function from the locations of each particle and remove "
841
859
" the particle whose position is at the maximum of the point density function." );
842
860
prm.declare_entry (" Point density kernel function" , " cutoff w1 dealii" ,
843
- Patterns::MultipleSelection (" cutoff w1 dealii|uniform|triangular|gaussian" ),
861
+ Patterns::Selection (" cutoff w1 dealii|uniform|triangular|gaussian" ),
844
862
" The kernel function is summed at each particle location to generate a point "
845
863
" density function of the particle locations according to a process known as "
846
864
" kernel density estimation. Because kernel density estimation sums the value of "
@@ -1024,7 +1042,7 @@ namespace aspect
1024
1042
1025
1043
if (kernel_function_string == " cutoff w1 dealii" )
1026
1044
kernel_function = ParticlePDF<dim>::KernelFunction::cutoff_function_w1_dealii;
1027
- if (kernel_function_string == " uniform" )
1045
+ else if (kernel_function_string == " uniform" )
1028
1046
kernel_function = ParticlePDF<dim>::KernelFunction::uniform;
1029
1047
else if (kernel_function_string == " triangular" )
1030
1048
kernel_function = ParticlePDF<dim>::KernelFunction::triangular;
0 commit comments