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_boundary_velocity_interface_h
23 #define _aspect_boundary_velocity_interface_h
24 
25 #include <aspect/plugins.h>
28 #include <aspect/utilities.h>
29 
30 #include <deal.II/base/point.h>
31 #include <deal.II/base/parameter_handler.h>
32 
33 #include <boost/core/demangle.hpp>
34 #include <typeinfo>
35 
36 
37 namespace aspect
38 {
45  namespace BoundaryVelocity
46  {
52  template <int dim>
53  class Interface : public Plugins::InterfaceBase
54  {
55  public:
68  virtual
69  Tensor<1,dim>
70  boundary_velocity (const types::boundary_id boundary_indicator,
71  const Point<dim> &position) const = 0;
72  };
73 
79  template <int dim>
80  class Manager : public Plugins::ManagerBase<Interface<dim>>, public SimulatorAccess<dim>
81  {
82  public:
88  Tensor<1,dim>
89  boundary_velocity (const types::boundary_id boundary_indicator,
90  const Point<dim> &position) const;
91 
109  static
110  void
111  register_boundary_velocity (const std::string &name,
112  const std::string &description,
113  void (*declare_parameters_function) (ParameterHandler &),
114  std::unique_ptr<Interface<dim>> (*factory_function) ());
115 
116 
132  DEAL_II_DEPRECATED
133  const std::map<types::boundary_id, std::pair<std::string,std::vector<std::string>>> &
134  get_active_boundary_velocity_names () const;
135 
148  DEAL_II_DEPRECATED
149  const std::map<types::boundary_id,std::vector<std::unique_ptr<BoundaryVelocity::Interface<dim>>>> &
150  get_active_boundary_velocity_conditions () const;
151 
158  const std::vector<types::boundary_id> &
159  get_active_plugin_boundary_indicators() const;
160 
171  ComponentMask
172  get_component_mask(const types::boundary_id boundary_id) const;
173 
178  const std::set<types::boundary_id> &
179  get_prescribed_boundary_velocity_indicators () const;
180 
185  const std::set<types::boundary_id> &
186  get_zero_boundary_velocity_indicators () const;
187 
192  const std::set<types::boundary_id> &
193  get_tangential_boundary_velocity_indicators () const;
194 
199  static
200  void
201  declare_parameters (ParameterHandler &prm);
202 
208  void
209  parse_parameters (ParameterHandler &prm) override;
210 
225  template <typename BoundaryVelocityType,
226  typename = typename std::enable_if_t<std::is_base_of<Interface<dim>,BoundaryVelocityType>::value>>
227  DEAL_II_DEPRECATED
228  bool
229  has_matching_boundary_velocity_model () const;
230 
247  template <typename BoundaryVelocityType,
248  typename = typename std::enable_if_t<std::is_base_of<Interface<dim>,BoundaryVelocityType>::value>>
249  DEAL_II_DEPRECATED
250  const BoundaryVelocityType &
251  get_matching_boundary_velocity_model () const;
252 
262  static
263  void
264  write_plugin_graph (std::ostream &output_stream);
265 
266 
270  DeclException1 (ExcBoundaryVelocityNameNotFound,
271  std::string,
272  << "Could not find entry <"
273  << arg1
274  << "> among the names of registered boundary velocity objects.");
275  private:
284  std::vector<types::boundary_id> boundary_indicators;
285 
294  std::vector<ComponentMask> component_masks;
295 
303  std::map<types::boundary_id,std::vector<std::unique_ptr<BoundaryVelocity::Interface<dim>>>> boundary_velocity_objects;
304 
318  std::map<types::boundary_id, std::pair<std::string,std::vector<std::string>>> boundary_velocity_indicators;
319 
323  std::set<types::boundary_id> prescribed_velocity_boundary_indicators;
324 
329  std::set<types::boundary_id> zero_velocity_boundary_indicators;
330 
335  std::set<types::boundary_id> tangential_velocity_boundary_indicators;
336  };
337 
338 
339 
340  template <int dim>
341  template <typename BoundaryVelocityType, typename>
342  inline
343  bool
345  {
346  for (const auto &boundary : boundary_velocity_objects)
347  for (const auto &p : boundary.second)
348  if (Plugins::plugin_type_matches<BoundaryVelocityType>(*p))
349  return true;
350  return false;
351  }
352 
353 
354  template <int dim>
355  template <typename BoundaryVelocityType, typename>
356  inline
357  const BoundaryVelocityType &
359  {
360  AssertThrow(has_matching_boundary_velocity_model<BoundaryVelocityType> (),
361  ExcMessage("You asked BoundaryVelocity::Manager::get_boundary_velocity_model() for a "
362  "boundary velocity model of type <" + boost::core::demangle(typeid(BoundaryVelocityType).name()) + "> "
363  "that could not be found in the current model. Activate this "
364  "boundary velocity model in the input file."));
365 
366  for (const auto &boundary : boundary_velocity_objects)
367  for (const auto &p : boundary)
368  if (Plugins::plugin_type_matches<BoundaryVelocityType>(*p))
369  return Plugins::get_plugin_as_type<BoundaryVelocityType>(*p);
370 
371  // We will never get here, because we had the Assert above. Just to avoid warnings.
372  return Plugins::get_plugin_as_type<BoundaryVelocityType>(**(boundary_velocity_objects.begin()));
373  }
374 
375 
382  template <int dim>
383  std::string
385 
386 
394 #define ASPECT_REGISTER_BOUNDARY_VELOCITY_MODEL(classname, name, description) \
395  template class classname<2>; \
396  template class classname<3>; \
397  namespace ASPECT_REGISTER_BOUNDARY_VELOCITY_MODEL_ ## classname \
398  { \
399  aspect::internal::Plugins::RegisterHelper<aspect::BoundaryVelocity::Interface<2>,classname<2>> \
400  dummy_ ## classname ## _2d (&aspect::BoundaryVelocity::Manager<2>::register_boundary_velocity, \
401  name, description); \
402  aspect::internal::Plugins::RegisterHelper<aspect::BoundaryVelocity::Interface<3>,classname<3>> \
403  dummy_ ## classname ## _3d (&aspect::BoundaryVelocity::Manager<3>::register_boundary_velocity, \
404  name, description); \
405  }
406  }
407 }
408 
409 
410 #endif
virtual void parse_parameters(ParameterHandler &prm)
void write_plugin_graph(std::ostream &output_stream)
DEAL_II_DEPRECATED const BoundaryVelocityType & get_matching_boundary_velocity_model() const
std::set< types::boundary_id > tangential_velocity_boundary_indicators
Definition: interface.h:335
std::set< types::boundary_id > prescribed_velocity_boundary_indicators
Definition: interface.h:323
virtual Tensor< 1, dim > boundary_velocity(const types::boundary_id boundary_indicator, const Point< dim > &position) const =0
std::map< types::boundary_id, std::pair< std::string, std::vector< std::string > > > boundary_velocity_indicators
Definition: interface.h:318
DEAL_II_DEPRECATED bool has_matching_boundary_velocity_model() const
std::string get_valid_model_names_pattern()
std::map< types::boundary_id, std::vector< std::unique_ptr< BoundaryVelocity::Interface< dim > > > > boundary_velocity_objects
Definition: interface.h:303
std::vector< ComponentMask > component_masks
Definition: interface.h:294
Definition: compat.h:59
std::set< types::boundary_id > zero_velocity_boundary_indicators
Definition: interface.h:329
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.")
std::vector< types::boundary_id > boundary_indicators
Definition: interface.h:284