ASPECT
interface.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 - 2022 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_termination_criteria_interface_h
23 #define _aspect_termination_criteria_interface_h
24 
25 #include <aspect/global.h>
26 #include <aspect/plugins.h>
27 
28 #include <memory>
29 #include <deal.II/base/parameter_handler.h>
31 
32 
33 namespace aspect
34 {
35  using namespace dealii;
36 
37  template <int dim> class Simulator;
38 
39 
47  namespace TerminationCriteria
48  {
49 
64  template <int dim>
65  class Interface
66  {
67  public:
72  virtual ~Interface () = default;
73 
79  virtual void initialize ();
80 
97  virtual
98  bool
99  execute () = 0;
100 
113  virtual double check_for_last_time_step (const double time_step) const;
114 
128  static
129  void
130  declare_parameters (ParameterHandler &prm);
131 
138  virtual
139  void
140  parse_parameters (ParameterHandler &prm);
141  };
142 
143 
144 
145 
146 
147 
154  template <int dim>
155  class Manager : public ::aspect::SimulatorAccess<dim>
156  {
157  public:
171  virtual
172  bool
173  execute () const;
174 
188  double check_for_last_time_step (const double time_step) const;
189 
194  static
195  void
196  declare_parameters (ParameterHandler &prm);
197 
203  void
204  parse_parameters (ParameterHandler &prm);
205 
223  static
224  void
225  register_termination_criterion (const std::string &name,
226  const std::string &description,
227  void (*declare_parameters_function) (ParameterHandler &),
228  std::unique_ptr<Interface<dim>> (*factory_function) ());
229 
239  static
240  void
241  write_plugin_graph (std::ostream &output_stream);
242 
246  DeclException1 (ExcTerminationCriteriaNameNotFound,
247  std::string,
248  << "Could not find entry <"
249  << arg1
250  << "> among the names of registered termination criteria objects.");
251  private:
256  std::list<std::unique_ptr<Interface<dim>>> termination_objects;
257 
262  std::list<std::string> termination_obj_names;
263 
264  };
265 
266 
267 
275 #define ASPECT_REGISTER_TERMINATION_CRITERION(classname,name,description) \
276  template class classname<2>; \
277  template class classname<3>; \
278  namespace ASPECT_REGISTER_TERMINATION_CRITERION_ ## classname \
279  { \
280  aspect::internal::Plugins::RegisterHelper<aspect::TerminationCriteria::Interface<2>,classname<2>> \
281  dummy_ ## classname ## _2d (&aspect::TerminationCriteria::Manager<2>::register_termination_criterion, \
282  name, description); \
283  aspect::internal::Plugins::RegisterHelper<aspect::TerminationCriteria::Interface<3>,classname<3>> \
284  dummy_ ## classname ## _3d (&aspect::TerminationCriteria::Manager<3>::register_termination_criterion, \
285  name, description); \
286  }
287  }
288 }
289 
290 
291 #endif
void write_plugin_graph(std::ostream &output_stream)
std::list< std::unique_ptr< Interface< dim > > > termination_objects
Definition: interface.h:256
std::list< std::string > termination_obj_names
Definition: interface.h:262
void declare_parameters(ParameterHandler &prm)
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.")