ASPECT
interface.h
Go to the documentation of this file.
1 // ------------------------------------------------------
2 //
3 // SPDX-License-Identifier: GPL-2.0-or-later
4 //
5 // SPDX-FileCopyrightText: Copyright (C) 2011-2025 by the ASPECT authors.
6 //
7 // This file is part of ASPECT.
8 //
9 // Detailed license information governing the source code and
10 // contributions can be found in the folder LICENSES and in
11 // LICENSE and CONTRIBUTING.md at the top level directory.
12 //
13 // ------------------------------------------------------
14 
15 
16 #ifndef _aspect_boundary_velocity_interface_h
17 #define _aspect_boundary_velocity_interface_h
18 
19 #include <aspect/plugins.h>
22 #include <aspect/utilities.h>
23 
24 #include <deal.II/base/point.h>
26 
27 #include <boost/core/demangle.hpp>
28 #include <typeinfo>
29 
30 
31 namespace aspect
32 {
39  namespace BoundaryVelocity
40  {
46  template <int dim>
47  class Interface : public Plugins::InterfaceBase
48  {
49  public:
62  virtual
64  boundary_velocity (const types::boundary_id boundary_indicator,
65  const Point<dim> &position) const = 0;
66  };
67 
73  template <int dim>
74  class Manager : public Plugins::ManagerBase<Interface<dim>>, public SimulatorAccess<dim>
75  {
76  public:
83  boundary_velocity (const types::boundary_id boundary_indicator,
84  const Point<dim> &position) const;
85 
103  static
104  void
105  register_boundary_velocity (const std::string &name,
106  const std::string &description,
107  void (*declare_parameters_function) (ParameterHandler &),
108  std::unique_ptr<Interface<dim>> (*factory_function) ());
109 
110 
127  const std::map<types::boundary_id, std::pair<std::string,std::vector<std::string>>> &
128  get_active_boundary_velocity_names () const;
129 
143  const std::map<types::boundary_id,std::vector<std::unique_ptr<BoundaryVelocity::Interface<dim>>>> &
144  get_active_boundary_velocity_conditions () const;
145 
152  const std::vector<types::boundary_id> &
153  get_active_plugin_boundary_indicators() const;
154 
166  get_component_mask(const types::boundary_id boundary_id) const;
167 
172  const std::set<types::boundary_id> &
173  get_prescribed_boundary_velocity_indicators () const;
174 
179  const std::set<types::boundary_id> &
180  get_zero_boundary_velocity_indicators () const;
181 
186  const std::set<types::boundary_id> &
187  get_tangential_boundary_velocity_indicators () const;
188 
193  static
194  void
196 
202  void
203  parse_parameters (ParameterHandler &prm) override;
204 
219  template <typename BoundaryVelocityType,
220  typename = typename std::enable_if_t<std::is_base_of<Interface<dim>,BoundaryVelocityType>::value>>
222  bool
223  has_matching_boundary_velocity_model () const;
224 
241  template <typename BoundaryVelocityType,
242  typename = typename std::enable_if_t<std::is_base_of<Interface<dim>,BoundaryVelocityType>::value>>
244  const BoundaryVelocityType &
245  get_matching_boundary_velocity_model () const;
246 
256  static
257  void
258  write_plugin_graph (std::ostream &output_stream);
259 
260 
264  DeclException1 (ExcBoundaryVelocityNameNotFound,
265  std::string,
266  << "Could not find entry <"
267  << arg1
268  << "> among the names of registered boundary velocity objects.");
269  private:
278  std::vector<types::boundary_id> boundary_indicators;
279 
288  std::vector<ComponentMask> component_masks;
289 
297  std::map<types::boundary_id,std::vector<std::unique_ptr<BoundaryVelocity::Interface<dim>>>> boundary_velocity_objects;
298 
312  std::map<types::boundary_id, std::pair<std::string,std::vector<std::string>>> boundary_velocity_indicators;
313 
317  std::set<types::boundary_id> prescribed_velocity_boundary_indicators;
318 
323  std::set<types::boundary_id> zero_velocity_boundary_indicators;
324 
329  std::set<types::boundary_id> tangential_velocity_boundary_indicators;
330  };
331 
332 
333 
334  template <int dim>
335  template <typename BoundaryVelocityType, typename>
336  inline
337  bool
339  {
340  for (const auto &boundary : boundary_velocity_objects)
341  for (const auto &p : boundary.second)
342  if (Plugins::plugin_type_matches<BoundaryVelocityType>(*p))
343  return true;
344  return false;
345  }
346 
347 
348  template <int dim>
349  template <typename BoundaryVelocityType, typename>
350  inline
351  const BoundaryVelocityType &
353  {
354  AssertThrow(has_matching_boundary_velocity_model<BoundaryVelocityType> (),
355  ExcMessage("You asked BoundaryVelocity::Manager::get_boundary_velocity_model() for a "
356  "boundary velocity model of type <" + boost::core::demangle(typeid(BoundaryVelocityType).name()) + "> "
357  "that could not be found in the current model. Activate this "
358  "boundary velocity model in the input file."));
359 
360  for (const auto &boundary : boundary_velocity_objects)
361  for (const auto &p : boundary)
362  if (Plugins::plugin_type_matches<BoundaryVelocityType>(*p))
363  return Plugins::get_plugin_as_type<BoundaryVelocityType>(*p);
364 
365  // We will never get here, because we had the Assert above. Just to avoid warnings.
366  return Plugins::get_plugin_as_type<BoundaryVelocityType>(**(boundary_velocity_objects.begin()));
367  }
368 
369 
376  template <int dim>
377  std::string
379 
380 
388 #define ASPECT_REGISTER_BOUNDARY_VELOCITY_MODEL(classname, name, description) \
389  template class classname<2>; \
390  template class classname<3>; \
391  namespace ASPECT_REGISTER_BOUNDARY_VELOCITY_MODEL_ ## classname \
392  { \
393  aspect::internal::Plugins::RegisterHelper<aspect::BoundaryVelocity::Interface<2>,classname<2>> \
394  dummy_ ## classname ## _2d (&aspect::BoundaryVelocity::Manager<2>::register_boundary_velocity, \
395  name, description); \
396  aspect::internal::Plugins::RegisterHelper<aspect::BoundaryVelocity::Interface<3>,classname<3>> \
397  dummy_ ## classname ## _3d (&aspect::BoundaryVelocity::Manager<3>::register_boundary_velocity, \
398  name, description); \
399  }
400  }
401 }
402 
403 
404 #endif
virtual void parse_parameters(ParameterHandler &prm)
#define AssertThrow(cond, exc)
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:329
std::set< types::boundary_id > prescribed_velocity_boundary_indicators
Definition: interface.h:317
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:312
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:297
std::vector< ComponentMask > component_masks
Definition: interface.h:288
static ::ExceptionBase & ExcMessage(std::string arg1)
std::set< types::boundary_id > zero_velocity_boundary_indicators
Definition: interface.h:323
#define DEAL_II_DEPRECATED
unsigned int boundary_id
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:278