Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : #pragma once 5 : 6 : #include <optional> 7 : #include <tuple> 8 : 9 : #include "DataStructures/DataBox/DataBox.hpp" 10 : #include "Evolution/VariableFixing/Tags.hpp" 11 : #include "Parallel/AlgorithmExecution.hpp" 12 : #include "Parallel/GlobalCache.hpp" 13 : #include "Utilities/Requires.hpp" 14 : #include "Utilities/TMPL.hpp" 15 : 16 : /// \cond 17 : namespace tuples { 18 : template <typename...> 19 : class TaggedTuple; 20 : } // namespace tuples 21 : /// \endcond 22 : 23 1 : namespace VariableFixing { 24 0 : namespace Actions { 25 : /// \ingroup ActionsGroup 26 : /// \ingroup VariableFixingGroup 27 : /// \brief Adjust variables with a variable fixer. 28 : /// 29 : /// Typically this action is called to adjust either conservative or primitive 30 : /// variables when they violate physical constraints. See the individual 31 : /// variable fixers in the VariableFixing namespace for more details. 32 : /// 33 : /// Uses: 34 : /// - DataBox: 35 : /// - Metavariables::variable_fixer::argument_tags 36 : /// - GlobalCache: 37 : /// - Metavariables::variable_fixer 38 : /// 39 : /// DataBox changes: 40 : /// - Adds: nothing 41 : /// - Removes: nothing 42 : /// - Modifies: Metavariables::variable_fixer::return_tags 43 : template <typename VariableFixer> 44 1 : struct FixVariables { 45 0 : using const_global_cache_tags = 46 : tmpl::list<Tags::VariableFixer<VariableFixer>>; 47 : 48 : template <typename DbTagsList, typename... InboxTags, typename Metavariables, 49 : typename ArrayIndex, typename ActionList, 50 : typename ParallelComponent, 51 : Requires<tmpl::size<DbTagsList>::value != 0> = nullptr> 52 0 : static Parallel::iterable_action_return_t apply( 53 : db::DataBox<DbTagsList>& box, 54 : tuples::TaggedTuple<InboxTags...>& /*inboxes*/, 55 : const Parallel::GlobalCache<Metavariables>& cache, 56 : const ArrayIndex& /*array_index*/, const ActionList /*meta*/, 57 : const ParallelComponent* const /*meta*/) { 58 : const auto& variable_fixer = get<Tags::VariableFixer<VariableFixer>>(cache); 59 : db::mutate_apply(variable_fixer, make_not_null(&box)); 60 : return {Parallel::AlgorithmExecution::Continue, std::nullopt}; 61 : } 62 : }; 63 : } // namespace Actions 64 : } // namespace VariableFixing