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,
64  };
65 
76  ParticlePDF(const unsigned int granularity,
77  const double bandwidth,
79 
88  ParticlePDF(const double bandwidth,
89  const KernelFunction kernel_function);
90 
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 
121  void
122  insert_kernel_sum_from_particle_range(const Point<dim> &reference_point,
123  const std::array<unsigned int,dim> &table_index,
124  const typename Triangulation<dim>::cell_iterator &cell,
125  const std::vector<typename Particles::ParticleHandler<dim>::particle_iterator_range>
126  &particle_ranges_to_sum_over,
127  const typename ::Mapping<dim> &mapping);
128 
136  void
137  add_value_to_function_table(const unsigned int x_index,
138  const unsigned int y_index,
139  const unsigned int z_index,
140  const double input_value);
141 
148  void
149  add_value_to_function_table(const std::array<unsigned int,dim> &index_point,
150  const double input_value);
151 
159  void
160  add_value_to_function_table(const double input_value,
161  const types::particle_index reference_particle_id);
162 
170  double
171  evaluate_function_at_index(const unsigned int x_index,
172  const unsigned int y_index,
173  const unsigned int z_index) const;
174 
178  void
180 
184  double
185  get_max() const;
186 
190  double
191  get_min() const;
192 
196  Point<dim>
197  get_max_position() const;
198 
202  std::vector<Point<dim>>
203  get_min_positions() const;
204 
208  double
209  get_standard_deviation() const;
210 
216  types::particle_index
217  get_max_particle() const;
218 
224  types::particle_index
225  get_min_particle() const;
226 
227  private:
234  Table<dim,double> function_output_table;
235 
244  double bandwidth;
245 
251 
257  unsigned int granularity;
258 
262  double max;
263 
267  double min;
268 
272  Point<dim> max_position;
273 
279  std::vector<Point<dim>> min_positions;
280 
285 
289  double mean;
290 
297 
304 
309  types::particle_index max_particle_index;
310 
315  types::particle_index min_particle_index;
316 
322  double apply_selected_kernel_function(const double distance) const;
323 
330  double kernelfunction_uniform(const double distance) const;
331 
338  double kernelfunction_triangular(const double distance) const;
339 
346  double kernelfunction_gaussian(const double distance) const;
347  };
348  }
349 }
350 
351 #endif
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)
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:296
std::vector< Point< dim > > min_positions
Definition: distribution.h:279
void insert_kernel_sum_from_particle_range(const Point< dim > &reference_point, const std::array< unsigned int, dim > &table_index, const typename Triangulation< dim >::cell_iterator &cell, const std::vector< typename Particles::ParticleHandler< dim >::particle_iterator_range > &particle_ranges_to_sum_over, const typename ::Mapping< dim > &mapping)
types::particle_index get_max_particle() const
std::vector< Point< dim > > get_min_positions() const
double kernelfunction_gaussian(const double distance) const
types::particle_index min_particle_index
Definition: distribution.h:315
Point< dim > get_max_position() 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:252
Table< dim, double > function_output_table
Definition: distribution.h:234
types::particle_index max_particle_index
Definition: distribution.h:309
double evaluate_function_at_index(const unsigned int x_index, const unsigned int y_index, const unsigned int z_index) const