Actions.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <tuple>
7 
9 #include "Evolution/VariableFixing/Tags.hpp"
10 #include "Parallel/GlobalCache.hpp"
11 #include "Utilities/Requires.hpp"
12 #include "Utilities/TMPL.hpp"
13 
14 /// \cond
15 namespace tuples {
16 template <typename...>
17 class TaggedTuple;
18 } // namespace tuples
19 /// \endcond
20 
21 namespace VariableFixing {
22 namespace Actions {
23 /// \ingroup ActionsGroup
24 /// \ingroup VariableFixingGroup
25 /// \brief Adjust variables with a variable fixer.
26 ///
27 /// Typically this action is called to adjust either conservative or primitive
28 /// variables when they violate physical constraints. See the individual
29 /// variable fixers in the VariableFixing namespace for more details.
30 ///
31 /// Uses:
32 /// - DataBox:
33 /// - Metavariables::variable_fixer::argument_tags
34 /// - GlobalCache:
35 /// - Metavariables::variable_fixer
36 ///
37 /// DataBox changes:
38 /// - Adds: nothing
39 /// - Removes: nothing
40 /// - Modifies: Metavariables::variable_fixer::return_tags
41 template <typename VariableFixer>
42 struct FixVariables {
43  using const_global_cache_tags =
44  tmpl::list<Tags::VariableFixer<VariableFixer>>;
45 
46  template <typename DbTagsList, typename... InboxTags, typename Metavariables,
47  typename ArrayIndex, typename ActionList,
48  typename ParallelComponent,
50  static std::tuple<db::DataBox<DbTagsList>&&> apply(
51  db::DataBox<DbTagsList>& box,
54  const ArrayIndex& /*array_index*/, const ActionList /*meta*/,
55  const ParallelComponent* const /*meta*/) noexcept {
56  const auto& variable_fixer = get<Tags::VariableFixer<VariableFixer>>(cache);
57  db::mutate_apply(variable_fixer, make_not_null(&box));
58  return std::forward_as_tuple(std::move(box));
59  }
60 };
61 } // namespace Actions
62 } // namespace VariableFixing
db::mutate_apply
constexpr void mutate_apply(F &&f, const gsl::not_null< DataBox< BoxTags > * > box, Args &&... args) noexcept
Apply the invokable f mutating items MutateTags and taking as additional arguments ArgumentTags and a...
Definition: DataBox.hpp:1381
Parallel::GlobalCache
Definition: ElementReceiveInterpPoints.hpp:15
GlobalCache.hpp
VariableFixing::Actions::FixVariables
Adjust variables with a variable fixer.
Definition: Actions.hpp:42
tuple
DataBox.hpp
tuples::TaggedTuple
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:271
Requires.hpp
make_not_null
gsl::not_null< T * > make_not_null(T *ptr) noexcept
Construct a not_null from a pointer. Often this will be done as an implicit conversion,...
Definition: Gsl.hpp:880
Requires
typename Requires_detail::requires_impl< B >::template_error_type_failed_to_meet_requirements_on_template_parameters Requires
Express requirements on the template parameters of a function or class, replaces std::enable_if_t
Definition: Requires.hpp:67
VariableFixing
Contains all variable fixers.
Definition: Actions.hpp:21
TMPL.hpp