/home/runner/work/DiFfRG_current/DiFfRG_current/DiFfRG/include/DiFfRG/timestepping/sundials_diagnostics.hh Source File#

DiFfRG: /home/runner/work/DiFfRG_current/DiFfRG_current/DiFfRG/include/DiFfRG/timestepping/sundials_diagnostics.hh Source File
DiFfRG
Discretization Framework for functional Renormalization Group flows
sundials_diagnostics.hh
Go to the documentation of this file.
1#pragma once
2
3#include <deal.II/sundials/ida.h>
4
7
8namespace DiFfRG
9{
11
12 template <typename VectorType>
13 TimesteppingDiagnostics make_timestepping_diagnostics(const SUNDIALS::IDA<VectorType> &time_stepper,
14 const IDACallbackDiagnostics &callbacks)
15 {
16 TimesteppingDiagnostics diagnostics;
17
18 if constexpr (requires { time_stepper.get_statistics(); }) {
19 const auto ida = time_stepper.get_statistics();
20 if (ida.valid) {
21 diagnostics.ida.emplace();
22 diagnostics.ida->ida_steps = ida.num_steps;
23 diagnostics.ida->ida_error_test_failures = ida.num_error_test_failures;
24 diagnostics.ida->ida_nonlinear_convergence_failures = ida.num_nonlinear_convergence_failures;
25 diagnostics.ida->ida_step_solve_failures = ida.num_step_solve_failures;
26 diagnostics.ida->ida_residual_evaluations = ida.num_residual_evaluations;
27 diagnostics.ida->ida_nonlinear_iterations = ida.num_nonlinear_iterations;
28 diagnostics.ida->ida_last_step_size = ida.last_step_size;
29 diagnostics.ida->ida_current_step_size = ida.current_step_size;
30 diagnostics.ida->ida_current_time = ida.current_time;
31 }
32 }
33
34 diagnostics.callbacks = callbacks;
35
36 return diagnostics;
37 }
38
39 template <typename VectorType>
40 TimestepperJacobianBuildDiagnostics
41 make_ida_jacobian_build_diagnostics(const SUNDIALS::IDA<VectorType> &time_stepper, const std::size_t build_id,
42 const double alpha,
44 {
46 diagnostics.jacobian_build_id = build_id;
47 diagnostics.stepper_kind = stepper_kind;
48 diagnostics.alpha = alpha;
49 diagnostics.beta = 1.;
50 diagnostics.residual_weight = 1.;
51 if constexpr (requires { time_stepper.get_statistics(); }) {
52 const auto ida = time_stepper.get_statistics();
53 if (ida.valid) {
54 diagnostics.step = static_cast<double>(ida.num_steps);
55 diagnostics.ida_step = static_cast<double>(ida.num_steps);
56 diagnostics.last_h = ida.last_step_size;
57 diagnostics.current_h = ida.current_step_size;
58 }
59 }
60 return diagnostics;
61 }
62} // namespace DiFfRG
Definition complex_math.hh:10
TimestepperJacobianBuildDiagnostics make_ida_jacobian_build_diagnostics(const SUNDIALS::IDA< VectorType > &time_stepper, const std::size_t build_id, const double alpha, const ImplicitTimestepperKind stepper_kind=ImplicitTimestepperKind::ida)
Definition sundials_diagnostics.hh:41
ImplicitTimestepperKind
Definition jacobian_diagnostics.hh:34
TimesteppingDiagnostics make_timestepping_diagnostics(const SUNDIALS::IDA< VectorType > &time_stepper, const IDACallbackDiagnostics &callbacks)
Definition sundials_diagnostics.hh:13
Definition abstract_timestepper.hh:83
Definition jacobian_diagnostics.hh:44
double beta
Definition jacobian_diagnostics.hh:52
ImplicitTimestepperKind stepper_kind
Definition jacobian_diagnostics.hh:46
double residual_weight
Definition jacobian_diagnostics.hh:53
double current_h
Definition jacobian_diagnostics.hh:55
std::size_t jacobian_build_id
Definition jacobian_diagnostics.hh:45
double ida_step
Definition jacobian_diagnostics.hh:50
double alpha
Definition jacobian_diagnostics.hh:51
double step
Definition jacobian_diagnostics.hh:48
double last_h
Definition jacobian_diagnostics.hh:54
Definition abstract_timestepper.hh:105
std::optional< IDAProgressDiagnostics > ida
Definition abstract_timestepper.hh:106
SolverCallbackDiagnostics callbacks
Definition abstract_timestepper.hh:107