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) 2019-2026 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_time_stepping_interface_h
17 #define _aspect_time_stepping_interface_h
18 
19 #include <aspect/global.h>
22 
23 namespace aspect
24 {
28  namespace TimeStepping
29  {
30 
39  enum class Reaction
40  {
56  advance
57  };
58 
63  struct TimeStepInfo
64  {
70 
76  };
77 
83  template <int dim>
85  {
86  public:
95  virtual
96  double
97  execute() = 0;
98 
111  virtual
112  std::pair<Reaction, double>
113  determine_reaction(const TimeStepInfo &info);
114  };
115 
116 
121  template <int dim>
122  class Manager : public Plugins::ManagerBase<Interface<dim>>, public SimulatorAccess<dim>
123  {
124  public:
129  void initialize_simulator (const Simulator<dim> &simulator_object) override;
130 
131 
139  void
140  update() override;
141 
145  double get_next_time_step_size() const;
146 
151  bool should_repeat_time_step() const;
152 
157  bool should_refine_mesh() const;
158 
162  bool need_checkpoint_on_terminate() const;
163 
167  bool should_simulation_terminate_now() const;
168 
173  static
174  void
176 
182  void
183  parse_parameters (ParameterHandler &prm) override;
184 
185  template <class Archive>
186  void
187  serialize (Archive &ar, const unsigned int)
188  {
189  ar &termination_manager;
190  }
191 
201  static
202  void
203  write_plugin_graph (std::ostream &output_stream);
204 
223  static
224  void
225  register_time_stepping_model (const std::string &name,
226  const std::string &description,
227  void (*declare_parameters_function) (ParameterHandler &),
228  std::unique_ptr<Interface<dim>> (*factory_function) ());
229 
230  private:
231 
236 
241 
249 
258 
264  };
265 
266 
267 
274 #define ASPECT_REGISTER_TIME_STEPPING_MODEL(classname,name,description) \
275  template class classname<2>; \
276  template class classname<3>; \
277  namespace ASPECT_REGISTER_TIME_STEPPING_MODEL_ ## classname \
278  { \
279  aspect::internal::Plugins::RegisterHelper<aspect::TimeStepping::Interface<2>,classname<2>> \
280  dummy_ ## classname ## _2d (&aspect::TimeStepping::Manager<2>::register_time_stepping_model, \
281  name, description); \
282  aspect::internal::Plugins::RegisterHelper<aspect::TimeStepping::Interface<3>,classname<3>> \
283  dummy_ ## classname ## _3d (&aspect::TimeStepping::Manager<3>::register_time_stepping_model, \
284  name, description); \
285  }
286 
287  }
288 }
289 
290 #endif
void serialize(Archive &ar, const unsigned int)
Definition: interface.h:187
TerminationCriteria::Manager< dim > termination_manager
Definition: interface.h:263
void write_plugin_graph(std::ostream &output_stream)
void declare_parameters(ParameterHandler &prm)