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-2025 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_property_interface_h
16 #define _aspect_particle_property_interface_h
17 
19 #include <aspect/global.h>
20 
23 #include <aspect/advection_field.h>
24 
29 
30 #include <memory>
31 
32 namespace aspect
33 {
34  namespace Particle
35  {
36  namespace Property
37  {
38  using namespace ::Particles;
39 
44  template <int dim>
46  {
47  public:
52  std::vector<small_vector<double,50>> solution;
53 
59  std::vector<small_vector<Tensor<1,dim>,50>> gradients;
60 
68  };
69 
105  {
106  public:
111 
124  ParticlePropertyInformation(const std::vector<std::vector<std::pair<std::string,unsigned int>>> &property_information);
125 
130  bool
131  fieldname_exists(const std::string &name) const;
132 
136  unsigned int
137  get_field_index_by_name(const std::string &name) const;
138 
142  std::string
143  get_field_name_by_index(const unsigned int field_index) const;
144 
149  unsigned int
150  get_position_by_field_name(const std::string &name) const;
151 
156  unsigned int
157  get_components_by_field_name(const std::string &name) const;
158 
164  unsigned int
165  get_position_by_field_index(const unsigned int field_index) const;
166 
171  unsigned int
172  get_components_by_field_index(const unsigned int field_index) const;
173 
179  unsigned int
180  get_position_by_plugin_index(const unsigned int plugin_index) const;
181 
186  unsigned int
187  get_components_by_plugin_index(const unsigned int plugin_index) const;
188 
193  unsigned int
194  get_fields_by_plugin_index(const unsigned int plugin_index) const;
195 
196 
200  std::vector<std::string>
201  get_property_names() const;
202 
206  unsigned int
207  n_plugins() const;
208 
212  unsigned int
213  n_fields() const;
214 
218  unsigned int
219  n_components() const;
220 
221  private:
225  std::vector<std::string> field_names;
226 
230  std::vector<unsigned int> components_per_field;
231 
236  std::vector<unsigned int> position_per_field;
237 
242  std::vector<unsigned int> fields_per_plugin;
243 
247  std::vector<unsigned int> components_per_plugin;
248 
253  std::vector<unsigned int> position_per_plugin;
254 
259  unsigned int number_of_components;
260 
264  unsigned int number_of_fields;
265 
269  unsigned int number_of_plugins;
270  };
271 
273  {
294  };
295 
302  {
328  };
329 
338  template <int dim>
340  {
341  public:
353  virtual
354  void
355  initialize_one_particle_property (const Point<dim> &position,
356  std::vector<double> &particle_properties) const;
357 
378  virtual
379  void
380  update_particle_properties (const ParticleUpdateInputs<dim> &inputs,
381  typename ParticleHandler<dim>::particle_iterator_range &particles) const;
382 
414  virtual
415  void
416  update_particle_property (const unsigned int data_position,
417  const Vector<double> &solution,
418  const std::vector<Tensor<1,dim>> &gradients,
419  typename ParticleHandler<dim>::particle_iterator &particle) const;
420 
421 
434  virtual
436  need_update () const;
437 
458  virtual
460  get_update_flags (const unsigned int component) const;
461 
474  virtual
476  get_needed_update_flags () const;
477 
492  virtual
494  late_initialization_mode () const;
495 
503  virtual
505  advection_field_for_boundary_initialization(const unsigned int property_component) const;
506 
520  virtual
521  std::vector<std::pair<std::string, unsigned int>>
522  get_property_information() const = 0;
523 
527  virtual
528  void
529  set_data_position (const unsigned int data_position);
530 
534  virtual
535  unsigned int
536  get_data_position () const;
537 
538  protected:
544  unsigned int data_position;
545  };
546 
556  template <int dim>
557  class IntegratorProperties : public Interface<dim>
558  {
559  public:
565  void
566  initialize_one_particle_property (const Point<dim> &position,
567  std::vector<double> &particle_properties) const override;
568 
576  std::vector<std::pair<std::string, unsigned int>>
577  get_property_information() const override;
578 
583  void
584  parse_parameters (ParameterHandler &prm) override;
585 
586  private:
592  };
593 
594 
595 
601  template <int dim>
602  class Manager : public Plugins::ManagerBase<Interface<dim>>, public SimulatorAccess<dim>
603  {
604  public:
609  void
610  initialize () override;
611 
617  void
618  initialize_one_particle (typename ParticleHandler<dim>::particle_iterator &particle) const;
619 
626  std::vector<double>
627  initialize_late_particle (const Point<dim> &particle_location,
628  const ParticleHandler<dim> &particle_handler,
629  const Interpolator::Interface<dim> &interpolator,
631 
644  void
645  update_particles (ParticleUpdateInputs<dim> &inputs,
646  typename ParticleHandler<dim>::particle_iterator_range &particles) const;
647 
660  need_update () const;
661 
675  std::vector<UpdateFlags>
676  get_update_flags () const;
677 
682  bool
683  plugin_name_exists(const std::string &name) const;
684 
694  bool
695  check_plugin_order(const std::string &first, const std::string &second) const;
696 
700  unsigned int get_plugin_index_by_name(const std::string &name) const;
701 
716  template <typename ParticlePropertyType,
717  typename = typename std::enable_if_t<std::is_base_of<Interface<dim>,ParticlePropertyType>::value>>
719  bool
720  has_matching_property () const;
721 
738  template <typename ParticlePropertyType,
739  typename = typename std::enable_if_t<std::is_base_of<Interface<dim>,ParticlePropertyType>::value>>
741  const ParticlePropertyType &
742  get_matching_property () const;
743 
751  unsigned int
752  get_n_property_components () const;
753 
762  std::size_t
763  get_particle_size () const;
764 
772  get_data_info() const;
773 
792  static
793  void
794  register_particle_property (const std::string &name,
795  const std::string &description,
796  void (*declare_parameters_function) (ParameterHandler &),
797  std::unique_ptr<Property::Interface<dim>> (*factory_function) ());
798 
799 
803  static
804  void
806 
810  void
811  parse_parameters (ParameterHandler &prm) override;
812 
818  void set_particle_manager_index(unsigned int particle_manager_index);
819 
829  static
830  void
831  write_plugin_graph (std::ostream &output_stream);
832 
833  private:
838 
844  };
845 
846  /* -------------------------- inline and template functions ---------------------- */
847 
848 
849  template <int dim>
850  template <typename ParticlePropertyType, typename>
851  inline
852  bool
854  {
855  return this->template has_matching_active_plugin<ParticlePropertyType>();
856  }
857 
858 
859  template <int dim>
860  template <typename ParticlePropertyType, typename>
861  inline
862  const ParticlePropertyType &
864  {
865  return this->template get_matching_active_plugin<ParticlePropertyType>();
866  }
867 
868 
875 #define ASPECT_REGISTER_PARTICLE_PROPERTY(classname,name,description) \
876  template class classname<2>; \
877  template class classname<3>; \
878  namespace ASPECT_REGISTER_PARTICLE_PROPERTY_ ## classname \
879  { \
880  aspect::internal::Plugins::RegisterHelper<aspect::Particle::Property::Interface<2>,classname<2>> \
881  dummy_ ## classname ## _2d (&aspect::Particle::Property::Manager<2>::register_particle_property, \
882  name, description); \
883  aspect::internal::Plugins::RegisterHelper<aspect::Particle::Property::Interface<3>,classname<3>> \
884  dummy_ ## classname ## _3d (&aspect::Particle::Property::Manager<3>::register_particle_property, \
885  name, description); \
886  }
887 
888  }
889  }
890 }
891 
892 #endif
DoFHandler< dim >::active_cell_iterator current_cell
Definition: interface.h:67
DEAL_II_DEPRECATED const ParticlePropertyType & get_matching_property() const
typename ::Triangulation< dim, spacedim >::active_cell_iterator active_cell_iterator
ParticlePropertyInformation property_information
Definition: interface.h:843
std::vector< small_vector< Tensor< 1, dim >, 50 > > gradients
Definition: interface.h:59
Point< 2 > second
void write_plugin_graph(std::ostream &output_stream)
UpdateFlags
Point< 2 > first
std::vector< small_vector< double, 50 > > solution
Definition: interface.h:52
boost::iterator_range< particle_iterator > particle_iterator_range
ParticleIterator< dim, spacedim > particle_iterator
DEAL_II_DEPRECATED bool has_matching_property() const
void declare_parameters(ParameterHandler &prm)
#define DEAL_II_DEPRECATED