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 #include <aspect/advection_field.h>
30 
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 
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>
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
362  std::vector<double> &particle_properties) const;
363 
384  virtual
385  void
387  typename ParticleHandler<dim>::particle_iterator_range &particles) const;
388 
420  virtual
421  void
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
466  get_update_flags (const unsigned int component) const;
467 
480  virtual
483 
498  virtual
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>>
529 
533  virtual
534  void
535  set_data_position (const unsigned int data_position);
536 
540  virtual
541  unsigned int
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
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
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
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,
637 
650  void
652  typename ParticleHandler<dim>::particle_iterator_range &particles) const;
653 
666  need_update () const;
667 
681  std::vector<UpdateFlags>
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>>
725  bool
727 
744  template <typename ParticlePropertyType,
745  typename = typename std::enable_if_t<std::is_base_of<Interface<dim>,ParticlePropertyType>::value>>
747  const ParticlePropertyType &
749 
757  unsigned int
759 
768  std::size_t
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
812 
816  void
818 
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
boost::iterator_range< particle_iterator > particle_iterator_range
ParticleIterator< dim, spacedim > particle_iterator
void parse_parameters(ParameterHandler &prm) override
void initialize_one_particle_property(const Point< dim > &position, std::vector< double > &particle_properties) const override
std::vector< std::pair< std::string, unsigned int > > get_property_information() const override
virtual void initialize_one_particle_property(const Point< dim > &position, std::vector< double > &particle_properties) const
virtual DEAL_II_DEPRECATED void update_particle_property(const unsigned int data_position, const Vector< double > &solution, const std::vector< Tensor< 1, dim >> &gradients, typename ParticleHandler< dim >::particle_iterator &particle) const
virtual unsigned int get_data_position() const
virtual void update_particle_properties(const ParticleUpdateInputs< dim > &inputs, typename ParticleHandler< dim >::particle_iterator_range &particles) const
virtual InitializationModeForLateParticles late_initialization_mode() const
virtual void set_data_position(const unsigned int data_position)
virtual AdvectionField advection_field_for_boundary_initialization(const unsigned int property_component) const
virtual UpdateFlags get_update_flags(const unsigned int component) const
virtual std::vector< std::pair< std::string, unsigned int > > get_property_information() const =0
virtual UpdateTimeFlags need_update() const
virtual DEAL_II_DEPRECATED UpdateFlags get_needed_update_flags() const
void set_particle_manager_index(unsigned int particle_manager_index)
Set the particle manager index for all particle properties.
std::size_t get_particle_size() const
const ParticlePropertyInformation & get_data_info() const
std::vector< double > initialize_late_particle(const Point< dim > &particle_location, const ParticleHandler< dim > &particle_handler, const Interpolator::Interface< dim > &interpolator, const typename parallel::distributed::Triangulation< dim >::active_cell_iterator &cell=typename parallel::distributed::Triangulation< dim >::active_cell_iterator()) const
unsigned int get_n_property_components() const
void parse_parameters(ParameterHandler &prm) override
unsigned int get_plugin_index_by_name(const std::string &name) const
DEAL_II_DEPRECATED bool has_matching_property() const
void update_particles(ParticleUpdateInputs< dim > &inputs, typename ParticleHandler< dim >::particle_iterator_range &particles) const
DEAL_II_DEPRECATED const ParticlePropertyType & get_matching_property() const
static void write_plugin_graph(std::ostream &output_stream)
static void declare_parameters(ParameterHandler &prm)
bool plugin_name_exists(const std::string &name) const
UpdateTimeFlags need_update() const
ParticlePropertyInformation property_information
Definition: interface.h:849
static void register_particle_property(const std::string &name, const std::string &description, void(*declare_parameters_function)(ParameterHandler &), std::unique_ptr< Property::Interface< dim >>(*factory_function)())
std::vector< UpdateFlags > get_update_flags() const
void initialize_one_particle(typename ParticleHandler< dim >::particle_iterator &particle) const
bool check_plugin_order(const std::string &first, const std::string &second) const
unsigned int get_components_by_field_name(const std::string &name) const
unsigned int get_position_by_field_index(const unsigned int field_index) const
unsigned int get_position_by_plugin_index(const unsigned int plugin_index) const
unsigned int get_position_by_field_name(const std::string &name) const
unsigned int get_field_index_by_name(const std::string &name) const
unsigned int get_fields_by_plugin_index(const unsigned int plugin_index) const
std::vector< std::string > get_property_names() const
ParticlePropertyInformation(const std::vector< std::vector< std::pair< std::string, unsigned int >>> &property_information)
unsigned int get_components_by_field_index(const unsigned int field_index) const
unsigned int get_components_by_plugin_index(const unsigned int plugin_index) const
bool fieldname_exists(const std::string &name) const
std::string get_field_name_by_index(const unsigned int field_index) const
#define DEAL_II_DEPRECATED
typename ::Triangulation< dim, spacedim >::active_cell_iterator active_cell_iterator
UpdateFlags
std::vector< small_vector< Tensor< 1, dim >, 50 > > gradients
Definition: interface.h:65
DoFHandler< dim >::active_cell_iterator current_cell
Definition: interface.h:73
std::vector< small_vector< double, 50 > > solution
Definition: interface.h:58