ASPECT
interface.h
Go to the documentation of this file.
1 // ------------------------------------------------------
2 //
3 // SPDX-License-Identifier: GPL-2.0-or-later
4 //
5 // SPDX-FileCopyrightText: Copyright (C) 2015-2026 by the ASPECT authors.
6 //
7 // This file is part of ASPECT.
8 //
9 // Detailed license information governing the source code and
10 // contributions can be found in the folder LICENSES and in
11 // LICENSE and CONTRIBUTING.md at the top level directory.
12 //
13 // ------------------------------------------------------
14 
15 #ifndef _aspect_particle_generator_interface_h
16 #define _aspect_particle_generator_interface_h
17 
20 
24 
25 #include <random>
26 
27 #include <map>
28 
29 namespace aspect
30 {
31  namespace Particle
32  {
39  namespace Generator
40  {
41  using namespace ::Particles;
42  using ::Particles::Particle;
43 
47  DeclExceptionMsg (ExcParticlePointNotInDomain,
48  "You requested to generate a particle at a position that "
49  "is not owned by this process, therefore the "
50  "Particle::Generator::Interface::generate_particle() function "
51  "refused to create it. You can circumvent this error message "
52  "by catching the ExcParticlePointNotInDomain exception and "
53  "do whatever you think is appropriate in this case.");
54 
60  template <int dim>
61  class Interface : public SimulatorAccess<dim>, public ParticleInterfaceBase
62  {
63  public:
64  void
65  initialize() override;
66 
67  void
68  update() override;
69 
81  virtual
82  void
84 
93  std::pair<Particles::internal::LevelInd,Particle<dim>>
95  const types::particle_index id);
96 
107  std::pair<Particles::internal::LevelInd,Particle<dim>>
109  const types::particle_index id,
110  const Point<dim> &reference_position);
111 
112  protected:
125  std::pair<Particles::internal::LevelInd,Particle<dim>>
126  generate_particle(const Point<dim> &position,
127  const types::particle_index id) const;
128 
150  insert_particle_at_position(const Point<dim> &position,
151  const types::particle_index id,
152  Particles::ParticleHandler<dim> &particle_handler) const;
153 
164  };
165 
181  template <int dim>
182  void
183  register_particle_generator (const std::string &name,
184  const std::string &description,
185  void (*declare_parameters_function) (ParameterHandler &),
186  std::unique_ptr<Interface<dim>> (*factory_function) ());
187 
198  template <int dim>
199  std::unique_ptr<Interface<dim>>
201 
207  template <int dim>
208  void
210 
211 
221  template <int dim>
222  void
223  write_plugin_graph (std::ostream &output_stream);
224 
225 
233 #define ASPECT_REGISTER_PARTICLE_GENERATOR(classname, name, description) \
234  template class classname<2>; \
235  template class classname<3>; \
236  namespace ASPECT_REGISTER_PARTICLE_GENERATOR_ ## classname \
237  { \
238  aspect::internal::Plugins::RegisterHelper<aspect::Particle::Generator::Interface<2>,classname<2 >> \
239  dummy_ ## classname ## _2d (&aspect::Particle::Generator::register_particle_generator<2>, \
240  name, description); \
241  aspect::internal::Plugins::RegisterHelper<aspect::Particle::Generator::Interface<3>,classname<3>> \
242  dummy_ ## classname ## _3d (&aspect::Particle::Generator::register_particle_generator<3>, \
243  name, description); \
244  }
245  }
246  }
247 }
248 
249 #endif
Particles::ParticleIterator< dim > insert_particle_at_position(const Point< dim > &position, const types::particle_index id, Particles::ParticleHandler< dim > &particle_handler) const
typename ::Triangulation< dim, spacedim >::active_cell_iterator active_cell_iterator
virtual void generate_particles(Particles::ParticleHandler< dim > &particle_handler)=0
std::pair< Particles::internal::LevelInd, Particle< dim > > generate_particle(const typename parallel::distributed::Triangulation< dim >::active_cell_iterator &cell, const types::particle_index id)
DeclExceptionMsg(ExcParticlePointNotInDomain, "You requested to generate a particle at a position that " "is not owned by this process, therefore the " "Particle::Generator::Interface::generate_particle() function " "refused to create it. You can circumvent this error message " "by catching the ExcParticlePointNotInDomain exception and " "do whatever you think is appropriate in this case.")
void register_particle_generator(const std::string &name, const std::string &description, void(*declare_parameters_function)(ParameterHandler &), std::unique_ptr< Interface< dim >>(*factory_function)())
void write_plugin_graph(std::ostream &output_stream)
std::unique_ptr< Interface< dim > > create_particle_generator(ParameterHandler &prm)
#define DEAL_II_DEPRECATED
static void declare_parameters(ParameterHandler &prm)