ASPECT
interface.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2019 - 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_time_stepping_interface_h
23 #define _aspect_time_stepping_interface_h
24 
25 #include <aspect/global.h>
28 
29 namespace aspect
30 {
31  using namespace dealii;
32 
36  namespace TimeStepping
37  {
38 
47  enum class Reaction
48  {
64  advance
65  };
66 
71  struct TimeStepInfo
72  {
78 
84  };
85 
91  template <int dim>
92  class Interface
93  {
94  public:
99  virtual ~Interface() = default;
100 
106  virtual
107  void
108  initialize ();
109 
116  virtual
117  void
118  update ();
119 
128  virtual
129  double
130  execute() = 0;
131 
144  virtual
145  std::pair<Reaction, double>
146  determine_reaction(const TimeStepInfo &info);
147 
154  static
155  void
156  declare_parameters (ParameterHandler &prm);
157 
164  virtual
165  void
166  parse_parameters (ParameterHandler &prm);
167  };
168 
169 
174  template <int dim>
175  class Manager : public SimulatorAccess<dim>
176  {
177  public:
182  void initialize_simulator (const Simulator<dim> &simulator_object) override;
183 
184 
192  void update();
193 
197  double get_next_time_step_size() const;
198 
203  bool should_repeat_time_step() const;
204 
209  bool should_refine_mesh() const;
210 
214  bool need_checkpoint_on_terminate() const;
215 
219  bool should_simulation_terminate_now() const;
220 
225  static
226  void
227  declare_parameters (ParameterHandler &prm);
228 
234  void
235  parse_parameters (ParameterHandler &prm);
236 
246  static
247  void
248  write_plugin_graph (std::ostream &output_stream);
249 
250 
269  static
270  void
271  register_time_stepping_model (const std::string &name,
272  const std::string &description,
273  void (*declare_parameters_function) (ParameterHandler &),
274  std::unique_ptr<Interface<dim>> (*factory_function) ());
275 
276  private:
277 
282 
287 
292 
298 
304 
308  std::list<std::unique_ptr<Interface<dim>>> active_plugins;
309  };
310 
317 #define ASPECT_REGISTER_TIME_STEPPING_MODEL(classname,name,description) \
318  template class classname<2>; \
319  template class classname<3>; \
320  namespace ASPECT_REGISTER_TIME_STEPPING_MODEL_ ## classname \
321  { \
322  aspect::internal::Plugins::RegisterHelper<aspect::TimeStepping::Interface<2>,classname<2>> \
323  dummy_ ## classname ## _2d (&aspect::TimeStepping::Manager<2>::register_time_stepping_model, \
324  name, description); \
325  aspect::internal::Plugins::RegisterHelper<aspect::TimeStepping::Interface<3>,classname<3>> \
326  dummy_ ## classname ## _3d (&aspect::TimeStepping::Manager<3>::register_time_stepping_model, \
327  name, description); \
328  }
329 
330  }
331 }
332 
333 #endif
TerminationCriteria::Manager< dim > termination_manager
Definition: interface.h:303
void write_plugin_graph(std::ostream &output_stream)
std::list< std::unique_ptr< Interface< dim > > > active_plugins
Definition: interface.h:308
void declare_parameters(ParameterHandler &prm)
Definition: compat.h:42