SpECTRE Documentation Coverage Report
Current view: top level - ParallelAlgorithms/LinearSolver/Gmres - ResidualMonitor.hpp Hit Total Coverage
Commit: 058fd9f3a53606b32c6beec17aafdb5fcf4268be Lines: 0 1 0.0 %
Date: 2024-04-27 02:05:51
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 <limits>
       8             : #include <optional>
       9             : #include <utility>
      10             : 
      11             : #include "DataStructures/DataBox/DataBox.hpp"
      12             : #include "DataStructures/DataBox/PrefixHelpers.hpp"
      13             : #include "IO/Logging/Tags.hpp"
      14             : #include "NumericalAlgorithms/Convergence/Tags.hpp"
      15             : #include "Parallel/AlgorithmExecution.hpp"
      16             : #include "Parallel/Algorithms/AlgorithmSingleton.hpp"
      17             : #include "Parallel/GlobalCache.hpp"
      18             : #include "Parallel/Local.hpp"
      19             : #include "Parallel/ParallelComponentHelpers.hpp"
      20             : #include "Parallel/Phase.hpp"
      21             : #include "Parallel/PhaseDependentActionList.hpp"
      22             : #include "ParallelAlgorithms/Initialization/MutateAssign.hpp"
      23             : #include "ParallelAlgorithms/LinearSolver/Tags.hpp"
      24             : #include "Utilities/TMPL.hpp"
      25             : 
      26             : /// \cond
      27             : namespace tuples {
      28             : template <typename...>
      29             : class TaggedTuple;
      30             : }  // namespace tuples
      31             : namespace LinearSolver::gmres::detail {
      32             : template <typename FieldsTag, typename OptionsGroup>
      33             : struct InitializeResidualMonitor;
      34             : }  // namespace LinearSolver::gmres::detail
      35             : /// \endcond
      36             : 
      37             : namespace LinearSolver::gmres::detail {
      38             : 
      39             : template <typename Metavariables, typename FieldsTag, typename OptionsGroup>
      40             : struct ResidualMonitor {
      41             :   using chare_type = Parallel::Algorithms::Singleton;
      42             :   using const_global_cache_tags =
      43             :       tmpl::list<logging::Tags::Verbosity<OptionsGroup>,
      44             :                  Convergence::Tags::Criteria<OptionsGroup>>;
      45             :   using metavariables = Metavariables;
      46             :   // The actions in `ResidualMonitorActions.hpp` are invoked as simple actions
      47             :   // on this component as the result of reductions from the actions in
      48             :   // `ElementActions.hpp`. See `LinearSolver::gmres::Gmres` for details.
      49             :   using phase_dependent_action_list = tmpl::list<Parallel::PhaseActions<
      50             :       Parallel::Phase::Initialization,
      51             :       tmpl::list<InitializeResidualMonitor<FieldsTag, OptionsGroup>>>>;
      52             :   using simple_tags_from_options = Parallel::get_simple_tags_from_options<
      53             :       Parallel::get_initialization_actions_list<phase_dependent_action_list>>;
      54             : 
      55             :   static void execute_next_phase(
      56             :       const Parallel::Phase next_phase,
      57             :       Parallel::CProxy_GlobalCache<Metavariables>& global_cache) {
      58             :     auto& local_cache = *Parallel::local_branch(global_cache);
      59             :     Parallel::get_parallel_component<ResidualMonitor>(local_cache)
      60             :         .start_phase(next_phase);
      61             :   }
      62             : };
      63             : 
      64             : template <typename FieldsTag, typename OptionsGroup>
      65             : struct InitializeResidualMonitor {
      66             :  private:
      67             :   using fields_tag = FieldsTag;
      68             :   using residual_magnitude_tag = LinearSolver::Tags::Magnitude<
      69             :       db::add_tag_prefix<LinearSolver::Tags::Residual, fields_tag>>;
      70             :   using initial_residual_magnitude_tag =
      71             :       ::Tags::Initial<residual_magnitude_tag>;
      72             :   using previous_residual_magnitude_tag =
      73             :       ::Tags::Previous<residual_magnitude_tag>;
      74             :   using orthogonalization_history_tag =
      75             :       LinearSolver::Tags::OrthogonalizationHistory<fields_tag>;
      76             : 
      77             :  public:
      78             :   using simple_tags = tmpl::list<initial_residual_magnitude_tag,
      79             :                                  previous_residual_magnitude_tag,
      80             :                                  orthogonalization_history_tag>;
      81             :   using compute_tags = tmpl::list<>;
      82             : 
      83             :   template <typename DbTagsList, typename... InboxTags, typename ArrayIndex,
      84             :             typename Metavariables, typename ActionList,
      85             :             typename ParallelComponent>
      86             :   static Parallel::iterable_action_return_t apply(
      87             :       db::DataBox<DbTagsList>& box,
      88             :       const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
      89             :       const Parallel::GlobalCache<Metavariables>& /*cache*/,
      90             :       const ArrayIndex& /*array_index*/, const ActionList /*meta*/,
      91             :       const ParallelComponent* const /*meta*/) {
      92             :     // The `InitializeResidualMagnitude` action populates these tags
      93             :     // with initial values
      94             :     Initialization::mutate_assign<tmpl::list<initial_residual_magnitude_tag,
      95             :                                              previous_residual_magnitude_tag>>(
      96             :         make_not_null(&box), std::numeric_limits<double>::signaling_NaN(),
      97             :         std::numeric_limits<double>::signaling_NaN());
      98             :     return {Parallel::AlgorithmExecution::Pause, std::nullopt};
      99             :   }
     100             : };
     101             : 
     102             : }  // namespace LinearSolver::gmres::detail

Generated by: LCOV version 1.14