ASPECT
interface.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 - 2023 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  {
48  using namespace dealii;
49 
55  template <int dim>
56  class Interface : public Plugins::InterfaceBase
57  {
58  public:
62  virtual
63  double initial_composition (const Point<dim> &position, const unsigned int n_comp) const = 0;
64  };
65 
66 
67 
73  template <int dim>
74  class Manager : public Plugins::ManagerBase<Interface<dim>>, public SimulatorAccess<dim>
75  {
76  public:
81  static
82  void
83  declare_parameters (ParameterHandler &prm);
84 
90  void
91  parse_parameters (ParameterHandler &prm) override;
92 
99  double
100  initial_composition (const Point<dim> &position,
101  const unsigned int n_comp) const;
102 
120  static
121  void
122  register_initial_composition (const std::string &name,
123  const std::string &description,
124  void (*declare_parameters_function) (ParameterHandler &),
125  std::unique_ptr<Interface<dim>> (*factory_function) ());
126 
127 
136  const std::vector<std::string> &
137  get_active_initial_composition_names () const;
138 
147  const std::list<std::unique_ptr<Interface<dim>>> &
148  get_active_initial_composition_conditions () const;
149 
164  template <typename InitialCompositionType,
165  typename = typename std::enable_if_t<std::is_base_of<Interface<dim>,InitialCompositionType>::value>>
167  bool
168  has_matching_initial_composition_model () const;
169 
186  template <typename InitialCompositionType,
187  typename = typename std::enable_if_t<std::is_base_of<Interface<dim>,InitialCompositionType>::value>>
189  const InitialCompositionType &
190  get_matching_initial_composition_model () const;
191 
201  static
202  void
203  write_plugin_graph (std::ostream &output_stream);
204 
208  DeclException1 (ExcInitialCompositionNameNotFound,
209  std::string,
210  << "Could not find entry <"
211  << arg1
212  << "> among the names of registered initial composition objects.");
213  private:
220  std::vector<aspect::Utilities::Operator> model_operators;
221  };
222 
223 
224 
225  template <int dim>
226  template <typename InitialCompositionType, typename>
227  inline
228  bool
230  {
231  return this->template has_matching_active_plugin<InitialCompositionType>();
232  }
233 
234 
235  template <int dim>
236  template <typename InitialCompositionType, typename>
237  inline
238  const InitialCompositionType &
240  {
241  return this->template get_matching_active_plugin<InitialCompositionType>();
242  }
243 
244 
253  template <int dim>
254  std::string
256 
257 
258 
266 #define ASPECT_REGISTER_INITIAL_COMPOSITION_MODEL(classname,name,description) \
267  template class classname<2>; \
268  template class classname<3>; \
269  namespace ASPECT_REGISTER_INITIAL_COMPOSITION_MODEL_ ## classname \
270  { \
271  aspect::internal::Plugins::RegisterHelper<aspect::InitialComposition::Interface<2>,classname<2>> \
272  dummy_ ## classname ## _2d (&aspect::InitialComposition::Manager<2>::register_initial_composition, \
273  name, description); \
274  aspect::internal::Plugins::RegisterHelper<aspect::InitialComposition::Interface<3>,classname<3>> \
275  dummy_ ## classname ## _3d (&aspect::InitialComposition::Manager<3>::register_initial_composition, \
276  name, description); \
277  }
278  }
279 }
280 
281 
282 #endif
DEAL_II_DEPRECATED bool has_matching_initial_composition_model() const
StructuredDataLookup< dim > DEAL_II_DEPRECATED
void write_plugin_graph(std::ostream &output_stream)
DEAL_II_DEPRECATED const InitialCompositionType & get_matching_initial_composition_model() const
std::string get_valid_model_names_pattern()
Definition: compat.h:59
void declare_parameters(ParameterHandler &prm)
std::vector< aspect::Utilities::Operator > model_operators
Definition: interface.h:220
Definition: compat.h:42
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.")