ASPECT
interface.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 - 2019 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
73  ~Interface ();
74 
80  virtual void initialize ();
81 
98  virtual
99  bool
100  execute () = 0;
101 
114  virtual double check_for_last_time_step (const double time_step) const;
115 
129  static
130  void
132 
139  virtual
140  void
141  parse_parameters (ParameterHandler &prm);
142  };
143 
144 
145 
146 
147 
148 
155  template <int dim>
156  class Manager : public ::aspect::SimulatorAccess<dim>
157  {
158  public:
174  virtual
175  std::pair<bool,bool>
176  execute () const;
177 
191  double check_for_last_time_step (const double time_step) const;
192 
197  static
198  void
200 
206  void
207  parse_parameters (ParameterHandler &prm);
208 
226  static
227  void
228  register_termination_criterion (const std::string &name,
229  const std::string &description,
230  void (*declare_parameters_function) (ParameterHandler &),
231  Interface<dim> *(*factory_function) ());
232 
242  static
243  void
244  write_plugin_graph (std::ostream &output_stream);
245 
249  DeclException1 (ExcTerminationCriteriaNameNotFound,
250  std::string,
251  << "Could not find entry <"
252  << arg1
253  << "> among the names of registered termination criteria objects.");
254  private:
259  std::list<std::unique_ptr<Interface<dim> > > termination_objects;
260 
265  std::list<std::string> termination_obj_names;
266 
272  };
273 
274 
275 
283 #define ASPECT_REGISTER_TERMINATION_CRITERION(classname,name,description) \
284  template class classname<2>; \
285  template class classname<3>; \
286  namespace ASPECT_REGISTER_TERMINATION_CRITERION_ ## classname \
287  { \
288  aspect::internal::Plugins::RegisterHelper<aspect::TerminationCriteria::Interface<2>,classname<2> > \
289  dummy_ ## classname ## _2d (&aspect::TerminationCriteria::Manager<2>::register_termination_criterion, \
290  name, description); \
291  aspect::internal::Plugins::RegisterHelper<aspect::TerminationCriteria::Interface<3>,classname<3> > \
292  dummy_ ## classname ## _3d (&aspect::TerminationCriteria::Manager<3>::register_termination_criterion, \
293  name, description); \
294  }
295  }
296 }
297 
298 
299 #endif
void write_plugin_graph(std::ostream &output_stream)
#define DeclException1(Exception1, type1, outsequence)
std::list< std::unique_ptr< Interface< dim > > > termination_objects
Definition: interface.h:259
std::list< std::string > termination_obj_names
Definition: interface.h:265
Definition: compat.h:53
void declare_parameters(ParameterHandler &prm)