ASPECT
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 
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 
74  void
75  save (std::map<std::string, std::string> &status_strings) const override;
76 
77  void
78  load (const std::map<std::string, std::string> &status_strings) override;
79 
91  virtual
92  void
94 
103  std::pair<Particles::internal::LevelInd,Particle<dim>>
105  const types::particle_index id);
106 
117  std::pair<Particles::internal::LevelInd,Particle<dim>>
119  const types::particle_index id,
120  const Point<dim> &reference_position);
121 
122  protected:
135  std::pair<Particles::internal::LevelInd,Particle<dim>>
136  generate_particle(const Point<dim> &position,
137  const types::particle_index id) const;
138 
161  const types::particle_index id,
162  Particles::ParticleHandler<dim> &particle_handler) const;
163 
169  };
170 
186  template <int dim>
187  void
188  register_particle_generator (const std::string &name,
189  const std::string &description,
190  void (*declare_parameters_function) (ParameterHandler &),
191  std::unique_ptr<Interface<dim>> (*factory_function) ());
192 
203  template <int dim>
204  std::unique_ptr<Interface<dim>>
206 
212  template <int dim>
213  void
215 
216 
226  template <int dim>
227  void
228  write_plugin_graph (std::ostream &output_stream);
229 
230 
238 #define ASPECT_REGISTER_PARTICLE_GENERATOR(classname, name, description) \
239  template class classname<2>; \
240  template class classname<3>; \
241  namespace ASPECT_REGISTER_PARTICLE_GENERATOR_ ## classname \
242  { \
243  aspect::internal::Plugins::RegisterHelper<aspect::Particle::Generator::Interface<2>,classname<2 >> \
244  dummy_ ## classname ## _2d (&aspect::Particle::Generator::register_particle_generator<2>, \
245  name, description); \
246  aspect::internal::Plugins::RegisterHelper<aspect::Particle::Generator::Interface<3>,classname<3>> \
247  dummy_ ## classname ## _3d (&aspect::Particle::Generator::register_particle_generator<3>, \
248  name, description); \
249  }
250  }
251  }
252 }
253 
254 #endif
std::pair< Particles::internal::LevelInd, Particle< dim > > generate_particle(const typename parallel::distributed::Triangulation< dim >::active_cell_iterator &cell, const types::particle_index id)
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, const Point< dim > &reference_position)
virtual void initialize() override
void load(const std::map< std::string, std::string > &status_strings) override
Particles::ParticleIterator< dim > insert_particle_at_position(const Point< dim > &position, const types::particle_index id, Particles::ParticleHandler< dim > &particle_handler) const
DEAL_II_DEPRECATED std::pair< Particles::internal::LevelInd, Particle< dim > > generate_particle(const Point< dim > &position, const types::particle_index id) const
void save(std::map< std::string, std::string > &status_strings) const override
#define DEAL_II_DEPRECATED
typename ::Triangulation< dim, spacedim >::active_cell_iterator active_cell_iterator
void declare_parameters(ParameterHandler &prm)
std::unique_ptr< Interface< dim > > create_particle_generator(ParameterHandler &prm)
void register_particle_generator(const std::string &name, const std::string &description, void(*declare_parameters_function)(ParameterHandler &), std::unique_ptr< Interface< dim >>(*factory_function)())
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 write_plugin_graph(std::ostream &output_stream)
unsigned int particle_index