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 
33 namespace aspect
34 {
35  namespace Particle
36  {
46  template <int dim>
48  {
49  public:
50 
56  enum class KernelFunction
57  {
58  gaussian,
59  triangular,
60  uniform,
62  };
63 
74  ParticlePDF(const unsigned int granularity,
75  const double bandwidth,
77 
86  ParticlePDF(const double bandwidth,
87  const KernelFunction kernel_function);
88 
94  void
95  fill_from_particle_range(const typename Particles::ParticleHandler<dim>::particle_iterator_range particle_range,
96  const unsigned int n_particles_in_cell);
97 
108  void
109  insert_kernel_sum_from_particle_range(const Point<dim> reference_point,
110  std::array<unsigned int,dim> table_index,
111  const unsigned int n_particles_in_cell,
112  const typename Particles::ParticleHandler<dim>::particle_iterator_range particle_range);
113 
121  void
122  add_value_to_function_table(const unsigned int x_index,
123  const unsigned int y_index,
124  const unsigned int z_index,
125  const double input_value);
126 
133  void
134  add_value_to_function_table(const std::array<unsigned int,dim> &index_point,
135  const double input_value);
136 
144  void
145  add_value_to_function_table(const double input_value,
146  const types::particle_index reference_particle_id);
147 
155  double
156  evaluate_function_at_index(const unsigned int x_index,
157  const unsigned int y_index,
158  const unsigned int z_index) const;
159 
163  void
165 
169  double
170  get_max() const;
171 
175  double
176  get_min() const;
177 
181  double
182  get_standard_deviation() const;
183 
184  private:
191  Table<dim,double> function_output_table;
192 
201  double bandwidth;
202 
208 
214  unsigned int granularity;
215 
219  double max;
220 
224  double min;
225 
230 
234  double mean;
235 
242 
249 
254  types::particle_index max_particle_index;
255 
260  types::particle_index min_particle_index;
261 
267  double apply_selected_kernel_function(const double distance) const;
268 
275  double kernelfunction_uniform(const double distance) const;
276 
283  double kernelfunction_triangular(const double distance) const;
284 
291  double kernelfunction_gaussian(const double distance) const;
292  };
293  }
294 }
295 
296 #endif
double kernelfunction_triangular(const double distance) const
ParticlePDF(const unsigned int granularity, const double bandwidth, const KernelFunction kernel_function)
void fill_from_particle_range(const typename Particles::ParticleHandler< dim >::particle_iterator_range particle_range, const unsigned int n_particles_in_cell)
double kernelfunction_uniform(const double distance) const
double get_standard_deviation() const
small_vector< double > function_output_vector
Definition: distribution.h:241
double kernelfunction_gaussian(const double distance) const
types::particle_index min_particle_index
Definition: distribution.h:260
void insert_kernel_sum_from_particle_range(const Point< dim > reference_point, std::array< unsigned int, dim > table_index, const unsigned int n_particles_in_cell, const typename Particles::ParticleHandler< dim >::particle_iterator_range particle_range)
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:191
types::particle_index max_particle_index
Definition: distribution.h:254
double evaluate_function_at_index(const unsigned int x_index, const unsigned int y_index, const unsigned int z_index) const