ASPECT
simulator_signals.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2015 - 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_simulator_signals_h
23 #define _aspect_simulator_signals_h
24 
25 #include <aspect/global.h>
27 #include <aspect/parameters.h>
28 
29 #include <deal.II/base/parameter_handler.h>
30 #include <deal.II/numerics/data_out.h>
31 
32 #include <boost/signals2.hpp>
33 
34 namespace aspect
35 {
36  namespace Assemblers
37  {
38  template <int dim>
39  class Manager;
40 
41  template <int dim>
42  class Interface;
43  }
44 
63  template <int dim>
64  struct SimulatorSignals
65  {
76  boost::signals2::signal<void (std::vector<VariableDeclaration<dim>> &)>
77  edit_finite_element_variables;
78 
85  boost::signals2::signal<void (typename parallel::distributed::Triangulation<dim> &)> pre_set_initial_state;
86 
93  boost::signals2::signal<void (const SimulatorAccess<dim> &)> post_set_initial_state;
94 
101  boost::signals2::signal<void (const SimulatorAccess<dim> &)> start_timestep;
102 
114  boost::signals2::signal<void (const SimulatorAccess<dim> &,
115  AffineConstraints<double> &)> post_constraints_creation;
116 
128  boost::signals2::signal<void (const SimulatorAccess<dim> &,
129  Parameters<dim> &parameters)> edit_parameters_pre_setup_dofs;
130 
141  boost::signals2::signal<void (typename parallel::distributed::Triangulation<dim> &)> pre_refinement_store_user_data;
142 
152  boost::signals2::signal<void (typename parallel::distributed::Triangulation<dim> &)> post_refinement_load_user_data;
153 
166  boost::signals2::signal<void (typename parallel::distributed::Triangulation<dim> &)> pre_compute_no_normal_flux_constraints;
167 
180  boost::signals2::signal<void (typename parallel::distributed::Triangulation<dim> &)> post_compute_no_normal_flux_constraints;
181 
191  boost::signals2::signal<void (typename parallel::distributed::Triangulation<dim> &)> pre_checkpoint_store_user_data;
192 
205  boost::signals2::signal<void (typename parallel::distributed::Triangulation<dim> &)> post_resume_load_user_data;
206 
219  boost::signals2::signal<double (const double pressure_scaling, const double reference_viscosity, const double length_scale)> modify_pressure_scaling;
220 
233  static boost::signals2::signal<void (const unsigned int aspect_dim,
234  ParameterHandler &prm)> declare_additional_parameters;
235 
246  static boost::signals2::signal<void (const Parameters<dim> &,
247  ParameterHandler &)> parse_additional_parameters;
248 
261  boost::signals2::signal<void (const SimulatorAccess<dim> &,
262  const unsigned int number_S_iterations,
263  const unsigned int number_A_iterations,
264  const SolverControl &solver_control_cheap,
265  const SolverControl &solver_control_expensive)> post_stokes_solver;
266 
275  boost::signals2::signal<void (const SimulatorAccess<dim> &,
276  const bool solved_temperature_field,
277  const unsigned int compositional_index,
278  const SolverControl &solver_control)> post_advection_solver;
279 
289  boost::signals2::signal<void (const SolverControl &)> post_nonlinear_solver;
290 
297  boost::signals2::signal<void (const SimulatorAccess<dim> &,
298  const unsigned int iteration_count)> post_ARKode_solve;
299 
305  boost::signals2::signal<void (const SimulatorAccess<dim> &)> post_mesh_deformation;
306 
311  boost::signals2::signal<void (const SimulatorAccess<dim> &,
313  set_assemblers;
314 
322  boost::signals2::signal<void (DataOut<dim> &)> pre_data_out_build_patches;
323  };
324 
325 
326  // Explain to the compiler that we instantiate this class elsewhere, along
327  // with its static members. This is necessary to avoid warnings by some
328  // compilers.
329  extern template struct SimulatorSignals<2>;
330  extern template
331  boost::signals2::signal<void (const unsigned int aspect_dim, ParameterHandler &prm)>
333  extern template
334  boost::signals2::signal<void (const Parameters<2> &, ParameterHandler &)>
336 
337  extern template struct SimulatorSignals<3>;
338  extern template
339  boost::signals2::signal<void (const unsigned int aspect_dim, ParameterHandler &prm)>
341  extern template
342  boost::signals2::signal<void (const Parameters<3> &, ParameterHandler &)>
344 
345 
346  namespace internals
347  {
353  {
361 
369  template <int dim>
371  }
372  }
373 
374 
385 #define ASPECT_REGISTER_SIGNALS_CONNECTOR(connector_function_2d,connector_function_3d) \
386  namespace ASPECT_REGISTER_SIGNALS_CONNECTOR \
387  { \
388  struct dummy_do_register \
389  { \
390  dummy_do_register () \
391  { \
392  aspect::internals::SimulatorSignals::register_connector_function_2d (connector_function_2d); \
393  aspect::internals::SimulatorSignals::register_connector_function_3d (connector_function_3d); \
394  } \
395  } dummy_variable; \
396  }
397 
398 
407 #define ASPECT_REGISTER_SIGNALS_PARAMETER_CONNECTOR(connector_function) \
408  namespace ASPECT_REGISTER_SIGNALS_PARAMETER_CONNECTOR_ ## connector_function \
409  { \
410  struct dummy_do_register_ ## connector_function \
411  { \
412  dummy_do_register_ ## connector_function () \
413  { \
414  connector_function (); \
415  } \
416  } dummy_variable_ ## classname; \
417  }
418 
419 }
420 #endif
void register_connector_function_2d(const std::function< void(aspect::SimulatorSignals< 2 > &)> &connector)
boost::signals2::signal< double(const double pressure_scaling, const double reference_viscosity, const double length_scale)> modify_pressure_scaling
boost::signals2::signal< void(const SolverControl &)> post_nonlinear_solver
void call_connector_functions(aspect::SimulatorSignals< dim > &signals)
Definition: compat.h:59
void register_connector_function_3d(const std::function< void(aspect::SimulatorSignals< 3 > &)> &connector)
static boost::signals2::signal< void(const unsigned int aspect_dim, ParameterHandler &prm)> declare_additional_parameters