SpECTRE Documentation Coverage Report
Current view: top level - Evolution/Initialization - NonconservativeSystem.hpp Coverage Total Hit
Commit: 0d1d717af84a81fb1284a20c4013708fe85cc2f0 Lines: 10.0 % 10 1
Test Date: 2026-10-22 17:29:42
Legend: Lines:     hit not hit

            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 <type_traits>
      10              : #include <utility>
      11              : 
      12              : #include "DataStructures/DataBox/DataBox.hpp"
      13              : #include "DataStructures/TaggedTuple.hpp"
      14              : #include "DataStructures/VariablesTag.hpp"
      15              : #include "Evolution/DiscontinuousGalerkin/Actions/ComputeTimeDerivativeHelpers.hpp"
      16              : #include "Evolution/DiscontinuousGalerkin/BoundaryEvolvedVariables.hpp"
      17              : #include "Evolution/Initialization/InitialData.hpp"
      18              : #include "Parallel/AlgorithmExecution.hpp"
      19              : #include "Parallel/GlobalCache.hpp"
      20              : #include "ParallelAlgorithms/Initialization/MutateAssign.hpp"
      21              : #include "Utilities/TMPL.hpp"
      22              : 
      23              : /// \cond
      24              : namespace domain {
      25              : namespace Tags {
      26              : template <size_t VolumeDim>
      27              : struct Mesh;
      28              : }  // namespace Tags
      29              : }  // namespace domain
      30              : 
      31              : /// \endcond
      32              : 
      33              : namespace Initialization {
      34              : namespace Actions {
      35              : /// \ingroup InitializationGroup
      36              : /// \brief Allocate variables needed for evolution of nonconservative systems
      37              : ///
      38              : /// Uses:
      39              : /// - DataBox:
      40              : ///   * `Tags::Mesh<Dim>`
      41              : ///
      42              : /// DataBox changes:
      43              : /// - Adds:
      44              : ///   * System::variables_tag (for a system with boundary-evolved variables,
      45              : ///     only its first entry, which holds the volume variables)
      46              : ///   * `::Tags::Variables<System::auxiliary_variables>` (only if the system
      47              : ///     declares a non-empty `auxiliary_variables`)
      48              : ///
      49              : /// - Removes: nothing
      50              : /// - Modifies: nothing
      51              : template <typename System>
      52            1 : struct NonconservativeSystem {
      53              :   static_assert(not System::is_in_flux_conservative_form,
      54              :                 "System is in flux conservative form");
      55            0 :   static constexpr size_t dim = System::volume_dim;
      56              : 
      57            0 :   using variables_tag = tmpl::conditional_t<
      58              :       evolution::dg::system_has_boundary_variables_v<System>,
      59              :       tmpl::front<typename System::variables_tag>,
      60              :       typename System::variables_tag>;
      61            0 :   using auxiliary_variables =
      62              :       evolution::dg::Actions::detail::get_auxiliary_variables_or_default_t<
      63              :           System, tmpl::list<>>;
      64            0 :   static constexpr bool has_auxiliary_variables =
      65              :       not std::is_same_v<auxiliary_variables, tmpl::list<>>;
      66            0 :   using auxiliary_variables_tag = ::Tags::Variables<auxiliary_variables>;
      67            0 :   using simple_tags = tmpl::conditional_t<
      68              :       has_auxiliary_variables,
      69              :       db::AddSimpleTags<variables_tag, auxiliary_variables_tag>,
      70              :       db::AddSimpleTags<variables_tag>>;
      71            0 :   using compute_tags = db::AddComputeTags<>;
      72              : 
      73              :   template <typename DbTagsList, typename... InboxTags, typename Metavariables,
      74              :             typename ArrayIndex, typename ActionList,
      75              :             typename ParallelComponent>
      76            0 :   static Parallel::iterable_action_return_t apply(
      77              :       db::DataBox<DbTagsList>& box,
      78              :       const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
      79              :       const Parallel::GlobalCache<Metavariables>& /*cache*/,
      80              :       const ArrayIndex& /*array_index*/, ActionList /*meta*/,
      81              :       const ParallelComponent* const /*meta*/) {
      82              :     using Vars = typename variables_tag::type;
      83              :     const size_t number_of_grid_points =
      84              :         db::get<domain::Tags::Mesh<dim>>(box).number_of_grid_points();
      85              :     if constexpr (has_auxiliary_variables) {
      86              :       using AuxVars = typename auxiliary_variables_tag::type;
      87              :       Initialization::mutate_assign<simple_tags>(
      88              :           make_not_null(&box), Vars{number_of_grid_points},
      89              :           AuxVars{number_of_grid_points});
      90              :     } else {
      91              :       Initialization::mutate_assign<simple_tags>(make_not_null(&box),
      92              :                                                  Vars{number_of_grid_points});
      93              :     }
      94              : 
      95              :     return {Parallel::AlgorithmExecution::Continue, std::nullopt};
      96              :   }
      97              : };
      98              : }  // namespace Actions
      99              : }  // namespace Initialization
        

Generated by: LCOV version 2.0-1