ASPECT
interface.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2015 - 2022 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_property_interface_h
22 #define _aspect_particle_property_interface_h
23 
24 #include <aspect/global.h>
25 #include <aspect/plugins.h>
26 
29 
30 #include <deal.II/particles/particle.h>
31 #include <deal.II/particles/particle_handler.h>
32 #include <deal.II/particles/property_pool.h>
33 #include <deal.II/fe/fe_update_flags.h>
34 
35 #include <memory>
36 
37 namespace aspect
38 {
39  namespace Particle
40  {
41  namespace Property
42  {
43  using namespace ::Particles;
44 
80  {
81  public:
86 
99  ParticlePropertyInformation(const std::vector<std::vector<std::pair<std::string,unsigned int>>> &property_information);
100 
105  bool
106  fieldname_exists(const std::string &name) const;
107 
111  unsigned int
112  get_field_index_by_name(const std::string &name) const;
113 
117  std::string
118  get_field_name_by_index(const unsigned int field_index) const;
119 
124  unsigned int
125  get_position_by_field_name(const std::string &name) const;
126 
131  unsigned int
132  get_components_by_field_name(const std::string &name) const;
133 
139  unsigned int
140  get_position_by_field_index(const unsigned int field_index) const;
141 
146  unsigned int
147  get_components_by_field_index(const unsigned int field_index) const;
148 
154  unsigned int
155  get_position_by_plugin_index(const unsigned int plugin_index) const;
156 
161  unsigned int
162  get_components_by_plugin_index(const unsigned int plugin_index) const;
163 
168  unsigned int
169  get_fields_by_plugin_index(const unsigned int plugin_index) const;
170 
171 
175  unsigned int
176  n_plugins() const;
177 
181  unsigned int
182  n_fields() const;
183 
187  unsigned int
188  n_components() const;
189 
190  private:
194  std::vector<std::string> field_names;
195 
199  std::vector<unsigned int> components_per_field;
200 
205  std::vector<unsigned int> position_per_field;
206 
211  std::vector<unsigned int> fields_per_plugin;
212 
216  std::vector<unsigned int> components_per_plugin;
217 
222  std::vector<unsigned int> position_per_plugin;
223 
228  unsigned int number_of_components;
229 
233  unsigned int number_of_fields;
234 
238  unsigned int number_of_plugins;
239  };
240 
242  {
263  };
264 
271  {
297  };
298 
307  template <int dim>
308  class Interface
309  {
310  public:
315  virtual ~Interface () = default;
316 
321  virtual
322  void
323  initialize ();
324 
336  virtual
337  void
338  initialize_one_particle_property (const Point<dim> &position,
339  std::vector<double> &particle_properties) const;
340 
367  virtual
368  void
369  update_particle_property (const unsigned int data_position,
370  const Vector<double> &solution,
371  const std::vector<Tensor<1,dim>> &gradients,
372  typename ParticleHandler<dim>::particle_iterator &particle) const;
373 
403  virtual
404  void
405  update_one_particle_property (const unsigned int data_position,
406  const Point<dim> &position,
407  const Vector<double> &solution,
408  const std::vector<Tensor<1,dim>> &gradients,
409  const ArrayView<double> &particle_properties) const;
410 
423  virtual
425  need_update () const;
426 
435  virtual
436  UpdateFlags
437  get_needed_update_flags () const;
438 
453  virtual
455  late_initialization_mode () const;
456 
470  virtual
471  std::vector<std::pair<std::string, unsigned int>>
472  get_property_information() const = 0;
473 
474 
488  static
489  void
490  declare_parameters (ParameterHandler &prm);
491 
498  virtual
499  void
500  parse_parameters (ParameterHandler &prm);
501  };
502 
512  template <int dim>
513  class IntegratorProperties : public Interface<dim>
514  {
515  public:
521  void
522  initialize_one_particle_property (const Point<dim> &position,
523  std::vector<double> &particle_properties) const override;
524 
532  std::vector<std::pair<std::string, unsigned int>>
533  get_property_information() const override;
534 
539  virtual
540  void
541  parse_parameters (ParameterHandler &prm) override;
542 
543  private:
549  };
550 
551 
552 
558  template <int dim>
559  class Manager : public SimulatorAccess<dim>
560  {
561  public:
565  Manager ();
566 
570  ~Manager () override;
571 
576  void
577  initialize ();
578 
584  void
585  initialize_one_particle (typename ParticleHandler<dim>::particle_iterator &particle) const;
586 
593  std::vector<double>
594  initialize_late_particle (const Point<dim> &particle_location,
595  const ParticleHandler<dim> &particle_handler,
596  const Interpolator::Interface<dim> &interpolator,
597  const typename parallel::distributed::Triangulation<dim>::active_cell_iterator &cell = typename parallel::distributed::Triangulation<dim>::active_cell_iterator()) const;
598 
603  void
604  update_one_particle (typename ParticleHandler<dim>::particle_iterator &particle,
605  const Vector<double> &solution,
606  const std::vector<Tensor<1,dim>> &gradients) const;
607 
620  need_update () const;
621 
628  UpdateFlags
629  get_needed_update_flags () const;
630 
635  bool
636  plugin_name_exists(const std::string &name) const;
637 
647  bool
648  check_plugin_order(const std::string &first, const std::string &second) const;
649 
653  unsigned int get_plugin_index_by_name(const std::string &name) const;
654 
662  unsigned int
663  get_n_property_components () const;
664 
673  std::size_t
674  get_particle_size () const;
675 
683  get_data_info() const;
684 
693  unsigned int
694  get_property_component_by_name(const std::string &name) const;
695 
714  static
715  void
716  register_particle_property (const std::string &name,
717  const std::string &description,
718  void (*declare_parameters_function) (ParameterHandler &),
719  Property::Interface<dim> *(*factory_function) ());
720 
721 
725  static
726  void
727  declare_parameters (ParameterHandler &prm);
728 
732  void
733  parse_parameters (ParameterHandler &prm);
734 
735 
745  static
746  void
747  write_plugin_graph (std::ostream &output_stream);
748 
749  private:
754  std::vector<std::string> plugin_names;
755 
760  std::list<std::unique_ptr<Interface<dim>>> property_list;
761 
767  };
768 
769 
776 #define ASPECT_REGISTER_PARTICLE_PROPERTY(classname,name,description) \
777  template class classname<2>; \
778  template class classname<3>; \
779  namespace ASPECT_REGISTER_PARTICLE_PROPERTY_ ## classname \
780  { \
781  aspect::internal::Plugins::RegisterHelper<aspect::Particle::Property::Interface<2>,classname<2>> \
782  dummy_ ## classname ## _2d (&aspect::Particle::Property::Manager<2>::register_particle_property, \
783  name, description); \
784  aspect::internal::Plugins::RegisterHelper<aspect::Particle::Property::Interface<3>,classname<3>> \
785  dummy_ ## classname ## _3d (&aspect::Particle::Property::Manager<3>::register_particle_property, \
786  name, description); \
787  }
788 
789  }
790  }
791 }
792 
793 #endif
std::string get_field_name_by_index(const unsigned int field_index) const
StructuredDataLookup< dim > DEAL_II_DEPRECATED
ParticlePropertyInformation property_information
Definition: interface.h:766
unsigned int get_components_by_field_index(const unsigned int field_index) const
void write_plugin_graph(std::ostream &output_stream)
unsigned int get_components_by_field_name(const std::string &name) const
unsigned int get_position_by_field_name(const std::string &name) const
bool fieldname_exists(const std::string &name) const
unsigned int get_field_index_by_name(const std::string &name) const
std::list< std::unique_ptr< Interface< dim > > > property_list
Definition: interface.h:760
unsigned int get_position_by_plugin_index(const unsigned int plugin_index) const
unsigned int get_components_by_plugin_index(const unsigned int plugin_index) const
unsigned int get_fields_by_plugin_index(const unsigned int plugin_index) const
void declare_parameters(ParameterHandler &prm)
std::vector< std::string > plugin_names
Definition: interface.h:754
unsigned int get_position_by_field_index(const unsigned int field_index) const