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) 2011-2025 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_termination_criteria_interface_h
17 #define _aspect_termination_criteria_interface_h
18 
19 #include <aspect/global.h>
20 #include <aspect/plugins.h>
21 
22 #include <memory>
25 
26 
27 namespace aspect
28 {
29  template <int dim> class Simulator;
30 
31 
39  namespace TerminationCriteria
40  {
41 
56  template <int dim>
58  {
59  public:
76  virtual
77  bool
78  execute () = 0;
79 
92  virtual double check_for_last_time_step (const double time_step) const;
93  };
94 
95 
96 
97 
98 
99 
106  template <int dim>
107  class Manager : public Plugins::ManagerBase<Interface<dim>>, public SimulatorAccess<dim>
108  {
109  public:
123  virtual
124  bool
125  execute () const;
126 
140  double check_for_last_time_step (const double time_step) const;
141 
146  static
147  void
149 
155  void
156  parse_parameters (ParameterHandler &prm) override;
157 
175  static
176  void
177  register_termination_criterion (const std::string &name,
178  const std::string &description,
179  void (*declare_parameters_function) (ParameterHandler &),
180  std::unique_ptr<Interface<dim>> (*factory_function) ());
181 
191  static
192  void
193  write_plugin_graph (std::ostream &output_stream);
194 
198  DeclException1 (ExcTerminationCriteriaNameNotFound,
199  std::string,
200  << "Could not find entry <"
201  << arg1
202  << "> among the names of registered termination criteria objects.");
203  };
204 
205 
206 
214 #define ASPECT_REGISTER_TERMINATION_CRITERION(classname,name,description) \
215  template class classname<2>; \
216  template class classname<3>; \
217  namespace ASPECT_REGISTER_TERMINATION_CRITERION_ ## classname \
218  { \
219  aspect::internal::Plugins::RegisterHelper<aspect::TerminationCriteria::Interface<2>,classname<2>> \
220  dummy_ ## classname ## _2d (&aspect::TerminationCriteria::Manager<2>::register_termination_criterion, \
221  name, description); \
222  aspect::internal::Plugins::RegisterHelper<aspect::TerminationCriteria::Interface<3>,classname<3>> \
223  dummy_ ## classname ## _3d (&aspect::TerminationCriteria::Manager<3>::register_termination_criterion, \
224  name, description); \
225  }
226  }
227 }
228 
229 
230 #endif
virtual void parse_parameters(ParameterHandler &prm)
void write_plugin_graph(std::ostream &output_stream)
virtual double check_for_last_time_step(const double time_step) const
static void declare_parameters(ParameterHandler &prm)
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.")