Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : #pragma once 5 : 6 : #include <cstddef> 7 : #include <optional> 8 : #include <tuple> 9 : #include <utility> // IWYU pragma: keep // for move 10 : 11 : #include "DataStructures/DataBox/DataBox.hpp" 12 : #include "Evolution/Initialization/InitialData.hpp" 13 : #include "Parallel/AlgorithmExecution.hpp" 14 : #include "Parallel/GlobalCache.hpp" 15 : #include "ParallelAlgorithms/Initialization/MutateAssign.hpp" 16 : #include "Utilities/TMPL.hpp" 17 : #include "Utilities/TaggedTuple.hpp" 18 : 19 : /// \cond 20 : namespace domain { 21 : namespace Tags { 22 : template <size_t VolumeDim> 23 : struct Mesh; 24 : } // namespace Tags 25 : } // namespace domain 26 : // IWYU pragma: no_forward_declare db::DataBox 27 : /// \endcond 28 : 29 : namespace Initialization { 30 : namespace Actions { 31 : /// \ingroup InitializationGroup 32 : /// \brief Allocate variables needed for evolution of nonconservative systems 33 : /// 34 : /// Uses: 35 : /// - DataBox: 36 : /// * `Tags::Mesh<Dim>` 37 : /// 38 : /// DataBox changes: 39 : /// - Adds: 40 : /// * System::variables_tag 41 : /// 42 : /// - Removes: nothing 43 : /// - Modifies: nothing 44 : template <typename System> 45 1 : struct NonconservativeSystem { 46 : static_assert(not System::is_in_flux_conservative_form, 47 : "System is in flux conservative form"); 48 0 : static constexpr size_t dim = System::volume_dim; 49 0 : using variables_tag = typename System::variables_tag; 50 0 : using simple_tags = db::AddSimpleTags<variables_tag>; 51 0 : using compute_tags = db::AddComputeTags<>; 52 : 53 : template <typename DbTagsList, typename... InboxTags, typename Metavariables, 54 : typename ArrayIndex, typename ActionList, 55 : typename ParallelComponent> 56 0 : static Parallel::iterable_action_return_t apply( 57 : db::DataBox<DbTagsList>& box, 58 : const tuples::TaggedTuple<InboxTags...>& /*inboxes*/, 59 : const Parallel::GlobalCache<Metavariables>& /*cache*/, 60 : const ArrayIndex& /*array_index*/, ActionList /*meta*/, 61 : const ParallelComponent* const /*meta*/) { 62 : using Vars = typename variables_tag::type; 63 : Initialization::mutate_assign<simple_tags>( 64 : make_not_null(&box), 65 : Vars{db::get<domain::Tags::Mesh<dim>>(box).number_of_grid_points()}); 66 : 67 : return {Parallel::AlgorithmExecution::Continue, std::nullopt}; 68 : } 69 : }; 70 : } // namespace Actions 71 : } // namespace Initialization