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_property_interface_h
22 #define _aspect_particle_property_interface_h
23 
25 #include <aspect/global.h>
26 
29 #include <aspect/advection_field.h>
30 
31 #include <deal.II/particles/particle.h>
32 #include <deal.II/particles/particle_handler.h>
33 #include <deal.II/particles/property_pool.h>
34 #include <deal.II/fe/fe_update_flags.h>
35 
36 #include <memory>
37 
38 namespace aspect
39 {
40  namespace Particle
41  {
42  namespace Property
43  {
44  using namespace ::Particles;
45 
50  template <int dim>
52  {
53  public:
58  std::vector<small_vector<double,50>> solution;
59 
65  std::vector<small_vector<Tensor<1,dim>,50>> gradients;
66 
73  typename DoFHandler<dim>::active_cell_iterator current_cell;
74  };
75 
111  {
112  public:
117 
130  ParticlePropertyInformation(const std::vector<std::vector<std::pair<std::string,unsigned int>>> &property_information);
131 
136  bool
137  fieldname_exists(const std::string &name) const;
138 
142  unsigned int
143  get_field_index_by_name(const std::string &name) const;
144 
148  std::string
149  get_field_name_by_index(const unsigned int field_index) const;
150 
155  unsigned int
156  get_position_by_field_name(const std::string &name) const;
157 
162  unsigned int
163  get_components_by_field_name(const std::string &name) const;
164 
170  unsigned int
171  get_position_by_field_index(const unsigned int field_index) const;
172 
177  unsigned int
178  get_components_by_field_index(const unsigned int field_index) const;
179 
185  unsigned int
186  get_position_by_plugin_index(const unsigned int plugin_index) const;
187 
192  unsigned int
193  get_components_by_plugin_index(const unsigned int plugin_index) const;
194 
199  unsigned int
200  get_fields_by_plugin_index(const unsigned int plugin_index) const;
201 
202 
206  std::vector<std::string>
207  get_property_names() const;
208 
212  unsigned int
213  n_plugins() const;
214 
218  unsigned int
219  n_fields() const;
220 
224  unsigned int
225  n_components() const;
226 
227  private:
231  std::vector<std::string> field_names;
232 
236  std::vector<unsigned int> components_per_field;
237 
242  std::vector<unsigned int> position_per_field;
243 
248  std::vector<unsigned int> fields_per_plugin;
249 
253  std::vector<unsigned int> components_per_plugin;
254 
259  std::vector<unsigned int> position_per_plugin;
260 
265  unsigned int number_of_components;
266 
270  unsigned int number_of_fields;
271 
275  unsigned int number_of_plugins;
276  };
277 
279  {
300  };
301 
308  {
334  };
335 
344  template <int dim>
346  {
347  public:
359  virtual
360  void
361  initialize_one_particle_property (const Point<dim> &position,
362  std::vector<double> &particle_properties) const;
363 
384  virtual
385  void
386  update_particle_properties (const ParticleUpdateInputs<dim> &inputs,
387  typename ParticleHandler<dim>::particle_iterator_range &particles) const;
388 
419  DEAL_II_DEPRECATED
420  virtual
421  void
422  update_particle_property (const unsigned int data_position,
423  const Vector<double> &solution,
424  const std::vector<Tensor<1,dim>> &gradients,
425  typename ParticleHandler<dim>::particle_iterator &particle) const;
426 
427 
440  virtual
442  need_update () const;
443 
464  virtual
465  UpdateFlags
466  get_update_flags (const unsigned int component) const;
467 
479  DEAL_II_DEPRECATED
480  virtual
481  UpdateFlags
482  get_needed_update_flags () const;
483 
498  virtual
500  late_initialization_mode () const;
501 
509  virtual
511  advection_field_for_boundary_initialization(const unsigned int property_component) const;
512 
526  virtual
527  std::vector<std::pair<std::string, unsigned int>>
528  get_property_information() const = 0;
529 
533  virtual
534  void
535  set_data_position (const unsigned int data_position);
536 
540  virtual
541  unsigned int
542  get_data_position () const;
543 
544  protected:
550  unsigned int data_position;
551  };
552 
562  template <int dim>
563  class IntegratorProperties : public Interface<dim>
564  {
565  public:
571  void
572  initialize_one_particle_property (const Point<dim> &position,
573  std::vector<double> &particle_properties) const override;
574 
582  std::vector<std::pair<std::string, unsigned int>>
583  get_property_information() const override;
584 
589  void
590  parse_parameters (ParameterHandler &prm) override;
591 
592  private:
598  };
599 
600 
601 
607  template <int dim>
608  class Manager : public Plugins::ManagerBase<Interface<dim>>, public SimulatorAccess<dim>
609  {
610  public:
615  void
616  initialize () override;
617 
623  void
624  initialize_one_particle (typename ParticleHandler<dim>::particle_iterator &particle) const;
625 
632  std::vector<double>
633  initialize_late_particle (const Point<dim> &particle_location,
634  const ParticleHandler<dim> &particle_handler,
635  const Interpolator::Interface<dim> &interpolator,
636  const typename parallel::distributed::Triangulation<dim>::active_cell_iterator &cell = typename parallel::distributed::Triangulation<dim>::active_cell_iterator()) const;
637 
650  void
651  update_particles (ParticleUpdateInputs<dim> &inputs,
652  typename ParticleHandler<dim>::particle_iterator_range &particles) const;
653 
666  need_update () const;
667 
681  std::vector<UpdateFlags>
682  get_update_flags () const;
683 
688  bool
689  plugin_name_exists(const std::string &name) const;
690 
700  bool
701  check_plugin_order(const std::string &first, const std::string &second) const;
702 
706  unsigned int get_plugin_index_by_name(const std::string &name) const;
707 
722  template <typename ParticlePropertyType,
723  typename = typename std::enable_if_t<std::is_base_of<Interface<dim>,ParticlePropertyType>::value>>
724  DEAL_II_DEPRECATED
725  bool
726  has_matching_property () const;
727 
744  template <typename ParticlePropertyType,
745  typename = typename std::enable_if_t<std::is_base_of<Interface<dim>,ParticlePropertyType>::value>>
746  DEAL_II_DEPRECATED
747  const ParticlePropertyType &
748  get_matching_property () const;
749 
757  unsigned int
758  get_n_property_components () const;
759 
768  std::size_t
769  get_particle_size () const;
770 
778  get_data_info() const;
779 
798  static
799  void
800  register_particle_property (const std::string &name,
801  const std::string &description,
802  void (*declare_parameters_function) (ParameterHandler &),
803  std::unique_ptr<Property::Interface<dim>> (*factory_function) ());
804 
805 
809  static
810  void
811  declare_parameters (ParameterHandler &prm);
812 
816  void
817  parse_parameters (ParameterHandler &prm) override;
818 
824  void set_particle_manager_index(unsigned int particle_manager_index);
825 
835  static
836  void
837  write_plugin_graph (std::ostream &output_stream);
838 
839  private:
844 
850  };
851 
852  /* -------------------------- inline and template functions ---------------------- */
853 
854 
855  template <int dim>
856  template <typename ParticlePropertyType, typename>
857  inline
858  bool
860  {
861  return this->template has_matching_active_plugin<ParticlePropertyType>();
862  }
863 
864 
865  template <int dim>
866  template <typename ParticlePropertyType, typename>
867  inline
868  const ParticlePropertyType &
870  {
871  return this->template get_matching_active_plugin<ParticlePropertyType>();
872  }
873 
874 
881 #define ASPECT_REGISTER_PARTICLE_PROPERTY(classname,name,description) \
882  template class classname<2>; \
883  template class classname<3>; \
884  namespace ASPECT_REGISTER_PARTICLE_PROPERTY_ ## classname \
885  { \
886  aspect::internal::Plugins::RegisterHelper<aspect::Particle::Property::Interface<2>,classname<2>> \
887  dummy_ ## classname ## _2d (&aspect::Particle::Property::Manager<2>::register_particle_property, \
888  name, description); \
889  aspect::internal::Plugins::RegisterHelper<aspect::Particle::Property::Interface<3>,classname<3>> \
890  dummy_ ## classname ## _3d (&aspect::Particle::Property::Manager<3>::register_particle_property, \
891  name, description); \
892  }
893 
894  }
895  }
896 }
897 
898 #endif
DoFHandler< dim >::active_cell_iterator current_cell
Definition: interface.h:73
DEAL_II_DEPRECATED const ParticlePropertyType & get_matching_property() const
ParticlePropertyInformation property_information
Definition: interface.h:849
std::vector< small_vector< Tensor< 1, dim >, 50 > > gradients
Definition: interface.h:65
void write_plugin_graph(std::ostream &output_stream)
std::vector< small_vector< double, 50 > > solution
Definition: interface.h:58
DEAL_II_DEPRECATED bool has_matching_property() const
void declare_parameters(ParameterHandler &prm)