ASPECT
interface.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 - 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 
22 #ifndef _aspect_initial_composition_interface_h
23 #define _aspect_initial_composition_interface_h
24 
25 #include <aspect/plugins.h>
26 #include <aspect/utilities.h>
28 
29 #include <deal.II/base/point.h>
30 #include <deal.II/base/parameter_handler.h>
31 
32 #include <boost/core/demangle.hpp>
33 #include <typeinfo>
34 
35 
36 namespace aspect
37 {
38  template <int dim> class SimulatorAccess;
39 
46  namespace InitialComposition
47  {
53  template <int dim>
54  class Interface : public Plugins::InterfaceBase
55  {
56  public:
60  virtual
61  double initial_composition (const Point<dim> &position, const unsigned int n_comp) const = 0;
62  };
63 
64 
65 
71  template <int dim>
72  class Manager : public Plugins::ManagerBase<Interface<dim>>, public SimulatorAccess<dim>
73  {
74  public:
79  static
80  void
81  declare_parameters (ParameterHandler &prm);
82 
88  void
89  parse_parameters (ParameterHandler &prm) override;
90 
97  double
98  initial_composition (const Point<dim> &position,
99  const unsigned int n_comp) const;
100 
118  static
119  void
120  register_initial_composition (const std::string &name,
121  const std::string &description,
122  void (*declare_parameters_function) (ParameterHandler &),
123  std::unique_ptr<Interface<dim>> (*factory_function) ());
124 
125 
133  DEAL_II_DEPRECATED
134  const std::vector<std::string> &
135  get_active_initial_composition_names () const;
136 
144  DEAL_II_DEPRECATED
145  const std::list<std::unique_ptr<Interface<dim>>> &
146  get_active_initial_composition_conditions () const;
147 
162  template <typename InitialCompositionType,
163  typename = typename std::enable_if_t<std::is_base_of<Interface<dim>,InitialCompositionType>::value>>
164  DEAL_II_DEPRECATED
165  bool
166  has_matching_initial_composition_model () const;
167 
184  template <typename InitialCompositionType,
185  typename = typename std::enable_if_t<std::is_base_of<Interface<dim>,InitialCompositionType>::value>>
186  DEAL_II_DEPRECATED
187  const InitialCompositionType &
188  get_matching_initial_composition_model () const;
189 
199  static
200  void
201  write_plugin_graph (std::ostream &output_stream);
202 
206  DeclException1 (ExcInitialCompositionNameNotFound,
207  std::string,
208  << "Could not find entry <"
209  << arg1
210  << "> among the names of registered initial composition objects.");
211  private:
218  std::vector<aspect::Utilities::Operator> model_operators;
219  };
220 
221 
222 
223  template <int dim>
224  template <typename InitialCompositionType, typename>
225  inline
226  bool
228  {
229  return this->template has_matching_active_plugin<InitialCompositionType>();
230  }
231 
232 
233  template <int dim>
234  template <typename InitialCompositionType, typename>
235  inline
236  const InitialCompositionType &
238  {
239  return this->template get_matching_active_plugin<InitialCompositionType>();
240  }
241 
242 
251  template <int dim>
252  std::string
254 
255 
256 
264 #define ASPECT_REGISTER_INITIAL_COMPOSITION_MODEL(classname,name,description) \
265  template class classname<2>; \
266  template class classname<3>; \
267  namespace ASPECT_REGISTER_INITIAL_COMPOSITION_MODEL_ ## classname \
268  { \
269  aspect::internal::Plugins::RegisterHelper<aspect::InitialComposition::Interface<2>,classname<2>> \
270  dummy_ ## classname ## _2d (&aspect::InitialComposition::Manager<2>::register_initial_composition, \
271  name, description); \
272  aspect::internal::Plugins::RegisterHelper<aspect::InitialComposition::Interface<3>,classname<3>> \
273  dummy_ ## classname ## _3d (&aspect::InitialComposition::Manager<3>::register_initial_composition, \
274  name, description); \
275  }
276  }
277 }
278 
279 
280 #endif
virtual void parse_parameters(ParameterHandler &prm)
DEAL_II_DEPRECATED bool has_matching_initial_composition_model() const
void write_plugin_graph(std::ostream &output_stream)
DEAL_II_DEPRECATED const InitialCompositionType & get_matching_initial_composition_model() const
virtual double initial_composition(const Point< dim > &position, const unsigned int n_comp) const =0
std::string get_valid_model_names_pattern()
Definition: compat.h:59
std::vector< aspect::Utilities::Operator > model_operators
Definition: interface.h:218
static void declare_parameters(ParameterHandler &prm)
DeclException1(ProbabilityFunctionNegative, Point< dim >,<< "Your probability density function in the particle generator " "returned a negative probability density for the following position: "<< arg1<< ". Please check your function expression.")