ASPECT
interface.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 - 2024 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_postprocess_interface_h
23 #define _aspect_postprocess_interface_h
24 
25 #include <aspect/global.h>
26 #include <aspect/plugins.h>
28 
29 #include <memory>
32 
33 #include <boost/serialization/split_member.hpp>
34 #include <boost/core/demangle.hpp>
35 
36 #include <typeinfo>
37 
38 
39 namespace aspect
40 {
41  template <int dim> class Simulator;
42  template <int dim> class SimulatorAccess;
43 
44 
51  namespace Postprocess
52  {
53 
68  template <int dim>
70  {
71  public:
92  virtual
93  std::pair<std::string,std::string>
94  execute (TableHandler &statistics) = 0;
95 
118  virtual
119  std::list<std::string>
121  };
122 
123 
124 
134  template <int dim>
135  class Manager : public Plugins::ManagerBase<Interface<dim>>, public SimulatorAccess<dim>
136  {
137  public:
146  std::list<std::pair<std::string,std::string>>
147  execute (TableHandler &statistics);
148 
163  template <typename PostprocessorType,
164  typename = typename std::enable_if_t<std::is_base_of<Interface<dim>,PostprocessorType>::value>>
166  bool
167  has_matching_postprocessor () const;
168 
185  template <typename PostprocessorType,
186  typename = typename std::enable_if_t<std::is_base_of<Interface<dim>,PostprocessorType>::value>>
188  const PostprocessorType &
189  get_matching_postprocessor () const;
190 
195  static
196  void
198 
204  void
205  parse_parameters (ParameterHandler &prm) override;
206 
224  static
225  void
226  register_postprocessor (const std::string &name,
227  const std::string &description,
228  void (*declare_parameters_function) (ParameterHandler &),
229  std::unique_ptr<Interface<dim>> (*factory_function) ());
230 
240  static
241  void
242  write_plugin_graph (std::ostream &output_stream);
243 
247  DeclException1 (ExcPostprocessorNameNotFound,
248  std::string,
249  << "Could not find entry <"
250  << arg1
251  << "> among the names of registered postprocessors.");
252  };
253 
254 
255  /* -------------------------- inline and template functions ---------------------- */
256 
257  template <int dim>
258  template <typename PostprocessorType, typename>
259  inline
260  bool
262  {
263  return this->template has_matching_active_plugin<PostprocessorType>();
264  }
265 
266 
267 
268  template <int dim>
269  template <typename PostprocessorType, typename>
270  inline
271  const PostprocessorType &
273  {
274  return this->template get_matching_active_plugin<PostprocessorType>();
275  }
276 
277 
285 #define ASPECT_REGISTER_POSTPROCESSOR(classname,name,description) \
286  template class classname<2>; \
287  template class classname<3>; \
288  namespace ASPECT_REGISTER_POSTPROCESSOR_ ## classname \
289  { \
290  aspect::internal::Plugins::RegisterHelper<aspect::Postprocess::Interface<2>,classname<2>> \
291  dummy_ ## classname ## _2d (&aspect::Postprocess::Manager<2>::register_postprocessor, \
292  name, description); \
293  aspect::internal::Plugins::RegisterHelper<aspect::Postprocess::Interface<3>,classname<3>> \
294  dummy_ ## classname ## _3d (&aspect::Postprocess::Manager<3>::register_postprocessor, \
295  name, description); \
296  }
297  }
298 }
299 
300 
301 #endif
virtual void parse_parameters(ParameterHandler &prm)
void write_plugin_graph(std::ostream &output_stream)
DEAL_II_DEPRECATED const PostprocessorType & get_matching_postprocessor() const
virtual std::pair< std::string, std::string > execute(TableHandler &statistics)=0
DEAL_II_DEPRECATED bool has_matching_postprocessor() const
virtual std::list< std::string > required_other_postprocessors() const
#define DEAL_II_DEPRECATED
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.")