ASPECT
distribution.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2025 - by the authors of the ASPECT code.
3 
4  This file is part of ASPECT.
5 
6  ASPECT is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2, or (at your option)
9  any later version.
10 
11  ASPECT is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with ASPECT; see the file LICENSE. If not see
18  <http://www.gnu.org/licenses/>.
19 */
20 
21 #ifndef _aspect_particle_distribution_h
22 #define _aspect_particle_distribution_h
23 
26 #include <algorithm>
27 #include <limits>
28 #include <deal.II/base/table.h>
29 #include <deal.II/particles/property_pool.h>
30 #include <deal.II/particles/particle_handler.h>
31 #include <deal.II/base/function_lib.h>
32 #include <vector>
33 
34 namespace aspect
35 {
36  namespace Particle
37  {
47  template <int dim>
49  {
50  public:
51 
57  enum class KernelFunction
58  {
59  gaussian,
60  triangular,
61  uniform,
65  };
66 
77  ParticlePDF(const unsigned int granularity,
78  const double bandwidth,
80 
89  ParticlePDF(const double bandwidth,
90  const KernelFunction kernel_function);
91 
101  void
102  fill_from_particle_range(const typename Particles::ParticleHandler<dim>::particle_iterator_range &particle_range,
103  const std::vector<typename Particles::ParticleHandler<dim>::particle_iterator_range>
104  &particle_ranges_to_sum_over,
105  const unsigned int n_particles_in_cell,
106  const typename ::Mapping<dim> &mapping,
107  const typename Triangulation<dim>::active_cell_iterator &cell);
108 
120  void
121  insert_kernel_sum_from_particle_range(const Point<dim> &reference_point,
122  const std::array<unsigned int,dim> &table_index,
123  const typename Triangulation<dim>::active_cell_iterator &cell,
124  const std::vector<typename Particles::ParticleHandler<dim>::particle_iterator_range>
125  &particle_ranges_to_sum_over,
126  const typename ::Mapping<dim> &mapping);
127 
135  void
136  add_value_to_function_table(const unsigned int x_index,
137  const unsigned int y_index,
138  const unsigned int z_index,
139  const double input_value);
140 
147  void
148  add_value_to_function_table(const std::array<unsigned int,dim> &index_point,
149  const double input_value);
150 
158  void
159  add_value_to_function_table(const double input_value,
160  const types::particle_index reference_particle_id);
161 
169  double
170  evaluate_function_at_index(const unsigned int x_index,
171  const unsigned int y_index,
172  const unsigned int z_index) const;
173 
177  void
179 
183  double
184  get_max() const;
185 
189  double
190  get_min() const;
191 
195  Point<dim>
196  get_max_position() const;
197 
201  std::vector<Point<dim>>
202  get_min_positions() const;
203 
207  double
208  get_standard_deviation() const;
209 
215  types::particle_index
216  get_max_particle() const;
217 
223  types::particle_index
224  get_min_particle() const;
225 
226  private:
233  Table<dim,double> function_output_table;
234 
243  double bandwidth;
244 
250 
256  unsigned int granularity;
257 
261  double max;
262 
266  double min;
267 
271  Point<dim> max_position;
272 
278  std::vector<Point<dim>> min_positions;
279 
284 
288  double mean;
289 
296 
303 
308  types::particle_index max_particle_index;
309 
314  types::particle_index min_particle_index;
315 
321  double apply_selected_kernel_function(const double distance) const;
322 
329  double kernelfunction_uniform(const double distance) const;
330 
337  double kernelfunction_triangular(const double distance) const;
338 
345  double kernelfunction_gaussian(const double distance) const;
346 
353  double kernelfunction_epanechnikov(const double distance) const;
354  };
355  }
356 }
357 
358 #endif
double kernelfunction_triangular(const double distance) const
ParticlePDF(const unsigned int granularity, const double bandwidth, const KernelFunction kernel_function)
types::particle_index get_min_particle() const
double kernelfunction_uniform(const double distance) const
double get_standard_deviation() const
small_vector< double > function_output_vector
Definition: distribution.h:295
void insert_kernel_sum_from_particle_range(const Point< dim > &reference_point, const std::array< unsigned int, dim > &table_index, const typename Triangulation< dim >::active_cell_iterator &cell, const std::vector< typename Particles::ParticleHandler< dim >::particle_iterator_range > &particle_ranges_to_sum_over, const typename ::Mapping< dim > &mapping)
std::vector< Point< dim > > min_positions
Definition: distribution.h:278
types::particle_index get_max_particle() const
std::vector< Point< dim > > get_min_positions() const
double kernelfunction_gaussian(const double distance) const
void fill_from_particle_range(const typename Particles::ParticleHandler< dim >::particle_iterator_range &particle_range, const std::vector< typename Particles::ParticleHandler< dim >::particle_iterator_range > &particle_ranges_to_sum_over, const unsigned int n_particles_in_cell, const typename ::Mapping< dim > &mapping, const typename Triangulation< dim >::active_cell_iterator &cell)
types::particle_index min_particle_index
Definition: distribution.h:314
Point< dim > get_max_position() const
double kernelfunction_epanechnikov(const double distance) const
double apply_selected_kernel_function(const double distance) const
void add_value_to_function_table(const unsigned int x_index, const unsigned int y_index, const unsigned int z_index, const double input_value)
boost::container::small_vector< T, N > small_vector
Definition: global.h:261
Table< dim, double > function_output_table
Definition: distribution.h:233
types::particle_index max_particle_index
Definition: distribution.h:308
double evaluate_function_at_index(const unsigned int x_index, const unsigned int y_index, const unsigned int z_index) const