ASPECT
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
interface.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2015 - 2024 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_generator_interface_h
22 #define _aspect_particle_generator_interface_h
23 
26 
27 #include <deal.II/particles/particle.h>
28 #include <deal.II/particles/generators.h>
29 #include <deal.II/base/parameter_handler.h>
30 
31 #include <random>
32 
33 #include <map>
34 
35 namespace aspect
36 {
37  namespace Particle
38  {
45  namespace Generator
46  {
47  using namespace ::Particles;
48  using ::Particles::Particle;
49 
53  DeclExceptionMsg (ExcParticlePointNotInDomain,
54  "You requested to generate a particle at a position that "
55  "is not owned by this process, therefore the "
56  "Particle::Generator::Interface::generate_particle() function "
57  "refused to create it. You can circumvent this error message "
58  "by catching the ExcParticlePointNotInDomain exception and "
59  "do whatever you think is appropriate in this case.");
60 
66  template <int dim>
67  class Interface : public SimulatorAccess<dim>, public ParticleInterfaceBase
68  {
69  public:
70  virtual
71  void
72  initialize () override;
73 
85  virtual
86  void
87  generate_particles(Particles::ParticleHandler<dim> &particle_handler) = 0;
88 
95  std::pair<Particles::internal::LevelInd,Particle<dim>>
96  generate_particle (const typename parallel::distributed::Triangulation<dim>::active_cell_iterator &cell,
97  const types::particle_index id);
98 
99  protected:
111  DEAL_II_DEPRECATED
112  std::pair<Particles::internal::LevelInd,Particle<dim>>
113  generate_particle(const Point<dim> &position,
114  const types::particle_index id) const;
115 
136  Particles::ParticleIterator<dim>
137  insert_particle_at_position(const Point<dim> &position,
138  const types::particle_index id,
139  Particles::ParticleHandler<dim> &particle_handler) const;
140 
146  };
147 
163  template <int dim>
164  void
165  register_particle_generator (const std::string &name,
166  const std::string &description,
167  void (*declare_parameters_function) (ParameterHandler &),
168  std::unique_ptr<Interface<dim>> (*factory_function) ());
169 
180  template <int dim>
181  std::unique_ptr<Interface<dim>>
182  create_particle_generator (ParameterHandler &prm);
183 
189  template <int dim>
190  void
191  declare_parameters (ParameterHandler &prm);
192 
193 
203  template <int dim>
204  void
205  write_plugin_graph (std::ostream &output_stream);
206 
207 
215 #define ASPECT_REGISTER_PARTICLE_GENERATOR(classname, name, description) \
216  template class classname<2>; \
217  template class classname<3>; \
218  namespace ASPECT_REGISTER_PARTICLE_GENERATOR_ ## classname \
219  { \
220  aspect::internal::Plugins::RegisterHelper<aspect::Particle::Generator::Interface<2>,classname<2 >> \
221  dummy_ ## classname ## _2d (&aspect::Particle::Generator::register_particle_generator<2>, \
222  name, description); \
223  aspect::internal::Plugins::RegisterHelper<aspect::Particle::Generator::Interface<3>,classname<3>> \
224  dummy_ ## classname ## _3d (&aspect::Particle::Generator::register_particle_generator<3>, \
225  name, description); \
226  }
227  }
228  }
229 }
230 
231 #endif
Particles::ParticleIterator< dim > insert_particle_at_position(const Point< dim > &position, const types::particle_index id, Particles::ParticleHandler< dim > &particle_handler) const
virtual void initialize() override
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)
static void declare_parameters(ParameterHandler &prm)