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_property_interface_h
22 #define _aspect_particle_property_interface_h
23 
25 #include <aspect/global.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 
49  template <int dim>
51  {
52  public:
57  std::vector<small_vector<double,50>> solution;
58 
64  std::vector<small_vector<Tensor<1,dim>,50>> gradients;
65 
72  typename DoFHandler<dim>::active_cell_iterator current_cell;
73  };
74 
110  {
111  public:
116 
129  ParticlePropertyInformation(const std::vector<std::vector<std::pair<std::string,unsigned int>>> &property_information);
130 
135  bool
136  fieldname_exists(const std::string &name) const;
137 
141  unsigned int
142  get_field_index_by_name(const std::string &name) const;
143 
147  std::string
148  get_field_name_by_index(const unsigned int field_index) const;
149 
154  unsigned int
155  get_position_by_field_name(const std::string &name) const;
156 
161  unsigned int
162  get_components_by_field_name(const std::string &name) const;
163 
169  unsigned int
170  get_position_by_field_index(const unsigned int field_index) const;
171 
176  unsigned int
177  get_components_by_field_index(const unsigned int field_index) const;
178 
184  unsigned int
185  get_position_by_plugin_index(const unsigned int plugin_index) const;
186 
191  unsigned int
192  get_components_by_plugin_index(const unsigned int plugin_index) const;
193 
198  unsigned int
199  get_fields_by_plugin_index(const unsigned int plugin_index) const;
200 
201 
205  unsigned int
206  n_plugins() const;
207 
211  unsigned int
212  n_fields() const;
213 
217  unsigned int
218  n_components() const;
219 
220  private:
224  std::vector<std::string> field_names;
225 
229  std::vector<unsigned int> components_per_field;
230 
235  std::vector<unsigned int> position_per_field;
236 
241  std::vector<unsigned int> fields_per_plugin;
242 
246  std::vector<unsigned int> components_per_plugin;
247 
252  std::vector<unsigned int> position_per_plugin;
253 
258  unsigned int number_of_components;
259 
263  unsigned int number_of_fields;
264 
268  unsigned int number_of_plugins;
269  };
270 
272  {
293  };
294 
301  {
327  };
328 
337  template <int dim>
339  {
340  public:
352  virtual
353  void
354  initialize_one_particle_property (const Point<dim> &position,
355  std::vector<double> &particle_properties) const;
356 
377  virtual
378  void
379  update_particle_properties (const ParticleUpdateInputs<dim> &inputs,
380  typename ParticleHandler<dim>::particle_iterator_range &particles) const;
381 
412  DEAL_II_DEPRECATED
413  virtual
414  void
415  update_particle_property (const unsigned int data_position,
416  const Vector<double> &solution,
417  const std::vector<Tensor<1,dim>> &gradients,
418  typename ParticleHandler<dim>::particle_iterator &particle) const;
419 
420 
433  virtual
435  need_update () const;
436 
457  virtual
458  UpdateFlags
459  get_update_flags (const unsigned int component) const;
460 
472  DEAL_II_DEPRECATED
473  virtual
474  UpdateFlags
475  get_needed_update_flags () const;
476 
491  virtual
493  late_initialization_mode () const;
494 
508  virtual
509  std::vector<std::pair<std::string, unsigned int>>
510  get_property_information() const = 0;
511 
515  virtual
516  void
517  set_data_position (const unsigned int data_position);
518 
522  virtual
523  unsigned int
524  get_data_position () const;
525 
526  protected:
532  unsigned int data_position;
533  };
534 
544  template <int dim>
545  class IntegratorProperties : public Interface<dim>
546  {
547  public:
553  void
554  initialize_one_particle_property (const Point<dim> &position,
555  std::vector<double> &particle_properties) const override;
556 
564  std::vector<std::pair<std::string, unsigned int>>
565  get_property_information() const override;
566 
571  void
572  parse_parameters (ParameterHandler &prm) override;
573 
574  private:
580  };
581 
582 
583 
589  template <int dim>
590  class Manager : public Plugins::ManagerBase<Interface<dim>>, public SimulatorAccess<dim>
591  {
592  public:
597  void
598  initialize () override;
599 
605  void
606  initialize_one_particle (typename ParticleHandler<dim>::particle_iterator &particle) const;
607 
614  std::vector<double>
615  initialize_late_particle (const Point<dim> &particle_location,
616  const ParticleHandler<dim> &particle_handler,
617  const Interpolator::Interface<dim> &interpolator,
618  const typename parallel::distributed::Triangulation<dim>::active_cell_iterator &cell = typename parallel::distributed::Triangulation<dim>::active_cell_iterator()) const;
619 
632  void
633  update_particles (ParticleUpdateInputs<dim> &inputs,
634  typename ParticleHandler<dim>::particle_iterator_range &particles) const;
635 
648  need_update () const;
649 
663  std::vector<UpdateFlags>
664  get_update_flags () const;
665 
670  bool
671  plugin_name_exists(const std::string &name) const;
672 
682  bool
683  check_plugin_order(const std::string &first, const std::string &second) const;
684 
688  unsigned int get_plugin_index_by_name(const std::string &name) const;
689 
704  template <typename ParticlePropertyType,
705  typename = typename std::enable_if_t<std::is_base_of<Interface<dim>,ParticlePropertyType>::value>>
706  DEAL_II_DEPRECATED
707  bool
708  has_matching_property () const;
709 
726  template <typename ParticlePropertyType,
727  typename = typename std::enable_if_t<std::is_base_of<Interface<dim>,ParticlePropertyType>::value>>
728  DEAL_II_DEPRECATED
729  const ParticlePropertyType &
730  get_matching_property () const;
731 
739  unsigned int
740  get_n_property_components () const;
741 
750  std::size_t
751  get_particle_size () const;
752 
760  get_data_info() const;
761 
780  static
781  void
782  register_particle_property (const std::string &name,
783  const std::string &description,
784  void (*declare_parameters_function) (ParameterHandler &),
785  std::unique_ptr<Property::Interface<dim>> (*factory_function) ());
786 
787 
791  static
792  void
793  declare_parameters (ParameterHandler &prm);
794 
798  void
799  parse_parameters (ParameterHandler &prm) override;
800 
806  void set_particle_manager_index(unsigned int particle_manager_index);
807 
817  static
818  void
819  write_plugin_graph (std::ostream &output_stream);
820 
821  private:
826 
832  };
833 
834  /* -------------------------- inline and template functions ---------------------- */
835 
836 
837  template <int dim>
838  template <typename ParticlePropertyType, typename>
839  inline
840  bool
842  {
843  return this->template has_matching_active_plugin<ParticlePropertyType>();
844  }
845 
846 
847  template <int dim>
848  template <typename ParticlePropertyType, typename>
849  inline
850  const ParticlePropertyType &
852  {
853  return this->template get_matching_active_plugin<ParticlePropertyType>();
854  }
855 
856 
863 #define ASPECT_REGISTER_PARTICLE_PROPERTY(classname,name,description) \
864  template class classname<2>; \
865  template class classname<3>; \
866  namespace ASPECT_REGISTER_PARTICLE_PROPERTY_ ## classname \
867  { \
868  aspect::internal::Plugins::RegisterHelper<aspect::Particle::Property::Interface<2>,classname<2>> \
869  dummy_ ## classname ## _2d (&aspect::Particle::Property::Manager<2>::register_particle_property, \
870  name, description); \
871  aspect::internal::Plugins::RegisterHelper<aspect::Particle::Property::Interface<3>,classname<3>> \
872  dummy_ ## classname ## _3d (&aspect::Particle::Property::Manager<3>::register_particle_property, \
873  name, description); \
874  }
875 
876  }
877  }
878 }
879 
880 #endif
DoFHandler< dim >::active_cell_iterator current_cell
Definition: interface.h:72
DEAL_II_DEPRECATED const ParticlePropertyType & get_matching_property() const
ParticlePropertyInformation property_information
Definition: interface.h:831
std::vector< small_vector< Tensor< 1, dim >, 50 > > gradients
Definition: interface.h:64
void write_plugin_graph(std::ostream &output_stream)
std::vector< small_vector< double, 50 > > solution
Definition: interface.h:57
Definition: compat.h:59
DEAL_II_DEPRECATED bool has_matching_property() const
void declare_parameters(ParameterHandler &prm)