SpECTRE Documentation Coverage Report
Current view: top level - Evolution/Initialization - ConservativeSystem.hpp Hit Total Coverage
Commit: 1f2210958b4f38fdc0400907ee7c6d5af5111418 Lines: 1 13 7.7 %
Date: 2025-12-05 05:03:31
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/DataBox/PrefixHelpers.hpp"
      14             : #include "DataStructures/DataBox/Prefixes.hpp"
      15             : #include "Domain/CoordinateMaps/Tags.hpp"
      16             : #include "Domain/FunctionsOfTime/Tags.hpp"
      17             : #include "Domain/Tags.hpp"
      18             : #include "Domain/TagsTimeDependent.hpp"
      19             : #include "Evolution/Initialization/InitialData.hpp"
      20             : #include "NumericalAlgorithms/LinearOperators/Divergence.tpp"  // Needs to be included somewhere and here seems most natural.
      21             : #include "Parallel/AlgorithmExecution.hpp"
      22             : #include "Parallel/GlobalCache.hpp"
      23             : #include "ParallelAlgorithms/Initialization/MutateAssign.hpp"
      24             : #include "PointwiseFunctions/AnalyticData/Tags.hpp"
      25             : #include "Utilities/ErrorHandling/Error.hpp"
      26             : #include "Utilities/Gsl.hpp"
      27             : #include "Utilities/NoSuchType.hpp"
      28             : #include "Utilities/TMPL.hpp"
      29             : 
      30             : /// \cond
      31             : namespace Frame {
      32             : struct Inertial;
      33             : }  // namespace Frame
      34             : 
      35             : namespace domain {
      36             : namespace Tags {
      37             : template <size_t VolumeDim, typename Frame>
      38             : struct Coordinates;
      39             : template <size_t VolumeDim>
      40             : struct Mesh;
      41             : }  // namespace Tags
      42             : }  // namespace domain
      43             : 
      44             : namespace tuples {
      45             : template <class... Tags>
      46             : class TaggedTuple;
      47             : }  // namespace tuples
      48             : /// \endcond
      49             : 
      50           0 : namespace Initialization {
      51           0 : namespace Actions {
      52             : /// \ingroup InitializationGroup
      53             : /// \brief Allocate variables needed for evolution of conservative systems
      54             : ///
      55             : /// Uses:
      56             : /// - DataBox:
      57             : ///   * `Tags::Mesh<Dim>`
      58             : ///
      59             : /// DataBox changes:
      60             : /// - Adds:
      61             : ///   * System::variables_tag
      62             : ///   * db::add_tag_prefix<Tags::Flux, System::variables_tag>
      63             : ///   * db::add_tag_prefix<Tags::Source, System::variables_tag>
      64             : ///
      65             : /// - Removes: nothing
      66             : /// - Modifies: nothing
      67             : template <typename System>
      68           1 : struct ConservativeSystem {
      69             :  private:
      70           0 :   static constexpr size_t dim = System::volume_dim;
      71             : 
      72           0 :   using variables_tag = typename System::variables_tag;
      73             : 
      74             :   template <typename LocalSystem,
      75             :             bool = LocalSystem::has_primitive_and_conservative_vars>
      76           0 :   struct simple_tags_impl {
      77           0 :     using type = tmpl::list<variables_tag>;
      78             :   };
      79             : 
      80             :   template <typename LocalSystem>
      81           0 :   struct simple_tags_impl<LocalSystem, true> {
      82           0 :     using type =
      83             :         tmpl::list<variables_tag, typename System::primitive_variables_tag>;
      84             :   };
      85             : 
      86             :  public:
      87           0 :   using simple_tags = typename simple_tags_impl<System>::type;
      88             : 
      89           0 :   using compute_tags = db::AddComputeTags<>;
      90             : 
      91             :   template <typename DbTagsList, typename... InboxTags, typename Metavariables,
      92             :             typename ArrayIndex, typename ActionList,
      93             :             typename ParallelComponent>
      94           0 :   static Parallel::iterable_action_return_t apply(
      95             :       db::DataBox<DbTagsList>& box,
      96             :       const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
      97             :       const Parallel::GlobalCache<Metavariables>& /*cache*/,
      98             :       const ArrayIndex& /*array_index*/, ActionList /*meta*/,
      99             :       const ParallelComponent* const /*meta*/) {
     100             :     const size_t num_grid_points =
     101             :         db::get<domain::Tags::Mesh<dim>>(box).number_of_grid_points();
     102             :     typename variables_tag::type vars(num_grid_points);
     103             : 
     104             :     if constexpr (System::has_primitive_and_conservative_vars) {
     105             :       using PrimitiveVars = typename System::primitive_variables_tag::type;
     106             : 
     107             :       PrimitiveVars primitive_vars{
     108             :           db::get<domain::Tags::Mesh<dim>>(box).number_of_grid_points()};
     109             :       Initialization::mutate_assign<simple_tags>(
     110             :           make_not_null(&box), std::move(vars), std::move(primitive_vars));
     111             :     } else {
     112             :       Initialization::mutate_assign<simple_tags>(make_not_null(&box),
     113             :                                                  std::move(vars));
     114             :     }
     115             :     return {Parallel::AlgorithmExecution::Continue, std::nullopt};
     116             :   }
     117             : };
     118             : }  // namespace Actions
     119             : }  // namespace Initialization

Generated by: LCOV version 1.14