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_boundary_temperature_interface_h
23 #define _aspect_boundary_temperature_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 {
39  template <int dim> class SimulatorAccess;
40 
47  namespace BoundaryTemperature
48  {
49  using namespace dealii;
50 
56  template <int dim>
57  class Interface
58  {
59  public:
64  virtual ~Interface() = default;
65 
71  virtual void initialize ();
72 
85  virtual
86  double boundary_temperature (const types::boundary_id boundary_indicator,
87  const Point<dim> &position) const = 0;
88 
96  virtual
97  double minimal_temperature (const std::set<types::boundary_id> &fixed_boundary_ids
98  = std::set<types::boundary_id>()) const = 0;
99 
107  virtual
108  double maximal_temperature (const std::set<types::boundary_id> &fixed_boundary_ids
109  = std::set<types::boundary_id>()) const = 0;
110 
122  virtual
123  void
124  update ();
125 
132  static
133  void
134  declare_parameters (ParameterHandler &prm);
135 
142  virtual
143  void
144  parse_parameters (ParameterHandler &prm);
145  };
146 
147 
153  template <int dim>
154  class Manager : public ::aspect::SimulatorAccess<dim>
155  {
156  public:
161  ~Manager () override;
162 
172  virtual
173  void
174  update ();
175 
180  static
181  void
182  declare_parameters (ParameterHandler &prm);
183 
189  void
190  parse_parameters (ParameterHandler &prm);
191 
197  double
198  boundary_temperature (const types::boundary_id boundary_indicator,
199  const Point<dim> &position) const;
200 
205  double minimal_temperature (const std::set<types::boundary_id> &fixed_boundary_ids
206  = std::set<types::boundary_id>()) const;
207 
212  double maximal_temperature (const std::set<types::boundary_id> &fixed_boundary_ids
213  = std::set<types::boundary_id>()) const;
214 
232  static
233  void
234  register_boundary_temperature (const std::string &name,
235  const std::string &description,
236  void (*declare_parameters_function) (ParameterHandler &),
237  std::unique_ptr<Interface<dim>> (*factory_function) ());
238 
239 
244  const std::vector<std::string> &
245  get_active_boundary_temperature_names () const;
246 
251  const std::vector<std::unique_ptr<Interface<dim>>> &
252  get_active_boundary_temperature_conditions () const;
253 
263  template <typename BoundaryTemperatureType,
264  typename = typename std::enable_if_t<std::is_base_of<Interface<dim>,BoundaryTemperatureType>::value>>
265  bool
266  has_matching_boundary_temperature_model () const;
267 
279  template <typename BoundaryTemperatureType,
280  typename = typename std::enable_if_t<std::is_base_of<Interface<dim>,BoundaryTemperatureType>::value>>
281  const BoundaryTemperatureType &
282  get_matching_boundary_temperature_model () const;
283 
284  /*
285  * Return a set of boundary indicators for which boundary
286  * temperatures are prescribed.
287  */
288  const std::set<types::boundary_id> &
289  get_fixed_temperature_boundary_indicators() const;
290 
291  /*
292  * Return whether Dirichlet boundary conditions will be applied
293  * on parts of the boundaries where material flows out.
294  */
295  bool
296  allows_fixed_temperature_on_outflow_boundaries() const;
297 
307  static
308  void
309  write_plugin_graph (std::ostream &output_stream);
310 
311 
315  DeclException1 (ExcBoundaryTemperatureNameNotFound,
316  std::string,
317  << "Could not find entry <"
318  << arg1
319  << "> among the names of registered boundary temperature objects.");
320  private:
325  std::vector<std::unique_ptr<Interface<dim>>> boundary_temperature_objects;
326 
331  std::vector<std::string> model_names;
332 
339  std::vector<aspect::Utilities::Operator> model_operators;
340 
345  std::set<types::boundary_id> fixed_temperature_boundary_indicators;
346 
352  };
353 
354 
355 
356  template <int dim>
357  template <typename BoundaryTemperatureType, typename>
358  inline
359  bool
361  {
362  for (const auto &p : boundary_temperature_objects)
363  if (Plugins::plugin_type_matches<BoundaryTemperatureType>(*p))
364  return true;
365  return false;
366  }
367 
368 
369  template <int dim>
370  template <typename BoundaryTemperatureType, typename>
371  inline
372  const BoundaryTemperatureType &
374  {
375  AssertThrow(has_matching_boundary_temperature_model<BoundaryTemperatureType> (),
376  ExcMessage("You asked BoundaryTemperature::Manager::get_boundary_temperature_model() for a "
377  "boundary temperature model of type <" + boost::core::demangle(typeid(BoundaryTemperatureType).name()) + "> "
378  "that could not be found in the current model. Activate this "
379  "boundary temperature model in the input file."));
380 
381  for (auto &p : boundary_temperature_objects)
382  if (Plugins::plugin_type_matches<BoundaryTemperatureType>(*p))
383  return Plugins::get_plugin_as_type<BoundaryTemperatureType>(*p);
384 
385  // We will never get here, because we had the Assert above. Just to avoid warnings.
386  typename std::vector<std::unique_ptr<Interface<dim>>>::const_iterator boundary_temperature_model;
387  return Plugins::get_plugin_as_type<BoundaryTemperatureType>(*(*boundary_temperature_model));
388  }
389 
390 
397  template <int dim>
398  std::string
400 
401 
409 #define ASPECT_REGISTER_BOUNDARY_TEMPERATURE_MODEL(classname, name, description) \
410  template class classname<2>; \
411  template class classname<3>; \
412  namespace ASPECT_REGISTER_BOUNDARY_TEMPERATURE_MODEL_ ## classname \
413  { \
414  aspect::internal::Plugins::RegisterHelper<aspect::BoundaryTemperature::Interface<2>,classname<2>> \
415  dummy_ ## classname ## _2d (&aspect::BoundaryTemperature::Manager<2>::register_boundary_temperature, \
416  name, description); \
417  aspect::internal::Plugins::RegisterHelper<aspect::BoundaryTemperature::Interface<3>,classname<3>> \
418  dummy_ ## classname ## _3d (&aspect::BoundaryTemperature::Manager<3>::register_boundary_temperature, \
419  name, description); \
420  }
421  }
422 }
423 
424 
425 #endif
std::vector< std::unique_ptr< Interface< dim > > > boundary_temperature_objects
Definition: interface.h:325
std::string get_valid_model_names_pattern()
const BoundaryTemperatureType & get_matching_boundary_temperature_model() const
Definition: interface.h:373
void write_plugin_graph(std::ostream &output_stream)
std::vector< std::string > model_names
Definition: interface.h:331
std::vector< aspect::Utilities::Operator > model_operators
Definition: interface.h:339
void declare_parameters(ParameterHandler &prm)
bool has_matching_boundary_temperature_model() const
Definition: interface.h:360
Definition: compat.h:42
std::set< types::boundary_id > fixed_temperature_boundary_indicators
Definition: interface.h:345
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.")