Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <memory>
7 : #include <type_traits>
8 : #include <typeindex>
9 : #include <vector>
10 :
11 : #include "DataStructures/DataBox/Tag.hpp"
12 : #include "ParallelAlgorithms/EventsAndTriggers/WhenToCheck.hpp"
13 : #include "Time/Tags/StepperErrorEstimatesEnabled.hpp"
14 : #include "Time/Tags/StepperErrorTolerances.hpp"
15 : #include "Utilities/Gsl.hpp"
16 : #include "Utilities/TMPL.hpp"
17 :
18 : /// \cond
19 : class EventsAndTriggers;
20 : template <typename StepChooserUse>
21 : class StepChooser;
22 : struct StepperErrorTolerances;
23 : class TimeStepper;
24 : class VariableOrderAlgorithm;
25 : namespace StepChooserUse {
26 : struct LtsStep;
27 : } // namespace StepChooserUse
28 : namespace Tags {
29 : template <Triggers::WhenToCheck WhenToCheck>
30 : struct EventsAndTriggers;
31 : struct LtsStepChoosers;
32 : template <typename StepperInterface>
33 : struct TimeStepper;
34 : struct VariableOrderAlgorithm;
35 : } // namespace Tags
36 : /// \endcond
37 :
38 : namespace Tags {
39 : namespace StepperErrorEstimatesEnabledCompute_detail {
40 : void function(
41 : gsl::not_null<bool*> error_estimates_enabled,
42 : const ::EventsAndTriggers& events_and_triggers,
43 : const std::vector<std::unique_ptr<::StepChooser<StepChooserUse::LtsStep>>>&
44 : step_choosers);
45 : } // namespace StepperErrorEstimatesEnabledCompute_detail
46 :
47 : /// \ingroup TimeGroup
48 : /// \brief Searches the StepChoosers for any requesting error estimates.
49 : template <template <typename> typename CacheTagPrefix = std::type_identity_t>
50 1 : struct StepperErrorEstimatesEnabledCompute : db::ComputeTag,
51 : StepperErrorEstimatesEnabled {
52 0 : using base = StepperErrorEstimatesEnabled;
53 0 : using return_type = type;
54 0 : using argument_tags =
55 : tmpl::list<::Tags::EventsAndTriggers<Triggers::WhenToCheck::AtSlabs>,
56 : CacheTagPrefix<::Tags::LtsStepChoosers>>;
57 :
58 0 : static constexpr auto function =
59 : &StepperErrorEstimatesEnabledCompute_detail::function;
60 : };
61 :
62 : namespace StepperErrorTolerancesCompute_detail {
63 : void function(
64 : gsl::not_null<::StepperErrorTolerances*> tolerances,
65 : const ::EventsAndTriggers& events_and_triggers,
66 : const std::vector<std::unique_ptr<::StepChooser<StepChooserUse::LtsStep>>>&
67 : step_choosers,
68 : const ::TimeStepper& time_stepper,
69 : const ::VariableOrderAlgorithm& variable_order_algorithm,
70 : const std::type_index& tag_type);
71 : } // namespace StepperErrorTolerancesCompute_detail
72 :
73 : /// \ingroup TimeGroup
74 : /// \brief A tag that contains the error tolerances if any StepChooser
75 : /// requests an error estimate for the variable.
76 : template <typename EvolvedVariableTag,
77 : template <typename> typename CacheTagPrefix = std::type_identity_t>
78 1 : struct StepperErrorTolerancesCompute
79 : : db::ComputeTag,
80 : StepperErrorTolerances<EvolvedVariableTag> {
81 0 : using base = StepperErrorTolerances<EvolvedVariableTag>;
82 0 : using return_type = typename base::type;
83 0 : using argument_tags =
84 : tmpl::list<::Tags::EventsAndTriggers<Triggers::WhenToCheck::AtSlabs>,
85 : CacheTagPrefix<::Tags::LtsStepChoosers>,
86 : CacheTagPrefix<::Tags::TimeStepper<::TimeStepper>>,
87 : CacheTagPrefix<::Tags::VariableOrderAlgorithm>>;
88 :
89 0 : static void function(
90 : const gsl::not_null<::StepperErrorTolerances*> tolerances,
91 : const ::EventsAndTriggers& events_and_triggers,
92 : const std::vector<
93 : std::unique_ptr<::StepChooser<StepChooserUse::LtsStep>>>&
94 : step_choosers,
95 : const ::TimeStepper& time_stepper,
96 : const ::VariableOrderAlgorithm& variable_order_algorithm) {
97 : StepperErrorTolerancesCompute_detail::function(
98 : tolerances, events_and_triggers, step_choosers, time_stepper,
99 : variable_order_algorithm, typeid(EvolvedVariableTag));
100 : }
101 : };
102 : } // namespace Tags
|