ASPECT
interface.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2013 - 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_boundary_composition_interface_h
23 #define _aspect_boundary_composition_interface_h
24 
25 #include <aspect/plugins.h>
27 #include <aspect/utilities.h>
29 
30 #include <deal.II/base/parameter_handler.h>
31 #include <deal.II/distributed/tria.h>
32 
33 #include <boost/core/demangle.hpp>
34 #include <typeinfo>
35 
36 
37 namespace aspect
38 {
45  namespace BoundaryComposition
46  {
47  using namespace dealii;
48 
54  template <int dim>
55  class Interface : public Plugins::InterfaceBase
56  {
57  public:
72  virtual
73  double
74  boundary_composition (const types::boundary_id boundary_indicator,
75  const Point<dim> &position,
76  const unsigned int compositional_field) const = 0;
77  };
78 
84  template <int dim>
85  class Manager : public Plugins::ManagerBase<Interface<dim>>, public SimulatorAccess<dim>
86  {
87  public:
92  ~Manager () override;
93 
103  void
104  update () override;
105 
110  static
111  void
112  declare_parameters (ParameterHandler &prm);
113 
119  void
120  parse_parameters (ParameterHandler &prm) override;
121 
127  double
128  boundary_composition (const types::boundary_id boundary_indicator,
129  const Point<dim> &position,
130  const unsigned int compositional_field) const;
131 
149  static
150  void
151  register_boundary_composition (const std::string &name,
152  const std::string &description,
153  void (*declare_parameters_function) (ParameterHandler &),
154  std::unique_ptr<Interface<dim>> (*factory_function) ());
155 
156 
161  const std::vector<std::string> &
162  get_active_boundary_composition_names () const;
163 
168  const std::list<std::unique_ptr<Interface<dim>>> &
169  get_active_boundary_composition_conditions () const;
170 
180  template <typename BoundaryCompositionType,
181  typename = typename std::enable_if_t<std::is_base_of<Interface<dim>,BoundaryCompositionType>::value>>
182  bool
183  has_matching_boundary_composition_model () const;
184 
196  template <typename BoundaryCompositionType,
197  typename = typename std::enable_if_t<std::is_base_of<Interface<dim>,BoundaryCompositionType>::value>>
198  const BoundaryCompositionType &
199  get_matching_boundary_composition_model () const;
200 
201  /*
202  * Return a set of boundary indicators for which boundary
203  * compositions are prescribed.
204  */
205  const std::set<types::boundary_id> &
206  get_fixed_composition_boundary_indicators() const;
207 
208  /*
209  * Return whether Dirichlet boundary conditions will be applied
210  * on parts of the boundaries where material flows out.
211  */
212  bool
213  allows_fixed_composition_on_outflow_boundaries() const;
214 
224  static
225  void
226  write_plugin_graph (std::ostream &output_stream);
227 
228 
232  DeclException1 (ExcBoundaryCompositionNameNotFound,
233  std::string,
234  << "Could not find entry <"
235  << arg1
236  << "> among the names of registered boundary composition objects.");
237  private:
242  std::vector<std::string> model_names;
243 
250  std::vector<aspect::Utilities::Operator> model_operators;
251 
256  std::set<types::boundary_id> fixed_composition_boundary_indicators;
257 
263  };
264 
265 
266 
267  template <int dim>
268  template <typename BoundaryCompositionType, typename>
269  inline
270  bool
272  {
273  return this->template has_matching_plugin_object<BoundaryCompositionType>();
274  }
275 
276 
277 
278  template <int dim>
279  template <typename BoundaryCompositionType, typename>
280  inline
281  const BoundaryCompositionType &
283  {
284  return this->template get_matching_plugin_object<BoundaryCompositionType>();
285  }
286 
287 
288 
295  template <int dim>
296  std::string
298 
299 
307 #define ASPECT_REGISTER_BOUNDARY_COMPOSITION_MODEL(classname, name, description) \
308  template class classname<2>; \
309  template class classname<3>; \
310  namespace ASPECT_REGISTER_BOUNDARY_COMPOSITION_MODEL_ ## classname \
311  { \
312  aspect::internal::Plugins::RegisterHelper<aspect::BoundaryComposition::Interface<2>,classname<2>> \
313  dummy_ ## classname ## _2d (&aspect::BoundaryComposition::Manager<2>::register_boundary_composition, \
314  name, description); \
315  aspect::internal::Plugins::RegisterHelper<aspect::BoundaryComposition::Interface<3>,classname<3>> \
316  dummy_ ## classname ## _3d (&aspect::BoundaryComposition::Manager<3>::register_boundary_composition, \
317  name, description); \
318  }
319  }
320 }
321 
322 
323 #endif
std::vector< aspect::Utilities::Operator > model_operators
Definition: interface.h:250
bool has_matching_boundary_composition_model() const
Definition: interface.h:271
void write_plugin_graph(std::ostream &output_stream)
const BoundaryCompositionType & get_matching_boundary_composition_model() const
Definition: interface.h:282
Definition: compat.h:59
std::vector< std::string > model_names
Definition: interface.h:242
void declare_parameters(ParameterHandler &prm)
std::string get_valid_model_names_pattern()
Definition: compat.h:42
std::set< types::boundary_id > fixed_composition_boundary_indicators
Definition: interface.h:256
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.")